I'm looking to create a simple voxel engine in C#. I know a lot of XNA but heard it would be better to do it in OpenGL / DirectX. Anybody know how I would accomplish such a thing? I do not want a library as I want to learn how to do it from scratch.
Asked
Active
Viewed 1,243 times
1 Answers
2
OpenGL and Direct3D are both "triangle" APIs - they aren't volumetric renderers. We need more information about what you want your voxel engine to do.
If you want to render voxels directly, then your best bet is to avoid OpenGL and Direct3D and write your own OpenCL or CUDA renderer (or even be 100% software on the CPU).
Rendering voxels to OpenGL or Direct3D would require converting the voxel world to triangles - using something like marching cubes. This technique can be efficient if the voxel world is fairly static and the voxels are large (like Minecraft). However this technique wouldn't work in massively-deformable worlds, for example, as you'd have to re-generate the triangle scene on a regular basis, which will be expensive.

Dai
- 141,631
- 28
- 261
- 374
-
I would want a full built world like minecraft. One that i could break and build blocks. Wouldn't even necessarily have to be Voxel, my goal is to create a "Minecraft" type game. Not to sell or anything, just for personal experience. – Tristan McPherson Nov 18 '12 at 18:18
-
I don't see the relevance of this answer since Minecraft employs OpenGL. – IAbstract Dec 01 '22 at 17:56
-
1@IAbstract I wrote this answser **over 10 years ago** before Vulcan and DX12 were out, and [before "shader-only" rendering took off](https://www.shadertoy.com/view/Xds3zN) - and Minecraft renders its cubes using traditional triangle-based rendering, i.e. it doesn't use "true" per-pixel voxel rendering techniques. Besides, the original question is overly vague as-written, so _any_ answer given would be irrelevant in some way or another. – Dai Dec 01 '22 at 20:17