diff --git a/Shader/phong.fsh b/Shader/phong.fsh index bd723e3..77cb8d6 100644 --- a/Shader/phong.fsh +++ b/Shader/phong.fsh @@ -27,7 +27,7 @@ uniform float directionalIntensity; uniform vec3 lightSources[32]; uniform vec3 lightColors[32]; uniform float lightIntensities[32]; -uniform float fogEnd; +uniform float farPlane; uniform vec4 fogColor; uniform vec3 cameraCenter; @@ -133,7 +133,7 @@ void main() vec3 finalColor = specularColor + diffuseColor + ambientColor; float distanceCameraCenter = distance(cameraCenter, vec3(fragPosition)); - float fogFactor = clamp((1.0 - (fogEnd-distanceCameraCenter)/30.0), 0.0, 1.0); + float fogFactor = clamp((1.0 - ((farPlane - 35.0) -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; diff --git a/graphics.cc b/graphics.cc index f23faad..f373ae1 100644 --- a/graphics.cc +++ b/graphics.cc @@ -212,8 +212,9 @@ void Graphics::render() lightingShader->setTexture("shadowMap_middle", depthTexture_middle, 2); lightingShader->setTexture("shadowMap_far", depthTexture_far, 3); + lightingShader->setUniform("farPlane", farPlane); + // set fog Parameters - lightingShader->setUniform("fogEnd", (farPlane)-35.0f); lightingShader->setUniform("fogColor", level->getFogColour()); lightingShader->setUniform("cameraCenter", level->getCameraCenter()->getPosition());