PDA

View Full Version : Lightmapping Question



HemiMG
11-08-2001, 01:09 PM
I'm trying to write a quake 1 level viewer and am having trouble with the lightmaps. The problem isn't specific to the quake format I don't think, but rather to the way I'm doing it in OpenGL.
Basically at this point I just wanted something that works so for now I'm loading in all the textures and lightmaps and using display lists for each leaf. Later I will move to vertex arrays and such for animation/optimization.
I turn on blending (it stays on.) for the first pass (I haven't used multitexturing yet.) I turn blend to glBlendFunc(GL_ZERO, GL_SRC_COLOR) then call glbegin and draw the first pass (followed by glend of course). I then switch blend to glBlendFunc(GL_ZERO, GL_SRC_COLOR) and repeat for the second pass, using the lightmap this time.
The problem is freaky stuff happens. I know for a fact that I am calculating the lightmap texture coordinates wrong (I am just using the texture map coordinates, I don't know how to calculate quake lightmap coordinates yet) but I don't think that really has alot to do with it.
Basically two freaky things are happening. First of all when I turn the screen "ghosts" meaning that I can see transparent images of the geometry beside the real geometry, and as I stop moving the "ghosts" appear to sorta move into the regular geometry. It's almost as if the blend function is drawing the real textures at an offset instead of the lightmaps. That idea is further illustrated by the point that I can see the lava overlayed on the walkway just infront of the real lava whether I am turning or not.
This is very confusing because I don't know why the textures would be drawn at all on the second pass, but the lightmaps are drawn because there are patches of black where I haven't calculated the coordinates right. I also don't see why, if the real texture is being called again, it would appear offset from where it is supposed to be.
Maybe I am calling the blend functions at a wrong location? Maybe I should turn blending off and on again at some point? Does this sound like something that maybe will just resolve itself when I get the lightmap coordinates working correctly (I wouldn't think so)?

zed
11-08-2001, 06:39 PM
theres many possible ways
1st pass
no blending draw decal textures
2nd pass
blend with src=zero dst=src_color + draw lightmaps