diff options
author | LaG1924 <lag1924@gmail.com> | 2021-12-04 20:51:39 +0100 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-12-04 20:56:29 +0100 |
commit | 3f122e57f118db1229a4bad2c54be624f2f8f19c (patch) | |
tree | 538ec737720cc8e344cbcfed1edcedff0d23a109 /cwd/assets/altcraft/shaders/frag/light.fs | |
parent | Added gamma correction (diff) | |
download | AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.tar AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.tar.gz AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.tar.bz2 AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.tar.lz AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.tar.xz AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.tar.zst AltCraft-3f122e57f118db1229a4bad2c54be624f2f8f19c.zip |
Diffstat (limited to 'cwd/assets/altcraft/shaders/frag/light.fs')
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/light.fs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs index 117e0ef..fd7aa4e 100644 --- a/cwd/assets/altcraft/shaders/frag/light.fs +++ b/cwd/assets/altcraft/shaders/frag/light.fs @@ -4,17 +4,22 @@ out vec4 fragColor; in vec2 uv; +uniform sampler2D depthStencil; uniform sampler2D color; uniform sampler2D normal; +uniform sampler2D worldPos; uniform sampler2D addColor; uniform sampler2D light; -uniform sampler2D depthStencil; +uniform sampler2D ssao; uniform int renderBuff; layout (std140) uniform Globals { mat4 projView; + mat4 proj; + mat4 view; uvec2 viewportSize; + vec4 ssaoKernels[64]; float globalTime; float dayTime; float gamma; @@ -23,9 +28,14 @@ layout (std140) uniform Globals { void main() { vec4 c = texture(color, uv); vec4 n = texture(normal, uv); + n += 1.0f; + n /= 2.0f; + + vec4 wp = texture(worldPos, uv); vec4 ac = texture(addColor, uv); vec4 l = texture(light, uv); float d = (1.0f - texture(depthStencil, uv).r) * 16.0f; + vec4 s = texture(ssao, uv); float faceLight = l.r; float skyLight = l.g; @@ -34,7 +44,7 @@ void main() { lightLevel = clamp(lightLevel, 0.005f, 1.0f); vec3 faceColor = mix(ac.rgb * lightLevel, vec3(1,1,1) * lightLevel, float(ac.rgb == vec3(0,0,0))); - vec4 finalColor = vec4(c.rgb * faceColor, 1.0f); + vec4 finalColor = vec4(c.rgb * faceColor * (1.0f - s.r), 1.0f); finalColor.rgb = pow(finalColor.rgb, vec3(1.0f / gamma)); @@ -49,13 +59,19 @@ void main() { fragColor = n; break; case 3: - fragColor = ac; + fragColor = wp; break; case 4: - fragColor = l; + fragColor = ac; break; case 5: + fragColor = l; + break; + case 6: fragColor = vec4(vec3(d), 1.0f); break; + case 7: + fragColor = s; + break; } } |