Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Paste into shadertoy.
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 c = (2.0*iMouse.xy - iResolution.xy)/iResolution.y;
vec2 p = (-iResolution.xy + 2.0*fragCoord)/iResolution.y;
vec2 d = c - p;
// angle of each pixel to the center offset by from
float from = radians(mod(10.0*iTime,360.0));
float a = (atan(d.x, d.y) + radians(180.0) - from)/radians(360.0);
a = fract(a);
vec3 col = vec3(0,0,0);
col = vec3(a, a, a);
fragColor = vec4( col, 1.0 );
}
@Nexuapex

This comment has been minimized.

Copy link

Nexuapex commented Jun 14, 2019

float sample( in float from, in vec2 d )
{
    // angle of each pixel to the center offset by from
    float a = (atan(d.x, d.y) - from)/radians(360.0);
    a = fract(a);
    return a;
}

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    vec2 c = iMouse.xy;
    vec2 p = fragCoord;
    vec2 d = c - p;

    float from = radians(mod(10.0*iTime,360.0));

    float sa = sample(from, d + vec2(-.125, -.375));
    float sb = sample(from, d + vec2(+.375, -.125));
    float sc = sample(from, d + vec2(-.375, +.125));
    float sd = sample(from, d + vec2(+.125, +.375));

    float avg = (1.0/4.0) * (sa + sb + sc + sd);

    vec3 col = vec3(avg, avg, avg);
    fragColor = vec4( col, 1.0 );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.