I’m using lightmaps to light (darken) my terrain, but I’m beginning to wonder if GL_MODULATE is actually doing what I think it should. When I apply the lightmap texture (with GL_MODULATE), the terrain gets darker, the way it is supposed. Only it gets a bit to dark! The problem is that even if I use an all white texture, the terrain still gets darker than if no lightmap is added.
Why is that? What am I doing wrong?
There can be quite a few things you do wrong. Given the information you gave, that’s about all I can say for now.
Post some code.
By the way, remeber that with modulation, you can never make the result brigter than the base texture, only darker.
It turned out to be a problem with my multipass setup: First texture in second pass should be applied with GL_REPLACE not GL_MODULATE. Found it while looking for the right code to post ;-).
Dithering can sometimes do that as well.
Aren’t they called attenuation maps then?
Try replace GL_MODULATE to GL_DECAL.
And try to play around with normal…
I believe that the problem is that you need to coax the blend function into doubling the intensity of the second texture. I ran into a similar problem before and tinkered around with a C++ class that would let me select single textured, multi-pass textured, and multitextured rendering options. You can view the source code at
You can download the test project, compiled executable, and associated data at …
Look in the render method at the 3 way if statement. If the bool m_DoubleSecondaryIntensity is true then the blending function used is glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR). Essentially that doubled the intensity of the 2nd texture and gave me a near exact match with the multitextured version.
Note the use of the state manager (class MgGlStateManager). While the code for it is in my engine which is not included in the zip archive, its syntax is fairly simple …
If we use a state manager such as this …
Then it can be used such as this …
glEnable(GL_BLEND) => sMgr.enable(GL_BLEND)
glDisable(GL_BLEND) => sMgr.disable(GL_BLEND)
glBlendFunc(GL_DST_COLOR, GL_SRC_COLOR) =>sMgr.setBlendFunc(GL_DST_COLOR, GL_SRC_COLOR)
Hope this helps …
[This message has been edited by pleopard (edited 07-30-2002).]