worldPostFragment.fs 692 B

1234567891011121314151617181920212223242526
  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. color = vec4(texture(colorSamp, varTex).xyz, 1.0);
  13. if(ssao) {
  14. color = vec4(color.xyz * (texture(ssaoSamp, varTex).r + 0.5), 1.0);
  15. }
  16. if(shadows) {
  17. float f = texture(shadowSamp, varTex).r * max(dot(texture(worldNormalSamp, varTex).xyz, -light), 0.0);
  18. color *= f * 0.5 + 0.5;
  19. }
  20. }