mirror of
https://github.com/patriciogonzalezvivo/thebookofshaders
synced 2024-11-08 01:10:27 +00:00
39 lines
959 B
GLSL
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);
|
|
}
|