Demo entry 3342839

shader

   

Submitted by anonymous on Dec 16, 2015 at 18:38
Language: C. Code size: 762 Bytes.

int N = 8;
vec2 CENTER = vec2(300.0, 200.0);
float SMALL_R = 70.0;
float BIG_R = 120.0;
float ALPHA = 0.5;
float PI = 3.141592653;
vec4 COLOR = vec4(0.0, 0.0, 1.0, 1.0);
vec4 BG_COLOR = vec4(1.0, 1.0, 1.0, 1.0);

void mainImage(out vec4 fragColor, in vec2 fragCoord )
{
    if (distance(fragCoord, CENTER) < SMALL_R){
        fragColor = COLOR;
    } else if (distance(fragCoord, CENTER) > BIG_R) {
        fragColor = BG_COLOR;
    } else {
        float angle = iGlobalTime + atan((fragCoord.y - CENTER.y) / (fragCoord.x - CENTER.x));
        float deltaAngle = (2.0 * PI) / float(N);
        if (mod(angle/deltaAngle, 1.0) < ALPHA) {
            fragColor = COLOR;
        } else{
            fragColor = BG_COLOR;
        }
    }   
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).