worldPostFragment.fs 785 B

1234567891011121314151617181920212223242526272829
  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. uniform float bump;
  9. in vec2 varTex;
  10. out vec4 color;
  11. const vec3 light = vec3(-0.280166, -0.573576, -0.769751);
  12. void main() {
  13. color = vec4(texture(colorSamp, varTex).xyz, 1.0);
  14. if(ssao) {
  15. color = vec4(color.xyz * (texture(ssaoSamp, varTex).r + 0.5), 1.0);
  16. }
  17. if(shadows) {
  18. float f = texture(shadowSamp, varTex).r;
  19. color *= f * 0.5 + 0.5;
  20. }
  21. float diffuseLight = max(dot(texture(worldNormalSamp, varTex).xyz, -light), 0.0) * bump + (1.0 - bump);
  22. color *= diffuseLight;
  23. }