]> git.lizzy.rs Git - dragonblocks_alpha.git/blob - assets/shaders/3d/terrain/fragment.glsl
Rework structure
[dragonblocks_alpha.git] / assets / shaders / 3d / terrain / fragment.glsl
1 in vec3 fragmentPosition;
2 in vec2 fragmentTextureCoordinates;
3 in float fragmentTextureIndex;
4 in vec3 fragmentColor;
5
6 out vec4 outColor;
7
8 uniform vec3 fogColor;
9 uniform vec3 cameraPos;
10 uniform sampler2D textures[MAX_TEXTURE_UNITS];
11
12 void main()
13 {
14         outColor = texture(textures[int(fragmentTextureIndex + 0.5)], fragmentTextureCoordinates) * vec4(fragmentColor, 1.0);
15         outColor.rgb = mix(outColor.rgb, fogColor, clamp(length(fragmentPosition - cameraPos) / VIEW_DISTANCE, 0.0, 1.0));
16
17         if (outColor.a == 0.0)
18                 discard;
19 }