how to render a scene to texture atlas


I’m new to opengl. I’ve read the texture altas documentations, to my understanding, most of them are talking about how to texture mapping different objects while look up to one single texture(that contains multiple textures in one layer).

Therefore, I’d like to render my scene(say a cornell box) to texture atlas. The idea is, since the scene is diffuse, it won’t matter where the camera is, so at run time I can look up texture atlas to shade these objects, instead of compute them.

My questions are:

do I need to separately render every objects to the texture? If so, how am I supposed to do that since the objects have provide occlusions for each other? Even if I succeeded in create the texture atlas, at run time, if I look up the texture atlas at fragment shader, I won’t have objects information to do that… what am I supposed to do?

Or, maybe I should directly render the scene to texture, but in this way I won’t be able to use the texture once the camera moves. :frowning:

Thanks very much!


It seems you want to “bake” a light map. Essentially, you need to assign a set of texture coordinates within the light map (even if you already have texture coordinates within the source texture(s)), then render all of the objects to the light map using the light-map texture coordinates as vertex positions. Then you can render the scene normally, using the light-map texture coordinates as texture coordinates.