Jump to content
  • Advertisement
Sign in to follow this  
ehmdjii

overwriting a texture's RGB color

This topic is 4352 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

hello, in order to perform the unique coloring i mentioned in my previous post, i have to overwrite the RGB channels of a texture, while leaving the alpha channel alone. i am thinking about using Materials. is it possible to set up a material (using ambient, diffuse, specular, emission terms) to give an object a solid color? no matter what color the texture has? thanks!

Share this post


Link to post
Share on other sites
Advertisement

// Use custom combiner function setup.
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);

// Combiner RGB output is the primary color.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);

// Combiner A output is the texture.
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);

Alpha is taken from the texture and the RGB from the primary color. The primary color can be set with glColor, glColorPointer or the lighting equation, depending on how you draw your objects.

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!