説明なし

scene.vert 953B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. out gl_PerVertex
  19. {
  20. vec4 gl_Position;
  21. };
  22. void main()
  23. {
  24. outNormal = inNormal;
  25. outColor = inColor;
  26. vec3 locPos = vec3(ubo.modelview * vec4(inPos, 1.0));
  27. vec3 worldPos = vec3(ubo.modelview * vec4(inPos + pushConsts.objPos, 1.0));
  28. gl_Position = ubo.projection /* ubo.modelview */ * vec4(worldPos, 1.0);
  29. vec4 pos = ubo.modelview * vec4(worldPos, 1.0);
  30. outNormal = mat3(ubo.modelview) * inNormal;
  31. outLightVec = ubo.lightPos.xyz - pos.xyz;
  32. outViewVec = -pos.xyz;
  33. }