Skip to content

Instantly share code, notes, and snippets.

@djg
Created June 14, 2019 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djg/8e82291d98d2c4b4e66fb0561dbc1b10 to your computer and use it in GitHub Desktop.
Save djg/8e82291d98d2c4b4e66fb0561dbc1b10 to your computer and use it in GitHub Desktop.
// 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
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