Monday 4 October 2010

Minecraft Rendering


So, Minecraft is getting great press. Whether it a flash-in-the-pan boom and bust economy or a slow builder is irrelevant at this time. The Minecraft Guy had a pretty good idea, implemented it and is getting the recognition he deserves.

Pulling apart the game, landscapes seem pretty important. Without being able to render a vast landscape the game wouldn’t be worth a fraction of what it is. So I’ve been pondering on what it takes to pull off such a techincal feat.

The world is made of blocks. About 1m each is a fair estimation for a sense of scale, and the visible world extends to about 192 units until you reach the far clip plane. The far clip plane can be reduced to about 128 units by adding fog which provide us the ‘Far’ and ‘Normal’ draw distances and it can be reduced further yet with Short and Tiny draw distances.

192 blocks radius is a 384x384 area containing a theoretical 384x384x384 blocks in the observable world reaching a staggering 56Million blocks to cull and render.

A broadphase pass that doesn’t even attempt to render air and creates a render list based on the occlusion of block using its six neighbours drops these unimaginable millions to a contemplatable two dimensional 384x384 ‘surface’ approaching 150,000 cubes at six quads each, still getting on for a million quads.

150,000 is a lot of cubes, and view frustrum culling with a <= 90’ field of view will reduce this to a ball-park of (192*192) 36864 Cubes and CPU side backface culling gives you a three quad per cube total of 110,000 Quads. Its a lot, to be sure, but its a managable amount compared to the 300Million+ Quads of the unculled estimate.

110,000 Quads feels like a lot, but might just be enough to brute force. At this point I’d probably still assume we are Render Bound so a sensible step would be to divide the task separate threads for Render, Occlusion, Game and Network and rely on the Host OS to manage four threads well enough.

A closer far clip plane and a 128 unit draw distance does reduce this to around 50,000 Quads and a 64 Unit draw distance reduces it further to a mere 12,000 Quads to render. The draw distance can probably be increased above 192 quite cheaply with a combination of untextured blocks, chunk sub-sampling and render proxies.


No comments:

Post a Comment