BFILogic.cginc 678 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef BFI_LOGIC_INCLUDED
  2. #define BFI_LOGIC_INCLUDED
  3. float when_eq(float x, float y) {
  4. return 1.0 - abs(sign(x - y));
  5. }
  6. float when_neq(float x, float y) {
  7. return abs(sign(x - y));
  8. }
  9. float when_gt(float x, float y) {
  10. return max(sign(x - y), 0.0);
  11. }
  12. float when_lt(float x, float y) {
  13. return max(sign(y - x), 0.0);
  14. }
  15. float when_ge(float x, float y) {
  16. return 1.0 - when_lt(x, y);
  17. }
  18. float when_le(float x, float y) {
  19. return 1.0 - when_gt(x, y);
  20. }
  21. float and(float a, float b) {
  22. return a * b;
  23. }
  24. float or(float a, float b) {
  25. return min(a + b, 1.0);
  26. }
  27. float xor(float a, float b) {
  28. return (a + b) % 2.0;
  29. }
  30. float not(float a) {
  31. return 1.0 - a;
  32. }
  33. #endif