Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My scene consists of individual meshes. At the moment each mesh has its associated light map texture, I was able to implement the light mapping using these many small textures.

1) Of course, I want to create an atlas, but how do you split atlases to pages, I mean do you group the lm's of objects that are close to each other, and load light maps on the fly if scene is expected to be big.

2) the 3d authoring software provides automatic uv coordinates for each mesh in the scene, but there are empty areas in the texel space, so if I scale the texture polygons the texel density of each face wil not match other meshes, if I create atlas like that there will be varying lm resolution, how do you solve this, just leave it as it is, or ignore resolution ?

Actually these questions also applies to other non tiled maps.

share|improve this question

3 Answers 3

up vote 1 down vote accepted

To create an atlas (without scaling the lightmaps), create an image that is, say 2x larger than your lightmap on each edge. Then you've got a 2x2 grid of lightmaps. Dump the lightmaps into it, and adjust the texture coordinates based upon which lightmap they came from. To directly answer your question, yes -- group close objects in the same lightmap. If you reverse the situation (have far away objects in the same lightmap) then you introduce performance problems almost immediately and unnecessarily.

Resolution is actually much less of a problem for lightmaps since it provides only subtle detail rather than the actual high frequency visual information such as bricks/concrete.

Scaling: don't scale things outside of the editor after generating lightmaps. Generally, you only generate lightmaps for static geometry anyways, so I don't know why you'd want to scale it. If it must be scalable, then you need some other [dynamic] solution since scaling a model can entirely change where shadows would normally occur in the lightmap generation process. In other words, it will look not just "pixely" or "blurry", but straight up wrong.

Any lightmap generation program that isn't brain dead should use area of the triangle as a way of generation "priority" for texel space. For example, if you had 4 triangles in your scene that had 2500, 300, 500, and 200 units of area, you'd expect the triangle with 2500 area to have more texel space in the lightmap allocated for it compared to the others, since increased resolution will actually be visible in the larger triangle.

share|improve this answer

Have you looked at the Q3A source code at all?
I don't know much about it's light map code other than that it is OpenGL so may answer some of your questions?

I would start with R_LoadLightmaps() in tr_bsp.c of the renderer project as a pointer...


share|improve this answer
I wonder why you brought up the Q3A sources? The OP didn't mention them anywhere? –  bummzack Mar 22 '11 at 6:48
  1. Since lightmaps only apply to geometry that won't move, having objects that are close to each other share atlases is sensible. It limits the number of lightmaps you need to use in any one frame. You can then load the lightmaps in the same way you load the other textures for those objects - reference count textures that are shared between multiple objects.

  2. The texel density of lightmaps can often be much lower than other texture maps and stil look good, especially where the lighting doesn't change much over the object. Ideally lightmap texel density would vary based on how much detail is in the texture - a smooth gradient will be approximated quite well by bilinear filtering. As doing that automatically isn't easy I'd suggest just giving the artist / designer control of the texel density for each object.

share|improve this answer
On #2, consider using area of the triangle in 3D space as a heuristic of how much texel space to allocate for it. –  PatrickB Mar 21 '11 at 17:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.