11
\$\begingroup\$

I'm developing a voxel game, but I think I use the wrong technique. I currently use flat tiles, to make blocks, and I think theres a better and more efficient way.

I have seen a voxel game, which have naturally looking terrain. By that I mean non blocky. The game have 4*4*4 blocks per cubic meter, and blocks like dirt, sand and stone, have round edges, and kind of melt together (Like in ordinary games). Heres a screenshot enter image description here

How is this achieved?

\$\endgroup\$
  • \$\begingroup\$ en.wikipedia.org/wiki/Marching_cubes \$\endgroup\$ – Raxvan Jan 15 '15 at 12:12
  • \$\begingroup\$ do you know which game this is? how can you be sure that it's voxels? Ok, found it myself, the game is called Blockscape: indiedb.com/games/blockscape \$\endgroup\$ – Babis Jan 15 '15 at 13:11
  • \$\begingroup\$ There is a blog at procworld.blogspot.com that has all sorts of detailed blog posts about how his voxel engine was created. Posts go back several years from when the engine was in infancy to now when it is currently being licensed for Everquest Next. \$\endgroup\$ – stokastic Jan 15 '15 at 17:29
14
\$\begingroup\$

This is achieved by interpolating ramps between cubes of different height.

When you have a scenery like this (seen from the side)

  #
 ####   ##
############

you would add polygons to make it look like this:

 /#\
/####\ /##\
############

An algorithm to calculate these ramps is the marching cubes algorithm.

When you want it to be even more beautiful, don't just use single polygons to interpolate between cubes, use curves of multiple polygons. But keep in mind that it will add quite a lot of polygons to your scene, so you should only do this for those cubes which are close to the camera.

\$\endgroup\$
  • \$\begingroup\$ Thank you! Do you know a place which explain how to do this in OpenGL, Light Weight Java Game Library? Edit: And if you know a good technique how to add collision detection for the marching terrain, that would be appreciated too. \$\endgroup\$ – KaareZ Jan 15 '15 at 12:38
  • \$\begingroup\$ @KaareZ Sorry, I never worked with LWJGL. \$\endgroup\$ – Philipp Jan 15 '15 at 12:41
  • \$\begingroup\$ @Philipp you might be interested in this answer \$\endgroup\$ – user39686 Jan 15 '15 at 20:26
  • 1
    \$\begingroup\$ Or you can skip marching cube altogether and go to the much more interesting frankpetterson.com/publications/dualcontour/dualcontour.pdf less complicated you can also simply add the noise fonction as an offset to the final chunk's vertex. You still have block but now they have the property of rolling hills by not being strictly aligned in atrict straightline ... combining dual contouring and this for even more interesting result (with a modifier on the vertex offset to control more or less organic generation). \$\endgroup\$ – user29244 Jan 16 '15 at 2:45
  • \$\begingroup\$ forum.unity3d.com/attachments/captura-jpg.23795 here is a picture of "rolling block" (offset applied as vertical displacement) Here is More picture but with displacement applied on every direction forum.unity3d.com/attachments/t1-jpg.23871 forum.unity3d.com/attachments/t2-jpg.23872 vimeo.com/27976287 \$\endgroup\$ – user29244 Jan 16 '15 at 2:57
6
\$\begingroup\$

There are two obstacles you need to deal with in order to achieve similar quality like the one in the image, the first is artistic and the second is technical (memory, processing). First I assume that you already solved your artistic problem, you can make the models, the art and the shaders etc. (Partially because I can't answer art problems)

The major technical problem is that when voxelizing those models you created in a high level of detail you will end up with huge number of tiny voxels. Processing and rendering huge number of voxels is not trivial. The answer to this is called Sparse Voxel Octrees

SVO will give you the ability to render highly detailed models without processing all the voxels, but only the visible ones. Note that in order to render SVO you will need to use ray-casting rather than the usual rasterization technique.

More details on SVO in this paper

Here is an open-source with BSD License implementation of SVO https://code.google.com/p/efficient-sparse-voxel-octrees/

Here is a video that explains polygon vs SVO based rendering (pros and cons).

\$\endgroup\$
  • \$\begingroup\$ This is awesome! Also, take a look at sauerbraten.org, it uses a similar technique (but doesn't implement marching cubes, that part is left to the level designer) \$\endgroup\$ – Kroltan Jan 15 '15 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.