Calulating fogEnd by farPlane.

This commit is contained in:
Faerbit 2014-12-19 13:27:05 +01:00
parent 5b2c4a6bbc
commit b16a90bd15
2 changed files with 4 additions and 3 deletions

View File

@ -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;

View File

@ -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());