From 49f03ba958dddf4dde8ff21aa51e4bdcb7fb3271 Mon Sep 17 00:00:00 2001 From: Jonathas Costa Date: Fri, 26 May 2017 16:20:13 -0400 Subject: [PATCH] Fixed bug in Sun position inside ATM. --- .../atmosphere/shaders/deferred_test_fs.glsl | 19 ++++++++++--------- src/interaction/interactionmode.cpp | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/modules/atmosphere/shaders/deferred_test_fs.glsl b/modules/atmosphere/shaders/deferred_test_fs.glsl index 6853850cc9..8ada6166d9 100644 --- a/modules/atmosphere/shaders/deferred_test_fs.glsl +++ b/modules/atmosphere/shaders/deferred_test_fs.glsl @@ -534,9 +534,10 @@ vec3 groundColor(const vec3 x, const float t, const vec3 v, const vec3 s, const * mu := cosine of the zenith view angle * attenuation := transmittance T(x,x0) */ -vec3 sunColor(const vec3 x, const float t, const vec3 v, const vec3 s, const float r, const float mu) { - vec3 transmittance = (r <= Rt) ? ( mu < -sqrt(1.0f - (Rg*Rg)/(r*r)) ? vec3(0.0f) : transmittanceLUT(r, mu)) : vec3(1.0f); - float sunFinalColor = step(cos(M_PI / 180.0), dot(v, s)) * sunRadiance; +vec3 sunColor(const vec3 x, const float t, const vec3 v, const vec3 s, const float r, + const float mu, const float irradianceFactor) { + vec3 transmittance = (r <= Rt) ? ( mu < -sqrt(1.0f - (Rg*Rg)/(r*r)) ? vec3(0.0f) : transmittanceLUT(r, mu)) : vec3(1.0f); + float sunFinalColor = step(cos(M_PI / 180.0), dot(v, s)) * sunRadiance * (1.0 - irradianceFactor); return transmittance * sunFinalColor; } @@ -618,7 +619,7 @@ void main() { maxLength, pixelDepth); vec3 groundColor = groundColor(x, tF, v, s, r, mu, attenuation, meanColor, meanNormal, irradianceFactor); - vec3 sunColor = sunColor(x, tF, v, s, r, mu); + vec3 sunColor = sunColor(x, tF, v, s, r, mu, irradianceFactor); vec4 finalRadiance = vec4(HDR(inscatterColor + groundColor + sunColor), 1.0); @@ -685,12 +686,12 @@ void main() { double pixelDepth = distance(cameraPositionInObject.xyz, fragObjectCoords.xyz); // All calculations are done in Km: - pixelDepth /= 1000.0; + pixelDepth /= 1000.0; fragObjectCoords.xyz /= 1000.0; if (meanPosition.xyz != vec3(0.0) && (pixelDepth < offset)) { - //renderTarget = meanColor; - renderTarget = vec4(0.0); + renderTarget = meanColor; + //renderTarget = vec4(1.0, 0.0, 0.0, 1.0); } else { // Following paper nomenclature double t = offset; @@ -719,7 +720,7 @@ void main() { maxLength, pixelDepth); vec3 groundColor = groundColor(x, tF, v, s, r, mu, attenuation, meanColor, meanNormal, irradianceFactor); - vec3 sunColor = sunColor(x, tF, v, s, r, mu); + vec3 sunColor = sunColor(x, tF, v, s, r, mu, irradianceFactor); //vec4 finalRadiance = vec4(HDR(inscatterColor + sunColor), 1.0); //finalRadiance = mix(finalRadiance, meanColor); @@ -738,7 +739,7 @@ void main() { //renderTarget = vec4(vec3(pixelDepth/100000),1.0); } } else { - renderTarget = meanColor; + renderTarget = meanColor; } } else { // No ATM defined. diff --git a/src/interaction/interactionmode.cpp b/src/interaction/interactionmode.cpp index cfb871bdf5..bfd45a2330 100644 --- a/src/interaction/interactionmode.cpp +++ b/src/interaction/interactionmode.cpp @@ -210,7 +210,7 @@ void KeyframeInteractionMode::updateCameraStateFromMouseStates(Camera& camera, d const CameraPose& prevPose = prevKeyframe->data; const CameraPose& nextPose = nextKeyframe->data; - + Scene* scene = camera.parent()->scene(); SceneGraphNode* prevFocusNode = scene->sceneGraphNode(prevPose.focusNode); SceneGraphNode* nextFocusNode = scene->sceneGraphNode(nextPose.focusNode);