Skip to content

Instantly share code, notes, and snippets.

@burritojustice
Last active January 22, 2019 05:10
Show Gist options
  • Save burritojustice/19ec6cf2c8a8e6c7f0042f7d2253d0ab to your computer and use it in GitHub Desktop.
Save burritojustice/19ec6cf2c8a8e6c7f0042f7d2253d0ab to your computer and use it in GitHub Desktop.
tangram slope shaders
import:
- https://www.nextzen.org/carto/walkabout-style/8/walkabout-style.zip
- https://www.nextzen.org/carto/walkabout-style/8/themes/label-10.zip
- https://www.nextzen.org/carto/walkabout-style/8/themes/walkabout-road-shields-usa.zip
- https://www.nextzen.org/carto/walkabout-style/8/themes/walkabout-road-shields-international.zip
styles:
slope:
base: lines
raster: custom
texcoords: true
shaders:
extensions: OES_standard_derivatives
blocks:
color: |
vec2 path = vec2(dFdy(v_texcoord.x), dFdx(v_texcoord.x));
path = normalize(path);
vec3 terrain = (sampleRaster(0).rgb - .5) * 2.;
float steepness = clamp(abs(dot(path, terrain.xy)) * 8., -1., 1.);
color.rgb = vec3(1., 1. - steepness, 1. - steepness);
layers:
roads:
draw:
lines:
style: slope
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment