pointShadow_optimized.geom 655 B

1234567891011121314151617181920212223242526272829
  1. #version 330 core
  2. layout (triangles) in;
  3. layout (triangle_strip, max_vertices=18) out;
  4. uniform mat4 u_shadowMatrices[6];
  5. uniform int u_lightIndex;
  6. out vec4 v_fragPos; // FragPos from GS (output per emitvertex)
  7. out vec2 v_finalTexCoord;
  8. in vec2 v_texCoord[3];
  9. void main()
  10. {
  11. for(int face = 0; face < 6; ++face)
  12. {
  13. gl_Layer = face + u_lightIndex * 6; // built-in variable that specifies to which face we render.
  14. for(int i = 0; i < 3; ++i) // for each triangle vertex
  15. {
  16. v_fragPos = gl_in[i].gl_Position;
  17. v_finalTexCoord = v_texCoord[i];
  18. gl_Position = u_shadowMatrices[face] * v_fragPos;
  19. EmitVertex();
  20. }
  21. EndPrimitive();
  22. }
  23. }