speedbird25
09-12-2011, 02:31 AM
Hi!
We have the following problem: We want to implement a grayscale fragment shader for the entire scene. The scene consists of a 2D graphics that uses
* non-textured primitives (e.g. GL_POLYGON) and
* textured primitives (GL_QUADS).
Rendering is done in an external library and some is done in our library.
The fragment shader code (very simple conversion to grayscale):
uniform sampler2D tex;
void main()
{
gl_FragColor = gl_Color * texture2D(tex, gl_TexCoord[0].st);
gl_FragColor = glFragColor.rrra;
}
Now, the following problem arises: When there is no texture used, the pixels are still combined with a texel color and look strange. The question is: Is there any way to check if a texture is currently bound? We know that we can use a uniform variable and set it from outside, but as some parts of the scene come from an external library, we don't know when a texture is used.
This post at stackoverflow is related:
http://stackoverflow.com/questions/6686741/fragment-shader-glsl-for-texture-color-and-texture-color
Thanks,
Stephan
We have the following problem: We want to implement a grayscale fragment shader for the entire scene. The scene consists of a 2D graphics that uses
* non-textured primitives (e.g. GL_POLYGON) and
* textured primitives (GL_QUADS).
Rendering is done in an external library and some is done in our library.
The fragment shader code (very simple conversion to grayscale):
uniform sampler2D tex;
void main()
{
gl_FragColor = gl_Color * texture2D(tex, gl_TexCoord[0].st);
gl_FragColor = glFragColor.rrra;
}
Now, the following problem arises: When there is no texture used, the pixels are still combined with a texel color and look strange. The question is: Is there any way to check if a texture is currently bound? We know that we can use a uniform variable and set it from outside, but as some parts of the scene come from an external library, we don't know when a texture is used.
This post at stackoverflow is related:
http://stackoverflow.com/questions/6686741/fragment-shader-glsl-for-texture-color-and-texture-color
Thanks,
Stephan