No Description

texture.vert 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 vec2 inUV;
  6. layout (location = 2) in vec3 inNormal;
  7. layout (binding = 0) uniform UBO
  8. {
  9. mat4 projection;
  10. mat4 view;
  11. mat4 model;
  12. vec4 viewPos;
  13. float lodBias;
  14. int samplerIndex;
  15. } ubo;
  16. layout (location = 0) out vec2 outUV;
  17. layout (location = 1) out float outLodBias;
  18. layout (location = 2) flat out int outSamplerIndex;
  19. layout (location = 3) out vec3 outNormal;
  20. layout (location = 4) out vec3 outViewVec;
  21. layout (location = 5) out vec3 outLightVec;
  22. out gl_PerVertex
  23. {
  24. vec4 gl_Position;
  25. };
  26. void main()
  27. {
  28. outUV = inUV * vec2(2.0, 1.0);
  29. outLodBias = ubo.lodBias;
  30. outSamplerIndex = ubo.samplerIndex;
  31. vec3 worldPos = vec3(ubo.model * vec4(inPos, 1.0));
  32. gl_Position = ubo.projection * ubo.view * ubo.model * vec4(inPos.xyz, 1.0);
  33. outNormal = mat3(inverse(transpose(ubo.model))) * inNormal;
  34. vec3 lightPos = vec3(-30.0, 0.0, 0.0);
  35. outLightVec = worldPos - lightPos;
  36. outViewVec = ubo.viewPos.xyz - worldPos;
  37. }