Pixel-Composer/shaders/sh_threshold/sh_threshold.fsh

23 lines
547 B
Plaintext
Raw Normal View History

2023-01-01 02:06:02 +01:00
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform int mode;
uniform float thr;
2023-01-25 06:49:00 +01:00
uniform float smooth;
2023-01-01 02:06:02 +01:00
void main() {
vec4 col = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
if(mode == 0) {
float bright = dot(col.rgb, vec3(0.2126, 0.7152, 0.0722));
2023-01-25 06:49:00 +01:00
col.rgb = vec3(smooth == 0.? step(thr, bright) : smoothstep(thr - smooth, thr + smooth, bright));
2023-01-01 02:06:02 +01:00
} else {
2023-01-25 06:49:00 +01:00
col.a = smooth == 0.? step(thr, col.a) : smoothstep(thr - smooth, thr + smooth, col.a);
2023-01-01 02:06:02 +01:00
}
gl_FragColor = col;
}