Fog and more blocks

This commit is contained in:
Ben
2019-10-18 22:34:22 +01:00
parent ababa43c72
commit 13b3e7f3b1
9 changed files with 69 additions and 22 deletions

View File

@@ -1,11 +1,23 @@
#version 450
vec3 SkyColour = vec3(186.0f / 255.0f, 214.0f / 255.0f, 254.0f / 255.0f);
in vec3 TexCoord;
in float Distance;
out vec4 outColour;
uniform sampler2DArray tex;
void main() {
outColour = texture(tex, TexCoord);
outColour = texture(tex, TexCoord);
if (outColour.w == .0)
discard;
float fogMax = 20000;
outColour = vec4(mix(outColour.xyz, SkyColour, min(1.0f, Distance / fogMax)), outColour.w);
}

View File

@@ -4,12 +4,23 @@ layout (location = 0) in vec3 position;
layout (location = 1) in vec3 texcoord;
out vec3 TexCoord;
out float Distance;
uniform mat4 model;
uniform mat4 view;
uniform mat4 proj;
void main() {
TexCoord = texcoord;
gl_Position = proj * view * model * vec4(position, 1.0);
TexCoord = texcoord;
gl_Position = proj * view * model * vec4(position, 1.0);
// Makes no sense but it works
Distance = (
gl_Position.x * gl_Position.x +
gl_Position.y * gl_Position.y +
gl_Position.z * gl_Position.z
);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B