Geen omschrijving

model.vert 1018B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 (set = 0, binding = 0) uniform UBO {
  6. mat4 projection;
  7. mat4 view;
  8. mat4 model;
  9. } ubo;
  10. layout (set = 1, binding = 0) uniform Node {
  11. mat4 matrix;
  12. } node;
  13. layout(push_constant) uniform PushBlock {
  14. vec4 baseColorFactor;
  15. } material;
  16. layout (location = 0) out vec3 outNormal;
  17. layout (location = 1) out vec3 outColor;
  18. layout (location = 2) out vec3 outViewVec;
  19. layout (location = 3) out vec3 outLightVec;
  20. out gl_PerVertex
  21. {
  22. vec4 gl_Position;
  23. };
  24. void main()
  25. {
  26. outNormal = inNormal;
  27. outColor = material.baseColorFactor.rgb;
  28. vec4 pos = vec4(inPos, 1.0);
  29. gl_Position = ubo.projection * ubo.view * ubo.model * node.matrix * pos;
  30. outNormal = mat3(ubo.view * ubo.model * node.matrix) * inNormal;
  31. vec4 localpos = ubo.view * ubo.model * node.matrix * pos;
  32. vec3 lightPos = vec3(10.0f, -10.0f, 10.0f);
  33. outLightVec = lightPos.xyz - localpos.xyz;
  34. outViewVec = -localpos.xyz;
  35. }