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 --
|
|
|
|
|
2023-01-25 06:49:00 +01:00
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
uniform vec2 dimension;
|
|
|
|
uniform int algorithm;
|
|
|
|
uniform int shape;
|
2023-01-25 06:49:00 +01:00
|
|
|
uniform float size;
|
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
float bright(in vec4 col) { return dot(col.rgb, vec3(0.2126, 0.7152, 0.0722)) * col.a; }
|
2023-01-25 06:49:00 +01:00
|
|
|
|
2023-12-23 09:39:55 +01:00
|
|
|
void main() {
|
|
|
|
vec2 tex = 1. / dimension;
|
|
|
|
vec4 acc = vec4(0.);
|
|
|
|
vec4 maxx = vec4(0.), minn = vec4(1.);
|
2023-01-25 06:49:00 +01:00
|
|
|
float weight = 0., _w;
|
2024-10-24 12:40:14 +02:00
|
|
|
vec4 col = sampleTexture( gm_BaseTexture, v_vTexcoord );
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
for(float i = -size; i <= size; i++)
|
|
|
|
for(float j = -size; j <= size; j++) {
|
|
|
|
if(shape == 1 && i * i + j * j > size * size)
|
|
|
|
continue;
|
|
|
|
if(shape == 2 && abs(i) + abs(j) > size)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(shape == 0)
|
|
|
|
_w = min(size - abs(i), size - abs(j));
|
|
|
|
else if(shape == 1)
|
|
|
|
_w = size - length(vec2(i, j));
|
|
|
|
else if(shape == 2)
|
|
|
|
_w = size - (abs(i) + abs(j));
|
|
|
|
|
2024-10-24 12:40:14 +02:00
|
|
|
vec4 col = sampleTexture( gm_BaseTexture, v_vTexcoord + vec2(i, j) * tex );
|
2023-01-25 06:49:00 +01:00
|
|
|
|
|
|
|
if(algorithm == 0) {
|
|
|
|
acc += col;
|
|
|
|
weight++;
|
|
|
|
} else if(algorithm == 1) {
|
|
|
|
maxx = max(maxx, col);
|
|
|
|
} else if(algorithm == 2) {
|
|
|
|
minn = min(minn, col);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(algorithm == 0)
|
|
|
|
gl_FragColor = acc / weight;
|
|
|
|
else if(algorithm == 1)
|
|
|
|
gl_FragColor = maxx;
|
|
|
|
else if(algorithm == 2)
|
|
|
|
gl_FragColor = minn;
|
|
|
|
}
|