From c8bef8651f904343901ff704ec4bbd8446a9435b Mon Sep 17 00:00:00 2001 From: Olivier Prat Date: Thu, 19 Apr 2018 10:04:38 +0200 Subject: [PATCH] Fixed weird specular on hair an teleportation target! Was a stupid mistake... --- libraries/render-utils/src/Haze.slh | 16 ++++++++-------- libraries/render-utils/src/model_translucent.slf | 4 ++-- .../render-utils/src/model_translucent_fade.slf | 2 +- .../src/model_translucent_normal_map.slf | 2 +- .../src/model_translucent_normal_map_fade.slf | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libraries/render-utils/src/Haze.slh b/libraries/render-utils/src/Haze.slh index a9c8ff829e..ab973ba752 100644 --- a/libraries/render-utils/src/Haze.slh +++ b/libraries/render-utils/src/Haze.slh @@ -109,17 +109,17 @@ vec4 computeHazeColor(vec4 fragColor, vec3 fragPositionES, vec3 fragPositionWS, // Convert haze colour from uniform into a vec4 vec4 hazeColor = vec4(hazeParams.hazeColor, 1.0); - // Directional light component is a function of the angle from the eye, between the fragment and the sun - vec3 fragToEyeDirWS = normalize(fragPositionWS - eyePositionWS); - - float glareComponent = max(0.0, dot(fragToEyeDirWS, -lightDirectionWS)); - float power = min(1.0, pow(glareComponent, hazeParams.hazeGlareBlend)); - - vec4 glareColor = vec4(hazeParams.hazeGlareColor, 1.0); - // Use the haze colour for the glare colour, if blend is not enabled vec4 blendedHazeColor; if ((hazeParams.hazeMode & HAZE_MODE_IS_ENABLE_LIGHT_BLEND) == HAZE_MODE_IS_ENABLE_LIGHT_BLEND) { + // Directional light component is a function of the angle from the eye, between the fragment and the sun + vec3 fragToEyeDirWS = normalize(fragPositionWS - eyePositionWS); + + float glareComponent = max(0.0, dot(fragToEyeDirWS, -lightDirectionWS)); + float power = min(1.0, pow(glareComponent, hazeParams.hazeGlareBlend)); + + vec4 glareColor = vec4(hazeParams.hazeGlareColor, 1.0); + blendedHazeColor = mix(hazeColor, glareColor, power); } else { blendedHazeColor = hazeColor; diff --git a/libraries/render-utils/src/model_translucent.slf b/libraries/render-utils/src/model_translucent.slf index f109170068..71f76c8a8d 100644 --- a/libraries/render-utils/src/model_translucent.slf +++ b/libraries/render-utils/src/model_translucent.slf @@ -64,7 +64,7 @@ void main(void) { vec3 fragNormalWS = normalize(_normalWS); TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = fragPositionWS - cam._viewInverse[3].xyz; + vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; vec3 fragToEyeDirWS = normalize(fragToEyeWS); SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS); @@ -77,7 +77,7 @@ void main(void) { vec4(0), vec4(0), opacity); } - _fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze( + _fragColor = vec4(evalGlobalLightingAlphaBlendedWithHaze( cam._viewInverse, 1.0, occlusionTex, diff --git a/libraries/render-utils/src/model_translucent_fade.slf b/libraries/render-utils/src/model_translucent_fade.slf index 47349930de..8b40186448 100644 --- a/libraries/render-utils/src/model_translucent_fade.slf +++ b/libraries/render-utils/src/model_translucent_fade.slf @@ -66,7 +66,7 @@ void main(void) { vec3 fragNormalWS = normalize(_normalWS); TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = fragPositionWS - cam._viewInverse[3].xyz; + vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; vec3 fragToEyeDirWS = normalize(fragToEyeWS); SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS); diff --git a/libraries/render-utils/src/model_translucent_normal_map.slf b/libraries/render-utils/src/model_translucent_normal_map.slf index 89f5f46f6a..320e883bb0 100644 --- a/libraries/render-utils/src/model_translucent_normal_map.slf +++ b/libraries/render-utils/src/model_translucent_normal_map.slf @@ -66,7 +66,7 @@ void main(void) { <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = fragPositionWS - cam._viewInverse[3].xyz; + vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; vec3 fragToEyeDirWS = normalize(fragToEyeWS); SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS); diff --git a/libraries/render-utils/src/model_translucent_normal_map_fade.slf b/libraries/render-utils/src/model_translucent_normal_map_fade.slf index a87167af63..0e114f7fdd 100644 --- a/libraries/render-utils/src/model_translucent_normal_map_fade.slf +++ b/libraries/render-utils/src/model_translucent_normal_map_fade.slf @@ -75,7 +75,7 @@ void main(void) { <$evalMaterialNormalLOD(_positionES, normalTex, _normalWS, _tangentWS, fragNormalWS)$> TransformCamera cam = getTransformCamera(); - vec3 fragToEyeWS = fragPositionWS - cam._viewInverse[3].xyz; + vec3 fragToEyeWS = cam._viewInverse[3].xyz - fragPositionWS; vec3 fragToEyeDirWS = normalize(fragToEyeWS); SurfaceData surfaceWS = initSurfaceData(roughness, fragNormalWS, fragToEyeDirWS);