Skip to content

Instantly share code, notes, and snippets.

@mnd999
Last active April 28, 2016 08:23
Show Gist options
  • Save mnd999/8714ed2566827372e759c199326c348c to your computer and use it in GitHub Desktop.
Save mnd999/8714ed2566827372e759c199326c348c to your computer and use it in GitHub Desktop.
// Buffer
const float PI = 3.1415926535897932384626433832795;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec2 mouse = iMouse.xy / iResolution.xy;
float angle = 2.0 * PI * uv.x;
float radius = uv.y;
bool shadowed = false;
for (int i=0; i<512; i++) {
float r = 512.0 / float(i);
vec2 xy = mouse + r * vec2(cos(angle), sin(angle));
vec4 pixel = texture2D(iChannel0, xy);
if ((pixel.z < 1.0) && (r < radius)) {
shadowed = true;
}
}
if (shadowed) {
fragColor = vec4(radius, 0.0, 1.0, 1.0);
} else {
fragColor = vec4(angle/(2.0*PI), radius, 0.0, 1.0);
}
}
// Image
const float PI = 3.1415926535897932384626433832795;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = fragCoord.xy / iResolution.xy;
vec2 mouse = iMouse.xy / iResolution.xy;
vec2 offset = mouse - uv;
float angle = atan(offset.y / offset.x);
float radius = sqrt(offset.x * offset.x + offset.y*offset.y);
fragColor = texture2D(iChannel1, vec2(angle/(2.0 * PI), radius));
//fragColor = texture2D(iChannel1, uv);
//return;
}rn;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment