summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/shaders/frag/light.fs
diff options
context:
space:
mode:
authorLaG1924 <lag1924@gmail.com>2021-11-21 13:49:23 +0100
committerLaG1924 <lag1924@gmail.com>2021-11-21 15:23:37 +0100
commit0ca11f9bee1cd918acf6ce8247a495442009fec9 (patch)
treed1e791cf44770660eca6783bc3e9c0a2470b7efb /cwd/assets/altcraft/shaders/frag/light.fs
parentAdded normals to faces (diff)
downloadAltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.gz
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.bz2
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.lz
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.xz
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.tar.zst
AltCraft-0ca11f9bee1cd918acf6ce8247a495442009fec9.zip
Diffstat (limited to 'cwd/assets/altcraft/shaders/frag/light.fs')
-rw-r--r--cwd/assets/altcraft/shaders/frag/light.fs16
1 files changed, 14 insertions, 2 deletions
diff --git a/cwd/assets/altcraft/shaders/frag/light.fs b/cwd/assets/altcraft/shaders/frag/light.fs
index 73686cc..12ab841 100644
--- a/cwd/assets/altcraft/shaders/frag/light.fs
+++ b/cwd/assets/altcraft/shaders/frag/light.fs
@@ -6,11 +6,23 @@ in vec2 uv;
uniform sampler2D color;
uniform sampler2D normal;
+uniform sampler2D addColor;
+uniform sampler2D light;
uniform sampler2D depthStencil;
+uniform float dayTime;
+
void main() {
vec4 c = texture(color, uv);
vec4 n = texture(normal, uv);
- float d = texture(depthStencil, uv).r;
- fragColor = n;
+ vec4 ac = texture(addColor, uv);
+ vec4 an = texture(light, uv);
+ float d = 1.0f - texture(depthStencil, uv).r;
+
+ float faceLight = an.r;
+ float skyLight = an.g;
+ float lightLevel = clamp(faceLight + skyLight * dayTime, 0.2f, 1.0f);
+ vec3 faceColor = mix(ac.rgb * lightLevel, vec3(1,1,1) * lightLevel, float(ac.rgb == vec3(0,0,0)));
+
+ fragColor = vec4(c.rgb * faceColor, 1.0f);
}