2022-02-27 13:32:12 +01:00
|
|
|
#version 410 core
|
|
|
|
out vec4 FragColor;
|
2022-02-02 00:25:38 +01:00
|
|
|
|
2022-02-27 13:32:12 +01:00
|
|
|
in vec3 TexCoords;
|
2022-02-02 00:25:38 +01:00
|
|
|
|
2022-02-27 13:32:12 +01:00
|
|
|
uniform samplerCube skybox;
|
|
|
|
|
|
|
|
float near = 0.1f;
|
|
|
|
float far = 70.0f;
|
|
|
|
|
|
|
|
float linearizeDepth(float depth)
|
|
|
|
{
|
|
|
|
return (2.0 * near * far) / (far + near - (depth * 2.0 - 1.0) * (far - near));
|
|
|
|
}
|
|
|
|
|
|
|
|
float logisticDepth(float depth)
|
2022-02-02 00:25:38 +01:00
|
|
|
{
|
2022-02-27 13:32:12 +01:00
|
|
|
// these 2 values were default function
|
|
|
|
// parameters before & didn't always work
|
|
|
|
float steepness = 0.4f;
|
|
|
|
float offset = 50.0f; //50.0f
|
|
|
|
|
|
|
|
float zVal = linearizeDepth(depth);
|
|
|
|
return (1 / (1 + exp(-steepness * (zVal - offset))));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
|
|
|
float depth = logisticDepth(gl_FragCoord.z);
|
2022-02-28 21:07:18 +01:00
|
|
|
FragColor = texture(skybox, TexCoords) * (1.0f - depth) + vec4(depth * vec3(27.0f/255.0f, 104.0f/255.0f, 149.0f/255.0f), 1.0f);
|
2022-02-27 13:32:12 +01:00
|
|
|
}
|