summaryrefslogtreecommitdiffstats
path: root/cwd/assets/altcraft/shaders/frag/fwd_face.fs
blob: 12deab89d9755d661435158672004b9dac1a76fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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));
}