From 7431d0d63ec98cb33054f07c4c7b72dcb7fc16f4 Mon Sep 17 00:00:00 2001 From: Faerbit Date: Tue, 25 Nov 2014 13:54:00 +0100 Subject: [PATCH] Changed fog functions a little bit more. Looks nice enough. --- Shader/phong.fsh | 6 +++--- graphics.cc | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Shader/phong.fsh b/Shader/phong.fsh index 4540159..436bee1 100644 --- a/Shader/phong.fsh +++ b/Shader/phong.fsh @@ -20,7 +20,7 @@ uniform float directionalIntensity; uniform vec3 lightSources[128]; uniform vec3 lightColors[128]; uniform float lightIntensities[128]; -uniform float fogStart; +uniform float fogEnd; uniform vec4 fogColor; uniform vec3 cameraCenter; @@ -54,8 +54,8 @@ void main() vec3 finalColor = specularColor + diffuseColor + ambientColor; float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition)); - float fogFactor = clamp((1.0 - exp(-distanceCameraCenter+fogStart)), 0.0, 1.0); - fogFactor = mix(fogFactor, 0.0, clamp((fragPosition.y/50.0), 0.0, 1.0)); + float fogFactor = clamp((1.0 - (fogEnd-distanceCameraCenter)/30.0), 0.0, 1.0); + fogFactor *= clamp((1.0-((fragPosition.y-8.0)/30.0)), 0.0, 1.0); vec4 texture = texture(uTexture, vTexCoord).rgba; oColor = vec4(finalColor, 1.0f)*texture; diff --git a/graphics.cc b/graphics.cc index f9ec463..3745972 100644 --- a/graphics.cc +++ b/graphics.cc @@ -140,7 +140,7 @@ void Graphics::render(Level* level, ACGL::OpenGL::SharedShaderProgram shader) } // set fog Parameters - shader->setUniform("fogStart", (float)((farPlane/2.0f)-20.0f)); + shader->setUniform("fogEnd", (farPlane/2.0f)-10.0f); shader->setUniform("fogColor", level->getFogColor()); shader->setUniform("cameraCenter", level->getCameraCenter()->getPosition());