worldPostFragment.fs 774 B

12345678910111213141516171819202122232425262728
  1. #version 430
  2. layout (binding = 0) uniform sampler2D colorSamp;
  3. layout (binding = 1) uniform sampler2D ssaoSamp;
  4. layout (binding = 2) uniform sampler2D shadowSamp;
  5. layout (binding = 3) uniform sampler2D worldNormalSamp;
  6. uniform bool ssao;
  7. uniform bool shadows;
  8. in vec2 varTex;
  9. out vec4 color;
  10. const vec3 light = vec3(-0.280166, -0.573576, -0.769751);
  11. void main() {
  12. if(ssao) {
  13. color = vec4(texture(colorSamp, varTex).xyz * (texture(ssaoSamp, varTex).r + 0.5), 1.0);
  14. } else {
  15. color = vec4(texture(colorSamp, varTex).xyz, 1.0);
  16. }
  17. if(shadows) {
  18. float diffuseLight = float(dot(texture(worldNormalSamp, varTex).xyz, -light) > 0);
  19. float f = diffuseLight * texture(shadowSamp, varTex).r;
  20. color *= f * 0.5 + 0.5;
  21. }
  22. }