screen.vert 781 B

1234567891011121314151617181920212223242526272829
  1. /* screen.vert -- Generic vertex shader for rendering a full-screen quad
  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. const vec2 positions[3] = vec2[]
  10. (
  11. vec2(-1.0, -1.0),
  12. vec2( 3.0, -1.0),
  13. vec2(-1.0, 3.0)
  14. );
  15. noperspective out vec2 vTexCoord;
  16. void main()
  17. {
  18. // Here Z is fixed at 1.0.
  19. // For fullscreen passes that match the depth buffer resolution:
  20. // - GL_EQUAL allows rendering only the background
  21. // - GL_GREATER allows invoking the shader only on geometry
  22. gl_Position = vec4(positions[gl_VertexID], 1.0, 1.0);
  23. vTexCoord = (gl_Position.xy * 0.5) + 0.5;
  24. }