No Description

texture.frag 895B

12345678910111213141516171819202122232425262728293031
  1. #version 450
  2. #extension GL_ARB_separate_shader_objects : enable
  3. #extension GL_ARB_shading_language_420pack : enable
  4. layout (binding = 1) uniform sampler2D samplerColorMap;
  5. layout (location = 0) in vec2 inUV;
  6. layout (location = 1) in vec3 inNormal;
  7. layout (location = 2) in vec3 inViewVec;
  8. layout (location = 3) in vec3 inLightVec;
  9. layout (location = 0) out vec4 outFragColor;
  10. void main()
  11. {
  12. vec4 color = texture(samplerColorMap, inUV);
  13. float distSqr = dot(inLightVec, inLightVec);
  14. vec3 lVec = inLightVec * inversesqrt(distSqr);
  15. const float attInvRadius = 1.0/5000.0;
  16. float atten = max(clamp(1.0 - attInvRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
  17. // Fake drop shadow
  18. const float shadowInvRadius = 1.0/2500.0;
  19. float dropshadow = max(clamp(1.0 - shadowInvRadius * sqrt(distSqr), 0.0, 1.0), 0.0);
  20. outFragColor = vec4(color.rgba * (1.0 - dropshadow));
  21. outFragColor.rgb *= atten;
  22. }