Skip to main content
GameDev.net gamedev.net
🔒 Locked

How to make a texture brighter

Started by cschueler Apr 16, 2001 at 7:47 AM 2 replies 1.1k views
Original Post
cschueler
cschueler
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
kashey
kashey
Many ways :
so first is to blend to this trignale other with glBlend(GL_ONE,GL_ONE) it will add new`s triangle color to existsing
next is do same on other TMU( but you need texture there)
also you can quicly regen texture.. so set in pixel tranfer that color will be transmited in 150% and glSubImage texture to itself.. if it is in video memory it will be fast..
cool programer
TaintedFire
TaintedFire
In DX, you can use COLOROP to add two colour arguments together, (to make it brighter), modulate it, add and shift (<<) 1, etc.

Is this what you mean?

-TF
cschueler
cschueler
Hi TaintedFile and kashey

thanks for the suggestions. I have rewritten the original post to make things more clear. glSubImage and things are pretty slow on my old card suppose the driver does it in software... I have tried with glCopyPixels, it slow like a pain.

I just want to know if someone knows of any graphics card which TMU can scale pixels with > 1. If no card can do this, then my question will ends there.

I''m just curious if anybody had the same intention than I and wanted to do this effect.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.