TriangleDepthVertexShader.vert 720 B

12345678910111213141516171819202122232425262728293031
  1. #version 450
  2. #include "VertexConstants.h"
  3. layout(location = 0) in vec3 vPos;
  4. layout(location = 1) in vec3 vNorm;
  5. layout(location = 2) in vec2 vTex;
  6. layout(location = 3) in vec4 vCol;
  7. layout(location = 4) in mat4 iModel;
  8. layout(location = 8) in mat4 iModelInvTrans;
  9. layout(location = 12) in vec4 iCol;
  10. void main()
  11. {
  12. // Check if the alpha = 0
  13. if (vCol.a * iCol.a == 0.0)
  14. {
  15. // Don't draw the triangle by moving it to an invalid location
  16. gl_Position = vec4(0, 0, 0, 0);
  17. }
  18. else
  19. {
  20. // Transform the position from world space to homogeneous projection space for the light
  21. vec4 pos = vec4(vPos, 1.0f);
  22. pos = iModel * pos;
  23. pos = c.LightView * pos;
  24. pos = c.LightProjection * pos;
  25. gl_Position = pos;
  26. }
  27. }