Sign in to follow this  
ehmdjii

overwriting a texture's RGB color

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this