Skip to content

Instantly share code, notes, and snippets.

@thomasvanta
Created August 18, 2019 11:24
Show Gist options
  • Save thomasvanta/3480e075f0d0a7895e93ee147c25987b to your computer and use it in GitHub Desktop.
Save thomasvanta/3480e075f0d0a7895e93ee147c25987b to your computer and use it in GitHub Desktop.
vec3 getNormal(vec3 p){
//sampling around the point
vec2 e = vec2(0.01, 0.0);
float d = map(p);
vec3 n = d - vec3(
map(p-e.xyy),
map(p-e.yxy),
map(p-e.yyx));
return normalize(n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment