GRK/cw 6/shaders/skybox_tex.frag

28 lines
626 B
GLSL
Raw Normal View History

2022-01-30 13:02:30 +01:00
#version 410 core
out vec4 FragColor;
2022-02-10 19:59:26 +01:00
in vec3 texCoords;
2022-01-30 13:02:30 +01:00
uniform samplerCube skybox;
2022-02-10 19:59:26 +01:00
float near = 00.01f;
float far = 7f;
float linearizeDepth(float depth)
{
return (2.0 * near * far) / (far + near - (depth * 2.0 - 1.0) * (far - near));
}
float logisticDepth(float depth, float steepness, float offset)
{
float zVal = linearizeDepth(depth);
return (1 / (1 + exp(-steepness * (zVal - offset))));
}
2022-01-30 13:02:30 +01:00
void main()
{
2022-02-10 19:59:26 +01:00
float depth = logisticDepth(gl_FragCoord.z, 0.5f, 4.0f);
FragColor = texture(skybox, texCoords) * (1.0f - depth) + vec4(depth * vec3(5.0f/255.0f, 35.0f/255.0f, 95.0f/255.0f), 1.0f);
2022-01-30 13:02:30 +01:00
}