Original Post
I understand this: If I draw a textured triangle, then the vertex colors are interpolated across the triangle like gouraud shading and modulate the texel colors. If the vertex colors are all white (1,1,1) then the texel colors are not modulated and drawn like they are stored.
Since vertex colors are clamped to the region [0..1] there seems to be no way to draw a texture with a positive gain. With "gain" I mean the factor that is applied to the texels to produce the screen pixels. I want to have a texel colors multiplied by a factor greater than 1 and the final pixels clamped to the region [0..1]. Like this:
Texels Vertex Pixels on Screen
Color
R 151 1.5 227
G 85 1.5 127
B 221 1.5 255
The texture is stored as is in memory, it's just that the vertex color can be > 1. Is the hardware TMU capable of multiplying texel colors with a positive gain?
Note that this is a different effect than alpha-blending. I could make a surface brighter by blending it with white, but that's not the correct effect in my eyes; black must remain black.
I have already (and successfully) implemented a routine that draws textures with an arbitrary gain factor using multiple additive passes. That is, if the desired gain was 2.5 it would get drawn 2 times originally (with factor 1) then a third pass modulated with 0.5 yielding a surface on the screen where each texel was brightened by factor 2.5. However this technique can get somewhat slow for high gain factors. Of course, normal "darkening" texture drawing is done in 1 pass, as it used to be. The routine works like this:
void Draw( float gain )
{
glDisable( GL_BLEND );
while( gain > 1 )
{
glColor3f( 1,1,1 );
DRAW TRIANGLE;
gain -= 1;
glEnable( GL_BLEND )
glBlendFunc( GL_ONE, GL_ONE );
}
glColor3f( gain, gain, gain );
DRAW TRIANGLE;
}
(This code is just to show the principle)
The thing is that I want to have both "normal" texture modulation (gain < 1) with amplifying modulation (gain > 1) on the same screen in the same scene, so there is no point in scaling the original texture data.
Is there any more effective method that I haven't discovered yet?
-chris
Edited by - cschueler on April 17, 2001 12:43:41 PM