T
Toxicosis
Guest
Hello,
I'm trying to do a shader that passes exactly one color, comparing the color to a list before drawing every pixel. If the color matches a parameter, it should draw a listed color, and if the color does not, it will draw a pixel with zero alpha. How could I go about this?
I tried using the Shaderific list of shader functions, available at http://www.shaderific.com/glsl-functions/ and picked the Equal function for this.
I tried it like this...
I get an unspecified error in line 16. The line highlighted is line 15, but commenting it out allows the compilation to proceed (given we comment out the gl_FragColor line too and use a different output).
The following variations on the bolded line also fail to compile.
How do I use the equal function?
I'm trying to do a shader that passes exactly one color, comparing the color to a list before drawing every pixel. If the color matches a parameter, it should draw a listed color, and if the color does not, it will draw a pixel with zero alpha. How could I go about this?
I tried using the Shaderific list of shader functions, available at http://www.shaderific.com/glsl-functions/ and picked the Equal function for this.
I tried it like this...
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec3 color_read;
uniform vec3 color_draw;
const vec4 color_blank = vec4(0, 0, 0, 0);
void main()
{
vec4 v_pointer = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
vec3 mix_control = bvec3 equal(v_pointer.rgb, color_read); //WHEN I COMMENT OUT THIS LINE IT WORKS
vec4 color_end = vec4 (color_draw.rgb, v_pointer.a);
gl_FragColor = mix(color_blank, color_end, mix_control);
}
The following variations on the bolded line also fail to compile.
Code:
vec3 mix_control = bvec3 equal(v_pointer.rgb, color_read);
vec3 mix_control = vec3 equal(v_pointer.rgb, color_read);
float mix_control = float equal(v_pointer.rgb, color_read);
float mix_control = float equal(v_pointer.r, color_read.r);
float mix_control = equal(v_pointer.r, color_read.r);
(The last one throws up a different error message. Error : [F]Shader_shd_one_color(16) : 'equal' : no matching overloaded function found)