Skip to content

Instantly share code, notes, and snippets.

@yiwenl
Created August 1, 2016 16:32
Show Gist options
  • Select an option

  • Save yiwenl/0e766ce84892a82cab371f5781c87199 to your computer and use it in GitHub Desktop.

Select an option

Save yiwenl/0e766ce84892a82cab371f5781c87199 to your computer and use it in GitHub Desktop.
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