Нет описания

1234567891011121314151617181920212223242526272829
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (set = 0, binding = 1) uniform texture2D textureColor;
  5. layout (set = 0, binding = 2) uniform sampler samplers[3];
  6. layout (location = 0) in vec2 inUV;
  7. layout (location = 1) in float inLodBias;
  8. layout (location = 2) flat in int inSamplerIndex;
  9. layout (location = 3) in vec3 inNormal;
  10. layout (location = 4) in vec3 inViewVec;
  11. layout (location = 5) in vec3 inLightVec;
  12. layout (location = 0) out vec4 outFragColor;
  13. void main()
  14. {
  15. vec4 color = texture(sampler2D(textureColor, samplers[inSamplerIndex]), inUV, inLodBias);
  16. vec3 N = normalize(inNormal);
  17. vec3 L = normalize(inLightVec);
  18. vec3 V = normalize(inViewVec);
  19. vec3 R = reflect(L, N);
  20. vec3 diffuse = max(dot(N, L), 0.65) * vec3(1.0);
  21. float specular = pow(max(dot(R, V), 0.0), 16.0) * color.a;
  22. outFragColor = vec4(diffuse * color.rgb + specular, 1.0);
  23. }