Created
April 20, 2018 23:42
-
-
Save eddietree/69d2966fc9c99d2acd7e2f159e092d7c to your computer and use it in GitHub Desktop.
SDF normal
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
float3 calcNormal(in float3 pos) { | |
float3 eps = float3(0.001, 0.0, 0.0); | |
float3 nor = float3( | |
map(pos + eps.xyy).x - map(pos - eps.xyy).x, | |
map(pos + eps.yxy).x - map(pos - eps.yxy).x, | |
map(pos + eps.yyx).x - map(pos - eps.yyx).x); | |
return normalize(nor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment