Jump to content
  • Advertisement
Sign in to follow this  
redb

OpenGL changing texture colors

This topic is 2600 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 am using SDL/Opengl in a game project, I am using textures with specific colors that I wish change to another ( on user choice, eg, replacing grey section by green color, blue section by red, etc .. )

My first solution was to load a SDL_Surface and changing every pixel from one color to another, but that is not really fast, is it possible to do a dynamic color change in a texture with opengl ?

Share this post


Link to post
Share on other sites
Advertisement
One way is to use a lookup table which is actually a texture.
http://www.opengl.org/wiki/Common_Mistakes#Paletted_textures

Share this post


Link to post
Share on other sites
If your doing something like team color markings, you can make a 2nd texture that overlays your actual texture with all white and alpha (or just an intensity from 0 to 1). Where 1 or white is where you want team color markings to show up. Then you can just send a color to the shader and it will be something like:

glFragColor = baseTexture.rgba + colorOutlineTexture.a*glColor;

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!