

Meshing in a Minecraft Game (2012) - rocky1138
http://0fps.wordpress.com/2012/06/30/meshing-in-a-minecraft-game/

======
exemd
In practice you need a texture atlas
([http://en.wikipedia.org/wiki/Texture_atlas](http://en.wikipedia.org/wiki/Texture_atlas))
to reduce number of meshes. But if you use texture atlas you can't combine
surfaces like in the article.

The solution is to create 1 dimensional texture atlas like this:
[http://manicdigger.sourceforge.net/webgl/data/atlas1.png](http://manicdigger.sourceforge.net/webgl/data/atlas1.png).
Then tile in only 1 direction. Minecraft does it and I first read about it in
one of Word of Notch posts -
[http://notch.tumblr.com/post/176620207/i-rewrote-the-
tessela...](http://notch.tumblr.com/post/176620207/i-rewrote-the-tesselator).

It's good enough. Manic Digger
([http://manicdigger.sourceforge.net](http://manicdigger.sourceforge.net)) has
great framerate at Pentium 4 and Geforce 2 MX.

But there is one problem: in mipmaps there is bleeding between individual
textures. The solution is to use:

    
    
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4);
    

It's good on desktop, but there is no GL_TEXTURE_MAX_LEVEL on OpenGL ES and
WebGL! I guess it must be done with custom mipmaps or with a pixel shader?

~~~
mbel
> In practice you need a texture atlas (...)to reduce number of meshes.

I believe you meant "to reduce number of texutre swaps"? Otherwise I fail to
find how texture atlas is helping in reducing number of meshes in the drawn
scene.

> But if you use texture atlas you can't combine surfaces like in the article.

Actually you can, pixel/fragment shader can be used later on to transform
texture coordinates just before the texel value will be fetched (obviously
this is only possible if you use shaders, but most games nowadays do).

~~~
exemd
I mean it reduces number of glDrawElements or glCallList calls.

If you have 256 different block types in 1 chunk, using texture atlas there's
only 1 mesh instead of 256 different meshes.

[https://docs.google.com/viewer?url=http%3A%2F%2Fnvidia.com%2...](https://docs.google.com/viewer?url=http%3A%2F%2Fnvidia.com%2Fdocs%2FIO%2F8230%2FBatchBatchBatch.ppt)

~~~
mbel
Oh ok, I haven't thought about it this way. You are surely right.

------
willvarfar
In C&C Tiberian Sun the voxel models were stored - and drawn - from a RLE
sparse array.

And we used the same data-structures in the modder voxel editors.

So its not really an 'open question' as the article says, more just an obvious
step.

~~~
pavlov
For anyone looking for an advanced sparse voxel data structure, there's
OpenVDB developed by DreamWorks Animation:

[http://www.openvdb.org/](http://www.openvdb.org/)

It's developed for film applications which naturally have a different set of
requirements than realtime game engines. But as PC performance grows, the
solutions developed for film rendering will become more directly adaptable for
games.

------
bajsejohannes
There's a really good writeup of that here as well:

[http://codeflow.org/entries/2010/dec/09/minecraft-like-
rende...](http://codeflow.org/entries/2010/dec/09/minecraft-like-rendering-
experiments-in-opengl-4/#tessellating-quads)

Less thorough on meshing (or tesselation as he calls it), but a very good
read.

------
andrewflnr
What? Minecraft "voxels" are huge. And then the cubes on the creatures are a
different size. How is it not just using meshes to start with?

~~~
bajsejohannes
Because there are order of magnitude differences between rendering each voxel
in a dense landscape compared to just the borders.

Consider a cube of 10x10x10 voxels. They each have 6 sides, so that's 6000
quads to render. If we only render the sides that can possibly be visible,
that's 6 sides on the cube times 10 * 10 voxels on each side, totalling 600
quads.

I'm sure the creatures are not treated like this; they're just meshes.

~~~
andrewflnr
AFAIK culling like that is standard in any mesh-based 3D engine, and most
minecraft landscapes aren't uniform enough to benefit from the adjacent-face
merging described. Standard 3D engines handle landscapes with way more polys
than I can imagine fitting into a minecraft screen. I don't see what the big
deal is here.

------
ginko
This completely ignores the problem of T-vertices.

