basic: added distance field example; utils: added polygon shape drawer
This commit is contained in:
21
basic/distance_field.glsl
Normal file
21
basic/distance_field.glsl
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
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.;
|
||||
|
||||
// Make the distance field
|
||||
d = length(st)+length(min(st,0.))+length(max(st,0.));
|
||||
|
||||
// Visualize the distance field
|
||||
gl_FragColor = vec4(vec3(fract(d*10.0)),1.0);
|
||||
}
|
Reference in New Issue
Block a user