Pixel-Composer/shaders/sh_blink_extract/sh_blink_extract.fsh

37 lines
741 B
Plaintext
Raw Permalink Normal View History

2023-07-18 17:51:40 +02:00
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
2024-01-12 13:11:26 +01:00
uniform float tolerance;
uniform int useMask;
2023-07-18 17:51:40 +02:00
uniform sampler2D mask;
2024-09-10 05:40:05 +02:00
#ifdef _YY_HLSL11_
#define PALETTE_LIMIT 1024
#else
#define PALETTE_LIMIT 256
#endif
2024-01-12 13:11:26 +01:00
uniform vec4 colorTarget[PALETTE_LIMIT];
2023-07-18 17:51:40 +02:00
uniform int colorTargetAmount;
void main() {
vec4 c1 = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = vec4(0.);
if(useMask == 1) {
vec4 m = texture2D( mask, v_vTexcoord );
if((m.r + m.g + m.b) * m.a < 0.5)
return;
}
float minDist = 10.;
for(int i = 0; i < colorTargetAmount; i++) {
float dist = distance(colorTarget[i].rgb, c1.rgb);
minDist = min(minDist, dist);
}
2024-01-12 13:11:26 +01:00
if(minDist > tolerance) return;
2023-07-18 17:51:40 +02:00
2024-01-12 13:11:26 +01:00
gl_FragColor = vec4(v_vTexcoord, 1., 1.);
2023-07-18 17:51:40 +02:00
}