Circle
Circle
distance는 input 변수가 2개 length는 input 변수가 1개라서 length가 더 빠르고 알려졌기때문에 length를 쓰는것이 좋다.
단 distance는 두개의 좌표의 거리를 구하지만 length는 하나의 값과 원점과의 거리를 나타내기때문에 구별해서는 써야 한다.
step
smoothstep
//화면 비율에 구애 받지 않고 유지 시켜주는 코드
st.x *= u_resolution.x/u_resolution.y;
d의 값이 최대 0.1이기 때문에 어둡게 나옴
#ifdef GL_ES
precision mediump float;
#endif
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
void main(){
vec2 coord = gl_FragCoord.xy/u_resolution;
coord = coord*2.0-1.;
coord.x*=u_resolution.x/u_resolution.y;
float a = atan(coord.y, coord.x); // 각도를 반환
float d = length(coord); // 거리
a += u_time;
a *= 4.; // 각도 x3
float r = sin(a); // 반지름
vec3 col = vec3(step(r, d));
gl_FragColor = vec4(col, 1.);
}