2024-10-24 12:40:14 +02:00
|
|
|
#pragma use(sampler_simple)
|
|
|
|
|
|
|
|
#region -- sampler_simple -- [1729740692.1417658]
|
|
|
|
uniform int sampleMode;
|
|
|
|
|
|
|
|
vec4 sampleTexture( sampler2D texture, vec2 pos) {
|
|
|
|
if(pos.x >= 0. && pos.y >= 0. && pos.x <= 1. && pos.y <= 1.)
|
|
|
|
return texture2D(texture, pos);
|
|
|
|
|
|
|
|
if(sampleMode <= 1) return vec4(0.);
|
|
|
|
else if(sampleMode == 2) return texture2D(texture, clamp(pos, 0., 1.));
|
|
|
|
else if(sampleMode == 3) return texture2D(texture, fract(pos));
|
|
|
|
else if(sampleMode == 4) return vec4(vec3(0.), 1.);
|
|
|
|
|
|
|
|
return vec4(0.);
|
|
|
|
}
|
|
|
|
#endregion -- sampler_simple --
|
|
|
|
|
2024-03-15 13:38:08 +01:00
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
|
|
|
uniform float size;
|
|
|
|
uniform float spread;
|
|
|
|
|
|
|
|
uniform vec2 direction;
|
|
|
|
uniform int directionUseSurf;
|
|
|
|
uniform sampler2D directionSurf;
|
|
|
|
|
|
|
|
uniform vec2 strength;
|
|
|
|
uniform int strengthUseSurf;
|
|
|
|
uniform sampler2D strengthSurf;
|
|
|
|
|
2024-07-09 13:24:20 +02:00
|
|
|
uniform vec2 dimension;
|
|
|
|
uniform int alpha;
|
|
|
|
uniform int modulateStr;
|
|
|
|
uniform int inv;
|
2024-08-25 10:18:22 +02:00
|
|
|
uniform int blend;
|
2024-10-16 12:34:26 +02:00
|
|
|
uniform int normalized;
|
2024-03-15 13:38:08 +01:00
|
|
|
|
2024-07-09 13:24:20 +02:00
|
|
|
vec4 smear(vec2 shift) {
|
2024-03-15 13:38:08 +01:00
|
|
|
float delta = 1. / size;
|
|
|
|
|
2024-10-24 12:40:14 +02:00
|
|
|
vec4 base = sampleTexture( gm_BaseTexture, v_vTexcoord );
|
2024-07-09 13:24:20 +02:00
|
|
|
float mBri = (base.r + base.g + base.b) / 3. * base.a;
|
2024-10-16 12:34:26 +02:00
|
|
|
vec4 res, col, rcol;
|
2024-07-09 13:24:20 +02:00
|
|
|
float bright, rbright, dist = 0.;
|
2024-03-15 13:38:08 +01:00
|
|
|
|
2024-07-09 13:24:20 +02:00
|
|
|
if(inv == 0) {
|
2024-10-16 12:34:26 +02:00
|
|
|
res = base;
|
|
|
|
|
2024-07-09 13:24:20 +02:00
|
|
|
for(float i = 0.; i <= 1.0; i += delta) {
|
2024-10-24 12:40:14 +02:00
|
|
|
col = sampleTexture( gm_BaseTexture, v_vTexcoord - shift * i);
|
2024-07-09 13:24:20 +02:00
|
|
|
|
|
|
|
if(modulateStr != 2) {
|
|
|
|
if(alpha == 0) col.rgb *= 1. - i;
|
|
|
|
else col.a *= 1. - i;
|
|
|
|
}
|
|
|
|
|
2024-10-24 12:40:14 +02:00
|
|
|
bright = (col.r + col.g + col.b) / 3. * col.a;
|
2024-07-09 13:24:20 +02:00
|
|
|
|
|
|
|
if(bright > mBri) {
|
|
|
|
mBri = bright;
|
|
|
|
res = col;
|
|
|
|
}
|
|
|
|
}
|
2024-04-27 10:34:32 +02:00
|
|
|
|
2024-07-09 13:24:20 +02:00
|
|
|
if(modulateStr == 1) {
|
|
|
|
if(alpha == 0) res.rgb *= mBri;
|
|
|
|
else res.a *= res.a;
|
2024-04-27 10:34:32 +02:00
|
|
|
}
|
2024-03-15 13:38:08 +01:00
|
|
|
|
2024-07-09 13:24:20 +02:00
|
|
|
} else if(inv == 1) {
|
|
|
|
base = alpha == 0? vec4(0., 0., 0., 1.) : vec4(0.);
|
|
|
|
mBri = 0.;
|
|
|
|
res = base;
|
|
|
|
|
|
|
|
for(float i = 0.; i <= 1.; i += delta) {
|
2024-10-24 12:40:14 +02:00
|
|
|
col = sampleTexture( gm_BaseTexture, v_vTexcoord + shift * i);
|
2024-07-09 13:24:20 +02:00
|
|
|
bright = (col.r + col.g + col.b) / 3. * col.a;
|
|
|
|
|
|
|
|
if(bright == 0.) continue;
|
|
|
|
if(i > bright) continue;
|
|
|
|
|
|
|
|
if(modulateStr != 2) {
|
|
|
|
if(alpha == 0) col.rgb *= i;
|
|
|
|
else col.a *= i;
|
|
|
|
}
|
|
|
|
|
|
|
|
mBri = bright;
|
2024-10-16 12:34:26 +02:00
|
|
|
|
|
|
|
float _i = normalized == 1? i / bright : i;
|
|
|
|
res = alpha == 0? vec4(vec3(_i), 1.) : vec4(vec3(1.), _i);
|
2024-03-15 13:38:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
2024-07-09 13:24:20 +02:00
|
|
|
}
|
2024-03-15 13:38:08 +01:00
|
|
|
|
|
|
|
void main() {
|
|
|
|
float str = strength.x;
|
|
|
|
if(strengthUseSurf == 1) {
|
|
|
|
vec4 _vMap = texture2D( strengthSurf, v_vTexcoord );
|
|
|
|
str = mix(strength.x, strength.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
|
|
|
}
|
|
|
|
|
|
|
|
float dir = direction.x;
|
|
|
|
if(directionUseSurf == 1) {
|
|
|
|
vec4 _vMap = texture2D( directionSurf, v_vTexcoord );
|
|
|
|
dir = mix(direction.x, direction.y, (_vMap.r + _vMap.g + _vMap.b) / 3.);
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4 col = vec4(0.);
|
|
|
|
|
|
|
|
for(float i = -spread; i <= spread; i++) {
|
|
|
|
float r = radians(dir + 90. + i);
|
|
|
|
vec2 dirr = vec2(sin(r), cos(r)) * str;
|
|
|
|
vec4 smr = smear(dirr);
|
|
|
|
|
2024-08-25 10:18:22 +02:00
|
|
|
if(blend == 0) col = max(col, smr);
|
|
|
|
else if(blend == 1) col += smr;
|
2024-03-15 13:38:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gl_FragColor = col;
|
|
|
|
}
|