Lightmaps III

The radiosity system is finally working in the editor. I’ll give a brief overview of how the system works.

As discussed previously, the level geometry is automatically unwrapped. After this direct lighting – for non-shadow casting lights – is rendered into the lightmaps using the GPU. In addition the positions and normals of each sample point (light map texel) is also rendered, to be used later.

Next the position and normal map rendered during the previous phase is downloaded into system memory. The alpha channel is used as a mask, so that texels that have no geometry associated with them are ignored. A hemicube is then rendered on the GPU for each valid texel. A cosine and distortion correction map is then multiplied with the unrolled hemicube – the result will be normalized later on the CPU.

Finally three additional GPU passes are applied, each summing 8×8 blocks of pixels and writing them into a 1/8 x 1/8 size render target. The final result of this is a single 1×1 texture in GPU memory which is then downloaded to the CPU. Finally this value is divided by a normalization factor – basically the lighting contribution over the entire hemicube should have a combined weight of 1.0.

This can be done multiple times, using the previously resulting lightmaps to generate the hemicubes. Each pass is a full radiosity bounce – so only 3 or 4 will be necessary for maximum quality (beyond that contributions become too small to be noticable). The last step is to add up the direct lighting and all the indirect lighting passes to be used on the iPhone and iPad.

Here is an example, captured directly from the iPad, of a single bounce. Note that textures have been disabled to make the effect easier to see:

The iPhone version looks the same – except smaller and a different aspect ratio. Note that the small lights on the floor are direct lights, but the effect on the walls and ceiling is caused from the indirect light. Here is an image from a previous post to compare:

Notice how much flatter the lighting is, with no reflected light on the walls and ceiling.

There are a variety of improvements I still plan on making, but I’m at the stage now where I need to start building some real environments in order to fully tweak the lighting. So next up I will start working on an area of the game (the second area you see, the first one requires some additional technology) – I hope to start putting together a gameplay prototype soon and then announce this project properly. šŸ™‚


~ by xlcontrol on April 10, 2010.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: