To make a voxel engine?

6e94c878e762a27858a68fda33ac857b
0
Hydrocharged 101 Jun 13, 2013 at 04:54 voxel

Hello!

I am wanting to program a voxel engine, but I do not know where to start. I am familiar with C# and C, and I have also learned very little Javascript. I am wanting the end result to produce something within the graphical range of this:
https://picroma.com/images/screenshots/jun2013/04.jpg
I’ve read that some have used the XNA framework, along with Visual Studio, however I don’t know where to proceed beyond that. I want my engine to incorporate DirectX 11 features such as ambient occlusion and bokeh DOF.

Of course, by now I know you’re thinking something along the lines of ‘just use something like Unity to create your game’, and that is where my situation is a little different. My end result is to create a game engine, and not an actual game. Of course, I want to be able to use my engine to create a game, however that is not the purpose behind my ambition. I’m not foolish enough to expect this task to be accomplished over a weekend; I’m actually ready to devote several years of my life to this project. It is very ambitious, and that is exactly why I want to pursue it. I’ve tried my hand at coding scripts for games using C# for Unity, and I enjoyed every minute of it.

The main problem is that I have literally no idea where to start. I’m not sure if I need to make use of my C# background, or if it would be more advantageous to learn C++ (which would not be a problem for me at all, as I love learning new languages) or something else entirely. I don’t know if I need to use XNA or something else entirely. From what I’m aware of, the set of tools is preferential, but I’m as lost as a man writing code on a napkin. Most resources that I’ve read have talked about the “general idea”, but I don’t know how to even put that information to any kind of use.

I know I’m asking for something quite specific, and I know that many have ambitions that are equally as large as mine, and they never finish them. I know it’s easy to look at someone on the internet and group them into piles, simply because of the general behavior that said people possess. I don’t want my dream to die, but I need the communities’ help to get it started.

Thank you for any and every resource, tip, and assistance that you can provide. I greatly appreciate it!!

5 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Jun 13, 2013 at 05:42

You can definitely do graphics in C#. If you want to use Direct3D 11 then XNA isn’t a good choice though, as it only supports D3D9, as far as I can tell from googling (I haven’t used it myself). However, you can use SharpDX, which is a more direct translation of the underlying Direct3D API, and will let you use Direct3D 11.

XNA also provides a bunch of other stuff besides graphics, though: vector/matrix/3D math, art asset management (models, textures, shaders), audio, timers, input, etc. XNA is much less than an engine, but much more than starting from scratch in C#. I’m not sure if you can use XNA for all that stuff and then use SharpDX for the graphics in the same app. Maybe someone who’s experienced with XNA can weigh in on that.

There’s also a lot more books, articles online, etc. about XNA than there are about SharpDX.

If you’re a complete newbie to graphics, which it sounds like you are, then it might make sense to forget about D3D11 for the time being, and just use XNA, knowing that it’s not going to give you access to the very latest graphics features, but it’s going to make your life a hell of a lot easier due to a lot of the fiddly little boring utility stuff, like loading images in various formats, being readily provided, which you’d otherwise have to code yourself or go find some library for. Later on, when you have more experience and knowledge, you can switch to D3D11.

BTW, ambient occlusion and bokeh DOF aren’t exclusive to D3D11, they’re just easier to implement well with the greater array of shader tools that D3D11 gives you. You can do AO and DOF in XNA/D3D9, for sure. In fact, off the top of my head I can’t think of any way that D3D11 particularly helps with any of the common AO techniques. It is convenient for generating bokeh sprites, but you can still do an acceptable DOF simulation in D3D9.

As for getting started, I would suggest picking up a book. If you search for XNA on Amazon there are tons of them. I didn’t find any books that explicitly use SharpDX. There are some about D3D11, but they use C++, so you’d have to either switch to that, or translate their code into C# and their D3D11 calls into the equivalent SharpDX calls. I’m sure there are also tutorials online, but for this sort of thing a book is likely better. There is a large enough amount of information that you’ll have to absorb that it’s worth it to get a book designed to be a self-contained lesson series. Try to find one that has exercises/problems, and do them (or at least take a good stab at them), plus spend some time experimenting on your own with what you’ve learned from the book after each chapter. The idea here is not just to rush through the book (which will leave you not having really learned anything) but to force your brain to digest the material bit by bit.

6837d514b487de395be51432d9cdd078
0
TheNut 179 Jun 13, 2013 at 07:11

You basically have 3 main categories to focus on.
1. Software design and development
2. Game theories, general algorithms, APIs (DirectX, XNA, OpenGL, OpenAL, whatever)
3. Voxel theories and algorithms

You should be comfortable with the first topic, then the second, and finally the third. If you jump straight into voxel development without fully understanding things like rasterization, polygons, textures, and shaders, then you may waste a lot of time writing a voxel engine that doesn’t work the way you intended it. Equally so, if you don’t have knowledge of designing software, then you’ll find the quality of your code will become poor and a maintenance nightmare.

Where to start? That really depends on how confident you are with the aforementioned topics. If we assume you know enough about writing well designed C# code, then your next step would be to learn XNA (if that’s what you want). It’s a viable API and Microsoft provides excellent documentation and samples to get you jump started. XNA is essentially a DirectX wrapper, without all the boilerplate code. You will still work with vertex buffer objects (VBO), fragment buffer objects (FBO), texture samplers, shaders (XNA calls them effects), etc. so the experience you gain is transferable. That might be technobabble to you now, but these are things you will pickup on if you want to know a thing or two about game rendering. It might also give you some design experience since XNA is generally well built, albeit inefficient in some areas.

Voxels are perhaps the easiest thing to learn and implement. If you can picture a point cloud in your head, then congrats, you just made a voxel engine in your head :) Really, that’s all there is to it. It’s essentially a 3D texture. Width x Length x Height, where a unit of space is called a “voxel”. In the 2D world, you would call it a pixel. The tricky part to voxels is how to efficiently store it in memory and then render it. Just a simple 1024\^3 voxel space will run you 1 GB of memory. Think about that for a minute, 1024 is NOTHING. It’s garbage. You can’t store anything of quality in something so tight. So there is a way to compress that so you can get 8x more data. Now 2048\^3 voxels can fit within 1024\^3 space. This is done by storing voxels as bits rather than bytes. Still garbage in terms of quality, but you’re making improvements. Next comes the harder part, streaming data. Working with layers and peeling off only the important parts of the voxel data and storing it into memory. More ideas to contemplate, and data algorithms like spatial partitioning to learn. A bit of a mouthful, but I’m just throwing ideas for you to think about. As far as rendering voxels go, well that’s up to you. The Minecraft world just renders them as cubes, like in your screenshot. That’s just dead simple. Zero effort. By the time you finish your first XNA tutorial, you’ll know how to do this. Other algorithms exist to make voxels much more lush and smooth. Algorithms like Marching Cubes combined with Catmull-Clark subdivision (FYI, Catmull-Clark is partly named after Edwin Catmull, one of the founders of Pixar) and these two produce some really great results. So there’s a lot of stuff there, simple cube rendering approach vs more complex smoothing algorithms. Lots of stuff for you to look over and decide what you prefer. The devil is in the details, and that’s where you will be spending a chunk of your time.

B5262118b588a5a420230bfbef4a2cdf
0
Stainless 151 Jun 13, 2013 at 08:31

My advice would be to forget about the underlying display technology at first.
Use anything you have access to. XNA, OpenGL, DirectX, doesn’t matter.

Solve the key problems of a voxel engine, storage, LOD, etc. keeping your voxel code separate from the actual display engine.

Once you have done that, you start optomising the display for a particular technology.

Otherwise you will end up sitting in front of your computer looking at web pages for the next year going,“direct3d is really nice for X, but opengl is really nice for Y, but XNA gives me Z, or I could just build on <insert graphic engine here>…. I’ll pick XNA, hang on there is a new one here…. I better look at that”

Fd80f81596aa1cf809ceb1c2077e190b
0
rouncer 103 Jun 13, 2013 at 08:53

If you devote 10 years to this project, and reinstanciate it 4 whole times in the process, youll be ready at the end to finish the final product in a month! once you know what your doing.

6e94c878e762a27858a68fda33ac857b
0
Hydrocharged 101 Jun 15, 2013 at 14:05

Hello everyone! I just wanted to let you all know that I’m learning C++, and will use DirectX 11 as a wrapper for my graphics. I’ve also bought a book by Frank Luna, which will help me tremendously from what I’ve seen. I appreciate everyone’s help in giving me somewhere to start!