player added

This commit is contained in:
maxwes08
2025-09-30 10:58:12 +02:00
parent 38dccf0a84
commit 11f76ca429
11 changed files with 259 additions and 48 deletions

View File

@@ -2,12 +2,24 @@
out vec4 FragColor;
in vec2 fragUV;
in vec3 fragPos;
in float lighting;
uniform sampler2D uTexture;
uniform vec3 cameraPosition;
void main()
{
vec4 texColor = texture(uTexture, fragUV);
FragColor = vec4(texColor.rgb * lighting, texColor.a);
float fogEnd = 512;
float fogStart = 32;
float dist = length(cameraPosition - fragPos);
float fogFactor = (fogEnd - dist) / (fogEnd - fogStart);
fogFactor = clamp(fogFactor, 0, 1);
vec4 fogColor = vec4(0.8,0.8,0.8,1);
vec4 texColor = texture(uTexture, fragUV) * lighting;
vec4 color = mix(fogColor, texColor, fogFactor);
FragColor = vec4(color.rgb, texColor.a);
}

View File

@@ -20,6 +20,7 @@ uniform int chunkY;
out vec2 fragUV;
out float lighting;
out vec3 fragPos;
const float lightMult[6] = float[6](0.6, 0.6, 1.0, 0.5, 0.8, 0.8);
@@ -111,5 +112,6 @@ void main()
fragUV = uv;
lighting = lightMult[facing];
fragPos = vec3(worldPos.x, worldPos.y, worldPos.z);
gl_Position = projection * view * worldPos;
}