DKGL2 sample codes

texture.vert 935B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #version 450
  2. layout (location = 0) in vec3 inPos;
  3. layout (location = 1) in vec2 inUV;
  4. layout (location = 2) in vec3 inNormal;
  5. layout (binding = 0) uniform UBO
  6. {
  7. mat4 projection;
  8. mat4 model;
  9. vec4 viewPos;
  10. float lodBias;
  11. } ubo;
  12. layout (location = 0) out vec2 outUV;
  13. layout (location = 1) out float outLodBias;
  14. layout (location = 2) out vec3 outNormal;
  15. layout (location = 3) out vec3 outViewVec;
  16. layout (location = 4) out vec3 outLightVec;
  17. out gl_PerVertex
  18. {
  19. vec4 gl_Position;
  20. };
  21. void main()
  22. {
  23. outUV = inUV;
  24. outLodBias = ubo.lodBias;
  25. vec3 worldPos = vec3(ubo.model * vec4(inPos, 1.0));
  26. gl_Position = ubo.projection * ubo.model * vec4(inPos.xyz, 1.0);
  27. vec4 pos = ubo.model * vec4(inPos, 1.0);
  28. outNormal = mat3(inverse(transpose(ubo.model))) * inNormal;
  29. vec3 lightPos = vec3(0.0);
  30. vec3 lPos = mat3(ubo.model) * lightPos.xyz;
  31. outLightVec = lPos - pos.xyz;
  32. outViewVec = ubo.viewPos.xyz - pos.xyz;
  33. }