PDA

View Full Version : 1 * x != x ?



abrodersen
07-29-2002, 11:28 PM
Hi.

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?

Thanks

Anders

Bob
07-30-2002, 01:38 AM
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.

abrodersen
07-30-2002, 02:26 AM
Hi again.

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

Thanks.

fresh
07-30-2002, 12:00 PM
Dithering can sometimes do that as well.

kevinhoque
07-30-2002, 01:00 PM
Aren't they called attenuation maps then? :-)

Kevin

cwc36
07-30-2002, 03:52 PM
Try replace GL_MODULATE to GL_DECAL.
And try to play around with normal..

pleopard
07-30-2002, 09:35 PM
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

http://www.magnacom-inc.com/pleopard/MultiTexturedQuad.h
http://www.magnacom-inc.com/pleopard/MultiTexturedQuad.cpp

You can download the test project, compiled executable, and associated data at ...
http://www.magnacom-inc.com/pleopard/MultiPassTexture2.zip


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 ...

MgGlStateManager sMgr;
sMgr.glSynchronize();

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).]