Last active
December 9, 2019 09:47
-
-
Save lepinay/7d72d4dd1ad7ae55dbafba288a8b2316 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Author @patriciogv - 2015 | |
| // http://patriciogonzalezvivo.com | |
| #ifdef GL_ES | |
| precision mediump float; | |
| #endif | |
| uniform vec2 u_resolution; | |
| uniform vec2 u_mouse; | |
| uniform float u_time; | |
| vec3 box(vec2 st, vec2 pos, float w, float h, vec3 color){ | |
| st -= pos; | |
| // bottom-left | |
| float blx = clamp(1.0-floor(st.x*1.0/(0.5+w/2.0)),0.0,1.0); | |
| float bly = clamp(1.0-floor(st.y*1.0/(0.5+h/2.0)),0.0,1.0); | |
| float pct = blx * bly; | |
| // top-right | |
| vec2 tr = vec2(clamp(floor(st.x*1.0/(0.5-w/2.0)),0.0,1.0),clamp(floor(st.y*1.0/(0.5-h/2.0)),0.0,1.0)); | |
| pct *= tr.x * tr.y; | |
| return pct*color; | |
| } | |
| void main(){ | |
| vec2 st = gl_FragCoord.xy/u_resolution.xy; | |
| vec3 color = vec3(0.0); | |
| color = box(st, vec2(0,0),0.5,0.5, vec3(0.8,0.0,0.3)); | |
| color += box(st, vec2(0.45,0),0.25,0.5, vec3(0.8,0.0,0.3)); | |
| color += box(st, vec2(-0.45,0),0.25,0.5, vec3(0.8,0.0,0.7)); | |
| color += box(st, vec2(-0.45,0.60),0.25,0.5, vec3(0.8,0.0,0.7)); | |
| gl_FragColor = vec4(color,1.0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment