worldPostFragment.fs 817 B

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