Improved fog a little bit.
This commit is contained in:
parent
c7518a7f8e
commit
4039bad9f9
@ -22,6 +22,7 @@ uniform vec3 lightColors[128];
|
|||||||
uniform float lightIntensities[128];
|
uniform float lightIntensities[128];
|
||||||
uniform float fogStart;
|
uniform float fogStart;
|
||||||
uniform vec4 fogColor;
|
uniform vec4 fogColor;
|
||||||
|
uniform vec3 cameraCenter;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
@ -52,8 +53,8 @@ void main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
vec3 finalColor = specularColor + diffuseColor + ambientColor;
|
vec3 finalColor = specularColor + diffuseColor + ambientColor;
|
||||||
float distanceCamera = distance(camera, vec3(fragPosition));
|
float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition));
|
||||||
float fogFactor = clamp((1.0 - exp(-distanceCamera+fogStart)), 0.0, 1.0);
|
float fogFactor = clamp((1.0 - exp(-distanceCameraCenter+fogStart)), 0.0, 1.0);
|
||||||
fogFactor = mix(fogFactor, 0.0, clamp((1.0 - exp(-fragPosition.y+20.0)), 0.0, 1.0));
|
fogFactor = mix(fogFactor, 0.0, clamp((1.0 - exp(-fragPosition.y+20.0)), 0.0, 1.0));
|
||||||
|
|
||||||
vec4 texture = texture(uTexture, vTexCoord).rgba;
|
vec4 texture = texture(uTexture, vTexCoord).rgba;
|
||||||
|
@ -140,8 +140,9 @@ void Graphics::render(Level* level, ACGL::OpenGL::SharedShaderProgram shader)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// set fog Parameters
|
// set fog Parameters
|
||||||
shader->setUniform("fogStart", farPlane-50.0f);
|
shader->setUniform("fogStart", (float)((farPlane-40.0f)/sqrt(2)));
|
||||||
shader->setUniform("fogColor", level->getFogColor());
|
shader->setUniform("fogColor", level->getFogColor());
|
||||||
|
shader->setUniform("cameraCenter", level->getCameraCenter()->getPosition());
|
||||||
|
|
||||||
// set Material Parameters
|
// set Material Parameters
|
||||||
shader->setUniform("ambientColor", level->getAmbientLight());
|
shader->setUniform("ambientColor", level->getAmbientLight());
|
||||||
|
Loading…
Reference in New Issue
Block a user