Pixel-Composer/shaders/sh_atlas_scan/sh_atlas_scan.fsh

39 lines
695 B
Text
Raw Normal View History

2024-04-11 05:51:13 +02:00
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
uniform int axis;
uniform float iteration;
void main() {
vec2 tx = 1. / dimension;
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor = col;
2024-04-27 11:53:57 +02:00
if(col.a > 0.) return;
2024-04-11 05:51:13 +02:00
2024-04-27 11:53:57 +02:00
float amo;
vec2 _axs;
vec4 ss;
2024-04-11 05:51:13 +02:00
if(axis == 0) {
2024-04-27 11:53:57 +02:00
amo = dimension.x;
2024-04-11 05:51:13 +02:00
_axs = vec2(tx.x, 0.);
} else {
2024-04-27 11:53:57 +02:00
amo = dimension.y;
2024-04-11 05:51:13 +02:00
_axs = vec2(0., tx.y);
}
2024-04-27 11:53:57 +02:00
for(float i = 1.; i < amo; i++) {
ss = texture2D( gm_BaseTexture, v_vTexcoord + _axs * i);
if(ss.a > 0.) { col = ss; break; }
2024-04-11 05:51:13 +02:00
2024-04-27 11:53:57 +02:00
ss = texture2D( gm_BaseTexture, v_vTexcoord - _axs * i);
if(ss.a > 0.) { col = ss; break; }
2024-04-11 05:51:13 +02:00
}
gl_FragColor = col;
}