Ei kuvausta

scene.vert 899B

123456789101112131415161718192021222324252627282930313233343536
  1. #version 450
  2. layout (location = 0) in vec3 inPos;
  3. layout (location = 1) in vec3 inNormal;
  4. layout (location = 2) in vec3 inColor;
  5. layout (binding = 0) uniform UBO
  6. {
  7. mat4 projection;
  8. mat4 modelview;
  9. vec4 lightPos;
  10. } ubo;
  11. layout (location = 0) out vec3 outNormal;
  12. layout (location = 1) out vec3 outColor;
  13. layout (location = 2) out vec3 outViewVec;
  14. layout (location = 3) out vec3 outLightVec;
  15. layout(push_constant) uniform PushConsts {
  16. vec3 objPos;
  17. } pushConsts;
  18. void main()
  19. {
  20. outNormal = inNormal;
  21. outColor = inColor;
  22. vec3 locPos = vec3(ubo.modelview * vec4(inPos, 1.0));
  23. vec3 worldPos = vec3(ubo.modelview * vec4(inPos + pushConsts.objPos, 1.0));
  24. gl_Position = ubo.projection /* ubo.modelview */ * vec4(worldPos, 1.0);
  25. vec4 pos = ubo.modelview * vec4(worldPos, 1.0);
  26. outNormal = mat3(ubo.modelview) * inNormal;
  27. outLightVec = ubo.lightPos.xyz - pos.xyz;
  28. outViewVec = -pos.xyz;
  29. }