像素精灵元素GLSL - 47-一个滑稽的图(the fool)

606 阅读1分钟

绘制一个滑稽的图

示例代码
#ifdef GL_ES
precision mediump float;
#endif

uniform float u_time;
uniform vec2 u_resolution;
uniform vec2 u_mouse;


float spiralSDF(vec2 st, float t) {
  st -= .5;
	float r = dot(st,st);
	float a = atan(st.y,st.x);
	return abs(sin(fract(log(r)*t+a*0.159)));
}

void main(){
    vec2 st = gl_FragCoord.xy / u_resolution;
    st.x *= u_resolution.x/u_resolution.y;
    st.y *= u_resolution.y/u_resolution.x;
    vec3 color = vec3(0.0);

    color += step(0.5, spiralSDF(st, 0.13));
    
    gl_FragColor = vec4(color, 1.0);
}
代码效果

《像素精灵元素GLSL》期待你的关注与点赞