round.glsl 496 B

12345678910111213141516171819202122
  1. /**
  2. * Round a floating point value. This function exists because round() doesn't
  3. * exist in GLSL 1.00.
  4. *
  5. * @param {float|vec2|vec3|vec4} value The value to round
  6. * @param {float|vec2|vec3|vec3} The rounded value. The type matches the input.
  7. */
  8. float czm_round(float value) {
  9. return floor(value + 0.5);
  10. }
  11. vec2 czm_round(vec2 value) {
  12. return floor(value + 0.5);
  13. }
  14. vec3 czm_round(vec3 value) {
  15. return floor(value + 0.5);
  16. }
  17. vec4 czm_round(vec4 value) {
  18. return floor(value + 0.5);
  19. }