PDA

View Full Version : Combining Lightmaps



Cebu
04-04-2001, 12:43 PM
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!

Lord crc
04-04-2001, 02:49 PM
ok, here i go answering something way over my head http://www.opengl.org/discussion_boards/ubb/smile.gif


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 http://www.opengl.org/discussion_boards/ubb/smile.gif

Lord crc
04-04-2001, 02:57 PM
right, i guess that should be

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

Cebu
04-04-2001, 03:32 PM
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.

Lord crc
04-04-2001, 03:41 PM
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.

zed
04-04-2001, 06:23 PM
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 )

Cebu
04-04-2001, 07:10 PM
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.

zed
04-05-2001, 12:44 PM
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.

04-05-2001, 11:22 PM
Have you considered procedural modification instead of performing multiple passes?

Cebu
04-06-2001, 09:32 AM
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?

04-06-2001, 11:28 AM
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.