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?
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 ;-).
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
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 …