Jump to content
  • Advertisement
Sign in to follow this  
_walrus

using combiners to increase saturation of a texture (with alpha)

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

Hey guys i'm trying to use combiners to increase the saturation level of a texture in one pass. It's a 2d sprite based iphone game. the effect is working except that there is a white rectangel around the sprite. its seems like it is adding the PRIMARY_COLOR (defined in glColor). I specify GL_REPLACE and GL_TEXTURE as the SRC for the alpha value computation so from what i understand it should be simply be using the alpha value from the texture. I've been at this about 6 hours and no luck with trying to figure out what is wrong. ALso the texture i am using has a premultipled alpha value (i dont think this is the problem tho). Any help would be greatly appreciated!!! Thanks!!

drawSaturatedMonster(float colorStep)
{
//setup saturation effect on texture
glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC1_RGB, GL_PRIMARY_COLOR);

//use the alpha from the texture
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SRC0_ALPHA, GL_TEXTURE);

//specify the ossolating color
glColor4f(colorStep, colorStep, colorStep, colorStep);

//draw the texture
drawTheTexture();

//revert to original mode
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

}

screen shot at (sry bout the quality of the image, i couldnt get a screen grab properly from the simulator):
http://www.flickr.co...N03/5509792066/

Share this post


Link to post
Share on other sites
Advertisement
I'm not an expert on texture combiners, but maybe you are forgetting to set the GL_OPERANDs? I'm guessing this purely from looking at the examples here:

http://www.opengl.org/wiki/Texture_Combiners

They all specify operands as well:


glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_ADD); //Add ALPHA with ALPHA
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);


Alternatively, this would be much simpler with a shader :)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!