2015-04-02 21:27:45 +00:00
|
|
|
#ifdef GL_ES
|
|
|
|
precision mediump float;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
uniform vec2 u_resolution;
|
|
|
|
uniform vec2 u_mouse;
|
|
|
|
uniform float u_time;
|
|
|
|
|
|
|
|
void main(){
|
|
|
|
vec2 st = gl_FragCoord.xy/u_resolution.xy;
|
|
|
|
st.x *= u_resolution.x/u_resolution.y;
|
|
|
|
vec3 color = vec3(0.0);
|
|
|
|
float d = 0.0;
|
|
|
|
|
|
|
|
// Remap the space to -1. to 1.
|
|
|
|
st = st *2.-1.;
|
|
|
|
|
2015-05-10 22:18:02 +00:00
|
|
|
// Make the distance field
|
2015-04-13 13:53:03 +00:00
|
|
|
d = length( abs(st)-.3 );
|
|
|
|
// d = length( min(abs(st)-.3,0.) );
|
|
|
|
// d = length( max(abs(st)-.3,0.) );
|
2015-04-02 21:27:45 +00:00
|
|
|
|
2015-05-10 22:18:02 +00:00
|
|
|
// Visualize the distance field
|
2015-04-13 13:53:03 +00:00
|
|
|
gl_FragColor = vec4(vec3(fract(d*10.0)),1.0);
|
2015-04-02 21:27:45 +00:00
|
|
|
|
2015-04-13 13:53:03 +00:00
|
|
|
// Drawing with the distance field
|
|
|
|
// gl_FragColor = vec4(vec3( step(.3,d) ),1.0);
|
|
|
|
// gl_FragColor = vec4(vec3( step(.3,d) * step(d,.4)),1.0);
|
|
|
|
// gl_FragColor = vec4(vec3( smoothstep(.3,.4,d)* smoothstep(.6,.5,d)) ,1.0);
|
2015-04-02 21:27:45 +00:00
|
|
|
}
|