diff --git a/libraries/render-utils/src/DeferredGlobalLight.slh b/libraries/render-utils/src/DeferredGlobalLight.slh index 6cdc02b7a5..de2d41be6b 100644 --- a/libraries/render-utils/src/DeferredGlobalLight.slh +++ b/libraries/render-utils/src/DeferredGlobalLight.slh @@ -221,7 +221,8 @@ vec3 evalGlobalLightingAlphaBlendedWithHaze( vec4(color, 1.0), // fragment original color position, // fragment position in eye coordinates fragEyeVector, // fragment position in world coordinates - invViewMat[3].y // eye height in world coordinates + invViewMat[3].y, // eye height in world coordinates + lightDirection // keylight direction vector ); color = colorV4.rgb; diff --git a/libraries/render-utils/src/Haze.slf b/libraries/render-utils/src/Haze.slf index 5f05d52f83..0270aa58f0 100644 --- a/libraries/render-utils/src/Haze.slf +++ b/libraries/render-utils/src/Haze.slf @@ -53,6 +53,8 @@ void main(void) { vec4 worldFragPos = viewInverse * eyeFragPos; vec4 worldEyePos = viewInverse[3]; - outFragColor = computeHazeColor(fragColor, eyeFragPos.xyz, worldFragPos.xyz, worldEyePos.y); -} + Light light = getLight(); + vec3 lightDirection = getLightDirection(light); + outFragColor = computeHazeColor(fragColor, eyeFragPos.xyz, worldFragPos.xyz, worldEyePos.y, lightDirection); +} diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh index 2fcf5f4418..15e484e055 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/render-utils/src/Haze.slh @@ -43,7 +43,7 @@ layout(std140) uniform hazeBuffer { // Input: // color - fragment original color -// directionalLight - parameters of the keylight +// lightDirection - parameters of the keylight // worldFragPos - fragment position in world coordinates // Output: // fragment colour after haze effect @@ -101,7 +101,7 @@ vec3 computeHazeColorKeyLightAttenuation(vec3 color, vec3 lightDirection, vec3 w // // General algorithm taken from http://www.iquilezles.org/www/articles/fog/fog.htm, with permission // -vec4 computeHazeColor(vec4 fragColor, vec3 eyeFragPos, vec3 worldFragPos, float worldEyeHeight) { +vec4 computeHazeColor(vec4 fragColor, vec3 eyeFragPos, vec3 worldFragPos, float worldEyeHeight, vec3 lightDirection) { // Distance to fragment float distance = length(eyeFragPos); @@ -111,9 +111,6 @@ vec4 computeHazeColor(vec4 fragColor, vec3 eyeFragPos, vec3 worldFragPos, float // Directional light component is a function of the angle from the eye, between the fragment and the sun vec3 eyeFragDir = normalize(worldFragPos); - Light light = getLight(); - vec3 lightDirection = getLightDirection(light); - float glareComponent = max(0.0, dot(eyeFragDir, -lightDirection)); float power = min(1.0, pow(glareComponent, hazeParams.hazeGlareBlend));