No Description

phong.vert 954B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 vec3 inNormal;
  6. layout (location = 2) in vec3 inColor;
  7. layout (std140, push_constant) uniform PushConsts
  8. {
  9. mat4 mvp;
  10. vec3 color;
  11. } pushConsts;
  12. layout (location = 0) out vec3 outNormal;
  13. layout (location = 1) out vec3 outColor;
  14. layout (location = 3) out vec3 outViewVec;
  15. layout (location = 4) out vec3 outLightVec;
  16. void main()
  17. {
  18. outNormal = inNormal;
  19. if ( (inColor.r == 1.0) && (inColor.g == 0.0) && (inColor.b == 0.0))
  20. {
  21. outColor = pushConsts.color;
  22. }
  23. else
  24. {
  25. outColor = inColor;
  26. }
  27. gl_Position = pushConsts.mvp * vec4(inPos.xyz, 1.0);
  28. vec4 pos = pushConsts.mvp * vec4(inPos, 1.0);
  29. outNormal = mat3(pushConsts.mvp) * inNormal;
  30. // vec3 lPos = ubo.lightPos.xyz;
  31. vec3 lPos = vec3(0.0);
  32. outLightVec = lPos - pos.xyz;
  33. outViewVec = -pos.xyz;
  34. }