add fog on skybox
This commit is contained in:
parent
deec0c2300
commit
9b0fed73c1
@ -5,7 +5,22 @@ in vec3 TexCoords;
|
||||
|
||||
uniform samplerCube skybox;
|
||||
|
||||
float near = 0.02f;
|
||||
float far = 100.0f;
|
||||
|
||||
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))));
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = texture(skybox, TexCoords);
|
||||
float depth = logisticDepth(gl_FragCoord.z, 0.1f, 3.0f);
|
||||
FragColor = texture(skybox, TexCoords)* (1.0f - depth) + vec4(depth * vec3(0.0f, 0.109f, 0.447f), 1.0f);
|
||||
}
|
Loading…
Reference in New Issue
Block a user