10
\$\begingroup\$

Minecraft is a game that is largely based on a heightmap and uses that heigtmap information to flood the world with light. From my understanding the highest point in the heightmap is the end of the sunlight influenced area. Everything above that is lit by sunlight, everything below that just is influenced by light nearby in a radius of 8 blocks.

Thus if you have a floating island on the top of your world everything below that will be seen essentially as a cave. When two lights influence the same point the brighter light wins (unsure about that).

Either way there are a couple of problems with minecrafts lighting model: first of all, if your world does not have a heightmap it becomes trickier to figure out what exactly is supposed to emit sunlight and what not. A simple way would be to assume that the world is (in my case) a floating rock and then traverse each axis from both directions and figure out where the rock starts and ends. But this does not fully eliminate the problem as dents in the rock are not supposed to be in darkness.

Minecraft itself will cache the light information in its chunks together with the information about the material of a block. Thus only if the world is modified the lighting has to update. Unfortunately that process is still pretty slow on updates and on quick light changes one can see the lighting lag behind. That's especially true if a lot of blocks change (TNT, sunset etc.) and you're not running the fastest computer (Or Java on Mac).

From my still limited understanding of 3D graphics lighting a world like minecraft shouldn't be the biggest issue. How would you tackle the problem?

I think the basic requirements for lighting in a voxel world would be

  1. update fast enough that it could happen in a single frame. One might be able to do the lighting in the graphics device and download the changed light information to the main RAM.
  2. light information must be quickly available for the main game logic so not entirely based on the graphics device: reasoning: light affects the growth of grass, spawning of monsters etc.
  3. light updates would have to be local to a chunk or have some other limit so that one does not have to relight the whole world which might be very large in size.

The main idea would be to make the light updates fast, not necessarily more beautiful. For general light rendering performance improvements one could easily add SSAO on top of that which should result in much nicer worlds.

\$\endgroup\$
0

3 Answers 3

7
\$\begingroup\$

Lighting in Minecraft is calculated asynchronously and is baked into the geometry. It is not done in realtime.

Each voxel stores the lighting for that voxel, probably as a single byte (or 2, notch uses a layered approach to make day and night cycles possible). There are only 16 levels of light. To light the world, Minecraft does 2 passes. One for the sunlight, and another to propagate or flood the light into caves and such. The lighting is localized because any light source can only propagate its light at most 16 blocks away. Water and lava works in almost the same way.

More info is available on his blog: http://notch.tumblr.com/post/434902871/per-request-this-is-how-the-new-lighting-will-work

\$\endgroup\$
1
  • \$\begingroup\$ I know. I think I wrote that above (minus the brightness 4 bit resolution). \$\endgroup\$ Dec 20, 2010 at 23:15
1
\$\begingroup\$

Can you not use GPU Render to Texture & double-buffer your results so you always have computed lighting information available to read-back each frame?

How you'd organise this data for lighting is entirely up to you but I don't see why this shouldn't be the first option for investigation if all you're looking to do is improve the speed of your lighting algorithm..?

\$\endgroup\$
1
  • \$\begingroup\$ Exactly what I was thinking. Pretty much all GPUs, unlike most CPUs are DESIGNED for this sort of massive parallel computational exercise. \$\endgroup\$ Dec 22, 2010 at 14:53
1
\$\begingroup\$

Real-time Rendering folks seem to have a bit of a love affair with Minecraft. There was a comment something about how they've not figured out the lighting yet.. but you might want to stay tuned for further developments / links.

http://www.realtimerendering.com/blog/?s=minecraft

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .