Files
glsl_playground/failed/rotation_gone_wrong.glsl
2017-06-08 10:07:59 -04:00

39 lines
891 B
GLSL

#ifdef GL_ES
precision mediump float;
#endif uniform vec2 u_resolution;
uniform float u_time;
#define PI 3.14159265358979323846
vec2 rotate2D(vec2 _st, float _angle){
_st -= 0.5;
_st = mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)) * _st;
_st += 0.5;
return _st;
}
vec2 tile(vec2 _st, float _zoom){
_st *= _zoom;
return fract(_st);
}
vec2 get_st() {
return gl_FragCoord.xy/min(u_resolution.x, u_resolution.y);
}
vec3 line(float width, float angle, vec3 color, vec2 st) {
float e = 0.003;
st -= vec2(0.5);
st *= rotate2D(st, angle);
return color*((smoothstep(-e-width/2., 0.-width/2., st.x)-smoothstep(0.+width/2., e+width/2., st.x)));
}
void main() {
vec2 st = gl_FragCoord.xy/u_resolution.xy;
vec3 color = vec3(0.5);
color += line(0.2, PI, vec3(0.1,0.,0.),st+0.2);
color += line(.02, 2./PI, vec3(0.9), st);
gl_FragColor = vec4(color, 1.0);
}