diff options
author | LaG1924 <lag1924@gmail.com> | 2021-12-06 01:39:15 +0100 |
---|---|---|
committer | LaG1924 <lag1924@gmail.com> | 2021-12-07 12:37:47 +0100 |
commit | aa591c73c818d7f26caa15bc567929e2d404dcf2 (patch) | |
tree | 2514facee211ef5eb16812658caae91d1ee078d6 /cwd/assets/altcraft/shaders/frag/fwd_face.fs | |
parent | Minor shader optimization (diff) | |
download | AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.tar AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.tar.gz AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.tar.bz2 AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.tar.lz AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.tar.xz AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.tar.zst AltCraft-aa591c73c818d7f26caa15bc567929e2d404dcf2.zip |
Diffstat (limited to 'cwd/assets/altcraft/shaders/frag/fwd_face.fs')
-rw-r--r-- | cwd/assets/altcraft/shaders/frag/fwd_face.fs | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/fwd_face.fs b/cwd/assets/altcraft/shaders/frag/fwd_face.fs new file mode 100644 index 0000000..deb8341 --- /dev/null +++ b/cwd/assets/altcraft/shaders/frag/fwd_face.fs @@ -0,0 +1,38 @@ +#version 330 core + +in vec4 faceWorldPos; +in vec3 faceTextureUv; +in vec3 faceAddColor; +in vec3 faceNormal; +in vec2 faceLight; + +out vec4 fragColor; + +uniform sampler2DArray textureAtlas; + +layout (std140) uniform Globals { + mat4 projView; + mat4 proj; + mat4 view; + uvec2 viewportSize; + vec4 ssaoKernels[64]; + float globalTime; + float dayTime; + float gamma; +}; + +void main() { + vec4 col = texture(textureAtlas, faceTextureUv); + if (col.a < 0.3f) + discard; + + float localLight = faceLight.r / 15.0f; + float skyLight = faceLight.g / 15.0f; + float lightLevel = clamp(localLight + skyLight * dayTime, 0.01f, 1.0f); + lightLevel = pow(lightLevel, 3); + lightLevel = clamp(lightLevel, 0.005f, 1.0f); + + fragColor = vec4(col.rgb * faceAddColor.rgb * lightLevel, 1.0f); + + fragColor.rgb = pow(fragColor.rgb, vec3(1.0f / gamma)); +} |