Ligthmap slow generation

Started by
3 comments, last by zedzeek 18 years ago
Hi all, I have a problem with the generation of lightmap... i created a texture id (in my init) for all object that use lightmap code in init: glGenTextures(1, &textLight); glBindTexture(GL_TEXTURE_2D, textLight); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); but when i refill this texture it is very slow code in the objects: glBindTexture(GL_TEXTURE_2D, textLight); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LIGHTMAPSIZE, LIGHTMAPSIZE, GL_RGB, GL_UNSIGNED_BYTE, dataLight); if i use a texture id for a single objects framerate is very fast, but i can't do it because it use very video card memory expansive (a texture is 8*8, 1000 object = 64 mega!) i think the problem is glBindTexture(GL_TEXTURE_2D, textLight); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LIGHTMAPSIZE, LIGHTMAPSIZE, GL_RGB, GL_UNSIGNED_BYTE, dataLight); [Edited by - raizen on March 28, 2006 6:06:27 AM]
Advertisement
im a bit worried about this line
(a texture is 8*8, 1000 object = 64 mega!)
if i understand correctly youre creating 1000 different lightmap textures (perhaps a differnet texture for each polygon or wall or something)
this is not the way to do it, u need to pack the smaller lightmap textures into a larger lightmap texture
eg quake3 has 1000's of lightmaps but packs them all into 3-6 lightmaps of 256x256
If these are static lightmaps that don't change, then I don't see why you can't just
do this lightmap generation outside the game, so this texture is always ready. This
way, you don't have to use a 1000 little lightmap textures, just pack them all onto one
or two large 1024 x 1024 textures. Everything is prepared beforehand.
Quote:Original post by zedzeek
im a bit worried about this line
(a texture is 8*8, 1000 object = 64 mega!)
if i understand correctly youre creating 1000 different lightmap textures (perhaps a differnet texture for each polygon or wall or something)
this is not the way to do it, u need to pack the smaller lightmap textures into a larger lightmap texture
eg quake3 has 1000's of lightmaps but packs them all into 3-6 lightmaps of 256x256


no no i use a single lightmap for all the objects, i use the same texture id when generate the next luightmap, but i think this is the problem... because i must generate every frame the texture with glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LIGHTMAPSIZE, LIGHTMAPSIZE, GL_RGB, GL_UNSIGNED_BYTE, dataLight);
Quote:
no no i use a single lightmap for all the objects, i use the same texture id when generate the next luightmap, but i think this is the problem... because i must generate every frame the texture with glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, LIGHTMAPSIZE, LIGHTMAPSIZE, GL_RGB, GL_UNSIGNED_BYTE, dataLight);

ok i understand, so you wanna do dynamic lightmaps ( as JakeM pointed out for static lights you would regenerate them)
for textures/drawing geometry etc its usually better doing as much as possible in one call instead of making lots of smaller calls.
thus in this case workout all the lightmap shading stuff + then upload it with glTexSubImage2D all at once.
perhaps look at humus's site i believe he has a dynamic lightmap demo there

This topic is closed to new replies.

Advertisement