mo49
9/4/2019 - 8:56 AM

00_AtanClover.md

#ifdef GL_ES
precision mediump float;
#endif

#extension GL_OES_standard_derivatives : enable

uniform float time;
uniform vec2 mouse;
uniform vec2 resolution;

void main( void ) {
	vec2 st = gl_FragCoord.xy/resolution.xy;
	vec3 color = vec3(0.0);
	vec2 pos = vec2(0.5)-st;
	float num_leaf = 4.;
	float r = length(pos)*2.0;
	float a = atan(pos.y,pos.x);
	
	// fill
	float u1 = cos((a+time)*num_leaf);
	float t1 = 1.-smoothstep(u1,u1+0.01,r);
	vec3 color1 = vec3(t1);
	
	// outline
	float u2 = sin((a+time)*num_leaf);
	float t2 = 0.01 / abs(u2 - r);
	vec3 color2 =  vec3(t2);
	
	color = color1 + color2;
	
	gl_FragColor = vec4(color, 1.0);
}