[PD] glsl code

marius schebella marius.schebella at gmail.com
Thu Nov 8 15:53:59 CET 2007


hi,
is it possible to ask shader related questions on the pd list? I am 
trying to write pix_alpha as a shader, but for now I have problems with 
the glsl code. (maybe you can also point me to a shader forum or mailing 
list that you know is good?)
I have a fragment shader, which is not working, and I don't know why.
the problem is that "A.a = other" does not set the value correct (it 
always sets 0).
If I write A.a = 0.5 for example, then it is working.
The variables are passed correctly, all other variables work too, so I 
think it is really a problem of how glsl works, and an error in the 
code. what it should do is when the red pixel value is within a certain 
range, the alpha value should be set to the pass value, and if it is 
outside, it should be set to the other value. (similar to pix_alpha, but 
only with red at the moment)
thanks,
marius.

---------
// red pix alpha

uniform sampler2D texture;
varying vec2 texcoord0;

uniform vec4 hithresh;	// hi and lo threshold
uniform vec4 lothresh;
uniform float pass;
uniform float other;

void main()
{
	vec4 A = texture2D(texture, texcoord0);
	A.a = pass;
	if ((A.r >= hithresh.r) || (A.r <= lothresh.r))
	{
		A.a = other;
	}
	gl_FragColor = A;
}




More information about the Pd-list mailing list