pass_viewray2.vert.glsl 474 B

123456789101112131415161718192021222324
  1. #version 450
  2. uniform mat4 invP;
  3. in vec2 pos;
  4. out vec2 texCoord;
  5. out vec3 viewRay;
  6. void main() {
  7. // Scale vertex attribute to [0-1] range
  8. const vec2 madd = vec2(0.5, 0.5);
  9. texCoord = pos.xy * madd + madd;
  10. #if defined(HLSL) || defined(METAL) || defined(SPIRV)
  11. texCoord.y = 1.0 - texCoord.y;
  12. #endif
  13. gl_Position = vec4(pos.xy, 0.0, 1.0);
  14. // NDC (at the back of cube)
  15. vec4 v = vec4(pos.x, pos.y, 1.0, 1.0);
  16. v = vec4(invP * v);
  17. viewRay = vec3(v.xy / v.z, 1.0);
  18. }