PDA

View Full Version : How to color a texture in glsl



elect
07-15-2014, 01:22 AM
I need to modify during runtime the appearence of textures..
Some examples may be rendering them with a gray scale to indicate a deactivation, orange color for selection and so on


A little example that better shows what I would like to achieve

1365


Right now my FS looks pretty simple



#version 330

in vec2 fragmentUV;

out vec4 outputColor;

uniform sampler2D textureNode;

void main()
{
outputColor = texture(textureNode, fragmentUV).rgba;
}


I thought I could control these few cases by setting an uniform variable to some hardcoded values...

Cornix
07-15-2014, 02:49 AM
Just google for examples of Fragment Shaders for greyscale or Hue-Change. There are plenty of tutorials and examples, I can remember how I was looking for this about a year ago.

elect
07-15-2014, 06:06 AM
Just google for examples of Fragment Shaders for greyscale or Hue-Change. There are plenty of tutorials and examples, I can remember how I was looking for this about a year ago.

And have you found anything working so far? Because the few clear examples I found dont work, such as http://gamedev.stackexchange.com/questions/59797/glsl-shader-change-hue-saturation-brightness

Cornix
07-15-2014, 07:00 AM
Yes of course, everything I found worked. Are you sure its the example? Perhaps you have made a small mistake at some point? Are you reading the error logs of the compiler and are you using debug output to see whats happening?