Skip to content

Instantly share code, notes, and snippets.

@funnylookinhat
Last active December 27, 2015 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save funnylookinhat/7264581 to your computer and use it in GitHub Desktop.
Save funnylookinhat/7264581 to your computer and use it in GitHub Desktop.
lmg grid overlay
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