2023-01-01 02:06:02 +01:00
|
|
|
//
|
|
|
|
// Simple passthrough fragment shader
|
|
|
|
//
|
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
2023-08-03 20:01:58 +02:00
|
|
|
uniform int bright;
|
|
|
|
uniform float brightThreshold;
|
|
|
|
uniform float brightSmooth;
|
|
|
|
|
|
|
|
uniform int alpha;
|
|
|
|
uniform float alphaThreshold;
|
|
|
|
uniform float alphaSmooth;
|
|
|
|
|
|
|
|
float _step( in float threshold, in float val ) { return val <= threshold? 0. : 1.; }
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
vec4 col = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
|
|
|
|
|
2023-08-03 20:01:58 +02:00
|
|
|
if(bright == 1) {
|
2023-01-01 02:06:02 +01:00
|
|
|
float bright = dot(col.rgb, vec3(0.2126, 0.7152, 0.0722));
|
2023-08-03 20:01:58 +02:00
|
|
|
col.rgb = vec3(brightSmooth == 0.? _step(brightThreshold, bright) : smoothstep(brightThreshold - brightSmooth, brightThreshold + brightSmooth, bright));
|
|
|
|
}
|
|
|
|
|
|
|
|
if(alpha == 1) {
|
|
|
|
col.a = alphaSmooth == 0.? _step(alphaThreshold, col.a) : smoothstep(alphaThreshold - alphaSmooth, alphaThreshold + alphaSmooth, col.a);
|
2023-01-01 02:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gl_FragColor = col;
|
|
|
|
}
|