Skip to content

Instantly share code, notes, and snippets.

@menduz
Created May 30, 2020 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save menduz/51e52f7daf989553e0463469cffe2256 to your computer and use it in GitHub Desktop.
Save menduz/51e52f7daf989553e0463469cffe2256 to your computer and use it in GitHub Desktop.
Spherical normal encoding
// Encoding:
normalOut=normalize(normalIn.xy)*sqrt(normalIn.z*0.5+0.5);
// Decoding:
normal.z=length2(normalOut.xy)*2- 1;
normal.xy=normalize(normalOut.xy)*sqrt(1- normal.z*normal.z);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment