Last active
December 27, 2015 04:09
-
-
Save funnylookinhat/7264581 to your computer and use it in GitHub Desktop.
lmg grid overlay
This file contains 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
uniform vec2 gridSize; | |
const vec4 gridColor = vec4(1.0,0.5,0.0, 0.1); | |
const float gridLineWidth = 0.03; | |
const float gridLineFade = 0.01; | |
// overlay grid | |
vec2 xy = vUv * gridSize; | |
vec2 dGrid = abs(xy - floor(xy+0.5)); // floor(i+0.5) == round | |
vec2 d = min( 2.0 * abs(dGrid) - (gridLineWidth/2.0 - gridLineFade), gridLineFade) / gridLineFade; | |
gl_FragColor.rgb = mix( gl_FragColor.rgb, gridColor.rgb, (1.0 - min(d.x,d.y)) * gridColor.a ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment