Nenhuma descrição

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (location = 0) in vec3 inPos;
  5. layout (location = 1) in vec3 inNormal;
  6. layout (location = 2) in vec3 inColor;
  7. layout (binding = 0) uniform UBO
  8. {
  9. mat4 projection;
  10. mat4 modelview;
  11. vec4 lightPos;
  12. float visible;
  13. } ubo;
  14. layout (location = 0) out vec3 outNormal;
  15. layout (location = 1) out vec3 outColor;
  16. layout (location = 2) out float outVisible;
  17. layout (location = 3) out vec3 outViewVec;
  18. layout (location = 4) out vec3 outLightVec;
  19. out gl_PerVertex
  20. {
  21. vec4 gl_Position;
  22. };
  23. void main()
  24. {
  25. outNormal = inNormal;
  26. outColor = inColor;
  27. outVisible = ubo.visible;
  28. gl_Position = ubo.projection * ubo.modelview * vec4(inPos.xyz, 1.0);
  29. vec4 pos = ubo.modelview * vec4(inPos, 1.0);
  30. outNormal = mat3(ubo.modelview) * inNormal;
  31. outLightVec = ubo.lightPos.xyz - pos.xyz;
  32. outViewVec = -pos.xyz;
  33. }