Live data from Hacker News

Meshing in a Minecraft Game (2012)

0fps.wordpress.com

1–10 of 21 posts

Re: Meshing in a Minecraft Game (2012)

#2
In practice you need a 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. 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....

It's good enough. Manic Digger (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?

Re: Meshing in a Minecraft Game (2012)

#5
post #2

In practice you need a 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 . Then tile in only 1 direction. Minecraft does it and I first read about it in one of Word of Notch posts -…

[deleted]

Re: Meshing in a Minecraft Game (2012)

#6
post #2

In practice you need a 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 . Then tile in only 1 direction. Minecraft does it and I first read about it in one of Word of Notch posts -…

Very insightful, thank you.

Are there no alternative to texture atlases? It seems weird to restrict yourself to merging in only one direction just because the representation of your texture won't allow it.

As for the bleeding, I suppose it's because the scaling kernel overlaps between the tiles in the atlas? Won't reducing the level of mipmapping degrade overall performances?

It seems weird to me that there's no better hardware support for texture atlases if it's so popular.

Re: Meshing in a Minecraft Game (2012)

#7

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.

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

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.

Re: Meshing in a Minecraft Game (2012)

#8
post #6
post #2

In practice you need a 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 . Then tile in only 1 direction. Minecraft does it and I first read about it in one of Word of Notch posts -…

Very insightful, thank you. Are there no alternative to texture atlases? It seems weird to restrict yourself to merging in only one direction just because the representation of your texture won't allow it. As for the bleeding, I suppose it's because the scaling kernel overlaps between the tiles in the atlas? Won't reducing the level of mipmapping degrade overall performances? It seems weird to me that there's no bett…

[deleted]

Re: Meshing in a Minecraft Game (2012)

#9
post #2

In practice you need a 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 . Then tile in only 1 direction. Minecraft does it and I first read about it in one of Word of Notch posts -…

> 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).

Re: Meshing in a Minecraft Game (2012)

#10
post #2

In practice you need a 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 . Then tile in only 1 direction. Minecraft does it and I first read about it in one of Word of Notch posts -…

Wouldn't it be possible to apply a pixel shader that does the tiling even though there is a texture atlas? Then tiling would be possible in both directions! The pixel shader would have to do the wrapping of u and v. Fabian Giesen (rygblog) wrote at http://fgiesen.wordpress.com/2011/07/01/a-trip-through-the-g... "Some of the API state may actually end up being compiled into the shader – to give an example, relatively exotic (or at least infrequently used) features such as texture borders are probably not implemented in the texture sampler, but emulated with extra code in the shader"
Post reply on HN