Pixel-Composer/shaders/sh_atlas/sh_atlas.fsh

44 lines
884 B
Text
Raw Normal View History

2022-01-13 05:24:03 +01:00
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform vec2 dimension;
2022-12-27 04:00:50 +01:00
#define TAU 6.283185307179586
#define angle_sample 4.
2022-12-21 02:30:23 +01:00
#define distance_sample 64.
2022-01-13 05:24:03 +01:00
void main() {
vec2 pixelPosition = v_vTexcoord * dimension;
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord );
vec2 scale = dimension / distance_sample;
float min_dist = 1.;
gl_FragColor = col;
2022-12-27 04:00:50 +01:00
if(col.a == 1.)
return;
2023-02-23 07:02:19 +01:00
for(float i = 1.; i <= distance_sample; i++) {
float base = 1.;
float top = 0.;
for(float j = 0.; j <= 64.; j++) {
float ang = top / base * TAU;
top += 2.;
if(top >= base) {
top = 1.;
base *= 2.;
}
vec2 pxs = (pixelPosition + vec2( cos(ang), sin(ang)) * scale * i) / dimension;
vec4 sam = texture2D( gm_BaseTexture, pxs );
2022-01-13 05:24:03 +01:00
2023-02-23 07:02:19 +01:00
if(sam.a < 1.) continue;
2022-12-27 04:00:50 +01:00
2023-02-23 07:02:19 +01:00
gl_FragColor = sam;
return;
}
2022-01-13 05:24:03 +01:00
}
}