Combining Lightmaps

Well I asked this over in the advanced forum, and no one has answered yet. Figured I’d try here instead:

I know this has come up before, but after following previous posts, I couldn’t get this to work. I’m basically trying to combine two lightmaps together. In my case, this would be used to add a dynamic lightmap to a static lightmap. I know this has to be possible.

I’ve messed around with GL_ADD in multitexturing, with no success. Is this what I should be using? If anyone could point me in the right direction, I would be grateful. If it has anything to do with GL_ADD, please include source, since I just can’t get this to work.

Thanks in advance!

ok, here i go answering something way over my head

ive never used lightmaps, so this might very well be totally wrong, but:

draw static lightmap using blend mode of
GL_SRC_COLOR, GL_ZERO
draw dynamic lightmap using GL_SRC_COLOR, GL_DST_COLOR (adding it to the static one)

then draw texture using GL_DST_COLOR, GL_ZERO (muliplying the lightmap with the texture)

sounds like it might work, but then, ive never been near lightmaps

right, i guess that should be

static: GL_ONE, GL_ZERO
dynamic: GL_ONE, GL_ONE
texture: GL_DST_COLOR, GL_ZERO

Hmm I was trying to avoid multiple passes if possible, but maybe it can’t be avoided. Or maybe it can be combined with multitexturing to bring it down to 2 passes. Thanks for the info though… I’ll try that out sometime soon and let you know how it goes.

hmmm, well, i guess you could mod the lightmap directly but then youd need to make a backup somewhere and youd have the same low res as the static. now, doesnt most modern cards do 3 pass multitexturing? im sure i heard they where going to support like 7 pass or something.

with multitexturing u can do both passes in one
try this
glActiveTextureARB(GL_TEXTURE0_ARB);
glBindTexture(GL_TEXTURE_2D, lightmap1); glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f(1,1,1,1)

glActiveTextureARB(GL_TEXTURE1_ARB);
glBindTexture(GL_TEXTURE_2D, lightmap2); glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glColor4f(1,1,1,1)

no need for blending, its up to you to choose if you want to modulate or add the colours ( though prolly modulating is a safe bet for lightmapping/darkmapping )

Zed, I’m not near my developing station right now so I can’t test stuff. So… thought I’d ask: where does the original texture fit into what you are suggesting? You’ve got both lightmaps covered but please explain/show source on what I’d do with the texture that these maps are going onto.

original texture , you only mentioned how to blend 2 lightmaps together, i take it you have some thing like this

tex0 bricks
tex1 static lm
tex2 dynamic lm

bind tex0 - bricks + tex1 static lm
set it up + draw it (using multitexture) like ive explained above.

now disable tex1.
bind tex0 -> dynamic lm
enable blending
blend func dst_color src_color
dont change anything else ie the colour stays at 1,1,1,1 + modulate.
make sure your depth stuff is sorted and then draw the dynamic lm.

Have you considered procedural modification instead of performing multiple passes?

Zed - I haven’t gotten it to work yet… but I haven’t been able to spend much time on it either. At a glance though, all I am getting is a very light spot where the whiteness on the second lightmap is. Everything else is black. I know the other stuff is working, if I take out the second pass, the first lightmap is on the bricks just fine.

Kludgy - What is that? I assume it deals with manipulating the actual textures instead of using multiples? If so, are there any handle tutorials / writeups on this?

I believe the glquake trick was to keep a conventional ram copy of every lightmap, only reuploading the changed ones on demand.

That being said, I’m afraid I don’t know anything about the implementation specifics.