summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/shaders/frag/fwd_face.fs
diff options
context:
space:
mode:
Diffstat (limited to 'cwd/assets/altcraft/shaders/frag/fwd_face.fs')
-rw-r--r--cwd/assets/altcraft/shaders/frag/fwd_face.fs39
1 files changed, 39 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..12deab8
--- /dev/null
+++ b/cwd/assets/altcraft/shaders/frag/fwd_face.fs
@@ -0,0 +1,39 @@
+#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 invProj;
+ 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));
+}