Skip to content

Commit

Permalink
Create square_wave.frag
Browse files Browse the repository at this point in the history
  • Loading branch information
algroznykh authored Nov 25, 2021
1 parent e280352 commit f107d0a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions square_wave.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
float circle(vec2 p, float r) {
return length(p) - pow(r, 2.);
}

void main(){
vec2 uv = uv();
float w = 0.;

for (int i=0; i<32; i++)
if (mod(float(i), 2.) !=0. ) {
w += sin(2. * acos(-1.) * circle(uv, .5) * float(i)) ;
}

// w = sin(circle(uv, 1.) * 8.);
vec3 color = w > 0. ? vec3(w, 0., 0.): vec3(0., 0., abs(w));
gl_FragColor = vec4(color, 1.) / 4.;
}

0 comments on commit f107d0a

Please sign in to comment.