signNotZero.glsl 898 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to the GLSL
  3. * built-in function <code>sign</code> except that returns 1.0 instead of 0.0 when the input value is 0.0.
  4. *
  5. * @name czm_signNotZero
  6. * @glslFunction
  7. *
  8. * @param {} value The value for which to determine the sign.
  9. * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative.
  10. */
  11. float czm_signNotZero(float value)
  12. {
  13. return value >= 0.0 ? 1.0 : -1.0;
  14. }
  15. vec2 czm_signNotZero(vec2 value)
  16. {
  17. return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));
  18. }
  19. vec3 czm_signNotZero(vec3 value)
  20. {
  21. return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));
  22. }
  23. vec4 czm_signNotZero(vec4 value)
  24. {
  25. return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));
  26. }