123456789101112131415161718192021222324252627282930 |
- #version 430
- layout (binding = 0) uniform sampler2D colorSamp;
- layout (binding = 1) uniform sampler2D ssaoSamp;
- layout (binding = 2) uniform sampler2D shadowSamp;
- layout (binding = 3) uniform sampler2D worldNormalSamp;
- uniform bool ssao;
- uniform bool shadows;
- in vec2 varTex;
- out vec4 color;
- const vec3 light = vec3(-0.280166, -0.573576, -0.769751);
- void main() {
- if(ssao) {
- color = vec4(texture(colorSamp, varTex).xyz * (texture(ssaoSamp, varTex).r + 0.5), 1.0);
- } else {
- color = vec4(texture(colorSamp, varTex).xyz, 1.0);
- }
- if(shadows) {
- float diffuseLight = float(dot(texture(worldNormalSamp, varTex).xyz, -light) > 0);
- float f = diffuseLight * texture(shadowSamp, varTex).r;
- color *= f * 0.5 + 0.5;
- }
- float diffuseLight = max(dot(texture(worldNormalSamp, varTex).xyz, -light), 0.0);
- color *= diffuseLight;
- }
|