Saturday, December 18, 2010

Minecraft level reader

Most of the framework consists of modules that can be chained together. One example is the part that reads and writes the game world to some kind of persistent storage. The default module is something that sits on top of the face-meltingly fast sqlite. (Bonus: save games are just one single file, not thousands.) And of course there's the binvox reader. But yesterday I wrote a module that can read Minecraft files, just to have some cool pre-made worlds to test with.

This module reads a Minecraft chunk, slices and dices it in 8 cubes, roughly translates the block types (far from perfect), and passes it to the server. Everything higher than 64 blocks is air, everything below -64 is rock. If the requested chunk is outside the map, it falls through to the "null" module, which does nothing. This triggers the terrain generator, which right now is a simple, infinitely large flat plain.

Today we're going to have a look around the Broville map. It is legen... wait for it... dary:






One of the problems I've encountered here is that windows don't let much light through:



The room is rather dark for several reasons.  One, the walls are 1m thick, so the sides occlude a good part of the sky outside.  Two, there's no radiosity: the light doesn't bounce around the room like it usually does.  I was planning to add a radiosity pass after I've implemented point light sources, and it should be interesting to see how much of a difference this makes.

Even the church with its big windows looks gloomy... (The trees right in front of all the windows don't help either...)



If the radiosity solution doesn't work, I guess people will have to build huge sun-facing windows and place plenty of lanterns. :P

(Minecraft doesn't have this problem; the light is always spread out across 15 blocks in a diamond pattern.)

The next step would be to convert the light map back to the Minecraft files. It would look odd once MC's own light model takes over again, but perhaps it'd be a cool addition for the static parts of a multiplayer map.


Also, check out this blog entry. Very interesting techniques! I've been toying with the idea of using geometry shaders to build the meshes, and this is an excellent demonstration of how to do that.

No comments:

Post a Comment