Jump to content
  • Advertisement
Sign in to follow this  
Desa

inverting and tinting a texture

This topic is 4415 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I want to invert the colors of a texture and then tint the inverted image. Is this possible? I know how to do both separately... // invert texture glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); glColor3ub(255, 255, 255); // tint texture glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glColor3ub(TintRed, TintGreen, TintBlue); ...but I don't know how to combine the effects. Is this possible?

Share this post


Link to post
Share on other sites
Advertisement
Check out this.

You want (1-A) * B where A is the texture color and B is the... whatever you call it... "tint color/factor". Not tested, but something like this should do it.

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE); // (1)
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE); // (2)
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTRE); // (3)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_ONE_MINUS_SRC_COLOR); // (4)
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR); // (5)
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR); // (6)

Quick walkthrough.

1: Set the texture environment to the general combiners.
2: Modulate multiplies source0 and source1.
3: source0 is taken from the texture color.
4: source0 inverts it's color before use.
5: source1 is taken from the primary color (glColor for example).
6: source1 uses the color unaltered.

So, output of the combiner is the product of the inverted texture color and the primary color.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!