25 lines
566 B
GLSL
25 lines
566 B
GLSL
#version 430 core
|
|
|
|
out vec4 FragColor;
|
|
in vec2 fragUV;
|
|
in vec3 fragPos;
|
|
in float lighting;
|
|
|
|
uniform sampler2D uTexture;
|
|
uniform vec3 cameraPosition;
|
|
|
|
void main()
|
|
{
|
|
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);
|
|
} |