Created
August 1, 2016 16:32
-
-
Save yiwenl/0e766ce84892a82cab371f5781c87199 to your computer and use it in GitHub Desktop.
Avoiding Shader Conditionals - http://theorangeduck.com/page/avoiding-shader-conditionals
This file contains hidden or 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
| vec4 when_eq(vec4 x, vec4 y) { | |
| return 1.0 - abs(sign(x - y)); | |
| } | |
| vec4 when_neq(vec4 x, vec4 y) { | |
| return abs(sign(x - y)); | |
| } | |
| vec4 when_gt(vec4 x, vec4 y) { | |
| return max(sign(x - y), 0.0); | |
| } | |
| vec4 when_lt(vec4 x, vec4 y) { | |
| return max(sign(y - x), 0.0); | |
| } | |
| vec4 when_ge(vec4 x, vec4 y) { | |
| return 1.0 - when_lt(x, y); | |
| } | |
| vec4 when_le(vec4 x, vec4 y) { | |
| return 1.0 - when_gt(x, y); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment