Created
May 18, 2018 04:55
-
-
Save up209d/1c5f6e53f13ce4bd27d6a4f9c37e3e9b to your computer and use it in GitHub Desktop.
GLSL Avoid Divide By Zero (Return 0 instead)
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
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