readNonPerspective.glsl 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. /**
  2. * Reads a value previously transformed with {@link czm_writeNonPerspective}
  3. * by dividing it by `w`, the value used in the perspective divide.
  4. * This function is intended to be called in a fragment shader to access a
  5. * `varying` that should not be subject to perspective interpolation.
  6. * For example, screen-space texture coordinates. The value should have been
  7. * previously written in the vertex shader with a call to
  8. * {@link czm_writeNonPerspective}.
  9. *
  10. * @name czm_readNonPerspective
  11. * @glslFunction
  12. *
  13. * @param {float|vec2|vec3|vec4} value The non-perspective value to be read.
  14. * @param {float} oneOverW One over the perspective divide value, `w`. Usually this is simply `gl_FragCoord.w`.
  15. * @returns {float|vec2|vec3|vec4} The usable value.
  16. */
  17. float czm_readNonPerspective(float value, float oneOverW) {
  18. return value * oneOverW;
  19. }
  20. vec2 czm_readNonPerspective(vec2 value, float oneOverW) {
  21. return value * oneOverW;
  22. }
  23. vec3 czm_readNonPerspective(vec3 value, float oneOverW) {
  24. return value * oneOverW;
  25. }
  26. vec4 czm_readNonPerspective(vec4 value, float oneOverW) {
  27. return value * oneOverW;
  28. }