From b154d5f1f5590fc593bbcb105e745ccaaecc4a93 Mon Sep 17 00:00:00 2001 From: Fabien Houlmann Date: Tue, 9 Jun 2020 10:19:29 -0400 Subject: [PATCH 1/5] removed warnings related to ray binning in XR --- .../RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs | 1 - .../Runtime/RenderPipeline/Raytracing/HDRaytracingReflection.cs | 1 - 2 files changed, 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs index e550ec2577f..0aa54df11d4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs @@ -138,7 +138,6 @@ DeferredLightingRTParameters PrepareIndirectDiffuseDeferredLightingRTParameters( if (deferredParameters.viewCount > 1 && deferredParameters.rayBinning) { deferredParameters.rayBinning = false; - Debug.LogWarning("Ray binning is not supported with XR single-pass rendering!"); } deferredParameters.globalCB = m_ShaderVariablesRayTracingCB; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingReflection.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingReflection.cs index b285371c2e8..f8dd305551a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingReflection.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingReflection.cs @@ -156,7 +156,6 @@ DeferredLightingRTParameters PrepareReflectionDeferredLightingRTParameters(HDCam if (deferredParameters.viewCount > 1 && deferredParameters.rayBinning) { deferredParameters.rayBinning = false; - Debug.LogWarning("Ray binning is not supported with XR single-pass rendering!"); } deferredParameters.globalCB = m_ShaderVariablesRayTracingCB; From bfff97e58d1eb80bdd3ad1731fc277751c6faa19 Mon Sep 17 00:00:00 2001 From: Fabien Houlmann Date: Tue, 9 Jun 2020 15:50:40 -0400 Subject: [PATCH 2/5] fix RenderRayTracedReflections with XR --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index bded97613a4..ace6dbdd996 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -4469,9 +4469,7 @@ void RenderSSRTransparent(HDCamera hdCamera, CommandBuffer cmd, ScriptableRender bool usesRaytracedReflections = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && settings.rayTracing.value; if (usesRaytracedReflections) { - hdCamera.xr.StartSinglePass(cmd); RenderRayTracedReflections(hdCamera, cmd, m_SsrLightingTexture, renderContext, m_FrameCount, true); - hdCamera.xr.StopSinglePass(cmd); } else { From 94fdc3ccf86ec90bfb7378e795db258387382b0d Mon Sep 17 00:00:00 2001 From: Fabien Houlmann Date: Wed, 10 Jun 2020 12:12:43 -0400 Subject: [PATCH 3/5] add errors if Path Tracing is used with XR single-pass --- .../Runtime/RenderPipeline/PathTracing/PathTracing.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs index 2e39e0d1f8a..e6bf26aee7a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/PathTracing.cs @@ -226,6 +226,12 @@ void RenderPathTracing(HDCamera hdCamera, CommandBuffer cmd, RTHandle outputText if (!pathTracingShader || !m_PathTracingSettings.enable.value) return; + if (hdCamera.viewCount > 1) + { + Debug.LogError("Path Tracing is not supported when using XR single-pass rendering."); + return; + } + CheckDirtiness(hdCamera); // Inject the ray-tracing sampling data From 5074d49c45b1c514b4f64131c7149fa8f811ab9d Mon Sep 17 00:00:00 2001 From: Fabien Houlmann Date: Mon, 8 Jun 2020 11:22:26 -0400 Subject: [PATCH 4/5] add missing shader macros --- .../ShaderPass/ShaderPassRayTracingSubSurface.hlsl | 2 ++ .../ShaderPass/ShaderPassRaytracingForward.hlsl | 4 ++++ .../ShaderPass/ShaderPassRaytracingGBuffer.hlsl | 5 +++++ .../ShaderPass/ShaderPassRaytracingIndirect.hlsl | 5 +++++ .../ShaderPass/ShaderPassRaytracingVisibility.hlsl | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRayTracingSubSurface.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRayTracingSubSurface.hlsl index bfa4280104a..e2a87b493fe 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRayTracingSubSurface.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRayTracingSubSurface.hlsl @@ -4,6 +4,8 @@ [shader("closesthit")] void ClosestSubSurface(inout RayIntersectionSubSurface rayIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // Always set the new t value rayIntersection.t = RayTCurrent(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl index fa3a2198791..b3a8542713a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingForward.hlsl @@ -5,6 +5,8 @@ [shader("closesthit")] void ClosestHitForward(inout RayIntersection rayIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); @@ -212,6 +214,8 @@ void ClosestHitForward(inout RayIntersection rayIntersection : SV_RayPayload, At [shader("anyhit")] void AnyHitMain(inout RayIntersection rayIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingGBuffer.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingGBuffer.hlsl index 962b866422b..8edbf5da3cc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingGBuffer.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingGBuffer.hlsl @@ -4,6 +4,8 @@ [shader("closesthit")] void ClosestHitGBuffer(inout RayIntersectionGBuffer rayIntersectionGbuffer : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); @@ -53,6 +55,9 @@ void AnyHitGBuffer(inout RayIntersectionGBuffer rayIntersectionGbuffer : SV_RayP #ifdef _SURFACE_TYPE_TRANSPARENT IgnoreHit(); #else + + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl index 0f215a1cdec..8949e17b721 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingIndirect.hlsl @@ -6,6 +6,8 @@ [shader("closesthit")] void ClosestHitMain(inout RayIntersection rayIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); @@ -141,6 +143,9 @@ void AnyHitMain(inout RayIntersection rayIntersection : SV_RayPayload, Attribute #ifdef _SURFACE_TYPE_TRANSPARENT IgnoreHit(); #else + + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingVisibility.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingVisibility.hlsl index 648edea6da2..afd9a25bf55 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingVisibility.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassRaytracingVisibility.hlsl @@ -5,6 +5,8 @@ [shader("closesthit")] void ClosestHitVisibility(inout RayIntersection rayIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); @@ -26,6 +28,8 @@ void ClosestHitVisibility(inout RayIntersection rayIntersection : SV_RayPayload, [shader("anyhit")] void AnyHitVisibility(inout RayIntersection rayIntersection : SV_RayPayload, AttributeData attributeData : SV_IntersectionAttributes) { + UNITY_XR_ASSIGN_VIEW_INDEX(DispatchRaysIndex().z); + // The first thing that we should do is grab the intersection vertice IntersectionVertex currentVertex; GetCurrentIntersectionVertex(attributeData, currentVertex); From 5f574d9beb812546f2592adbcc3238a3d74429e0 Mon Sep 17 00:00:00 2001 From: Fabien Houlmann Date: Fri, 12 Jun 2020 18:43:09 -0400 Subject: [PATCH 5/5] add entry to 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 6e5014a17a9..74d5f536670 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -680,6 +680,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Fixed AxF handling of roughness for Blinn-Phong type materials - Fixed AxF UI errors when surface type is switched to transparent - Fixed a serialization issue, preventing quality level parameters to undo/redo and update scene view on change. +- Fixed ray tracing with XR single-pass. ### Changed - Improve MIP selection for decals on Transparents