You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
thebookofshaders/09/tmp/lines-thin.frag

39 lines
959 B
GLSL

// Author @patriciogv - 2015 - patricio.io
#extension GL_OES_standard_derivatives : enable
#ifdef GL_ES
precision mediump float;
#endif
const float PI = 3.1415926535897932384626433832795;
uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;
float aastep(float threshold, float value) {
#ifdef GL_OES_standard_derivatives
float afwidth = length(vec2(dFdx(value), dFdy(value))) * 0.70710678118654757;
return smoothstep(threshold-afwidth, threshold+afwidth, value);
#else
return step(threshold, value);
#endif
}
mat2 rotate2d(float angle){
return mat2(cos(angle),-sin(angle),
sin(angle),cos(angle));
}
float stripes(vec2 st){
st = rotate2d(.72)*st;
st *= 92.;
return aastep(.3,abs(sin(st.y*3.14159265358)));
}
void main(){
vec2 st = gl_FragCoord.xy/u_resolution.xy;
st.x *= u_resolution.x/u_resolution.y;
vec3 color = vec3(stripes(st));
gl_FragColor = vec4(color, 1.0);
}