noobscratcher
10-23-2011, 03:31 AM
Hello i have been working on shaders for a little while now reading the orange book but still having troubles
Anyways i was hoping someone would be able to show or explain simply how to discard a fragment on the background colour of a texel
like so
///////////////////////////////////////////////////
fragment shader
sampler2D myTexture;
varying vec2 vTexCoord;
void main (void)
{
vec4 color = texture2D(myTexture, gl_TexCoord);
gl_FragColor = color;
if(color.rgb = vec3(1,0,0))
discard;
}
/////////////////////////////////////////////////
vertex shader
varying vec2 vTexCoord;
void main(void)
{
vTexCoord = gl_MultiTexCoord0.xy;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
////////////////////////////////////////////////////////
using version 1.2 glsl code
on another note is it wrong to not like too much technicality's?
I have looked around on the net namingly the clockworkers,lighthouse,gl site, all sorts and the tutorials arnt working especially the clockworkers one i'm not shore about the other few because i was only looking on how to colorkey.
http://www.opengl.or...ers/discard.php
This is the closes i have found to helping me but it dont work it discards everything rather then select color i asked and my texture has red color on the background ,that color is red like in the example above
thanks in advance
Anyways i was hoping someone would be able to show or explain simply how to discard a fragment on the background colour of a texel
like so
///////////////////////////////////////////////////
fragment shader
sampler2D myTexture;
varying vec2 vTexCoord;
void main (void)
{
vec4 color = texture2D(myTexture, gl_TexCoord);
gl_FragColor = color;
if(color.rgb = vec3(1,0,0))
discard;
}
/////////////////////////////////////////////////
vertex shader
varying vec2 vTexCoord;
void main(void)
{
vTexCoord = gl_MultiTexCoord0.xy;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
////////////////////////////////////////////////////////
using version 1.2 glsl code
on another note is it wrong to not like too much technicality's?
I have looked around on the net namingly the clockworkers,lighthouse,gl site, all sorts and the tutorials arnt working especially the clockworkers one i'm not shore about the other few because i was only looking on how to colorkey.
http://www.opengl.or...ers/discard.php
This is the closes i have found to helping me but it dont work it discards everything rather then select color i asked and my texture has red color on the background ,that color is red like in the example above
thanks in advance