mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-11-14 14:33:53 +01:00
37 lines
814 B
Plaintext
37 lines
814 B
Plaintext
|
//
|
||
|
// Simple passthrough fragment shader
|
||
|
//
|
||
|
varying vec2 v_vTexcoord;
|
||
|
varying vec4 v_vColour;
|
||
|
|
||
|
uniform vec2 dimension;
|
||
|
|
||
|
#define TAU 6.28318
|
||
|
#define angle_sample 32.
|
||
|
#define distance_sample 32.
|
||
|
|
||
|
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;
|
||
|
|
||
|
if(col.a < 1.) {
|
||
|
float tauDiv = TAU / angle_sample;
|
||
|
for(float i = 1.; i <= distance_sample; i++) {
|
||
|
for(float j = 0.; j < angle_sample; j++) {
|
||
|
float ang = j * tauDiv;
|
||
|
vec2 pxs = (pixelPosition + vec2( cos(ang), sin(ang)) * scale * i) / dimension;
|
||
|
vec4 sam = texture2D( gm_BaseTexture, pxs );
|
||
|
|
||
|
if(sam.a >= 1.) {
|
||
|
gl_FragColor = sam;
|
||
|
i = 999.;
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|