PDA

View Full Version : Lightmap slow



Neofit
03-28-2006, 09:21 AM
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);

CrazyButcher
03-28-2006, 10:31 AM
8x8x3 x 1000 is like 187.5 KB which is nothing ? for static stuff I wouldn submit textures like this, but try to make texture atlas of many small lightmaps, since lightmaps must be unique in uvcoords, there shouldnt be much problems. Looking at quake3 and other lightmap based games, this works very well...

Mikkel Gjoel
03-29-2006, 01:09 PM
I think you're right - doing a thousand calls to glBindTexture and glTexSubImage doesn't sound healthy. I'd suggest going with the texture-atlas approach too :)