writeNonPerspective.glsl 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. /**
  2. * Transforms a value for non-perspective interpolation by multiplying
  3. * it by w, the value used in the perspective divide. This function is
  4. * intended to be called in a vertex shader to compute the value of a
  5. * `varying` that should not be subject to perspective interpolation.
  6. * For example, screen-space texture coordinates. The fragment shader
  7. * must call {@link czm_readNonPerspective} to retrieve the final
  8. * non-perspective value.
  9. *
  10. * @name czm_writeNonPerspective
  11. * @glslFunction
  12. *
  13. * @param {float|vec2|vec3|vec4} value The value to be interpolated without accounting for perspective.
  14. * @param {float} w The perspective divide value. Usually this is the computed `gl_Position.w`.
  15. * @returns {float|vec2|vec3|vec4} The transformed value, intended to be stored in a `varying` and read in the
  16. * fragment shader with {@link czm_readNonPerspective}.
  17. */
  18. float czm_writeNonPerspective(float value, float w) {
  19. return value * w;
  20. }
  21. vec2 czm_writeNonPerspective(vec2 value, float w) {
  22. return value * w;
  23. }
  24. vec3 czm_writeNonPerspective(vec3 value, float w) {
  25. return value * w;
  26. }
  27. vec4 czm_writeNonPerspective(vec4 value, float w) {
  28. return value * w;
  29. }