Skip to content

Instantly share code, notes, and snippets.

@up209d
Created May 18, 2018 04:55
Show Gist options
  • Save up209d/1c5f6e53f13ce4bd27d6a4f9c37e3e9b to your computer and use it in GitHub Desktop.
Save up209d/1c5f6e53f13ce4bd27d6a4f9c37e3e9b to your computer and use it in GitHub Desktop.
GLSL Avoid Divide By Zero (Return 0 instead)
float avoidDivideByZero (float value) {
float signValue = sign(value);
return (1. * abs(sign(value))) / (value + (abs(sign(value)) - 1.));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment