skybox.vert 759 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* skybox.vert -- Vertex shader used to render skyboxes
  2. *
  3. * Copyright (c) 2025-2026 Le Juez Victor
  4. *
  5. * This software is provided 'as-is', without any express or implied warranty.
  6. * For conditions of distribution and use, see accompanying LICENSE file.
  7. */
  8. #version 330 core
  9. /* === Constants === */
  10. const vec2 positions[3] = vec2[]
  11. (
  12. vec2(-1.0, -1.0),
  13. vec2( 3.0, -1.0),
  14. vec2(-1.0, 3.0)
  15. );
  16. /* === Uniforms === */
  17. uniform mat4 uMatInvProj;
  18. uniform mat4 uMatInvView;
  19. /* === Varyings === */
  20. out vec3 vViewRay;
  21. /* === Program === */
  22. void main()
  23. {
  24. vec2 pos = positions[gl_VertexID];
  25. gl_Position = vec4(pos, 1.0, 1.0);
  26. vec4 unprojected = uMatInvProj * vec4(pos, 1.0, 1.0);
  27. vViewRay = mat3(uMatInvView) * unprojected.xyz;
  28. }