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 ?
changing texture colors
One way is to use a lookup table which is actually a texture.
http://www.opengl.org/wiki/Common_Mistakes#Paletted_textures
http://www.opengl.org/wiki/Common_Mistakes#Paletted_textures
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;
glFragColor = baseTexture.rgba + colorOutlineTexture.a*glColor;
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement