2023-01-01 02:06:02 +01:00
|
|
|
//
|
|
|
|
// Simple passthrough fragment shader
|
|
|
|
//
|
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
uniform int bright;
|
|
|
|
uniform vec2 brightThreshold;
|
|
|
|
uniform int brightThresholdUseSurf;
|
|
|
|
uniform sampler2D brightThresholdSurf;
|
|
|
|
uniform float brightSmooth;
|
2023-08-03 20:01:58 +02:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
uniform int alpha;
|
|
|
|
uniform vec2 alphaThreshold;
|
|
|
|
uniform int alphaThresholdUseSurf;
|
|
|
|
uniform sampler2D alphaThresholdSurf;
|
|
|
|
uniform float alphaSmooth;
|
2023-08-03 20:01:58 +02:00
|
|
|
|
2024-07-05 02:38:41 +02:00
|
|
|
float _step( in float threshold, in float val ) { return val < threshold? 0. : 1.; }
|
2023-01-01 02:06:02 +01:00
|
|
|
|
|
|
|
void main() {
|
2023-12-23 09:39:55 +01:00
|
|
|
float bri = brightThreshold.x;
|
|
|
|
if(brightThresholdUseSurf == 1) {
|
|
|
|
vec4 _vMap = texture2D( brightThresholdSurf, v_vTexcoord );
|
|
|
|
bri = mix(brightThreshold.x, brightThreshold.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
|
|
|
}
|
|
|
|
|
|
|
|
float alp = alphaThreshold.x;
|
|
|
|
if(alphaThresholdUseSurf == 1) {
|
|
|
|
vec4 _vMap = texture2D( alphaThresholdSurf, v_vTexcoord );
|
|
|
|
alp = mix(alphaThreshold.x, alphaThreshold.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
|
|
|
}
|
|
|
|
|
2023-01-01 02:06:02 +01:00
|
|
|
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-12-23 09:39:55 +01:00
|
|
|
col.rgb = vec3(brightSmooth == 0.? _step(bri, bright) : smoothstep(bri - brightSmooth, bri + brightSmooth, bright));
|
2023-08-03 20:01:58 +02:00
|
|
|
}
|
2023-12-23 09:39:55 +01:00
|
|
|
|
2023-08-03 20:01:58 +02:00
|
|
|
if(alpha == 1) {
|
2023-12-23 09:39:55 +01:00
|
|
|
col.a = alphaSmooth == 0.? _step(alp, col.a) : smoothstep(alp - alphaSmooth, alp + alphaSmooth, col.a);
|
2023-01-01 02:06:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gl_FragColor = col;
|
|
|
|
}
|