Lightmaps Part I

I’ve been modifying the level editor to support lightmaps. The tool unwraps the level geometry while keeping a nearly constant texel to worldspace ratio. This is done so that edges of different faces have the same texel density to limit errors and to generate consistent quality throughout the level. The tool then packs the surfaces into a single lightmap texture for a level. Right now I’m only rendering direct lighting into the lightmaps, using the GPU, but will be adding full GPU assisted radiosity support next. In addition I will be adding local light shadows, emissive textures (emissive surfaces will automatically emit light) and in-editor light painting.

Here is the lightmap generated – 512×512 right now. It is a small test level, the extra space will be used for real levels.

All screenshots below are taken from the level editor. Lightmap support will be added to the game (on the iPhone obviously) by the next update. Also diffuse textures have been disabled so the lighting is clearly visible.

After rendering the lightmap, I have to apply a hole filling pass on the texture (also done on the GPU) otherwise seams are visible. This is caused by limited rasterization precision when generating the lightmaps and bilinear filtering reading outside the primitive when rendering the lightmapped surfaces.

Lightmap seams (no hole filling):

After seam filling:


~ by xlcontrol on March 25, 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: