From b55576e0a4ac4f5ca8da8b61ce5856ce447d5341 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Tue, 7 Jul 2020 17:51:57 +0200 Subject: [PATCH 1/3] Fixed robustness issue with GetOddNegativeScale() in ray tracing. --- .../ShaderLibrary/SpaceTransforms.hlsl | 5 ++++- .../Raytracing/Shaders/RaytracingFragInputs.hlsl | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl index c7cbe86d610..fcf51f82fa9 100644 --- a/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl +++ b/com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl @@ -49,7 +49,10 @@ float3 GetCameraRelativePositionWS(float3 positionWS) real GetOddNegativeScale() { - return unity_WorldTransformParams.w; + // FIXME: We should be able to just return unity_WorldTransformParams.w, but it is not + // properly set at the moment, when doing ray-tracing; once this has been fixed in cpp, + // we can revert back to the former implementation. + return unity_WorldTransformParams.w >= 0.0 ? 1.0 : -1.0; } float3 TransformObjectToWorld(float3 positionOS) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingFragInputs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingFragInputs.hlsl index 189b8fb48a4..a1835907d3d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingFragInputs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingFragInputs.hlsl @@ -10,8 +10,8 @@ void BuildFragInputsFromIntersection(IntersectionVertex currentVertex, float3 in outFragInputs.color = currentVertex.color; float3 normalWS = normalize(mul(currentVertex.normalOS, (float3x3)WorldToObject3x4())); - float4 tangentWS = float4(normalize(mul(currentVertex.tangentOS.xyz, (float3x3)WorldToObject3x4())), currentVertex.tangentOS.w); - outFragInputs.tangentToWorld = BuildTangentToWorld(tangentWS, normalWS); + float3 tangentWS = normalize(mul(currentVertex.tangentOS.xyz, (float3x3)WorldToObject3x4())); + outFragInputs.tangentToWorld = CreateTangentToWorld(normalWS, tangentWS, sign(currentVertex.tangentOS.w)); outFragInputs.isFrontFace = dot(incidentDirection, outFragInputs.tangentToWorld[2]) < 0.0f; } \ No newline at end of file From d88c21082a9c702183fc6ab63963a824554bf19c Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Tue, 7 Jul 2020 17:56:37 +0200 Subject: [PATCH 2/3] Updated changelog. --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index c15c475ca09..b0b36e6eec8 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -723,6 +723,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed overused the atlas for Animated/Render Target Cookies (1259930). - Fixed sky asserts with XR multipass - Fixed for area light not updating baked light result when modifying with gizmo. +- Fixed robustness issue with GetOddNegativeScale() in ray tracing (that was impacting normal mapping). ### Changed - Improve MIP selection for decals on Transparents From 696203162d4c457f2f2fc6bbd7036c91cf4c0350 Mon Sep 17 00:00:00 2001 From: Emmanuel Turquin Date: Tue, 7 Jul 2020 19:13:12 +0200 Subject: [PATCH 3/3] Added fogbugz case id in changelog. --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index b0b36e6eec8..d1c141710f6 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -723,7 +723,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed overused the atlas for Animated/Render Target Cookies (1259930). - Fixed sky asserts with XR multipass - Fixed for area light not updating baked light result when modifying with gizmo. -- Fixed robustness issue with GetOddNegativeScale() in ray tracing (that was impacting normal mapping). +- Fixed robustness issue with GetOddNegativeScale() in ray tracing, which was impacting normal mapping (1261160). ### Changed - Improve MIP selection for decals on Transparents