From 2241eb52173a6c0cc3f2625731c5e25f751de3d3 Mon Sep 17 00:00:00 2001 From: Yorgos Petkakis Date: Fri, 30 Oct 2026 11:37:27 +0000 Subject: [PATCH 01/61] [6000.7] [GSDET-1288] Use the published Graphics Test Framework in SRP test projects --- .../Packages/local.gtf.references/package.json | 18 ++++++++++++++++++ .../local.gtf.references/package.json.meta | 7 +++++++ .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../HDRP_DXR_Tests/Packages/manifest.json | 2 +- .../HDRP_RuntimeTests/Packages/manifest.json | 2 +- .../Projects/HDRP_Tests/Packages/manifest.json | 2 +- .../SRP_SmokeTest/Packages/manifest.json | 2 +- .../ShaderGraph/Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- .../Packages/manifest.json | 2 +- 18 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 Tests/SRPTests/Packages/local.gtf.references/package.json create mode 100644 Tests/SRPTests/Packages/local.gtf.references/package.json.meta diff --git a/Tests/SRPTests/Packages/local.gtf.references/package.json b/Tests/SRPTests/Packages/local.gtf.references/package.json new file mode 100644 index 00000000000..744e1359532 --- /dev/null +++ b/Tests/SRPTests/Packages/local.gtf.references/package.json @@ -0,0 +1,18 @@ +{ + "displayName": "Graphics Test Framework (published v9)", + "name": "local.gtf.references", + "version": "1.0.0", + "unity": "6000.7", + "description": "Shim package that contains a reference to the com.unity.testframework.graphics package for easier version pinning.", + "keywords": [ + "qa", + "test", + "testing", + "tests", + "graphics" + ], + "category": "Libraries", + "dependencies": { + "com.unity.testframework.graphics": "9.0.0-pre.32" + } +} diff --git a/Tests/SRPTests/Packages/local.gtf.references/package.json.meta b/Tests/SRPTests/Packages/local.gtf.references/package.json.meta new file mode 100644 index 00000000000..592a323c294 --- /dev/null +++ b/Tests/SRPTests/Packages/local.gtf.references/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 81773ed82dd27614a859d3f421000966 +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/SRPTests/Projects/BatchRendererGroup_HDRP/Packages/manifest.json b/Tests/SRPTests/Projects/BatchRendererGroup_HDRP/Packages/manifest.json index 0e7e7d0ab22..ec3f1ad7619 100644 --- a/Tests/SRPTests/Projects/BatchRendererGroup_HDRP/Packages/manifest.json +++ b/Tests/SRPTests/Projects/BatchRendererGroup_HDRP/Packages/manifest.json @@ -11,7 +11,7 @@ "com.unity.render-pipelines.high-definition-config": "file:../../../../../Packages/com.unity.render-pipelines.high-definition-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.brg": "file:../../../Packages/com.unity.testing.brg", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", diff --git a/Tests/SRPTests/Projects/BatchRendererGroup_URP/Packages/manifest.json b/Tests/SRPTests/Projects/BatchRendererGroup_URP/Packages/manifest.json index 98fa0550153..66c876b2091 100644 --- a/Tests/SRPTests/Projects/BatchRendererGroup_URP/Packages/manifest.json +++ b/Tests/SRPTests/Projects/BatchRendererGroup_URP/Packages/manifest.json @@ -10,7 +10,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.brg": "file:../../../Packages/com.unity.testing.brg", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", "com.unity.ugui": "2.0.0", diff --git a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Packages/manifest.json b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Packages/manifest.json index 5457423e2ba..57e02af3472 100644 --- a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Packages/manifest.json +++ b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Packages/manifest.json @@ -14,7 +14,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", "com.unity.ugui": "2.0.0", "com.unity.modules.ai": "1.0.0", diff --git a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Packages/manifest.json b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Packages/manifest.json index 394e36dc3db..32dc9fb348c 100644 --- a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Packages/manifest.json +++ b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Packages/manifest.json @@ -15,7 +15,7 @@ "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", "com.unity.ugui": "2.0.0", "com.unity.modules.ai": "1.0.0", diff --git a/Tests/SRPTests/Projects/HDRP_DXR_Tests/Packages/manifest.json b/Tests/SRPTests/Projects/HDRP_DXR_Tests/Packages/manifest.json index 19f92f4b703..b0236527073 100644 --- a/Tests/SRPTests/Projects/HDRP_DXR_Tests/Packages/manifest.json +++ b/Tests/SRPTests/Projects/HDRP_DXR_Tests/Packages/manifest.json @@ -10,7 +10,7 @@ "com.unity.rendering.denoising": "1.0.5", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.hdrp": "file:../../../Packages/com.unity.testing.hdrp", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", diff --git a/Tests/SRPTests/Projects/HDRP_RuntimeTests/Packages/manifest.json b/Tests/SRPTests/Projects/HDRP_RuntimeTests/Packages/manifest.json index e3050aea989..c4a467ef3bc 100644 --- a/Tests/SRPTests/Projects/HDRP_RuntimeTests/Packages/manifest.json +++ b/Tests/SRPTests/Projects/HDRP_RuntimeTests/Packages/manifest.json @@ -10,7 +10,7 @@ "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.hdrp": "file:../../../Packages/com.unity.testing.hdrp", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", "com.unity.ugui": "2.0.0", diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Packages/manifest.json b/Tests/SRPTests/Projects/HDRP_Tests/Packages/manifest.json index 1fb807c2e60..c96bb53ce48 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/Packages/manifest.json +++ b/Tests/SRPTests/Projects/HDRP_Tests/Packages/manifest.json @@ -10,7 +10,7 @@ "com.unity.render-pipelines.high-definition-config": "file:../../../../../Packages/com.unity.render-pipelines.high-definition-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.hdrp": "file:../../../Packages/com.unity.testing.hdrp", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", diff --git a/Tests/SRPTests/Projects/SRP_SmokeTest/Packages/manifest.json b/Tests/SRPTests/Projects/SRP_SmokeTest/Packages/manifest.json index 380ae29677a..eac6baf8d6f 100644 --- a/Tests/SRPTests/Projects/SRP_SmokeTest/Packages/manifest.json +++ b/Tests/SRPTests/Projects/SRP_SmokeTest/Packages/manifest.json @@ -14,7 +14,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../../../Tests/SRPTests/Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../../../Tests/SRPTests/Packages/local.gtf.references", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", "com.unity.ugui": "2.0.0", diff --git a/Tests/SRPTests/Projects/ShaderGraph/Packages/manifest.json b/Tests/SRPTests/Projects/ShaderGraph/Packages/manifest.json index ba77102ebf5..cfcdc1ff581 100644 --- a/Tests/SRPTests/Projects/ShaderGraph/Packages/manifest.json +++ b/Tests/SRPTests/Projects/ShaderGraph/Packages/manifest.json @@ -8,7 +8,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.graph-authoring": "file:../../../../../Packages/com.unity.graph-authoring", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testtools.codecoverage": "1.3.0", "com.unity.ugui": "2.0.0", "com.unity.visualeffectgraph": "file:../../../../../Packages/com.unity.visualeffectgraph", diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Packages/manifest.json b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Packages/manifest.json index 47e9757eaef..ffe98bfe787 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Packages/manifest.json +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Packages/manifest.json @@ -15,7 +15,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.hdr-faking": "file:../../../Packages/com.unity.testing.hdr-faking", "com.unity.testing.urp": "file:../../../Packages/com.unity.testing.urp", diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Packages/manifest.json b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Packages/manifest.json index b76339d3e36..e5168521694 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Packages/manifest.json +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Packages/manifest.json @@ -15,7 +15,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.urp": "file:../../../Packages/com.unity.testing.urp", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Lighting/Packages/manifest.json b/Tests/SRPTests/Projects/UniversalGraphicsTest_Lighting/Packages/manifest.json index 36a22a0d843..9da7982d89e 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Lighting/Packages/manifest.json +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Lighting/Packages/manifest.json @@ -14,7 +14,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.urp": "file:../../../Packages/com.unity.testing.urp", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_PostPro/Packages/manifest.json b/Tests/SRPTests/Projects/UniversalGraphicsTest_PostPro/Packages/manifest.json index 1affc24df8d..e3123d2046a 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_PostPro/Packages/manifest.json +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_PostPro/Packages/manifest.json @@ -14,7 +14,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.hdr-faking": "file:../../../Packages/com.unity.testing.hdr-faking", "com.unity.testing.urp": "file:../../../Packages/com.unity.testing.urp", diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Terrain/Packages/manifest.json b/Tests/SRPTests/Projects/UniversalGraphicsTest_Terrain/Packages/manifest.json index 36a22a0d843..9da7982d89e 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Terrain/Packages/manifest.json +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Terrain/Packages/manifest.json @@ -14,7 +14,7 @@ "com.unity.render-pipelines.universal-config": "file:../../../../../Packages/com.unity.render-pipelines.universal-config", "com.unity.shadergraph": "file:../../../../../Packages/com.unity.shadergraph", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.testing.urp": "file:../../../Packages/com.unity.testing.urp", "com.unity.testing.common-graphics": "file:../../../Packages/com.unity.testing.common-graphics", "com.unity.testing.xr": "file:../../../Packages/com.unity.testing.xr", diff --git a/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Packages/manifest.json b/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Packages/manifest.json index 1f0ce3fcbce..b61dfbde14c 100644 --- a/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Packages/manifest.json +++ b/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Packages/manifest.json @@ -20,7 +20,7 @@ "com.unity.ugui": "2.0.0", "com.unity.ui.test-framework": "6.6.0", "com.unity.visualeffectgraph": "file:../../../../../Packages/com.unity.visualeffectgraph", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", diff --git a/Tests/SRPTests/Projects/VisualEffectGraph_URP/Packages/manifest.json b/Tests/SRPTests/Projects/VisualEffectGraph_URP/Packages/manifest.json index 4a8c00925ec..228338ef314 100644 --- a/Tests/SRPTests/Projects/VisualEffectGraph_URP/Packages/manifest.json +++ b/Tests/SRPTests/Projects/VisualEffectGraph_URP/Packages/manifest.json @@ -19,7 +19,7 @@ "com.unity.ugui": "2.0.0", "com.unity.visualeffectgraph": "file:../../../../../Packages/com.unity.visualeffectgraph", "com.unity.xr.legacyinputhelpers": "6.0.0", - "com.unity.testframework.graphics": "file:../../../Packages/com.unity.test-framework.graphics", + "local.gtf.references": "file:../../../Packages/local.gtf.references", "com.unity.test-framework": "file:../../../../../Packages/com.unity.test-framework", "com.unity.modules.ai": "1.0.0", "com.unity.modules.androidjni": "1.0.0", From 6b780025e49123ec341a62a5a4775297ec325da7 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 30 Oct 2026 15:44:15 +0000 Subject: [PATCH 02/61] [Port] [6000.7] [UUM-155328] [URP] Fix forward-only materials losing additional light shadows in Deferred --- .../Runtime/Passes/AdditionalLightsShadowCasterPass.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs index 8fe1064d83a..f5822cbc43b 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs @@ -471,7 +471,7 @@ bool SetupShadowPassMode(UniversalRenderingData renderingData, UniversalCameraDa { UniversalRenderer universalRenderer = cameraData.renderer as UniversalRenderer; bool isStencilDeferred = universalRenderer != null && universalRenderer.renderingModeActual == RenderingMode.Deferred; - m_NeedExtraForwardShadowParamsCopy = isStencilDeferred && universalRenderer.shadowTransparentReceive; + m_NeedExtraForwardShadowParamsCopy = isStencilDeferred; // Lazy init: ensure buffers exist (may have been destroyed by domain reload or graphics device reset) EnsureBuffersCreated(); From 681f947958bf3ef3f045481bde0d2e1492b5e808 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 30 Oct 2026 15:44:16 +0000 Subject: [PATCH 03/61] [Port] [6000.7] [UUM-159093] Fix 2D sprites and UI not rendering with Depth/Stencil Buffer off on GLES --- .../2D/Rendergraph/DrawNormal2DPass.cs | 2 +- .../2D/Rendergraph/Renderer2DRendergraph.cs | 29 +++++-- .../Runtime/Renderer2DBackbufferDepthTests.cs | 77 ++++++++++++++++--- 3 files changed, 92 insertions(+), 16 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawNormal2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawNormal2DPass.cs index 5cf40956a59..84df47cda02 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawNormal2DPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawNormal2DPass.cs @@ -50,7 +50,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex builder.SetRenderAttachment(universal2DResourceData.normalsTexture[batchIndex], 0); // Depth needed for sprite mask stencil or z test for 3d meshes - if (commonResourceData.activeDepthTexture.IsValid()) + if (Renderer2D.IsDepthUsageAllowed(frameData, rendererData) && commonResourceData.activeDepthTexture.IsValid()) { var depth = universal2DResourceData.normalsDepth.IsValid() ? universal2DResourceData.normalsDepth : commonResourceData.activeDepthTexture; builder.SetRenderAttachmentDepth(depth); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs index 5d5d86c6cb1..ed4ea3dbc36 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs @@ -221,6 +221,26 @@ internal static bool IsDepthUsageAllowed(ContextContainer frameData, Renderer2DD return allowDepth; } + static bool ShouldImportBackBufferDepth(ContextContainer frameData, Renderer2DData rendererData, bool createColorTexture) + { + if (IsDepthUsageAllowed(frameData, rendererData)) + return true; + + // OpenGL binds the default framebuffer's depth with its color even when no pass uses it, so it must still be cleared (UUM-159093) + var deviceType = SystemInfo.graphicsDeviceType; + if (deviceType != GraphicsDeviceType.OpenGLES3 && deviceType != GraphicsDeviceType.OpenGLCore) + return false; + + // Only when the 2D passes draw straight into the back buffer, since they are what attach and clear it + UniversalCameraData cameraData = frameData.Get(); + bool isBackBuffer = cameraData.targetTexture == null && !createColorTexture; +#if ENABLE_VR && ENABLE_XR_MODULE + isBackBuffer &= !cameraData.xr.enabled; +#endif + + return isBackBuffer && Graphics.backBufferHasDepthStencil; + } + private bool IsPixelPerfectCameraEnabled(UniversalCameraData cameraData, out PixelPerfectCamera ppc) { ppc = null; @@ -540,10 +560,7 @@ void CreateResources(RenderGraph renderGraph) depthDescriptor.depthStencilFormat = CoreUtils.GetDefaultDepthStencilFormat(); RenderingUtils.ReAllocateHandleIfNeeded(ref s_RenderGraphCameraDepthHandle, depthDescriptor, FilterMode.Point, TextureWrapMode.Clamp, name: "_CameraDepthAttachment"); - commonResourceData.activeDepthID = ActiveID.Camera; } - else - commonResourceData.activeDepthID = ActiveID.BackBuffer; } else // Overlay camera { @@ -557,9 +574,11 @@ void CreateResources(RenderGraph renderGraph) m_CreateDepthTexture = baseRenderer.m_CreateDepthTexture; commonResourceData.activeColorID = m_CreateColorTexture ? ActiveID.Camera : ActiveID.BackBuffer; - commonResourceData.activeDepthID = m_CreateDepthTexture ? ActiveID.Camera : ActiveID.BackBuffer; } + // An intermediate color target is never paired with the back buffer depth + commonResourceData.activeDepthID = m_CreateDepthTexture || m_CreateColorTexture ? ActiveID.Camera : ActiveID.BackBuffer; + // Report this camera's real back buffer MSAA need; a 2D camera renders directly to it only when // no intermediate color texture is created (m_CreateColorTexture == false). ReportDisplayTargetMSAA(cameraData, m_CreateColorTexture); @@ -600,7 +619,7 @@ void CreateResources(RenderGraph renderGraph) commonResourceData.backBufferColor = renderGraph.ImportTexture(m_RenderGraphBackbufferColorHandle, importSummary.importInfo, importSummary.backBufferColorParams); - if (IsDepthUsageAllowed(frameData, m_Renderer2DData)) + if (ShouldImportBackBufferDepth(frameData, m_Renderer2DData, m_CreateColorTexture)) { if (m_RenderGraphBackbufferDepthHandle == null) { diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Renderer2DBackbufferDepthTests.cs b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Renderer2DBackbufferDepthTests.cs index 5ae66800b2d..eda62cb932e 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Renderer2DBackbufferDepthTests.cs +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Runtime/Renderer2DBackbufferDepthTests.cs @@ -8,9 +8,10 @@ using UnityEngine.TestTools; // Verifies what the 2D renderer actually puts in the frame's resources when depth usage is disallowed: the -// back buffer depth must not be imported, and the rest of the frame must still record without errors (the -// overlay UI pass in particular reads UniversalResourceData.backBufferDepth and has to cope with it being -// invalid). +// back buffer depth is not imported, except on OpenGL when the 2D passes draw straight into a back buffer that +// has one (there it stays bound with the back buffer color whether a pass asks for it or not, so it must be +// cleared, see UUM-159093), and the rest of the frame must still record without errors (the overlay UI pass in +// particular reads UniversalResourceData.backBufferDepth and has to cope with it being invalid). // // A back buffer with no depth/stencil is not something a test can arrange - it is decided when the surface is // created - so the disallowed case is driven here through the renderer's own "Depth/Stencil Buffer" setting, @@ -81,6 +82,7 @@ public void SetUp() public void TearDown() { RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering; + m_ProbePass.requiresIntermediateTexture = false; if (m_RendererData != null) Renderer2DDepthUsageTests.SetUseDepthStencilBuffer(m_RendererData, m_PreviousUseDepthStencilBuffer); @@ -110,13 +112,44 @@ public IEnumerator BackbufferDepthIsImportedWhenDepthUsageIsAllowed() } [UnityTest] - public IEnumerator BackbufferDepthIsNotImportedWhenDepthUsageIsDisallowed() + public IEnumerator BackbufferDepthIsImportedOnlyOnOpenGLWhenDepthUsageIsDisallowed() { Renderer2DDepthUsageTests.SetUseDepthStencilBuffer(m_RendererData, false); yield return RecordFrame(); + IgnoreIfNotRenderingStraightToTheBackbuffer(); - Assert.IsFalse(m_ProbePass.backBufferDepthIsValid, "The 2D renderer imported the back buffer depth even though depth usage is disallowed."); + // On OpenGL the renderer setting must not drop the back buffer depth: left unimported it is never cleared, + // and draws into the back buffer test against undefined contents (UUM-159093). Elsewhere it is not imported. + Assert.AreEqual(BackbufferDepthStaysBound(), m_ProbePass.backBufferDepthIsValid, + "The imported back buffer depth did not match whether the graphics API keeps it bound with the back buffer color."); + } + + [UnityTest] + public IEnumerator ActiveDepthIsBackbufferDepthOnlyOnOpenGLWhenDepthUsageIsDisallowed() + { + Renderer2DDepthUsageTests.SetUseDepthStencilBuffer(m_RendererData, false); + + yield return RecordFrame(); + IgnoreIfNotRenderingStraightToTheBackbuffer(); + + // The 2D passes attach the active depth, which is what gets the back buffer depth cleared on first use + Assert.AreEqual(BackbufferDepthStaysBound(), m_ProbePass.activeDepthIsBackBufferDepth, + "The active depth did not match the back buffer depth when rendering straight to the back buffer."); + } + + [UnityTest] + public IEnumerator NoActiveDepthWithIntermediateColorWhenDepthUsageIsDisallowed() + { + Renderer2DDepthUsageTests.SetUseDepthStencilBuffer(m_RendererData, false); + m_ProbePass.requiresIntermediateTexture = true; + + yield return RecordFrame(); + + // The intermediate color target must not be paired with the back buffer depth, and the back buffer depth is + // not imported at all since no 2D pass would attach it and get it cleared + Assert.IsFalse(m_ProbePass.activeDepthIsValid, "An active depth was set for the intermediate color target even though depth usage is disallowed."); + Assert.IsFalse(m_ProbePass.backBufferDepthIsValid, "The back buffer depth was imported with an intermediate color target even though depth usage is disallowed."); } [UnityTest] @@ -130,6 +163,22 @@ public IEnumerator RenderingSucceedsWhenDepthUsageIsDisallowed() yield return null; } + // OpenGL binds the default framebuffer's depth with its color, so the renderer imports it to get it cleared. + static bool BackbufferDepthStaysBound() + { + var deviceType = SystemInfo.graphicsDeviceType; + bool isOpenGL = deviceType == GraphicsDeviceType.OpenGLES3 || deviceType == GraphicsDeviceType.OpenGLCore; + return isOpenGL && Graphics.backBufferHasDepthStencil; + } + + // The OpenGL import only applies without an intermediate color target, which the setup cannot rule out everywhere + // (e.g. a non-sRGB back buffer in Linear color space needs one for the sRGB conversion) + void IgnoreIfNotRenderingStraightToTheBackbuffer() + { + if (BackbufferDepthStaysBound() && !m_ProbePass.activeColorIsBackBuffer) + Assert.Ignore("The 2D renderer created an intermediate color target, so it does not render straight to the back buffer."); + } + // Renders frames until the probe pass has recorded one with the current settings. IEnumerator RecordFrame() { @@ -151,23 +200,28 @@ void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera) } // Reads the frame's back buffer depth handle at record time; it adds no render pass of its own. - class BackbufferDepthProbePass : ScriptableRenderPass + class BackbufferDepthProbePass : ScriptableRenderPass2D { public bool recorded; public bool backBufferDepthIsValid; + public bool activeDepthIsValid; + public bool activeDepthIsBackBufferDepth; + public bool activeColorIsBackBuffer; public BackbufferDepthProbePass() { - // The 2D renderer maps any event up to BeforeRenderingTransparents onto - // RenderPassEvent2D.BeforeRendering, which it records right after CreateResources - so the probe - // sees the back buffer depth as CreateResources left it. - renderPassEvent = RenderPassEvent.AfterRenderingOpaques; + // The 2D renderer records BeforeRendering passes right after CreateResources, so the probe sees the + // back buffer depth as CreateResources left it. + renderPassEvent2D = RenderPassEvent2D.BeforeRendering; } public void Reset() { recorded = false; backBufferDepthIsValid = false; + activeDepthIsValid = false; + activeDepthIsBackBufferDepth = false; + activeColorIsBackBuffer = false; } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) @@ -176,6 +230,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer recorded = true; backBufferDepthIsValid = resourceData.backBufferDepth.IsValid(); + activeDepthIsValid = resourceData.activeDepthTexture.IsValid(); + activeDepthIsBackBufferDepth = activeDepthIsValid && resourceData.activeDepthTexture == resourceData.backBufferDepth; + activeColorIsBackBuffer = resourceData.isActiveTargetBackBuffer; } } } From fa289914924817adc3543e07e04222b6986fb440 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 30 Oct 2026 21:37:07 +0000 Subject: [PATCH 04/61] [Port] [6000.7] [UUM-157356] [URP] Fix Shadow Layers multi-edit only updating the primary Light --- .../UniversalRenderPipelineLightUI.Drawers.cs | 34 ++---- .../Runtime/UniversalAdditionalLightData.cs | 2 +- .../Editor/LightShadowLayersMultiEditTests.cs | 105 ++++++++++++++++++ .../LightShadowLayersMultiEditTests.cs.meta | 2 + 4 files changed, 115 insertions(+), 28 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs b/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs index 7b2c0bd3eaa..e2af179238c 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs @@ -202,19 +202,13 @@ static void DrawGeneralContentInternal(UniversalRenderPipelineSerializedLight se } } - internal static void SyncLightAndShadowLayers(UniversalRenderPipelineSerializedLight serializedLight, SerializedProperty serialized) + internal static void SyncLightAndShadowLayers(UniversalRenderPipelineSerializedLight serializedLight) { - // If we're not in decoupled mode for light layers, we sync light with shadow layers. - // In mixed state, it makes sense to do it only on Light that links the mode. - foreach (var lightTarget in serializedLight.serializedObject.targetObjects) + serializedLight.serializedAdditionalDataObject.ApplyModifiedProperties(); + Undo.RecordObjects(serializedLight.serializedObject.targetObjects, "Sync Light and Shadow Layers"); + foreach (var additionalData in serializedLight.lightsAdditionalData) { - var additionData = (lightTarget as Component).gameObject.GetComponent(); - if (additionData.customShadowLayers) - continue; - - Light target = lightTarget as Light; - if (target.renderingLayerMask != serialized.intValue) - target.renderingLayerMask = serialized.intValue; + additionalData.SyncLightAndShadowLayers(); } } @@ -296,10 +290,7 @@ static void DrawRenderingContent(UniversalRenderPipelineSerializedLight serializ EditorGUILayout.PropertyField(serializedLight.renderingLayers, Styles.RenderingLayers); GUI.enabled = true; if (EditorGUI.EndChangeCheck()) - { - if (!serializedLight.customShadowLayers.boolValue) - SyncLightAndShadowLayers(serializedLight, serializedLight.renderingLayers); - } + SyncLightAndShadowLayers(serializedLight); if (!UniversalRenderPipeline.asset.useRenderingLayers) { CoreEditorUtils.DrawFixMeBox(Styles.RenderingLayersHelpBox, () => @@ -405,19 +396,8 @@ static void DrawShadowsContent(UniversalRenderPipelineSerializedLight serialized using (new EditorGUI.IndentLevelScope()) EditorGUILayout.PropertyField(serializedLight.shadowRenderingLayers, Styles.ShadowLayer); } - // Undo the changes in the light component because the SyncLightAndShadowLayers will change the value automatically when link is ticked if (EditorGUI.EndChangeCheck()) - { - if (serializedLight.customShadowLayers.boolValue) - { - serializedLight.settings.light.renderingLayerMask = serializedLight.shadowRenderingLayers.intValue; - } - else - { - serializedLight.serializedAdditionalDataObject.ApplyModifiedProperties(); // we need to push above modification the modification on object as it is used to sync - SyncLightAndShadowLayers(serializedLight, serializedLight.renderingLayers); - } - } + SyncLightAndShadowLayers(serializedLight); } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalAdditionalLightData.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalAdditionalLightData.cs index 686bf10f1b2..cd50ec00426 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalAdditionalLightData.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalAdditionalLightData.cs @@ -233,7 +233,7 @@ public RenderingLayerMask shadowRenderingLayers } } - void SyncLightAndShadowLayers() + internal void SyncLightAndShadowLayers() { if (light) light.renderingLayerMask = m_CustomShadowLayers ? m_ShadowRenderingLayersMask : m_RenderingLayersMask; diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs new file mode 100644 index 00000000000..85a6bb18cfe --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs @@ -0,0 +1,105 @@ +using NUnit.Framework; +using UnityEngine; +using UnityEngine.Rendering.Universal; + +namespace UnityEditor.Rendering.Universal.Tests +{ + [TestFixture] + class LightShadowLayersMultiEditTests + { + const int k_LightCount = 3; + + Light[] m_Lights; + UniversalRenderPipelineSerializedLight m_SerializedLight; + + [SetUp] + public void SetUp() + { + m_Lights = new Light[k_LightCount]; + for (int i = 0; i < k_LightCount; ++i) + { + m_Lights[i] = new GameObject("Light " + i).AddComponent(); + var additionalData = m_Lights[i].GetUniversalAdditionalLightData(); + additionalData.renderingLayers = 1u << i; + additionalData.shadowRenderingLayers = 1u << i; + additionalData.customShadowLayers = true; + } + + var serializedObject = new SerializedObject(m_Lights); + m_SerializedLight = new UniversalRenderPipelineSerializedLight(serializedObject, new LightEditor.Settings(serializedObject)); + } + + [TearDown] + public void TearDown() + { + foreach (var light in m_Lights) + { + Undo.ClearUndo(light.GetUniversalAdditionalLightData()); + Undo.ClearUndo(light); + Object.DestroyImmediate(light.gameObject); + } + } + + [Test] + public void ChangingShadowLayers_UpdatesRenderingLayerMaskOfAllLights() + { + const uint shadowLayers = 1u << 5; + m_SerializedLight.shadowRenderingLayers.uintValue = shadowLayers; + + UniversalRenderPipelineLightUI.SyncLightAndShadowLayers(m_SerializedLight); + + foreach (var light in m_Lights) + { + Assert.AreEqual((int)shadowLayers, light.renderingLayerMask, light.name); + } + } + + [Test] + public void ChangingLightLayersWithoutCustomShadowLayers_UpdatesRenderingLayerMaskOfAllLights() + { + m_SerializedLight.customShadowLayers.boolValue = false; + UniversalRenderPipelineLightUI.SyncLightAndShadowLayers(m_SerializedLight); + + const uint lightLayers = 1u << 4; + m_SerializedLight.renderingLayers.uintValue = lightLayers; + UniversalRenderPipelineLightUI.SyncLightAndShadowLayers(m_SerializedLight); + + foreach (var light in m_Lights) + { + Assert.AreEqual((int)lightLayers, light.renderingLayerMask, light.name); + } + } + + [Test] + public void DisablingCustomShadowLayers_RestoresEachLightsOwnRenderingLayers() + { + m_SerializedLight.shadowRenderingLayers.uintValue = 1u << 5; + UniversalRenderPipelineLightUI.SyncLightAndShadowLayers(m_SerializedLight); + + m_SerializedLight.customShadowLayers.boolValue = false; + UniversalRenderPipelineLightUI.SyncLightAndShadowLayers(m_SerializedLight); + + for (int i = 0; i < k_LightCount; ++i) + { + Assert.AreEqual(1 << i, m_Lights[i].renderingLayerMask, m_Lights[i].name); + } + } + + [Test] + public void UndoingShadowLayersChange_RestoresRenderingLayerMaskOfAllLights() + { + Undo.IncrementCurrentGroup(); + m_SerializedLight.shadowRenderingLayers.uintValue = 1u << 5; + UniversalRenderPipelineLightUI.SyncLightAndShadowLayers(m_SerializedLight); + + Undo.PerformUndo(); + + for (int i = 0; i < k_LightCount; ++i) + { + var additionalData = m_Lights[i].GetUniversalAdditionalLightData(); + Assert.AreEqual(1u << i, (uint)additionalData.shadowRenderingLayers, m_Lights[i].name); + Assert.AreEqual(1 << i, m_Lights[i].renderingLayerMask, m_Lights[i].name); + } + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs.meta new file mode 100644 index 00000000000..2d09fe7ab54 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/LightShadowLayersMultiEditTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: a1dc60853be541fea1553e8b54e745fa From f936c7e2f2798b330fcf84f5ba59f299eaf41b00 Mon Sep 17 00:00:00 2001 From: Rose Hirigoyen Date: Fri, 30 Oct 2026 21:37:08 +0000 Subject: [PATCH 05/61] [Port] [6000.7] [UUM-147726] Fix render requests to cubemaps rendering nothing --- .../Runtime/UniversalRenderPipeline.cs | 4 + .../Tests/Runtime/RuntimeTests.cs | 91 +++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs index 7e4ef5fb004..4751381bab6 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs @@ -892,6 +892,10 @@ protected override void ProcessRenderRequests(ScriptableRenderConte RTDesc.width = Mathf.Max(1, RTDesc.width); RTDesc.height = Mathf.Max(1, RTDesc.height); + RTDesc.depthStencilFormat = destination.depthStencilFormat; + if (RTDesc.depthStencilFormat == GraphicsFormat.None) + RTDesc.depthStencilFormat = CoreUtils.GetDefaultDepthStencilFormat(); + //if mip is 0 and target is Texture2D we can immediately render to the requested destination if(destination.dimension != TextureDimension.Tex2D || mipLevel != 0) { diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs index be45a68bba9..dae5a9e990b 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs @@ -14,6 +14,7 @@ class RuntimeTests Camera camera; RenderPipelineAsset currentAssetGraphics; RenderPipelineAsset currentAssetQuality; + RenderTexture m_Destination; [SetUp] public void Setup() @@ -30,6 +31,12 @@ public void Cleanup() GraphicsSettings.defaultRenderPipeline = currentAssetGraphics; QualitySettings.renderPipeline = currentAssetQuality; Object.DestroyImmediate(go); + if (m_Destination != null) + { + m_Destination.Release(); + Object.DestroyImmediate(m_Destination); + m_Destination = null; + } } static readonly (int tier, string textTier)[] k_ShadowResolutions = @@ -118,6 +125,90 @@ public IEnumerator PipelineHasCorrectColorSpace() "GraphicsSettings.lightsUseLinearIntensity must match active color space."); } + [UnityTest] + public IEnumerator RenderRequest_WithCubemapDestination_RendersIntoRequestedFace( + [Values] bool useSingleCameraRequest, + [Values] bool destinationHasDepth) + { + AssetCheck(); + + if ((SystemInfo.copyTextureSupport & CopyTextureSupport.DifferentTypes) == 0) + Assert.Ignore("Render requests into a cubemap require CopyTextureSupport.DifferentTypes."); + + camera.clearFlags = CameraClearFlags.SolidColor; + camera.backgroundColor = Color.red; + camera.cullingMask = 0; + + var depthStencilFormat = destinationHasDepth + ? CoreUtils.GetDefaultDepthStencilFormat() + : UnityEngine.Experimental.Rendering.GraphicsFormat.None; + m_Destination = new RenderTexture(64, 64, UnityEngine.Experimental.Rendering.GraphicsFormat.R8G8B8A8_UNorm, + depthStencilFormat) + { + dimension = TextureDimension.Cube + }; + m_Destination.Create(); + + if (useSingleCameraRequest) + { + RenderPipeline.SubmitRenderRequest(camera, new UniversalRenderPipeline.SingleCameraRequest + { + destination = m_Destination, + face = CubemapFace.PositiveX + }); + } + else + { + RenderPipeline.SubmitRenderRequest(camera, new RenderPipeline.StandardRequest + { + destination = m_Destination, + face = CubemapFace.PositiveX + }); + } + yield return null; + + var faceCopy = new RenderTexture(m_Destination.width, m_Destination.height, 0, m_Destination.graphicsFormat); + Texture2D readback = null; + var previousActive = RenderTexture.active; + try + { + Graphics.CopyTexture(m_Destination, (int)CubemapFace.PositiveX, 0, faceCopy, 0, 0); + + int centerX = faceCopy.width / 2; + int centerY = faceCopy.height / 2; + Color pixel; + + // ReadPixels does not work on WebGPU when the browser lacks JSPI + if (SystemInfo.supportsAsyncGPUReadback) + { + var request = AsyncGPUReadback.Request(faceCopy, 0, TextureFormat.RGBA32); + while (!request.done) + yield return null; + + Assert.IsFalse(request.hasError, "AsyncGPUReadback of the requested cubemap face failed."); + pixel = request.GetData()[centerY * faceCopy.width + centerX]; + } + else + { + readback = new Texture2D(faceCopy.width, faceCopy.height, TextureFormat.RGBA32, false); + RenderTexture.active = faceCopy; + readback.ReadPixels(new Rect(0, 0, faceCopy.width, faceCopy.height), 0, 0); + readback.Apply(); + pixel = readback.GetPixel(centerX, centerY); + } + + Assert.Greater(pixel.r, 0.9f, $"The requested cubemap face does not contain the camera rendering. Pixel: {pixel}"); + } + finally + { + RenderTexture.active = previousActive; + faceCopy.Release(); + Object.DestroyImmediate(faceCopy); + if (readback != null) + Object.DestroyImmediate(readback); + } + } + // When switching to URP it sets "UniversalPipeline" as global shader tag. // When switching to Built-in it sets "" as global shader tag. #if UNITY_EDITOR // TODO This API call does not reset in player From a8bf30107d29ef3750135430986f03e499ec8b5c Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 30 Oct 2026 21:37:09 +0000 Subject: [PATCH 06/61] [Port] [6000.7] Render Pipeline Converter: Animation Clip converter returns inconsistent results on an unchanged project (UUM-154762) --- .../AnimationClipConverter.cs | 151 +++++++++--------- 1 file changed, 75 insertions(+), 76 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/AnimationClipConverter/AnimationClipConverter.cs b/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/AnimationClipConverter/AnimationClipConverter.cs index f5299093027..435e81442ee 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/AnimationClipConverter/AnimationClipConverter.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/AnimationClipConverter/AnimationClipConverter.cs @@ -108,96 +108,95 @@ void OnSearchFinish() onScanFinish?.Invoke(results); } - using (UnityEngine.Pool.DictionaryPool>.Get(out var animatorUsingClip)) - using (UnityEngine.Pool.HashSetPool<(string,string)>.Get(out var animatorReferences)) - { - void OnAnimationClipDependenciesSearchFinish() - { - var query = new List<(string, string)>(animatorReferences); - SearchServiceUtils.RunQueuedSearch - ( - SearchServiceUtils.IndexingOptions.DeepSearch, - query, - (item, path) => - { - var unityObject = item.ToObject(); - - if (unityObject == null) - return; - - var gid = GlobalObjectId.GetGlobalObjectIdSlow(unityObject); - int type = gid.identifierType; // 1=Asset, 2=SceneObject - - var assetItem = new RenderPipelineConverterAssetItem(gid.ToString()) - { - name = unityObject.name, - info = path, - }; - - if (animatorUsingClip.TryGetValue(path, out var list)) - { - foreach (var i in list) - { - i.dependencies.Add(assetItem); - } - } - }, - OnSearchFinish // Invoked when all queued searches complete - ); - } + var animatorUsingClip = new Dictionary>(); + var animatorReferences = new HashSet<(string, string)>(); + void OnAnimationClipDependenciesSearchFinish() + { + var query = new List<(string, string)>(animatorReferences); SearchServiceUtils.RunQueuedSearch ( SearchServiceUtils.IndexingOptions.DeepSearch, - GetAnimationClipsSearchList(), - (searchItem, animationClipPath) => + query, + (item, path) => { - // Search callback invoked for each asset that references an animation clip. - // The queued search processes results grouped by animation clip. When we encounter - // a different animationClipPath than the current one, it indicates we've started - // processing dependencies for a new animation clip. - // - // This batching approach efficiently groups all dependencies (prefabs, GameObjects, etc.) - // under their respective animation clips without requiring separate searches per clip. - - // Create a new converter item when we encounter a different animation clip - if (currentAnimationClipItem == null || - !currentAnimationClipItem.assetPath.Equals(animationClipPath)) - { - currentAnimationClipItem = new AnimationClipConverterItem( - GlobalObjectId.GetGlobalObjectIdSlow(AssetDatabase.LoadAssetAtPath(animationClipPath)), - animationClipPath); - assets.Add(currentAnimationClipItem); - } + var unityObject = item.ToObject(); - // Add the dependent asset (prefab, GameObject, etc.) to the current clip's dependency list - var assetItem = new RenderPipelineConverterAssetItem(searchItem.id); - - // If the animation clip is being referenced by a controller, we need to enqueue where this controller is being used - // Handle everything at the end and fill clip dependencies, with controller dependencies. - if (assetItem.assetPath.EndsWith(".controller")) + if (unityObject == null) + return; + + var gid = GlobalObjectId.GetGlobalObjectIdSlow(unityObject); + int type = gid.identifierType; // 1=Asset, 2=SceneObject + + var assetItem = new RenderPipelineConverterAssetItem(gid.ToString()) { - var controller = assetItem.LoadObject(); - string formattedId = $"<$object:{GlobalObjectId.GetGlobalObjectIdSlow(controller)},UnityEngine.Object$>"; - animatorReferences.Add(($"ref={formattedId}", AssetDatabase.GetAssetPath(controller))); + name = unityObject.name, + info = path, + }; - if (!animatorUsingClip.TryGetValue(assetItem.assetPath, out var list)) + if (animatorUsingClip.TryGetValue(path, out var list)) + { + foreach (var i in list) { - list = new (); - animatorUsingClip[assetItem.assetPath] = list; + i.dependencies.Add(assetItem); } - - list.Add(currentAnimationClipItem); - } - else - { - // A game object with an Animation component directly referencing the animation clip - currentAnimationClipItem.dependencies.Add(assetItem); } }, - OnAnimationClipDependenciesSearchFinish // Queue animators + OnSearchFinish // Invoked when all queued searches complete ); } + + SearchServiceUtils.RunQueuedSearch + ( + SearchServiceUtils.IndexingOptions.DeepSearch, + GetAnimationClipsSearchList(), + (searchItem, animationClipPath) => + { + // Search callback invoked for each asset that references an animation clip. + // The queued search processes results grouped by animation clip. When we encounter + // a different animationClipPath than the current one, it indicates we've started + // processing dependencies for a new animation clip. + // + // This batching approach efficiently groups all dependencies (prefabs, GameObjects, etc.) + // under their respective animation clips without requiring separate searches per clip. + + // Create a new converter item when we encounter a different animation clip + if (currentAnimationClipItem == null || + !currentAnimationClipItem.assetPath.Equals(animationClipPath)) + { + currentAnimationClipItem = new AnimationClipConverterItem( + GlobalObjectId.GetGlobalObjectIdSlow(AssetDatabase.LoadAssetAtPath(animationClipPath)), + animationClipPath); + assets.Add(currentAnimationClipItem); + } + + // Add the dependent asset (prefab, GameObject, etc.) to the current clip's dependency list + var assetItem = new RenderPipelineConverterAssetItem(searchItem.id); + + // If the animation clip is being referenced by a controller, we need to enqueue where this controller is being used + // Handle everything at the end and fill clip dependencies, with controller dependencies. + if (assetItem.assetPath.EndsWith(".controller")) + { + var controller = assetItem.LoadObject(); + string formattedId = $"<$object:{GlobalObjectId.GetGlobalObjectIdSlow(controller)},UnityEngine.Object$>"; + animatorReferences.Add(($"ref={formattedId}", AssetDatabase.GetAssetPath(controller))); + + if (!animatorUsingClip.TryGetValue(assetItem.assetPath, out var list)) + { + list = new (); + animatorUsingClip[assetItem.assetPath] = list; + } + + list.Add(currentAnimationClipItem); + } + else + { + // A game object with an Animation component directly referencing the animation clip + currentAnimationClipItem.dependencies.Add(assetItem); + } + }, + OnAnimationClipDependenciesSearchFinish // Queue animators + ); } /// From d48543b256e1faf53cd135db75d6b89e178827e6 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 30 Oct 2026 21:37:10 +0000 Subject: [PATCH 07/61] [Port] [6000.7] [UUM-151921] [SurfaceCache] Defer environment cubemap draw until its shader is compiled --- .../PathTracing/Environment/CubemapRender.cs | 94 ++++++--- .../Runtime/PathTracing/CubemapRenderTests.cs | 199 ++++++++++++++++++ .../PathTracing/CubemapRenderTests.cs.meta | 11 + .../Unity.PathTracing.Runtime.Tests.asmdef | 3 +- 4 files changed, 281 insertions(+), 26 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs create mode 100644 Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Environment/CubemapRender.cs b/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Environment/CubemapRender.cs index f465a3bceae..b7f09467e55 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Environment/CubemapRender.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Environment/CubemapRender.cs @@ -17,8 +17,8 @@ internal enum Mode Color } - private Material _material; - private Shader _lastUsedShader; + private Material _cubemapMaterial; + private Shader _lastUsedCubemapShader; private LocalKeyword? _noSunKeyword; private Color[] _faceColors = new Color[6] { @@ -73,7 +73,7 @@ public void Dispose() public void SetMaterial(Material mat) { - _material = mat; + _cubemapMaterial = mat; } public void SetColor(Color color) @@ -94,7 +94,7 @@ public void SetMode(Mode mode) _mode = mode; } - public Material GetMaterial() => _material; + public Material GetMaterial() => _cubemapMaterial; Color LightColorInRenderingSpace(Light light) { @@ -116,13 +116,21 @@ public void Update(CommandBuffer cmd, Light sun, int resolution, out bool viewAn } if (newHash != _hash) + { + _colorMaterial ??= CoreUtils.CreateEngineMaterial(_solidColorShader); +#if UNITY_EDITOR + // The editor skips procedural draws while the shader compiles async, so keep the old hash and retry next frame + if (RequestShaderCompilationIfNeeded(_colorMaterial, 1)) + return; +#endif RenderWithColor(cmd); + } } else if (_mode == Mode.Material) { - if (_material) + if (_cubemapMaterial) { - newHash = HashCode.Combine(newHash, _material.ComputeCRC()); + newHash = HashCode.Combine(newHash, _cubemapMaterial.ComputeCRC()); if (sun != null) { var color = LightColorInRenderingSpace(sun); @@ -132,7 +140,20 @@ public void Update(CommandBuffer cmd, Light sun, int resolution, out bool viewAn } if (newHash != _hash) + { + if (_lastUsedCubemapShader != _cubemapMaterial.shader) + { + var keyword = _cubemapMaterial.shader.keywordSpace.FindKeyword("_SUNDISK_NONE"); + _noSunKeyword = keyword.isValid ? keyword : null; + _lastUsedCubemapShader = _cubemapMaterial.shader; + } +#if UNITY_EDITOR + // Drawing while the shader compiles async would bake the placeholder shader into the cubemap + if (RequestCubemapMaterialCompilationIfNeeded(_cubemapMaterial, _noSunKeyword)) + return; +#endif RenderWithMaterial(cmd, sun, resolution, out viewAndProjectionMatricesChanged); + } } else { @@ -164,7 +185,9 @@ private void RenderWithColor(CommandBuffer cmd) // Draw the color rather than ClearRenderTarget it: on some platforms a fast clear // collapses a non-{0,1} HDR clear color to ~white, while a fullscreen draw is exact. - _colorMaterial ??= CoreUtils.CreateEngineMaterial(_solidColorShader); +#if UNITY_EDITOR + Debug.Assert(ShaderUtil.IsPassCompiled(_colorMaterial, 0) || !ShaderUtil.allowAsyncCompilation, "The solid color shader is expected to be compiled before drawing the environment cubemap."); +#endif _colorProperties ??= new MaterialPropertyBlock(); for (int faceIndex = 0; faceIndex < 6; ++faceIndex) @@ -192,15 +215,8 @@ private void RenderWithMaterial(CommandBuffer cmd, Light sun, int cubemapResolut properties.SetVector(Shader.PropertyToID("_WorldSpaceLightPos0"), new Vector4(0, 0, -1, 0)); } - if (_lastUsedShader != _material.shader) - { - var keyword = _material.shader.keywordSpace.FindKeyword("_SUNDISK_NONE"); - _noSunKeyword = keyword.isValid ? keyword : null; - _lastUsedShader = _material.shader; - } - if (_noSunKeyword.HasValue) - cmd.EnableKeyword(_material, _noSunKeyword.Value); + cmd.EnableKeyword(_cubemapMaterial, _noSunKeyword.Value); for (int faceIndex = 0; faceIndex < 6; ++faceIndex) { @@ -214,29 +230,57 @@ private void RenderWithMaterial(CommandBuffer cmd, Light sun, int cubemapResolut cmd.SetViewport(new Rect(0, 0, _cubemap.width, _cubemap.height)); cmd.ClearRenderTarget(false, true, new Color(0, 0, 0, 1)); -#if UNITY_EDITOR - ShaderUtil.SetAsyncCompilation(cmd, false); -#endif - if (_material.passCount == 6) + if (_cubemapMaterial.passCount == 6) { int passIndex = _cubeFaceToSkyboxPass[faceIndex]; - cmd.DrawMesh(_sixFaceSkyboxMesh, Matrix4x4.identity, _material, passIndex, passIndex, properties); + cmd.DrawMesh(_sixFaceSkyboxMesh, Matrix4x4.identity, _cubemapMaterial, passIndex, passIndex, properties); } else { - cmd.DrawMesh(_skyboxMesh, Matrix4x4.identity, _material, 0, 0, properties); + cmd.DrawMesh(_skyboxMesh, Matrix4x4.identity, _cubemapMaterial, 0, 0, properties); } -#if UNITY_EDITOR - ShaderUtil.RestoreAsyncCompilation(cmd); -#endif } viewAndProjectionMatricesChanged = true; if (_noSunKeyword.HasValue) - cmd.DisableKeyword(_material, _noSunKeyword.Value); + cmd.DisableKeyword(_cubemapMaterial, _noSunKeyword.Value); } +#if UNITY_EDITOR + // Requests compilation of the passes that are not compiled yet and returns whether any pass is still compiling + private static bool RequestShaderCompilationIfNeeded(Material material, int passCount) + { + if (!ShaderUtil.allowAsyncCompilation) + return false; + + bool compiling = false; + for (int passIndex = 0; passIndex < passCount; ++passIndex) + { + if (ShaderUtil.IsPassCompiled(material, passIndex)) + continue; + + ShaderUtil.CompilePass(material, passIndex); + compiling = true; + } + return compiling; + } + + private static bool RequestCubemapMaterialCompilationIfNeeded(Material cubemapMaterial, LocalKeyword? noSunKeyword) + { + // Check the variant the draw uses, which has the no-sun keyword enabled + bool toggleKeyword = noSunKeyword.HasValue && !cubemapMaterial.IsKeywordEnabled(noSunKeyword.Value); + if (toggleKeyword) + cubemapMaterial.SetKeyword(noSunKeyword.Value, true); + + bool compiling = RequestShaderCompilationIfNeeded(cubemapMaterial, cubemapMaterial.passCount == 6 ? 6 : 1); + + if (toggleKeyword) + cubemapMaterial.SetKeyword(noSunKeyword.Value, false); + return compiling; + } +#endif + private void EnsureCubemapExistsWithParticularResolution(int resolution) { if (_cubemap == null || _cubemap.width != resolution) diff --git a/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs new file mode 100644 index 00000000000..15740795106 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs @@ -0,0 +1,199 @@ +#if UNITY_EDITOR +using System; +using System.Collections; +using NUnit.Framework; +using UnityEditor; +using UnityEngine.PathTracing.Core; +using UnityEngine.Rendering; +using UnityEngine.TestTools; +#endif + +namespace UnityEngine.PathTracing.Tests +{ + // The shader sources stay outside the UNITY_EDITOR block. Player builds skip that block, and the compiler + // then reads the #if lines inside the shader strings as C# preprocessor directives + internal partial class CubemapRenderTests + { + // CreateUncompiledShader replaces UNIQUE_ID with a new GUID, so the shaders are never in the shader cache yet + const string k_SolidColorShaderSource = +@"Shader ""Hidden/Tests/CubemapRenderUncompiledSolidColor"" +{ + Properties { _Color (""Color"", Vector) = (0,0,0,0) } + SubShader + { + Pass + { + ZTest Always Cull Off ZWrite Off + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag + // UNIQUE_ID + float4 _Color; + float4 Vert(uint vertexID : SV_VertexID) : SV_POSITION + { + float2 uv = float2((vertexID << 1) & 2, vertexID & 2); + return float4(uv * 2.0 - 1.0, 0.0, 1.0); + } + float4 Frag() : SV_Target { return _Color; } + ENDHLSL + } + } + Fallback Off +}"; + + // Outputs magenta unless the no-sun keyword is enabled, like the draw does + const string k_CubemapMaterialShaderSource = +@"Shader ""Hidden/Tests/CubemapRenderUncompiledCubemapMaterial"" +{ + Properties { _Color (""Color"", Vector) = (0,0,0,0) } + SubShader + { + Pass + { + ZTest Always Cull Off ZWrite Off + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag + #pragma multi_compile_local __ _SUNDISK_NONE + // UNIQUE_ID + float4 _Color; + float4 Vert(float3 position : POSITION) : SV_POSITION { return float4(position.xy, 0.5, 1.0); } + float4 Frag() : SV_Target + { + #if defined(_SUNDISK_NONE) + return _Color; + #else + return float4(1.0, 0.0, 1.0, 1.0); + #endif + } + ENDHLSL + } + } + Fallback Off +}"; + } + +#if UNITY_EDITOR + internal partial class CubemapRenderTests + { + const float k_TimeoutSeconds = 60.0f; + const int k_CubemapMaterialResolution = 4; + + bool m_OldAsyncShaderCompilation; + bool m_OldAllowAsync; + Shader m_SolidColorShader; + Shader m_CubemapMaterialShader; + Material m_CubemapMaterial; + Mesh m_FullscreenMesh; + CubemapRender m_CubemapRender; + CommandBuffer m_Cmd; + + [SetUp] + public void SetUp() + { + m_OldAsyncShaderCompilation = EditorSettings.asyncShaderCompilation; + m_OldAllowAsync = ShaderUtil.allowAsyncCompilation; + EditorSettings.asyncShaderCompilation = true; + ShaderUtil.allowAsyncCompilation = true; + + m_SolidColorShader = CreateUncompiledShader(k_SolidColorShaderSource); + m_CubemapMaterialShader = CreateUncompiledShader(k_CubemapMaterialShaderSource); + m_CubemapMaterial = new Material(m_CubemapMaterialShader); + + m_FullscreenMesh = new Mesh + { + vertices = new[] { new Vector3(-1, -1, 0), new Vector3(3, -1, 0), new Vector3(-1, 3, 0) }, + triangles = new[] { 0, 1, 2 }, + bounds = new Bounds(Vector3.zero, Vector3.one * 1000.0f), + }; + + m_CubemapRender = new CubemapRender(m_FullscreenMesh, m_FullscreenMesh, m_SolidColorShader); + m_Cmd = new CommandBuffer { name = "CubemapRenderTests" }; + } + + [TearDown] + public void TearDown() + { + m_Cmd?.Release(); + m_CubemapRender?.Dispose(); + Object.DestroyImmediate(m_FullscreenMesh); + Object.DestroyImmediate(m_CubemapMaterial); + Object.DestroyImmediate(m_CubemapMaterialShader); + Object.DestroyImmediate(m_SolidColorShader); + ShaderUtil.allowAsyncCompilation = m_OldAllowAsync; + EditorSettings.asyncShaderCompilation = m_OldAsyncShaderCompilation; + } + + // A unique source guarantees the shader is not in the shader cache yet + static Shader CreateUncompiledShader(string source) + => ShaderUtil.CreateShaderAsset(source.Replace("UNIQUE_ID", Guid.NewGuid().ToString()), false); + + void UpdateCubemapRender(int resolution) + { + Assert.IsTrue(ShaderUtil.allowAsyncCompilation, "The test expects async shader compilation to be enabled."); + m_Cmd.Clear(); + m_CubemapRender.Update(m_Cmd, null, resolution, out _); + Graphics.ExecuteCommandBuffer(m_Cmd); + } + + IEnumerator UpdateUntilCubemapIsUpToDate(int resolution) + { + float startTime = Time.realtimeSinceStartup; + while (m_CubemapRender.Hash == 0) + { + if (Time.realtimeSinceStartup - startTime > k_TimeoutSeconds) + Assert.Fail($"The environment cubemap was not drawn within {k_TimeoutSeconds} seconds."); + + UpdateCubemapRender(resolution); + yield return null; + } + } + + void AssertCubemapEquals(Color expected) + { + var cubemap = m_CubemapRender.GetCubemap(); + var request = AsyncGPUReadback.Request(cubemap, 0, 0, 1, 0, 1, 0, 6); + request.WaitForCompletion(); + Assert.IsFalse(request.hasError, "Failed to read back the environment cubemap."); + + for (int face = 0; face < 6; ++face) + { + Color actual = request.GetData(face)[0]; + string message = $"Face {(CubemapFace)face} is {actual} but expected {expected}. The cubemap was marked up to date without being drawn correctly."; + Assert.AreEqual(expected.r, actual.r, 1e-4f, message); + Assert.AreEqual(expected.g, actual.g, 1e-4f, message); + Assert.AreEqual(expected.b, actual.b, 1e-4f, message); + } + } + + [UnityTest] + public IEnumerator ColorMode_WhenShaderIsCompilingAsync_CubemapIsOnlyMarkedUpToDateOnceDrawn() + { + var expected = new Color(0.8f, 0.3f, 0.1f, 1.0f); + m_CubemapRender.SetMode(CubemapRender.Mode.Color); + m_CubemapRender.SetColor(expected); + + yield return UpdateUntilCubemapIsUpToDate(1); + + AssertCubemapEquals(expected); + } + + [UnityTest] + public IEnumerator MaterialMode_WhenShaderIsCompilingAsync_DefersDrawInsteadOfCompilingSynchronously() + { + var expected = new Color(0.2f, 0.5f, 0.9f, 1.0f); + m_CubemapMaterial.SetVector("_Color", expected); + m_CubemapRender.SetMode(CubemapRender.Mode.Material); + m_CubemapRender.SetMaterial(m_CubemapMaterial); + + UpdateCubemapRender(k_CubemapMaterialResolution); + Assert.AreEqual(0, m_CubemapRender.Hash, "The first frame should defer the draw while the cubemap material shader compiles, not block on a synchronous compile."); + + yield return UpdateUntilCubemapIsUpToDate(k_CubemapMaterialResolution); + + AssertCubemapEquals(expected); + Assert.IsFalse(m_CubemapMaterial.IsKeywordEnabled("_SUNDISK_NONE"), "The no-sun keyword should not stay enabled on the cubemap material."); + } + } +#endif +} diff --git a/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs.meta b/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs.meta new file mode 100644 index 00000000000..51643ec65ae --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/CubemapRenderTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 78b60cedc8c24bb4a7706aee1f9437b0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/Unity.PathTracing.Runtime.Tests.asmdef b/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/Unity.PathTracing.Runtime.Tests.asmdef index 51201104881..42ab3518b21 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/Unity.PathTracing.Runtime.Tests.asmdef +++ b/Packages/com.unity.render-pipelines.core/Tests/Runtime/PathTracing/Unity.PathTracing.Runtime.Tests.asmdef @@ -5,7 +5,8 @@ "GUID:214c0945bb158c940aada223f3223ee8", "GUID:c49c619b6af2be941af9bcbca2641964", "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:df380645f10b7bc4b97d4f5eb6303d95" + "GUID:df380645f10b7bc4b97d4f5eb6303d95", + "GUID:27619889b8ba8c24980f49ee34dbb44a" ], "includePlatforms": [], "excludePlatforms": [], From dc4d8680595aa442fe3c6c898460d3b3aaad5aa4 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 2 Nov 2026 15:56:07 +0000 Subject: [PATCH 08/61] [Port] [6000.7] Bugfix: Account for exposure multiplier in Surface Cache patch allocation --- .../PatchAllocation.compute | 7 +++++++ .../SurfaceCacheGIRendererFeature.cs | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/PatchAllocation.compute b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/PatchAllocation.compute index c7cf2b811b6..2cb5325fd29 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/PatchAllocation.compute +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/PatchAllocation.compute @@ -1,6 +1,7 @@ #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal glcore ps5 switch2 #pragma kernel AllocateMono DISABLE_TEXTURE2D_X_ARRAY #pragma kernel AllocateSinglePassStereoInstancing +#pragma multi_compile _ _EXPOSURE #define PATCH_UTIL_USE_RW_PATCH_IRRADIANCE_BUFFER #define PATCH_UTIL_USE_RW_CELL_PATCH_INDEX_BUFFER @@ -12,7 +13,9 @@ #include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/VectorLogic.hlsl" #include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/IrradianceCompression.hlsl" #include "Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/PatchUtil.hlsl" +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ExposureFunctions.hlsl" +Texture2D _ExposureMultiplier; RWStructuredBuffer _RingConfigBuffer; RWStructuredBuffer _PatchGeometries; RWStructuredBuffer _PatchStatistics; @@ -188,7 +191,11 @@ void Allocate(uint2 lowResPixelPos) seedLowResPixelPos); if (PatchUtil::IsValid(irradianceSeed)) + { + // Screen irradiances are pre-exposed, patch irradiances are not. + SphericalHarmonics::MulMut(irradianceSeed, GetInvPreExposureMultiplier(_ExposureMultiplier)); patchUpdateCount = PatchUtil::updateMax / 2; + } } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs index 77db5aacc2c..f338b4589a4 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs @@ -508,6 +508,7 @@ private class PatchAllocationPassData internal TextureHandle LowResScreenIrradiancesL11; internal TextureHandle LowResScreenIrradiancesL12; internal TextureHandle LowResScreenNdcDepths; + internal TextureHandle ExposureMultiplier; internal GraphicsBuffer CellAllocationMarks; internal GraphicsBuffer CellPatchIndices; internal GraphicsBuffer RingConfigBuffer; @@ -787,6 +788,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer passData.LowResScreenIrradiancesL11 = lowResScreenIrradiancesL11Handle; passData.LowResScreenIrradiancesL12 = lowResScreenIrradiancesL12Handle; passData.LowResScreenNdcDepths = lowResScreenNdcDepthsHandle; + passData.ExposureMultiplier = resourceData.exposureMultiplier; passData.CellAllocationMarks = cache.Volume.CellAllocationMarks; passData.CellPatchIndices = cache.Volume.CellPatchIndices; passData.RingConfigBuffer = cache.RingConfig.Buffer; @@ -826,6 +828,10 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer builder.UseTexture(lowResScreenIrradiancesL11Handle, AccessFlags.Read); builder.UseTexture(lowResScreenIrradiancesL12Handle, AccessFlags.Read); builder.UseTexture(lowResScreenNdcDepthsHandle, AccessFlags.Read); + if (passData.ExposureMultiplier.IsValid()) + { + builder.UseTexture(passData.ExposureMultiplier, AccessFlags.Read); + } builder.SetRenderFunc((PatchAllocationPassData data, ComputeGraphContext cgContext) => AllocatePatches(data, cgContext)); } @@ -1088,6 +1094,10 @@ static void AllocatePatches(PatchAllocationPassData data, ComputeGraphContext cg cmd.SetComputeTextureParam(shader, kernelIndex, ShaderIDs._PreviousLowResScreenIrradiancesL11, data.LowResScreenIrradiancesL11); cmd.SetComputeTextureParam(shader, kernelIndex, ShaderIDs._PreviousLowResScreenIrradiancesL12, data.LowResScreenIrradiancesL12); cmd.SetComputeTextureParam(shader, kernelIndex, ShaderIDs._PreviousLowResScreenNdcDepths, data.LowResScreenNdcDepths); + if (data.ExposureMultiplier.IsValid()) + { + cmd.SetComputeTextureParam(shader, kernelIndex, ShaderIDs._ExposureMultiplier, data.ExposureMultiplier); + } cmd.SetComputeBufferParam(shader, kernelIndex, ShaderIDs._CellAllocationMarks, data.CellAllocationMarks); cmd.SetComputeBufferParam(shader, kernelIndex, ShaderIDs._CellPatchIndices, data.CellPatchIndices); cmd.SetComputeBufferParam(shader, kernelIndex, ShaderIDs._RingConfigBuffer, data.RingConfigBuffer); From 81bfdb6ed590044965d7f7863ce0fd933a5aab95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simone=20Livieri=20=EF=BC=88Livieri=20Simone=20-=20?= =?UTF-8?q?=E3=83=AA=E3=83=93=E3=82=A8=E3=83=AA=20=E3=82=B7=E3=83=A2?= =?UTF-8?q?=E3=83=8D=EF=BC=89?= Date: Mon, 2 Nov 2026 15:56:08 +0000 Subject: [PATCH 09/61] [Templates] Remove commit ids from changelogs --- .../Packages/com.unity.template.hd/CHANGELOG.md | 2 +- .../Packages/com.unity.template.hdrp-blank/CHANGELOG.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Templates/com.unity.template-hd/Packages/com.unity.template.hd/CHANGELOG.md b/Templates/com.unity.template-hd/Packages/com.unity.template.hd/CHANGELOG.md index d3d73239e12..203398beb7c 100644 --- a/Templates/com.unity.template-hd/Packages/com.unity.template.hd/CHANGELOG.md +++ b/Templates/com.unity.template-hd/Packages/com.unity.template.hd/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project template will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [16.3.1] - 2026-10-23 (0c0935c210c44) +## [16.3.1] - 2026-10-23 ### Changed - UUM-158364: fixed product name and bundle identifiers (Standalone, Android, iOS) diff --git a/Templates/com.unity.template.hdrp-blank/Packages/com.unity.template.hdrp-blank/CHANGELOG.md b/Templates/com.unity.template.hdrp-blank/Packages/com.unity.template.hdrp-blank/CHANGELOG.md index d4746a94362..2d5fd12582e 100644 --- a/Templates/com.unity.template.hdrp-blank/Packages/com.unity.template.hdrp-blank/CHANGELOG.md +++ b/Templates/com.unity.template.hdrp-blank/Packages/com.unity.template.hdrp-blank/CHANGELOG.md @@ -4,7 +4,7 @@ All notable changes to this project template will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [17.3.1] - 2026-10-23 (0c0935c210c44) +## [17.3.1] - 2026-10-23 ### Changed - UUM-158364: fixed product name and bundle identifiers (Standalone, Android, iOS) From bef3340e61f57ee5f3fce7cc3e98395747cf12d1 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 2 Nov 2026 15:56:08 +0000 Subject: [PATCH 10/61] [Port] [6000.7] Fix incorrect offset of probe occlusion in APV when L2 disabled and disk streaming enabled --- .../Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs index cb3362b4cd6..41587f2328f 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeScratchBufferPool.cs @@ -68,7 +68,7 @@ public ProbeVolumeScratchBufferPool(ProbeVolumeBakingSet bakingSet, ProbeVolumeS m_ValidityLayerCount = bakingSet.bakedMaskCount; m_SkyOcclusionSize = bakingSet.sharedSkyOcclusionL0L1ChunkSize; m_SkyShadingDirectionSize = bakingSet.sharedSkyShadingDirectionIndicesChunkSize; - m_L2Size = bakingSet.L2TextureChunkSize; + m_L2Size = shBands == ProbeVolumeSHBands.SphericalHarmonicsL2 ? bakingSet.L2TextureChunkSize : 0; m_ProbeOcclusionSize = bakingSet.ProbeOcclusionChunkSize; } From cc1afaff6e9ef7d4137bcdee8da053e76b3c78b3 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 2 Nov 2026 22:01:47 +0000 Subject: [PATCH 11/61] [Port] [6000.7] [UUM-159132] [URP] Fix CPU light clustering for degenerate light setups --- .../Runtime/ForwardLights.cs | 4 +- .../Runtime/Tiling/LightMinMaxZJob.cs | 4 +- .../Tiling/ReflectionProbeMinMaxZJob.cs | 4 + .../Runtime/Tiling/TilingJob.cs | 760 +++++++++--------- .../Runtime/Tiling/ZBinningJob.cs | 2 + .../Tests/Runtime/LightClusteringOracle.cs | 756 +++++++++++++++++ .../Runtime/LightClusteringOracle.cs.meta | 2 + .../Tests/Runtime/LightClusteringTests.cs | 714 ++++------------ 8 files changed, 1281 insertions(+), 965 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs b/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs index 055d432d37b..daef12f2a94 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs @@ -404,7 +404,8 @@ out int wordsPerTile worldToViews = worldToViews, reflectionProbes = probes, reflectionProbeRotation = reflectionProbeRotation, - minMaxZs = minMaxZs.GetSubArray(localLightCount * viewCount, reflectionProbeCount * viewCount) + minMaxZs = minMaxZs.GetSubArray(localLightCount * viewCount, reflectionProbeCount * viewCount), + near = nearClipPlane }; var reflectionProbeMinMaxZHandle = reflectionProbeMinMaxZJob.ScheduleParallel(reflectionProbeCount * viewCount, 32, lightMinMaxZHandle); @@ -448,6 +449,7 @@ out int wordsPerTile viewToViewportScaleBiases = new Fixed2(viewToViewportScaleBias0, viewToViewportScaleBias1), tileCount = tileResolution, near = nearClipPlane, + far = farClipPlane, isOrthographic = isOrthographic }; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/LightMinMaxZJob.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/LightMinMaxZJob.cs index 513751ea59a..b6e1e644e37 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/LightMinMaxZJob.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/LightMinMaxZJob.cs @@ -58,9 +58,9 @@ public void Execute(int index) minMax.y = float.MinValue; } - // Clamp to near, not 0: an orthographic near plane can be negative. + // Clamp to near, not 0: an orthographic near plane can be negative. A light entirely closer than the near + // plane keeps max < min, which ZBinningJob treats as empty. minMax.x = math.max(minMax.x, near); - minMax.y = math.max(minMax.y, near); minMaxZs[index] = minMax; } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ReflectionProbeMinMaxZJob.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ReflectionProbeMinMaxZJob.cs index 30aaaf490de..a7cc93726ea 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ReflectionProbeMinMaxZJob.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ReflectionProbeMinMaxZJob.cs @@ -16,6 +16,8 @@ struct ReflectionProbeMinMaxZJob : IJobFor public bool reflectionProbeRotation; public NativeArray minMaxZs; + public float near; + public void Execute(int index) { var minMax = math.float2(float.MaxValue, float.MinValue); @@ -45,6 +47,8 @@ public void Execute(int index) minMax.y = math.max(minMax.y, cornerVS.z); } + // As in LightMinMaxZJob: a probe entirely closer than the near plane keeps max < min. + minMax.x = math.max(minMax.x, near); minMaxZs[index] = minMax; } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/TilingJob.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/TilingJob.cs index 86ded9b3cfe..05773bb64eb 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/TilingJob.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/TilingJob.cs @@ -32,6 +32,7 @@ struct TilingJob : IJobFor public Fixed2 viewToViewportScaleBiases; public int2 tileCount; public float near; + public float far; public bool isOrthographic; InclusiveRange m_TileYRange; @@ -75,7 +76,7 @@ void TileLight(int lightIndex) var lightToWorld = (float4x4)light.localToWorldMatrix; var lightPositionVS = math.mul(worldToViews[m_ViewIndex], math.float4(lightToWorld.c3.xyz, 1)).xyz; lightPositionVS.z *= -1; - if (lightPositionVS.z >= near) ExpandY(lightPositionVS); + if (IsInDepthRange(lightPositionVS)) ExpandY(lightPositionVS); var lightDirectionVS = math.normalize(math.mul(worldToViews[m_ViewIndex], math.float4(lightToWorld.c2.xyz, 0)).xyz); lightDirectionVS.z *= -1; @@ -84,39 +85,25 @@ void TileLight(int lightIndex) var rangesq = square(range); var cosHalfAngle = math.cos(halfAngle); var coneHeight = cosHalfAngle * range; - - // Radius of circle formed by intersection of sphere and near plane. - // Found using Pythagoras with a right triangle formed by three points: - // (a) light position - // (b) light position projected to near plane - // (c) a point on the near plane at a distance `range` from the light position - // (i.e. lies both on the sphere and the near plane) - // Thus the hypotenuse is formed by (a) and (c) with length `range`, and the known side is formed - // by (a) and (b) with length equal to the distance between the near plane and the light position. - // The remaining unknown side is formed by (b) and (c) with length equal to the radius of the circle. - // m_ClipCircleRadius = sqrt(sq(light.range) - sq(m_Near - m_LightPosition.z)); - var sphereClipRadius = math.sqrt(rangesq - square(near - lightPositionVS.z)); - - // Assumes a point on the sphere, i.e. at distance `range` from the light position. - // If spot light, we check the angle between the direction vector from the light position and the light direction vector. - // Note that division by range is to normalize the vector, as we know that the resulting vector will have length `range`. - bool SpherePointIsValid(float3 p) => light.lightType == LightType.Point || - math.dot(math.normalize(p - lightPositionVS), lightDirectionVS) >= cosHalfAngle; - - // Project light sphere onto YZ plane, find the horizon points, and re-construct view space position of found points. - // CalculateSphereYBounds(lightPositionVS, range, near, sphereClipRadius, out var sphereBoundY0, out var sphereBoundY1); - GetSphereHorizon(lightPositionVS.yz, range, near, sphereClipRadius, out var sphereBoundYZ0, out var sphereBoundYZ1); - var sphereBoundY0 = math.float3(lightPositionVS.x, sphereBoundYZ0); - var sphereBoundY1 = math.float3(lightPositionVS.x, sphereBoundYZ1); - if (SpherePointIsValid(sphereBoundY0)) ExpandY(sphereBoundY0); - if (SpherePointIsValid(sphereBoundY1)) ExpandY(sphereBoundY1); - - // Project light sphere onto XZ plane, find the horizon points, and re-construct view space position of found points. - GetSphereHorizon(lightPositionVS.xz, range, near, sphereClipRadius, out var sphereBoundXZ0, out var sphereBoundXZ1); - var sphereBoundX0 = math.float3(sphereBoundXZ0.x, lightPositionVS.y, sphereBoundXZ0.y); - var sphereBoundX1 = math.float3(sphereBoundXZ1.x, lightPositionVS.y, sphereBoundXZ1.y); - if (SpherePointIsValid(sphereBoundX0)) ExpandY(sphereBoundX0); - if (SpherePointIsValid(sphereBoundX1)) ExpandY(sphereBoundX1); + var isSpot = light.lightType == LightType.Spot; + + // Outline of the sphere projected onto the YZ and XZ planes: the horizon as seen from the camera, and the + // extremes of the circles cut by the near and far planes. Missing points are NaN. + GetCircleHorizon(lightPositionVS.yz, range, out var horizonY0, out var horizonY1); + GetCircleHorizon(lightPositionVS.xz, range, out var horizonX0, out var horizonX1); + ExpandYIfInSphereCap(math.float3(lightPositionVS.x, horizonY0), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandYIfInSphereCap(math.float3(lightPositionVS.x, horizonY1), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandYIfInSphereCap(math.float3(horizonX0.x, lightPositionVS.y, horizonX0.y), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandYIfInSphereCap(math.float3(horizonX1.x, lightPositionVS.y, horizonX1.y), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + for (var i = 0; i < 2; i++) + { + var depth = i == 0 ? near : far; + var sectionRadius = math.sqrt(rangesq - square(depth - lightPositionVS.z)); + ExpandYIfInSphereCap(math.float3(lightPositionVS.x, lightPositionVS.y - sectionRadius, depth), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandYIfInSphereCap(math.float3(lightPositionVS.x, lightPositionVS.y + sectionRadius, depth), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandYIfInSphereCap(math.float3(lightPositionVS.x - sectionRadius, lightPositionVS.y, depth), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandYIfInSphereCap(math.float3(lightPositionVS.x + sectionRadius, lightPositionVS.y, depth), lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + } if (light.lightType == LightType.Spot) { @@ -137,8 +124,8 @@ bool SpherePointIsValid(float3 p) => light.lightType == LightType.Point || GetProjectedCircleHorizon(baseCenter.yz, baseRadius, baseUY.yz, baseVY.yz, out var baseY1UV, out var baseY2UV); var baseY1 = baseCenter + baseY1UV.x * baseUY + baseY1UV.y * baseVY; var baseY2 = baseCenter + baseY2UV.x * baseUY + baseY2UV.y * baseVY; - if (baseY1.z >= near) ExpandY(baseY1); - if (baseY2.z >= near) ExpandY(baseY2); + if (IsInDepthRange(baseY1)) ExpandY(baseY1); + if (IsInDepthRange(baseY2)) ExpandY(baseY2); // Project cone base into the XZ plane, find the horizon points, and re-construct view space position of found points. // See comment for YZ plane for details. @@ -147,66 +134,62 @@ bool SpherePointIsValid(float3 p) => light.lightType == LightType.Point || GetProjectedCircleHorizon(baseCenter.xz, baseRadius, baseUX.xz, baseVX.xz, out var baseX1UV, out var baseX2UV); var baseX1 = baseCenter + baseX1UV.x * baseUX + baseX1UV.y * baseVX; var baseX2 = baseCenter + baseX2UV.x * baseUX + baseX2UV.y * baseVX; - if (baseX1.z >= near) ExpandY(baseX1); - if (baseX2.z >= near) ExpandY(baseX2); + if (IsInDepthRange(baseX1)) ExpandY(baseX1); + if (IsInDepthRange(baseX2)) ExpandY(baseX2); - // Handle base circle clipping by intersecting it with the near-plane if needed. + // Handle base circle clipping by intersecting it with the near and far planes if needed. if (GetCircleClipPoints(baseCenter, lightDirectionVS, baseRadius, near, out var baseClip0, out var baseClip1)) { ExpandY(baseClip0); ExpandY(baseClip1); } + if (GetCircleClipPoints(baseCenter, lightDirectionVS, baseRadius, far, out var baseFarClip0, out var baseFarClip1)) + { + ExpandY(baseFarClip0); + ExpandY(baseFarClip1); + } - bool ConicPointIsValid(float3 p) => - math.dot(math.normalize(p - lightPositionVS), lightDirectionVS) >= 0 && - math.dot(p - lightPositionVS, lightDirectionVS) <= coneHeight; + var sinHalfAngle = math.sin(halfAngle); + var coneDistanceTolerance = 1e-5f * (math.length(lightPositionVS) + range); + bool ConicPointIsValid(float3 p) => IsOnCone(p, lightPositionVS, lightDirectionVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance); - // Calculate Z bounds of cone and check if it's overlapping with the near plane. + // Calculate Z bounds of cone and check if it's overlapping with the near and far planes. // From https://www.iquilezles.org/www/articles/diskbbox/diskbbox.htm - var baseExtentZ = baseRadius * math.sqrt(1.0f - square(lightDirectionVS.z)); - var coneIsClipping = near >= math.min(baseCenter.z - baseExtentZ, lightPositionVS.z) && near <= math.max(baseCenter.z + baseExtentZ, lightPositionVS.z); - - var coneU = math.cross(lightDirectionVS, lightPositionVS); - // The cross product will be the 0-vector if the light-direction and camera-to-light-position vectors are parallel. - // In that case, {1, 0, 0} is orthogonal to the light direction and we use that instead. - coneU = math.csum(coneU) != 0f ? math.normalize(coneU) : math.float3(1, 0, 0); + var baseExtentZ = baseRadius * math.sqrt(math.saturate(1.0f - square(lightDirectionVS.z))); + var coneMinZ = math.min(baseCenter.z - baseExtentZ, lightPositionVS.z); + var coneMaxZ = math.max(baseCenter.z + baseExtentZ, lightPositionVS.z); + var coneIsClipping = near >= coneMinZ && near <= coneMaxZ; + var coneCrossesFar = far >= coneMinZ && far <= coneMaxZ; + + // Any frame orthogonal to the axis works; cross with the view axis least aligned with it to keep it well conditioned. + var coneU = math.normalize(math.cross(lightDirectionVS, math.abs(lightDirectionVS.x) < 0.5f ? math.float3(1, 0, 0) : math.float3(0, 1, 0))); var coneV = math.cross(lightDirectionVS, coneU); - if (coneIsClipping) + var nearSection = new ConeSection(near, lightPositionVS, lightDirectionVS, cosHalfAngle, sinHalfAngle); + var farSection = new ConeSection(far, lightPositionVS, lightDirectionVS, cosHalfAngle, sinHalfAngle); + for (var i = 0; i < 2; i++) { - var r = baseRadius / coneHeight; - - // Find the Y bounds of the near-plane cone intersection, i.e. where y' = 0 - var thetaY = FindNearConicTangentTheta(lightPositionVS.yz, lightDirectionVS.yz, r, coneU.yz, coneV.yz); - var p0Y = EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, thetaY.x); - var p1Y = EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, thetaY.y); + if (i == 0 ? !coneIsClipping : !coneCrossesFar) + continue; + var section = i == 0 ? nearSection : farSection; + section.GetYExtremes(out var p0Y, out var p1Y); if (ConicPointIsValid(p0Y)) ExpandY(p0Y); if (ConicPointIsValid(p1Y)) ExpandY(p1Y); - // Find the X bounds of the near-plane cone intersection, i.e. where x' = 0 - var thetaX = FindNearConicTangentTheta(lightPositionVS.xz, lightDirectionVS.xz, r, coneU.xz, coneV.xz); - var p0X = EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, thetaX.x); - var p1X = EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, thetaX.y); + section.GetXExtremes(out var p0X, out var p1X); if (ConicPointIsValid(p0X)) ExpandY(p0X); if (ConicPointIsValid(p1X)) ExpandY(p1X); } // Calculate the lines making up the sides of the cone as seen from the camera. `l1` and `l2` form lines // from the light position. - GetConeSideTangentPoints(lightPositionVS, lightDirectionVS, cosHalfAngle, baseRadius, coneHeight, range, coneU, coneV, out var l1, out var l2); + GetConeSideTangentPoints(-lightPositionVS, lightDirectionVS, cosHalfAngle, baseRadius, coneHeight, range, coneU, coneV, out var l1, out var l2); - { - var planeNormal = math.float3(0, 1, viewPlaneBottoms[m_ViewIndex]); - var l1t = math.dot(-lightPositionVS, planeNormal) / math.dot(l1, planeNormal); - var l1x = lightPositionVS + l1 * l1t; - if (l1t >= 0 && l1t <= 1 && l1x.z >= near) ExpandY(l1x); - } - { - var planeNormal = math.float3(0, 1, viewPlaneTops[m_ViewIndex]); - var l1t = math.dot(-lightPositionVS, planeNormal) / math.dot(l1, planeNormal); - var l1x = lightPositionVS + l1 * l1t; - if (l1t >= 0 && l1t <= 1 && l1x.z >= near) ExpandY(l1x); - } + // Where the cone sides cross the bottom and top of the screen. + ExpandYAtViewPlane(lightPositionVS, l1, viewPlaneBottoms[m_ViewIndex]); + ExpandYAtViewPlane(lightPositionVS, l1, viewPlaneTops[m_ViewIndex]); + ExpandYAtViewPlane(lightPositionVS, l2, viewPlaneBottoms[m_ViewIndex]); + ExpandYAtViewPlane(lightPositionVS, l2, viewPlaneTops[m_ViewIndex]); m_TileYRange.Clamp(0, (short)(tileCount.y - 1)); @@ -223,25 +206,28 @@ bool ConicPointIsValid(float3 p) => // Intersect lines with y-plane and clip if needed. var l1t = math.dot(-lightPositionVS, planeNormal) / math.dot(l1, planeNormal); var l1x = lightPositionVS + l1 * l1t; - if (l1t >= 0 && l1t <= 1 && l1x.z >= near) ExpandTileX(ref planeRange, ViewToTileSpace(l1x).x); + if (l1t >= 0 && l1t <= 1 && IsInDepthRange(l1x)) ExpandTileX(ref planeRange, ViewToTileSpace(l1x).x); var l2t = math.dot(-lightPositionVS, planeNormal) / math.dot(l2, planeNormal); var l2x = lightPositionVS + l2 * l2t; - if (l2t >= 0 && l2t <= 1 && l2x.z >= near) ExpandTileX(ref planeRange, ViewToTileSpace(l2x).x); + if (l2t >= 0 && l2t <= 1 && IsInDepthRange(l2x)) ExpandTileX(ref planeRange, ViewToTileSpace(l2x).x); - if (IntersectCircleYPlane(planeY, baseCenter, lightDirectionVS, baseUY, baseVY, baseRadius, out var circleTile0, out var circleTile1)) + if (IntersectCirclePlane(math.float4(0, 1, -planeY, 0), baseCenter, baseUY, baseVY, baseRadius, out var circleTile0, out var circleTile1)) { - if (circleTile0.z >= near) ExpandTileX(ref planeRange, ViewToTileSpace(circleTile0).x); - if (circleTile1.z >= near) ExpandTileX(ref planeRange, ViewToTileSpace(circleTile1).x); + if (IsInDepthRange(circleTile0)) ExpandTileX(ref planeRange, ViewToTileSpace(circleTile0).x); + if (IsInDepthRange(circleTile1)) ExpandTileX(ref planeRange, ViewToTileSpace(circleTile1).x); } if (coneIsClipping) { - var y = planeY * near; - var r = baseRadius / coneHeight; - var theta = FindNearConicYTheta(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, y); - var p0 = math.float3(EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, theta.x).x, y, near); - var p1 = math.float3(EvaluateNearConic(near, lightPositionVS, lightDirectionVS, r, coneU, coneV, theta.y).x, y, near); + nearSection.IntersectRow(planeY * near, out var p0, out var p1); + if (ConicPointIsValid(p0)) ExpandTileX(ref planeRange, ViewToTileSpace(p0).x); + if (ConicPointIsValid(p1)) ExpandTileX(ref planeRange, ViewToTileSpace(p1).x); + } + + if (coneCrossesFar) + { + farSection.IntersectRow(planeY * far, out var p0, out var p1); if (ConicPointIsValid(p0)) ExpandTileX(ref planeRange, ViewToTileSpace(p0).x); if (ConicPointIsValid(p1)) ExpandTileX(ref planeRange, ViewToTileSpace(p1).x); } @@ -258,9 +244,15 @@ bool ConicPointIsValid(float3 p) => var planeRange = InclusiveRange.empty; var planeY = math.lerp(viewPlaneBottoms[m_ViewIndex], viewPlaneTops[m_ViewIndex], planeIndex * tileScaleInv.y); - GetSphereYPlaneHorizon(lightPositionVS, range, near, sphereClipRadius, planeY, out var sphereTile0, out var sphereTile1); - if (SpherePointIsValid(sphereTile0)) ExpandTileX(ref planeRange, ViewToTileSpace(sphereTile0).x); - if (SpherePointIsValid(sphereTile1)) ExpandTileX(ref planeRange, ViewToTileSpace(sphereTile1).x); + GetSphereYPlaneHorizon(lightPositionVS, range, planeY, out var sphereTile0, out var sphereTile1); + ExpandTileXIfInSphereCap(ref planeRange, sphereTile0, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandTileXIfInSphereCap(ref planeRange, sphereTile1, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + for (var i = 0; i < 2; i++) + { + GetSphereSectionRowPoints(lightPositionVS, rangesq, i == 0 ? near : far, planeY, out var section0, out var section1); + ExpandTileXIfInSphereCap(ref planeRange, section0, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + ExpandTileXIfInSphereCap(ref planeRange, section1, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot); + } MergeTileRangeRows(planeIndex, planeRange); } @@ -271,110 +263,130 @@ bool ConicPointIsValid(float3 p) => void TileLightOrthographic(int lightIndex) { var light = lights[lightIndex]; + if (light.lightType != LightType.Point && light.lightType != LightType.Spot) + { + return; + } + var lightToWorld = (float4x4)light.localToWorldMatrix; var lightPosVS = math.mul(worldToViews[m_ViewIndex], math.float4(lightToWorld.c3.xyz, 1)).xyz; lightPosVS.z *= -1; - ExpandOrthographic(lightPosVS); + if (IsInDepthRange(lightPosVS)) ExpandOrthographic(lightPosVS); var lightDirVS = math.mul(worldToViews[m_ViewIndex], math.float4(lightToWorld.c2.xyz, 0)).xyz; lightDirVS.z *= -1; lightDirVS = math.normalize(lightDirVS); + var isSpot = light.lightType == LightType.Spot; var halfAngle = math.radians(light.spotAngle * 0.5f); var range = light.range; var rangeSq = square(range); var cosHalfAngle = math.cos(halfAngle); + var sinHalfAngle = math.sin(halfAngle); var coneHeight = cosHalfAngle * range; - var coneHeightSq = square(coneHeight); - var coneHeightInv = 1f / coneHeight; - var coneHeightInvSq = square(coneHeightInv); - bool SpherePointIsValid(float3 p) => light.lightType == LightType.Point || - math.dot(math.normalize(p - lightPosVS), lightDirVS) >= cosHalfAngle; - - var sphereBoundY0 = lightPosVS - math.float3(0, range, 0); - var sphereBoundY1 = lightPosVS + math.float3(0, range, 0); - var sphereBoundX0 = lightPosVS - math.float3(range, 0, 0); - var sphereBoundX1 = lightPosVS + math.float3(range, 0, 0); - - if (SpherePointIsValid(sphereBoundY0)) ExpandOrthographic(sphereBoundY0); - if (SpherePointIsValid(sphereBoundY1)) ExpandOrthographic(sphereBoundY1); - if (SpherePointIsValid(sphereBoundX0)) ExpandOrthographic(sphereBoundX0); - if (SpherePointIsValid(sphereBoundX1)) ExpandOrthographic(sphereBoundX1); + // The outline of the sphere is its equator facing the camera, clipped to the depth range, and the circles cut by + // the near and far planes. + var sphereOutline = math.bool3(IsInDepthRange(lightPosVS), math.abs(near - lightPosVS.z) <= range, math.abs(far - lightPosVS.z) <= range); + for (var i = 0; i < 3; i++) + { + if (!sphereOutline[i]) + continue; + var depth = i == 0 ? lightPosVS.z : i == 1 ? near : far; + var radius = math.sqrt(rangeSq - square(depth - lightPosVS.z)); + ExpandOrthographicIfInSphereCap(math.float3(lightPosVS.x - radius, lightPosVS.y, depth), lightPosVS, lightDirVS, cosHalfAngle, isSpot); + ExpandOrthographicIfInSphereCap(math.float3(lightPosVS.x + radius, lightPosVS.y, depth), lightPosVS, lightDirVS, cosHalfAngle, isSpot); + ExpandOrthographicIfInSphereCap(math.float3(lightPosVS.x, lightPosVS.y - radius, depth), lightPosVS, lightDirVS, cosHalfAngle, isSpot); + ExpandOrthographicIfInSphereCap(math.float3(lightPosVS.x, lightPosVS.y + radius, depth), lightPosVS, lightDirVS, cosHalfAngle, isSpot); + } var circleCenter = lightPosVS + lightDirVS * coneHeight; - var circleRadius = math.sqrt(rangeSq - coneHeightSq); - var circleRadiusSq = square(circleRadius); - var circleUp = math.normalize(math.float3(0, 1, 0) - lightDirVS * lightDirVS.y); - var circleRight = math.normalize(math.float3(1, 0, 0) - lightDirVS * lightDirVS.x); - var circleBoundY0 = circleCenter - circleUp * circleRadius; - var circleBoundY1 = circleCenter + circleUp * circleRadius; - - if (light.lightType == LightType.Spot) + var circleRadius = range * sinHalfAngle; + var coneU = math.normalize(math.cross(lightDirVS, math.abs(lightDirVS.x) < 0.5f ? math.float3(1, 0, 0) : math.float3(0, 1, 0))); + var coneV = math.cross(lightDirVS, coneU); + var nearSection = new ConeSection(near, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle); + var farSection = new ConeSection(far, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle); + var circleExtentZ = circleRadius * math.sqrt(math.saturate(1.0f - square(lightDirVS.z))); + var coneMinZ = math.min(circleCenter.z - circleExtentZ, lightPosVS.z); + var coneMaxZ = math.max(circleCenter.z + circleExtentZ, lightPosVS.z); + var coneCrosses = math.bool2(near >= coneMinZ && near <= coneMaxZ, far >= coneMinZ && far <= coneMaxZ); + float3 l1 = 0, l2 = 0; + var coneDistanceTolerance = 1e-5f * (math.length(lightPosVS) + range); + + if (isSpot) { - var circleBoundX0 = circleCenter - circleRight * circleRadius; - var circleBoundX1 = circleCenter + circleRight * circleRadius; - ExpandOrthographic(circleBoundY0); - ExpandOrthographic(circleBoundY1); - ExpandOrthographic(circleBoundX0); - ExpandOrthographic(circleBoundX1); - } + // Extremes of the cone base circle, and its points on the near and far planes. + var circleUp = math.normalize(math.float3(0, 1, 0) - lightDirVS * lightDirVS.y) * circleRadius; + var circleRight = math.normalize(math.float3(1, 0, 0) - lightDirVS * lightDirVS.x) * circleRadius; + ExpandOrthographicIfInDepthRange(circleCenter - circleUp); + ExpandOrthographicIfInDepthRange(circleCenter + circleUp); + ExpandOrthographicIfInDepthRange(circleCenter - circleRight); + ExpandOrthographicIfInDepthRange(circleCenter + circleRight); + for (var i = 0; i < 2; i++) + { + if (GetCircleClipPoints(circleCenter, lightDirVS, circleRadius, i == 0 ? near : far, out var clip0, out var clip1)) + { + ExpandOrthographic(clip0); + ExpandOrthographic(clip1); + } + } - m_TileYRange.Clamp(0, (short)(tileCount.y - 1)); + // Extremes of the cone sections with the near and far planes. + for (var i = 0; i < 2; i++) + { + if (!coneCrosses[i]) + continue; + var section = i == 0 ? nearSection : farSection; + section.GetYExtremes(out var p0Y, out var p1Y); + section.GetXExtremes(out var p0X, out var p1X); + if (IsOnCone(p0Y, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance)) ExpandOrthographic(p0Y); + if (IsOnCone(p1Y, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance)) ExpandOrthographic(p1Y); + if (IsOnCone(p0X, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance)) ExpandOrthographic(p0X); + if (IsOnCone(p1X, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance)) ExpandOrthographic(p1X); + } - // Find two lines in screen-space for the cone if the light is a spot. - float coneDir0X = 0, coneDir0YInv = 0, coneDir1X = 0, coneDir1YInv = 0; - if (light.lightType == LightType.Spot) - { - // Distance from light position to and radius of sphere fitted to the end of the cone. - var sphereDistance = coneHeight + circleRadiusSq * coneHeightInv; - var sphereRadius = math.sqrt(square(circleRadiusSq) * coneHeightInvSq + circleRadiusSq); - var directionXYSqInv = math.rcp(math.lengthsq(lightDirVS.xy)); - var polarIntersection = -circleRadiusSq * coneHeightInv * directionXYSqInv * lightDirVS.xy; - var polarDir = math.sqrt((square(sphereRadius) - math.lengthsq(polarIntersection)) * directionXYSqInv) * math.float2(lightDirVS.y, -lightDirVS.x); - var conePBase = lightPosVS.xy + sphereDistance * lightDirVS.xy + polarIntersection; - var coneP0 = conePBase - polarDir; - var coneP1 = conePBase + polarDir; - - coneDir0X = coneP0.x - lightPosVS.x; - coneDir0YInv = math.rcp(coneP0.y - lightPosVS.y); - coneDir1X = coneP1.x - lightPosVS.x; - coneDir1YInv = math.rcp(coneP1.y - lightPosVS.y); + // Silhouette lines of the cone as seen along the view direction. + GetConeSideTangentPoints(math.float3(0, 0, -1), lightDirVS, cosHalfAngle, circleRadius, coneHeight, range, coneU, coneV, out l1, out l2); } - // Tile plane ranges + m_TileYRange.Clamp(0, (short)(tileCount.y - 1)); + + // Tile plane ranges; the rows are the planes y = planeY. for (var planeIndex = m_TileYRange.start; planeIndex <= m_TileYRange.end + 1; planeIndex++) { var planeRange = InclusiveRange.empty; - - // Sphere var planeY = math.lerp(viewPlaneBottoms[m_ViewIndex], viewPlaneTops[m_ViewIndex], planeIndex * tileScaleInv.y); - var sphereX = math.sqrt(rangeSq - square(planeY - lightPosVS.y)); - var sphereX0 = math.float3(lightPosVS.x - sphereX, planeY, lightPosVS.z); - var sphereX1 = math.float3(lightPosVS.x + sphereX, planeY, lightPosVS.z); - if (SpherePointIsValid(sphereX0)) { ExpandRangeOrthographic(ref planeRange, sphereX0.x); } - if (SpherePointIsValid(sphereX1)) { ExpandRangeOrthographic(ref planeRange, sphereX1.x); } - if (light.lightType == LightType.Spot) + for (var i = 0; i < 3; i++) + { + if (!sphereOutline[i]) + continue; + var depth = i == 0 ? lightPosVS.z : i == 1 ? near : far; + var halfWidth = math.sqrt(rangeSq - square(depth - lightPosVS.z) - square(planeY - lightPosVS.y)); + ExpandRangeOrthographicIfInSphereCap(ref planeRange, math.float3(lightPosVS.x - halfWidth, planeY, depth), lightPosVS, lightDirVS, cosHalfAngle, isSpot); + ExpandRangeOrthographicIfInSphereCap(ref planeRange, math.float3(lightPosVS.x + halfWidth, planeY, depth), lightPosVS, lightDirVS, cosHalfAngle, isSpot); + } + + if (isSpot) { - // Circle - if (planeY >= circleBoundY0.y && planeY <= circleBoundY1.y) + if (IntersectCirclePlane(math.float4(0, 1, 0, -planeY), circleCenter, coneU, coneV, circleRadius, out var circle0, out var circle1)) { - var intersectionDistance = (planeY - circleCenter.y) / circleUp.y; - var closestPointX = circleCenter.x + intersectionDistance * circleUp.x; - var intersectionDirX = -lightDirVS.z / math.length(math.float3(-lightDirVS.z, 0, lightDirVS.x)); - var sideDistance = math.sqrt(square(circleRadius) - square(intersectionDistance)); - var circleX0 = closestPointX - sideDistance * intersectionDirX; - var circleX1 = closestPointX + sideDistance * intersectionDirX; - ExpandRangeOrthographic(ref planeRange, circleX0); - ExpandRangeOrthographic(ref planeRange, circleX1); + if (IsInDepthRange(circle0)) ExpandRangeOrthographic(ref planeRange, circle0.x); + if (IsInDepthRange(circle1)) ExpandRangeOrthographic(ref planeRange, circle1.x); } - // Cone - var deltaY = planeY - lightPosVS.y; - var coneT0 = deltaY * coneDir0YInv; - var coneT1 = deltaY * coneDir1YInv; - if (coneT0 >= 0 && coneT0 <= 1) { ExpandRangeOrthographic(ref planeRange, lightPosVS.x + coneT0 * coneDir0X); } - if (coneT1 >= 0 && coneT1 <= 1) { ExpandRangeOrthographic(ref planeRange, lightPosVS.x + coneT1 * coneDir1X); } + var line0 = lightPosVS + l1 * ((planeY - lightPosVS.y) / l1.y); + var line1 = lightPosVS + l2 * ((planeY - lightPosVS.y) / l2.y); + if (IsOnSegment(line0, lightPosVS, l1)) ExpandRangeOrthographic(ref planeRange, line0.x); + if (IsOnSegment(line1, lightPosVS, l2)) ExpandRangeOrthographic(ref planeRange, line1.x); + + for (var i = 0; i < 2; i++) + { + if (!coneCrosses[i]) + continue; + (i == 0 ? nearSection : farSection).IntersectRow(planeY, out var p0, out var p1); + if (IsOnCone(p0, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance)) ExpandRangeOrthographic(ref planeRange, p0.x); + if (IsOnCone(p1, lightPosVS, lightDirVS, cosHalfAngle, sinHalfAngle, coneHeight, coneDistanceTolerance)) ExpandRangeOrthographic(ref planeRange, p1.x); + } } MergeTileRangeRows(planeIndex, planeRange); @@ -383,6 +395,28 @@ bool SpherePointIsValid(float3 p) => light.lightType == LightType.Point || tileRanges[m_Offset] = m_TileYRange; } + // Whether p = origin + t * line lies on the segment (t in [0, 1]) and in the depth range. + bool IsOnSegment(float3 p, float3 origin, float3 line) + { + var t = math.dot(p - origin, line) / math.lengthsq(line); + return t >= 0 && t <= 1 && IsInDepthRange(p); + } + + void ExpandOrthographicIfInDepthRange(float3 positionVS) + { + if (IsInDepthRange(positionVS)) ExpandOrthographic(positionVS); + } + + void ExpandOrthographicIfInSphereCap(float3 positionVS, float3 lightPositionVS, float3 lightDirectionVS, float cosHalfAngle, bool isSpot) + { + if (IsInSphereCap(positionVS, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot)) ExpandOrthographic(positionVS); + } + + void ExpandRangeOrthographicIfInSphereCap(ref InclusiveRange range, float3 positionVS, float3 lightPositionVS, float3 lightDirectionVS, float cosHalfAngle, bool isSpot) + { + if (IsInSphereCap(positionVS, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot)) ExpandRangeOrthographic(ref range, positionVS.x); + } + static readonly float3[] k_CubePoints = { new(-1, -1, -1), @@ -428,8 +462,9 @@ void TileReflectionProbe(int index) // The vertices of the cube in view space. var points = new NativeArray(k_CubePoints.Length, Allocator.Temp); - // This is initially filled with just the cube vertices that lie in front of the near plane. - var clippedPoints = new NativeArray(k_CubePoints.Length + k_CubeLineIndices.Length * 3, Allocator.Temp); + // This is initially filled with just the cube vertices that lie between the near and far planes. Each edge can add + // two more points where it crosses them. + var clippedPoints = new NativeArray(k_CubePoints.Length + k_CubeLineIndices.Length * 3 * 2, Allocator.Temp); var clippedPointsCount = 0; var leftmostIndex = 0; for (var i = 0; i < k_CubePoints.Length; i++) @@ -438,7 +473,7 @@ void TileReflectionProbe(int index) var point = math.mul(worldToViews[m_ViewIndex], math.float4(rotatedPointsWS, 1)).xyz; point.z *= -1; points[i] = point; - if (point.z >= near) + if (IsInDepthRange(point)) { var clippedPoint = isOrthographic ? point.xy : point.xy/point.z; var clippedIndex = clippedPointsCount++; @@ -447,8 +482,8 @@ void TileReflectionProbe(int index) } } - // Clip the cube's line segments with the near plane, and add the new vertices to clippedPoints. Only lines - // that are clipped will generate new vertices. + // Clip the cube's line segments with the near and far planes, and add the new vertices to clippedPoints. Only + // lines that cross a plane generate new vertices. for (var i = 0; i < k_CubeLineIndices.Length; i++) { var indices = k_CubeLineIndices[i]; @@ -456,12 +491,11 @@ void TileReflectionProbe(int index) for (var j = 0; j < 3; j++) { var p1 = points[indices[j+1]]; - // The entire line is in front of the near plane. - if (p0.z < near && p1.z < near) continue; - // Check whether the line needs clipping. - if (p0.z < near || p1.z < near) + for (var k = 0; k < 2; k++) { - var d = (near - p0.z) / (p1.z - p0.z); + var depth = k == 0 ? near : far; + if ((p0.z < depth) == (p1.z < depth)) continue; + var d = (depth - p0.z) / (p1.z - p0.z); var p = math.lerp(p0, p1, d); var clippedPoint = isOrthographic ? p.xy : p.xy/p.z; var clippedIndex = clippedPointsCount++; @@ -560,6 +594,42 @@ float2 ViewToTileSpaceOrthographic(float3 positionVS) void ExpandY(float3 positionVS) => ExpandTile(ViewToTileSpace(positionVS)); + bool IsInDepthRange(float3 positionVS) => positionVS.z >= near && positionVS.z <= far; + + // Whether a point of a cone section lies on the cone, up to its base. Also rejects points off the cone, which + // degenerate sections can produce. Tolerates ~1e-4 rad, or a distance from the surface on the order of the float + // precision of the light's coordinates. + internal static bool IsOnCone(float3 p, float3 vertex, float3 axis, float cosHalfAngle, float sinHalfAngle, float coneHeight, float distanceTolerance) + { + var q = p - vertex; + var length = math.length(q); + var axial = math.dot(q, axis); + return axial >= cosHalfAngle * length - sinHalfAngle * (1e-4f * length + distanceTolerance) && axial <= coneHeight; + } + + // For points on a light's sphere: skips points outside the depth range and, for spot lights, outside the cone. + bool IsInSphereCap(float3 positionVS, float3 lightPositionVS, float3 lightDirectionVS, float cosHalfAngle, bool isSpot) => + IsInDepthRange(positionVS) && (!isSpot || math.dot(math.normalize(positionVS - lightPositionVS), lightDirectionVS) >= cosHalfAngle); + + void ExpandYIfInSphereCap(float3 positionVS, float3 lightPositionVS, float3 lightDirectionVS, float cosHalfAngle, bool isSpot) + { + if (IsInSphereCap(positionVS, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot)) ExpandY(positionVS); + } + + void ExpandTileXIfInSphereCap(ref InclusiveRange range, float3 positionVS, float3 lightPositionVS, float3 lightDirectionVS, float cosHalfAngle, bool isSpot) + { + if (IsInSphereCap(positionVS, lightPositionVS, lightDirectionVS, cosHalfAngle, isSpot)) ExpandTileX(ref range, ViewToTileSpace(positionVS).x); + } + + // Expands the tile Y range where the segment from origin to origin + line crosses the view plane y = planeY * z. + void ExpandYAtViewPlane(float3 origin, float3 line, float planeY) + { + var planeNormal = math.float3(0, 1, -planeY); + var t = math.dot(-origin, planeNormal) / math.dot(line, planeNormal); + var positionVS = origin + line * t; + if (t >= 0 && t <= 1 && IsInDepthRange(positionVS)) ExpandY(positionVS); + } + void ExpandOrthographic(float3 positionVS) => ExpandTile(ViewToTileSpaceOrthographic(positionVS)); void ExpandRangeOrthographic(ref InclusiveRange range, float xVS) => ExpandTileX(ref range, ViewToTileSpaceOrthographic(xVS).x); @@ -609,138 +679,53 @@ void MergeTileRangeRows(int planeIndex, InclusiveRange planeRange) static float square(float x) => x * x; /// - /// Finds the two horizon points seen from (0, 0) of a sphere projected onto either XZ or YZ. Takes clipping into account. + /// Returns the points where the tangents from the origin touch a 2D circle, or NaN if the origin is inside it. /// - static void GetSphereHorizon(float2 center, float radius, float near, float clipRadius, out float2 p0, out float2 p1) + static void GetCircleHorizon(float2 center, float radius, out float2 p0, out float2 p1) { - var direction = math.normalize(center); - - // Distance from camera to center of sphere - var d = math.length(center); - - // Distance from camera to sphere horizon edge - var l = math.sqrt(d * d - radius * radius); - - // Height of circle horizon - var h = l * radius / d; - - // Center of circle horizon - var c = direction * (l * h / radius); - - p0 = math.float2(float.MinValue, 1f); - p1 = math.float2(float.MaxValue, 1f); - - // Handle clipping - if (center.y - radius < near) - { - p0 = math.float2(center.x + clipRadius, near); - p1 = math.float2(center.x - clipRadius, near); - } - - // Compare by x/z, not x: clip and horizon points lie at different depths. - var c0 = c + math.float2(-direction.y, direction.x) * h; - if (square(d) >= square(radius) && c0.y >= near) - { - if (c0.x / c0.y > p0.x / p0.y) { p0 = c0; } - if (c0.x / c0.y < p1.x / p1.y) { p1 = c0; } - } - - var c1 = c + math.float2(direction.y, -direction.x) * h; - if (square(d) >= square(radius) && c1.y >= near) - { - if (c1.x / c1.y > p0.x / p0.y) { p0 = c1; } - if (c1.x / c1.y < p1.x / p1.y) { p1 = c1; } - } + // With d the distance to the center and l the tangent length, the points are (l^2 * center +- l * r * perp(center)) / d^2. + var dSq = math.lengthsq(center); + var l = math.sqrt(dSq - square(radius)); + var side = l * radius * math.float2(-center.y, center.x); + p0 = (square(l) * center + side) / dSq; + p1 = (square(l) * center - side) / dSq; } - static void GetSphereYPlaneHorizon(float3 center, float sphereRadius, float near, float clipRadius, float y, out float3 left, out float3 right) + /// + /// Returns the horizon points, as seen from the origin, of the circle cut from a sphere by the plane through the + /// origin and the view-plane row at height y. NaN if the plane misses the sphere or the origin is inside the circle. + /// + static void GetSphereYPlaneHorizon(float3 center, float sphereRadius, float y, out float3 left, out float3 right) { - // Note: The y-plane is the plane that is determined by `y` in that it contains the vector (1, 0, 0) - // and goes through the points (0, y, 1) and (0, 0, 0). This would become a straight line in screen-space, and so it - // represents the boundary between two rows of tiles. - - // Near-plane clipping - will get overwritten if no clipping is needed. - // `y` is given for the view plane (Z=1), scale it so that it is on the near plane instead. - var yNear = y * near; - // Find the two points of intersection between the clip circle of the sphere and the y-plane. - // Found using Pythagoras with a right triangle formed by three points: - // (a) center of the clip circle - // (b) a point straight above the clip circle center on the y-plane - // (c) a point that is both on the circle and the y-plane (this is the point we want to find in the end) - // The hypotenuse is formed by (a) and (c) with length equal to the clip radius. The known side is - // formed by (a) and (b) and is simply the distance from the center to the y-plane along the y-axis. - // The remaining side gives us the x-displacement needed to find the intersection points. - var clipHalfWidth = math.sqrt(square(clipRadius) - square(yNear - center.y)); - left = math.float3(center.x - clipHalfWidth, yNear, near); - right = math.float3(center.x + clipHalfWidth, yNear, near); - - // Basis vectors in the y-plane for being able to parameterize the plane. + // Basis vectors in the y-plane, which contains (1, 0, 0) and (0, y, 1), and its normal (0, 1, -y). var planeU = math.normalize(math.float3(0, y, 1)); var planeV = math.float3(1, 0, 0); - - // Calculate the normal of the y-plane. Found from: (0, y, 1) × (1, 0, 0) = (0, 1, -y) - // This is used to represent the plane along with the origin, which is just 0 and thus doesn't show up - // in the calculations. var normal = math.normalize(math.float3(0, 1, -y)); - // We want to first find the circle from the intersection of the y-plane and the sphere. - - // The shortest distance from the sphere center and the y-plane. The sign determines which side of the plane - // the center is on. - var signedDistance = math.dot(normal, center); - - // Unsigned shortest distance from the sphere center to the plane. - var distanceToPlane = math.abs(signedDistance); - - // The center of the intersection circle in the y-plane, which is the point on the plane closest to the - // sphere center. I.e. this is at `distanceToPlane` from the center. + // The section circle is centered at the point of the plane closest to the sphere center. + var distanceToPlane = math.dot(normal, center); var centerOnPlane = math.float2(math.dot(center, planeU), math.dot(center, planeV)); - - // Distance from origin to the circle center. - var distanceInPlane = math.length(centerOnPlane); - - // Direction from origin to the circle center. - var directionPS = centerOnPlane / distanceInPlane; - - // Calculate the radius of the circle using Pythagoras. We know that any point on the circle is a point on - // the sphere. Thus we can construct a triangle with the sphere center, circle center, and a point on the - // circle. We then want to find its distance to the circle center, as that will be equal to the radius. As - // the point is on the sphere, it must be `sphereRadius` from the sphere center, forming the hypotenuse. The - // other side is between the sphere and circle centers, which we've already calculated to be - // `distanceToPlane`. var circleRadius = math.sqrt(square(sphereRadius) - square(distanceToPlane)); - // Now that we have the circle, we can find the horizon points. Since we've parametrized the plane, we can - // just do this in 2D. - - // Any of these conditions will yield NaN due to negative square roots. They are signs that clipping is needed, - // so we fallback on the already calculated values in that case. - if (square(distanceToPlane) <= square(sphereRadius) && square(circleRadius) <= square(distanceInPlane)) - { - // Distance from origin to circle horizon edge. - var l = math.sqrt(square(distanceInPlane) - square(circleRadius)); - - // Height of circle horizon. - var h = l * circleRadius / distanceInPlane; - - // Center of circle horizon. - var c = directionPS * (l * h / circleRadius); - - // Calculate the horizon points in the plane. - var leftOnPlane = c + math.float2(directionPS.y, -directionPS.x) * h; - var rightOnPlane = c + math.float2(-directionPS.y, directionPS.x) * h; - - // Transform horizon points to view space and use if not clipped. - var leftCandidate = leftOnPlane.x * planeU + leftOnPlane.y * planeV; - if (leftCandidate.z >= near) left = leftCandidate; + GetCircleHorizon(centerOnPlane, circleRadius, out var leftOnPlane, out var rightOnPlane); + left = leftOnPlane.x * planeU + leftOnPlane.y * planeV; + right = rightOnPlane.x * planeU + rightOnPlane.y * planeV; + } - var rightCandidate = rightOnPlane.x * planeU + rightOnPlane.y * planeV; - if (rightCandidate.z >= near) right = rightCandidate; - } + /// + /// Returns the points where the plane through the origin and the view-plane row at height planeY crosses the + /// circle cut from a sphere by the plane z = depth, or NaN if there are none. + /// + static void GetSphereSectionRowPoints(float3 center, float radiusSq, float depth, float planeY, out float3 p0, out float3 p1) + { + var y = planeY * depth; + var halfWidth = math.sqrt(radiusSq - square(depth - center.z) - square(y - center.y)); + p0 = math.float3(center.x - halfWidth, y, depth); + p1 = math.float3(center.x + halfWidth, y, depth); } /// - /// Finds the two points of intersection of a 3D circle and the near plane. + /// Finds the two points of intersection of a 3D circle and the plane z = near. /// static bool GetCircleClipPoints(float3 circleCenter, float3 circleNormal, float circleRadius, float near, out float3 p0, out float3 p1) { @@ -777,32 +762,6 @@ static bool GetCircleClipPoints(float3 circleCenter, float3 circleNormal, float return math.abs(distance) <= circleRadius; } - static (float, float) IntersectEllipseLine(float a, float b, float3 line) - { - // The line is represented as a homogenous 2D line {u, v, w} such that ux + vy + w = 0. - // The ellipse is represented by the implicit equation x^2/a^2 + y^2/b^2 = 1. - // We solve the line equation for y: y = (ux + w) / v - // We then substitute this into the ellipse equation and expand and re-arrange a bit: - // x^2/a^2 + ((ux + w) / v)^2/b^2 = 1 => - // x^2/a^2 + ((ux + w)^2 / v^2)/b^2 = 1 => - // x^2/a^2 + (ux + w)^2/(v^2 b^2) = 1 => - // x^2/a^2 + (u^2 x^2 + w^2 + 2 u x w)/(v^2 b^2) = 1 => - // x^2/a^2 + x^2 u^2 / (v^2 b^2) + w^2/(v^2 b^2) + x 2 u w / (v^2 b^2) = 1 => - // x^2 (1/a^2 + u^2 / (v^2 b^2)) + x 2 u w / (v^2 b^2) + w^2 / (v^2 b^2) - 1 = 0 - // We now have a quadratic equation with: - // a = 1/a^2 + u^2 / (v^2 b^2) - // b = 2 u w / (v^2 b^2) - // c = w^2 / (v^2 b^2) - 1 - var div = math.rcp(square(line.y) * square(b)); - var qa = 1f / square(a) + square(line.x) * div; - var qb = 2f * line.x * line.z * div; - var qc = square(line.z) * div - 1f; - var sqrtD = math.sqrt(qb * qb - 4f * qa * qc); - var x1 = (-qb + sqrtD) / (2f * qa); - var x2 = (-qb - sqrtD) / (2f * qa); - return (x1, x2); - } - /// /// Calculates the horizon of a circle orthogonally projected to a plane as seen from the origin on the plane. /// @@ -812,7 +771,7 @@ static bool GetCircleClipPoints(float3 circleCenter, float3 circleNormal, float /// The minor axis of the ellipse formed by the projection of the circle. /// The first horizon point expressed as factors of and . /// The second horizon point expressed as factors of and . - static void GetProjectedCircleHorizon(float2 center, float radius, float2 U, float2 V, out float2 uv1, out float2 uv2) + internal static void GetProjectedCircleHorizon(float2 center, float radius, float2 U, float2 V, out float2 uv1, out float2 uv2) { // U is assumed to be constructed such that it is never 0, but V can be if the circle projects to a line segment. // In that case, the solution can be trivially found using U only. @@ -825,76 +784,47 @@ static void GetProjectedCircleHorizon(float2 center, float radius, float2 U, flo else { var ul = math.length(U); - var ulinv = math.rcp(ul); - var vlinv = math.rcp(vl); // Normalize U and V in the plane. - var u = U * ulinv; - var v = V * vlinv; + var u = U / ul; + var v = V / vl; // Major and minor axis of the ellipse. var a = ul * radius; var b = vl * radius; - // Project the camera position into a 2D coordinate system with the circle at (0, 0) and - // the ellipse major and minor axes as the coordinate system axes. This allows us to use the standard - // form of the ellipse equation, greatly simplifying the calculations. - var cameraUV = math.float2(math.dot(-center, u), math.dot(-center, v)); - - // Find the polar line of the camera position in the normalized UV coordinate system. - var polar = math.float3(cameraUV.x / square(a), cameraUV.y / square(b), -1); - var (t1, t2) = IntersectEllipseLine(a, b, polar); - - // Find Y by putting polar into line equation and solving. Denormalize by dividing by U and V lengths. - uv1 = math.float2(t1 * ulinv, (-polar.x / polar.y * t1 - polar.z / polar.y) * vlinv); - uv2 = math.float2(t2 * ulinv, (-polar.x / polar.y * t2 - polar.z / polar.y) * vlinv); + // Scale the ellipse to the unit circle, where the tangent points from the camera q are + // (q +- sqrt(|q|^2 - 1) * perp(q)) / |q|^2. A camera inside the ellipse has no horizon and yields NaN. + var q = math.float2(math.dot(-center, u), math.dot(-center, v)) / math.float2(a, b); + var qq = math.lengthsq(q); + var side = math.sqrt(qq - 1f) * math.float2(-q.y, q.x); + uv1 = (q + side) / qq * radius; + uv2 = (q - side) / qq * radius; } } - static bool IntersectCircleYPlane( - float y, float3 circleCenter, float3 circleNormal, float3 circleU, float3 circleV, float circleRadius, + /// + /// Intersects a 3D circle with the plane dot(plane.xyz, p) + plane.w = 0. + /// + static bool IntersectCirclePlane( + float4 plane, float3 circleCenter, float3 circleU, float3 circleV, float circleRadius, out float3 p1, out float3 p2) { p1 = p2 = 0; - // Intersecting a circle with a plane yields 2 points, or the whole circle if the plane and the plane of the - // circle are the same, or nothing if the planes are parallel but offset. We're only interested in the first - // case. Our other tests will catch the other cases. - - // The two points will be on the line of intersection of the two planes. Thus we first have to find that line. - - // Shoot 2 rays along the y-plane and intersect the circle plane. We then transform them into the circle - // plane, so that we can work in 2D. - var CdotN = math.dot(circleCenter, circleNormal); - var h1v = math.float3(1, y, 1) * CdotN / math.dot(math.float3(1, y, 1), circleNormal) - circleCenter; - var h1 = math.float2(math.dot(h1v, circleU), math.dot(h1v, circleV)); - var h2v = math.float3(-1, y, 1) * CdotN / math.dot(math.float3(-1, y, 1), circleNormal) - circleCenter; - var h2 = math.float2(math.dot(h2v, circleU), math.dot(h2v, circleV)); - - var lineDirection = math.normalize(h2 - h1); - // We now have the direction of the line, and would like to find the point on it that is closest to the - // circle center. A line in 2D is similar to a plane in 3D. So we can calculate a normal, which is just a - // perpendicular/orthogonal direction, and then take the dot product to find the distance. This is similar - // to when calculating the d-term for a plane in 3D, which is also just calculating the closest distance - // from the origin to the plane. - var lineNormal = math.float2(lineDirection.y, -lineDirection.x); - var distToLine = math.dot(h1, lineNormal); - // We can then get that point on the line by following our normal with the distance we just calculated. - var lineCenter = lineNormal * distToLine; - - // Avoid negative square roots, as this means we've hit one of the cases that we do not care about. - if (distToLine > circleRadius) return false; - - // What's left now is to intersect the line with the circle. We can do so with Pythagoras. Our triangle - // is made up of `lineCenter`, the circle center and one of the intersection points. - // We know the distance from `lineCenter` to the circle center (`distToLine`), and the distance from - // the circle center to one of the intersection points must be the circle radius, as it lies on the - // circle, forming the hypotenuse. - var l = math.sqrt(circleRadius * circleRadius - distToLine * distToLine); - - // What we found above is the distance from `lineCenter` to each of the intersection points. So we just - // scrub along the line in both directions using the found distance, and then transform back into view - // space. + // In circle coordinates (s, t), the plane is the line a * s + b * t + k = 0. Parallel planes (a = b = 0) + // give the whole circle or nothing, which the other bounds cover. + var lineNormal = math.float2(math.dot(plane.xyz, circleU), math.dot(plane.xyz, circleV)); + var lineNormalLengthSq = math.lengthsq(lineNormal); + if (lineNormalLengthSq == 0f) return false; + + var k = math.dot(plane.xyz, circleCenter) + plane.w; + var distToLineSq = k * k / lineNormalLengthSq; + if (distToLineSq > circleRadius * circleRadius) return false; + + var lineCenter = -k / lineNormalLengthSq * lineNormal; + var lineDirection = math.float2(-lineNormal.y, lineNormal.x) * math.rsqrt(lineNormalLengthSq); + var l = math.sqrt(circleRadius * circleRadius - distToLineSq); var x1 = lineCenter + l * lineDirection; var x2 = lineCenter - l * lineDirection; p1 = circleCenter + x1.x * circleU + x1.y * circleV; @@ -903,11 +833,14 @@ static bool IntersectCircleYPlane( return true; } - static void GetConeSideTangentPoints(float3 vertex, float3 axis, float cosHalfAngle, float circleRadius, float coneHeight, float range, float3 circleU, float3 circleV, out float3 l1, out float3 l2) + /// + /// Finds the cone's silhouette lines from its vertex, as seen along toCamera: the vector from the vertex to the + /// camera, or the direction towards the camera for an orthographic projection. + /// + static void GetConeSideTangentPoints(float3 toCamera, float3 axis, float cosHalfAngle, float circleRadius, float coneHeight, float range, float3 circleU, float3 circleV, out float3 l1, out float3 l2) { l1 = l2 = 0; - var toCamera = -vertex; if (math.dot(math.normalize(toCamera), axis) >= cosHalfAngle) { return; @@ -933,26 +866,77 @@ static void GetConeSideTangentPoints(float3 vertex, float3 axis, float cosHalfAn l2 = (cosHalfAngle * axis + sinHalfAngle * (e2.x * circleU + e2.y * circleV)) * range; } - static float3 EvaluateNearConic(float near, float3 o, float3 d, float r, float3 u, float3 v, float theta) + /// + /// Section of a cone with the plane z = depth. With q = p - vertex = (x, y, z) and z = depth - vertex.z fixed, the cone + /// is dot(q, axis)^2 = cos^2 * dot(q, q), which is solved directly in the plane to stay stable when the vertex is close to it. + /// + internal struct ConeSection { - var h = (near - o.z) / (d.z + r * u.z * math.cos(theta) + r * v.z * math.sin(theta)); - return math.float3(o.xy + h * (d.xy + r * u.xy * math.cos(theta) + r * v.xy * math.sin(theta)), near); - } + float3 m_Vertex; + float3 m_Axis; + float m_Depth; + float m_Z; + float m_CosSq; + float m_SinSq; + + public ConeSection(float depth, float3 vertex, float3 axis, float cosHalfAngle, float sinHalfAngle) + { + m_Vertex = vertex; + m_Axis = axis; + m_Depth = depth; + m_Z = depth - vertex.z; + m_CosSq = cosHalfAngle * cosHalfAngle; + m_SinSq = sinHalfAngle * sinHalfAngle; + } - // o, d, u and v are expected to contain {x or y, z}. I.e. pass in x values to find tangents where x' = 0 - // Returns the two theta values as a float2. - static float2 FindNearConicTangentTheta(float2 o, float2 d, float r, float2 u, float2 v) - { - var sqrt = math.sqrt(square(d.x) * square(u.y) + square(d.x) * square(v.y) - 2f * d.x * d.y * u.x * u.y - 2f * d.x * d.y * v.x * v.y + square(d.y) * square(u.x) + square(d.y) * square(v.x) - square(r) * square(u.x) * square(v.y) + 2f * square(r) * u.x * u.y * v.x * v.y - square(r) * square(u.y) * square(v.x)); - var denom = d.x * v.y - d.y * v.x - r * u.x * v.y + r * u.y * v.x; - return 2 * math.atan((-d.x * u.y + d.y * u.x + math.float2(1, -1) * sqrt) / denom); + /// + /// Returns the points with extreme y, NaN or infinite where there are none. + /// + public void GetYExtremes(out float3 p0, out float3 p1) + { + var d = m_Axis; + var y = SolveQuadratic(d.z * d.z - m_SinSq, -d.y * d.z * m_Z, m_Z * m_Z * (d.y * d.y - m_SinSq)); + var x = -d.x * (d.y * y + d.z * m_Z) / (d.x * d.x - m_CosSq); + p0 = ToView(x.x, y.x); + p1 = ToView(x.y, y.y); + } + + /// + /// Returns the points with extreme x, NaN or infinite where there are none. + /// + public void GetXExtremes(out float3 p0, out float3 p1) + { + var d = m_Axis; + var x = SolveQuadratic(d.z * d.z - m_SinSq, -d.x * d.z * m_Z, m_Z * m_Z * (d.x * d.x - m_SinSq)); + var y = -d.y * (d.x * x + d.z * m_Z) / (d.y * d.y - m_CosSq); + p0 = ToView(x.x, y.x); + p1 = ToView(x.y, y.y); + } + + /// + /// Returns the points at view-space height y, NaN or infinite where there are none. + /// + public void IntersectRow(float yVS, out float3 p0, out float3 p1) + { + var d = m_Axis; + var y = yVS - m_Vertex.y; + var k = d.y * y + d.z * m_Z; + var x = SolveQuadratic(d.x * d.x - m_CosSq, d.x * k, k * k - m_CosSq * (y * y + m_Z * m_Z)); + p0 = ToView(x.x, y); + p1 = ToView(x.y, y); + } + + float3 ToView(float x, float y) => math.float3(m_Vertex.xy + math.float2(x, y), m_Depth); } - static float2 FindNearConicYTheta(float near, float3 o, float3 d, float r, float3 u, float3 v, float y) + /// + /// Returns the roots of a * t^2 + 2 * b * t + c = 0: NaN if there are none, and one is infinite if a is 0. + /// + static float2 SolveQuadratic(float a, float b, float c) { - var sqrt = math.sqrt(-square(d.y) * square(o.z) + 2 * square(d.y) * o.z * near - square(d.y) * square(near) + 2 * d.y * d.z * o.y * o.z - 2 * d.y * d.z * o.y * near - 2 * d.y * d.z * o.z * y + 2 * d.y * d.z * y * near - square(d.z) * square(o.y) + 2 * square(d.z) * o.y * y - square(d.z) * square(y) + square(o.y) * square(r) * square(u.z) + square(o.y) * square(r) * square(v.z) - 2 * o.y * o.z * square(r) * u.y * u.z - 2 * o.y * o.z * square(r) * v.y * v.z - 2 * o.y * y * square(r) * square(u.z) - 2 * o.y * y * square(r) * square(v.z) + 2 * o.y * square(r) * u.y * u.z * near + 2 * o.y * square(r) * v.y * v.z * near + square(o.z) * square(r) * square(u.y) + square(o.z) * square(r) * square(v.y) + 2 * o.z * y * square(r) * u.y * u.z + 2 * o.z * y * square(r) * v.y * v.z - 2 * o.z * square(r) * square(u.y) * near - 2 * o.z * square(r) * square(v.y) * near + square(y) * square(r) * square(u.z) + square(y) * square(r) * square(v.z) - 2 * y * square(r) * u.y * u.z * near - 2 * y * square(r) * v.y * v.z * near + square(r) * square(u.y) * square(near) + square(r) * square(v.y) * square(near)); - var denom = d.y * o.z - d.y * near - d.z * o.y + d.z * y + o.y * r * u.z - o.z * r * u.y - y * r * u.z + r * u.y * near; - return 2 * math.atan((r * (o.y * v.z - o.z * v.y - y * v.z + v.y * near) + math.float2(1, -1) * sqrt) / denom); + // Avoids the cancellation in -b + sqrt(b^2 - ac) by computing that root as c / q. + var q = -(b + (b < 0f ? -math.sqrt(b * b - a * c) : math.sqrt(b * b - a * c))); + return math.float2(q / a, c / q); } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ZBinningJob.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ZBinningJob.cs index 1c4e6b7f95b..247292de32f 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ZBinningJob.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Tiling/ZBinningJob.cs @@ -81,6 +81,8 @@ void FillZBins(int binStart, int binEnd, int itemStart, int itemEnd, int headerI for (var index = itemStart; index < itemEnd; index++) { var minMax = minMaxZs[itemOffset + index]; + // Empty depth range, e.g. an item entirely closer than the near plane; skipping it also keeps log2 away from non-positive depths. + if (minMax.x > minMax.y) continue; var minBin = math.max((int)((isOrthographic ? minMax.x : math.log2(minMax.x)) * zBinScale + zBinOffset), binStart); var maxBin = math.min((int)((isOrthographic ? minMax.y : math.log2(minMax.y)) * zBinScale + zBinOffset), binEnd); diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs new file mode 100644 index 00000000000..f1707f7e80a --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs @@ -0,0 +1,756 @@ +using System; +using System.Collections.Generic; +using Unity.Collections; +using Unity.Jobs; +using Unity.Mathematics; +using UnityEngine.Rendering.Universal.Internal; + +namespace UnityEngine.Rendering.Universal.Tests +{ + enum ClusteringItemKind + { + Point, + Spot, + Probe, + } + + /// + /// A light or reflection probe in world space, as the clustering jobs receive it. + /// + struct ClusteringItem + { + public ClusteringItemKind kind; + public float3 position; + public float3 direction; + public float range; + public float spotAngle; + public float3 extents; + public quaternion rotation; + + public static ClusteringItem Point(float3 position, float range) => + new ClusteringItem { kind = ClusteringItemKind.Point, position = position, direction = new float3(0, 0, 1), range = range, spotAngle = 30f, rotation = quaternion.identity }; + + public static ClusteringItem Spot(float3 position, float3 direction, float range, float spotAngle) => + new ClusteringItem { kind = ClusteringItemKind.Spot, position = position, direction = direction, range = range, spotAngle = spotAngle, rotation = quaternion.identity }; + + public static ClusteringItem Probe(float3 center, float3 extents, quaternion rotation) => + new ClusteringItem { kind = ClusteringItemKind.Probe, position = center, direction = new float3(0, 0, 1), extents = extents, rotation = rotation }; + + public override string ToString() => kind == ClusteringItemKind.Probe + ? $"Probe(center=({position.x:R},{position.y:R},{position.z:R}) extents=({extents.x:R},{extents.y:R},{extents.z:R}) rotation=({rotation.value.x:R},{rotation.value.y:R},{rotation.value.z:R},{rotation.value.w:R}))" + : $"{kind}(position=({position.x:R},{position.y:R},{position.z:R}) direction=({direction.x:R},{direction.y:R},{direction.z:R}) range={range:R} spotAngle={spotAngle:R})"; + } + + /// + /// One view, or two for XR, and the items to cluster. + /// + class ClusteringScene + { + public bool orthographic; + public int viewCount = 1; + public float4x4[] worldToViews = { float4x4.identity, float4x4.identity }; + public float4x4[] viewToClips = new float4x4[2]; + public float near; + public float far; + public int2 screenSize; + public List items = new List(); + + public static float4x4 Perspective(float p00, float p11, float2 lensShift, float near, float far) => new float4x4( + new float4(p00, 0, 0, 0), + new float4(0, p11, 0, 0), + new float4(lensShift.x, lensShift.y, -(far + near) / (far - near), -1), + new float4(0, 0, -(2f * far * near) / (far - near), 0)); + + public static float4x4 Orthographic(float halfWidth, float halfHeight, float2 lensShift, float near, float far) + { + var m = float4x4.identity; + m.c0.x = 1f / halfWidth; + m.c1.y = 1f / halfHeight; + m.c2.z = -2f / (far - near); + m.c3 = new float4(lensShift.x, lensShift.y, -(far + near) / (far - near), 1); + return m; + } + + /// + /// A perspective scene with an identity world-to-view matrix and one item given in view space with +z forward. + /// + public static ClusteringScene PerspectiveViewSpace(float p00, float p11, float2 lensShift, float near, float far, int2 screenSize, ClusteringItem itemVS) + { + var scene = new ClusteringScene { near = near, far = far, screenSize = screenSize }; + scene.viewToClips[0] = scene.viewToClips[1] = Perspective(p00, p11, lensShift, near, far); + scene.items.Add(FlipZ(itemVS)); + return scene; + } + + public static ClusteringScene PerspectiveViewSpace(float fovYDeg, float aspect, float near, float far, int2 screenSize, ClusteringItem itemVS) + { + var p11 = 1f / math.tan(math.radians(fovYDeg) * 0.5f); + return PerspectiveViewSpace(p11 / aspect, p11, float2.zero, near, far, screenSize, itemVS); + } + + /// + /// An orthographic scene with an identity world-to-view matrix and one item given in view space with +z forward. + /// + public static ClusteringScene OrthographicViewSpace(float halfWidth, float halfHeight, float near, float far, int2 screenSize, ClusteringItem itemVS) + { + var scene = new ClusteringScene { orthographic = true, near = near, far = far, screenSize = screenSize }; + scene.viewToClips[0] = scene.viewToClips[1] = Orthographic(halfWidth, halfHeight, float2.zero, near, far); + scene.items.Add(FlipZ(itemVS)); + return scene; + } + + static ClusteringItem FlipZ(ClusteringItem item) + { + item.position.z = -item.position.z; + item.direction.z = -item.direction.z; + item.rotation = new quaternion(-item.rotation.value.x, -item.rotation.value.y, item.rotation.value.z, item.rotation.value.w); + return item; + } + + public override string ToString() + { + var s = $"orthographic={orthographic} views={viewCount} near={near:R} far={far:R} screen={screenSize}\n"; + for (var v = 0; v < viewCount; v++) + s += $" view {v}: worldToView={worldToViews[v]} viewToClip={viewToClips[v]}\n"; + foreach (var item in items) + s += $" {item}\n"; + return s; + } + } + + /// + /// Reference for the light clustering jobs. Runs ForwardLights.ScheduleClusteringJobs on a scene and compares its tile + /// masks and z-bins with ray casts against the exact light and probe volumes. + /// + /// Each item is converted to view space in double precision from the same float inputs the jobs receive, so the + /// reference is the exact geometry of those inputs and any float error in the jobs counts against the jobs. The + /// volumes are the ones the jobs cover: a sphere for a point light, a cone of half the spot angle intersected with the + /// range sphere for a spot light, and a box for a reflection probe, all limited to depths between the near and far + /// planes. + /// + /// Two kinds of errors are reported: + /// - Missing: the GPU looks up lights per pixel center, so an item must be in every tile that contains a pixel center + /// whose view ray hits its volume, and in every z-bin between the depths where that ray enters and leaves it. + /// This check is exact up to double precision. + /// - Outside: over-coverage is allowed but costs performance, so this check only reports an item in a tile or z-bin + /// it clearly does not reach. It errs towards passing: a tile counts as reached when the volume comes within + /// k_TouchMargin pixels of the tile rectangle, which accepts slivers and contact along a tile edge, and a z-bin + /// counts as reached when it is at most one bin away from the depth extent of the volume. + /// + /// The layout of the outputs is checked as well. Each z-bin has a header with the range of light indices and the + /// range of probe indices the shader iterates; a range must cover the items of its kind in the bin, stay within the + /// indices of its kind, and be empty when the bin has none. No bit may be set for an item index that does not exist, + /// and nothing may be written past the tiles and z-bins in use. + /// + static class LightClusteringOracle + { + // Distance in pixels within which a volume counts as touching a tile rectangle. Absorbs float error in the jobs + // and volumes that touch a tile along an edge or in a sliver too thin to sample. + const double k_TouchMargin = 0.125; + + public class Result + { + public List missing = new List(); + public List outside = new List(); + public bool failed => missing.Count > 0 || outside.Count > 0; + + public override string ToString() => + (missing.Count > 0 ? $"Missing ({missing.Count}): {string.Join("; ", missing.GetRange(0, math.min(10, missing.Count)))}\n" : "") + + (outside.Count > 0 ? $"Outside ({outside.Count}): {string.Join("; ", outside.GetRange(0, math.min(10, outside.Count)))}\n" : ""); + } + + class Output + { + public int2 tileResolution; + public int tileWidth; + public int wordsPerTile; + public int binCount; + public float zBinScale; + public float zBinOffset; + public uint[] tileMasks; + public uint[] zBins; + } + + static bool reflectionProbeRotation => + !GraphicsSettings.TryGetRenderPipelineSettings(out var settings) || settings.UseReflectionProbeRotation; + + // The jobs index lights before probes; the reference uses the same order to find each item's bit. + static List InJobOrder(ClusteringScene scene) + { + var ordered = new List(); + ordered.AddRange(scene.items.FindAll(i => i.kind != ClusteringItemKind.Probe)); + ordered.AddRange(scene.items.FindAll(i => i.kind == ClusteringItemKind.Probe)); + return ordered; + } + + static Output Run(ClusteringScene scene, List ordered) + { + var lightCount = ordered.FindAll(i => i.kind != ClusteringItemKind.Probe).Count; + var lights = new NativeArray(lightCount, Allocator.TempJob); + var probes = new NativeArray(ordered.Count - lightCount, Allocator.TempJob); + var zBins = new NativeArray(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); + var tileMasks = new NativeArray(UniversalRenderPipeline.maxTileWords, Allocator.TempJob); + try + { + for (var i = 0; i < ordered.Count; i++) + { + var item = ordered[i]; + if (item.kind == ClusteringItemKind.Probe) + { + probes[i - lightCount] = new VisibleReflectionProbe + { + bounds = new Bounds(item.position, 2f * (Vector3)item.extents), + localToWorldMatrix = Matrix4x4.TRS(item.position, item.rotation, Vector3.one), + }; + } + else + { + lights[i] = new VisibleLight + { + lightType = item.kind == ClusteringItemKind.Spot ? LightType.Spot : LightType.Point, + finalColor = Color.white, + screenRect = new Rect(0, 0, 1, 1), + localToWorldMatrix = new Matrix4x4( + new Vector4(1, 0, 0, 0), + new Vector4(0, 1, 0, 0), + new Vector4(item.direction.x, item.direction.y, item.direction.z, 0), + new Vector4(item.position.x, item.position.y, item.position.z, 1)), + range = item.range, + spotAngle = item.spotAngle, + intersectsNearPlane = true, + intersectsFarPlane = true, + }; + } + } + + var output = new Output(); + var handle = ForwardLights.ScheduleClusteringJobs( + false, true, lights, probes, zBins, tileMasks, + new Fixed2(scene.worldToViews[0], scene.worldToViews[1]), + new Fixed2(scene.viewToClips[0], scene.viewToClips[1]), + scene.viewCount, scene.screenSize, scene.near, scene.far, scene.orthographic, + out _, out _, out output.binCount, out output.zBinScale, out output.zBinOffset, + out output.tileResolution, out output.tileWidth, out output.wordsPerTile); + JobHandle.ScheduleBatchedJobs(); + handle.Complete(); + output.tileMasks = tileMasks.ToArray(); + output.zBins = zBins.ToArray(); + return output; + } + finally + { + lights.Dispose(); + probes.Dispose(); + zBins.Dispose(); + tileMasks.Dispose(); + } + } + + /// + /// Runs the clustering jobs on the scene and returns every missing or outside tile and z-bin, per item and view. + /// + public static Result Check(ClusteringScene scene) + { + var ordered = InJobOrder(scene); + var output = Run(scene, ordered); + var result = new Result(); + var tileResolution = output.tileResolution; + var tileWidth = output.tileWidth; + for (var view = 0; view < scene.viewCount; view++) + { + var camera = new Camera(scene, view); + for (var index = 0; index < ordered.Count; index++) + { + var volume = new Volume(scene, view, ordered[index]); + var (zMin, zMax) = volume.DepthExtent(); + + // Relative tolerance for depth comparisons, a few hundred times the float precision of the depths. + var zTolerance = 1e-5 * (math.abs(zMin) + math.abs(zMax) + math.abs(scene.near) + 1); + + // A volume that only touches the near or far plane has a visible part of zero area, a point or a line, + // which no ray sampling can find. Its tiles are not checked for over-coverage. + var degenerate = zMax < scene.near + zTolerance || zMin > scene.far - zTolerance; + var word = index / 32; + var bit = 1u << (index % 32); + var label = $"item {index} {ordered[index].kind} view {view}"; + var maskBase = view * output.wordsPerTile * tileResolution.x * tileResolution.y; + bool InTile(int tx, int ty) => (output.tileMasks[maskBase + (ty * tileResolution.x + tx) * output.wordsPerTile + word] & bit) != 0; + bool InBin(int b) => b >= 0 && b < output.binCount && + (output.zBins[(view * output.binCount + b) * (ZBinningJob.headerLength + output.wordsPerTile) + ZBinningJob.headerLength + word] & bit) != 0; + // Same z-bin mapping as the shader: linear in depth for orthographic cameras, logarithmic otherwise. + int BinOf(double z) => (int)math.floor((scene.orthographic ? z : math.log2(z)) * output.zBinScale + output.zBinOffset); + + // Cast a ray through each pixel center on screen. A tile is reached when one of its rays hits the volume, + // and every z-bin between the depths where that ray enters and leaves the volume must hold the item. + // Partial tiles at the screen edges only have rays for their on-screen pixels. + for (var ty = 0; ty < tileResolution.y; ty++) + { + for (var tx = 0; tx < tileResolution.x; tx++) + { + var hit = false; + var binMissing = false; + for (var py = ty * tileWidth; py < math.min(scene.screenSize.y, (ty + 1) * tileWidth); py++) + { + for (var px = tx * tileWidth; px < math.min(scene.screenSize.x, (tx + 1) * tileWidth); px++) + { + camera.Ray(px + 0.5, py + 0.5, out var origin, out var direction); + var (lo, hi) = volume.Hit(origin, direction, scene.near, scene.far); + if (lo > hi) + continue; + hit = true; + var lastBin = math.min(BinOf(hi), output.binCount - 1); + for (var b = math.max(BinOf(lo), 0); b <= lastBin && !binMissing; b++) + { + if (!InBin(b)) + { + binMissing = true; + result.missing.Add($"{label} z-bin {b} (depths {lo:G6}..{hi:G6} at pixel {px},{py})"); + } + } + } + } + + if (hit && !InTile(tx, ty)) + result.missing.Add($"{label} tile ({tx},{ty})"); + if (!hit && !degenerate && InTile(tx, ty) && !volume.TouchesTile(camera, tx, ty, tileWidth, scene.near, scene.far)) + result.outside.Add($"{label} tile ({tx},{ty})"); + } + } + + // A z-bin is over-covered when it lies more than one bin beyond the depth extent of the volume, clipped to + // the near and far planes. A volume entirely outside them allows no bin. + zMin = math.max(zMin - zTolerance, scene.near); + zMax = math.min(zMax + zTolerance, scene.far); + var allowedMin = zMin <= zMax ? BinOf(zMin) - 1 : int.MaxValue; + var allowedMax = zMin <= zMax ? BinOf(zMax) + 1 : int.MinValue; + for (var b = 0; b < output.binCount; b++) + { + if (InBin(b) && (b < allowedMin || b > allowedMax)) + result.outside.Add($"{label} z-bin {b} (volume depths {zMin:G6}..{zMax:G6})"); + } + } + } + CheckLayout(scene, ordered, output, result); + return result; + } + + static void CheckLayout(ClusteringScene scene, List ordered, Output output, Result result) + { + var lightCount = ordered.FindAll(i => i.kind != ClusteringItemKind.Probe).Count; + var stride = ZBinningJob.headerLength + output.wordsPerTile; + // The first header word of a z-bin is the range of light indices the shader iterates in that bin, the second + // the range of probe indices. A range must cover every item of its kind in the bin, stay within the indices of + // its kind, and be empty when the bin has no item of its kind; otherwise the shader would visit an item of the + // other kind. + var kindBegin = new int2(0, lightCount); + var kindEnd = new int2(lightCount, ordered.Count); + for (var bin = 0; bin < scene.viewCount * output.binCount; bin++) + { + var present = new bool2(false, false); + for (var word = 0; word < output.wordsPerTile; word++) + { + var bits = output.zBins[bin * stride + ZBinningJob.headerLength + word]; + for (var bit = 0; bit < 32; bit++) + { + if ((bits & (1u << bit)) == 0) + continue; + var index = word * 32 + bit; + if (index >= ordered.Count) + { + result.outside.Add($"z-bin {bin} has a bit for item {index}, which does not exist"); + continue; + } + + var kind = index < lightCount ? 0 : 1; + present[kind] = true; + var header = output.zBins[bin * stride + kind]; + if (index < (header & 0xFFFF) || index > header >> 16) + result.missing.Add($"z-bin {bin} header {kind} is {header & 0xFFFF}..{header >> 16} and leaves out item {index}"); + } + } + + for (var kind = 0; kind < 2; kind++) + { + var header = output.zBins[bin * stride + kind]; + int min = (int)(header & 0xFFFF), max = (int)(header >> 16); + if (min > max) + continue; + if (!present[kind]) + result.outside.Add($"z-bin {bin} header {kind} is {min}..{max} but the bin has no item of its kind"); + else if (min < kindBegin[kind] || max >= kindEnd[kind]) + result.outside.Add($"z-bin {bin} header {kind} is {min}..{max}, outside the item indices {kindBegin[kind]}..{kindEnd[kind] - 1} of its kind"); + } + } + for (var i = scene.viewCount * output.binCount * stride; i < output.zBins.Length; i++) + { + if (output.zBins[i] != 0) + result.outside.Add($"z-bin word {i} past the bins in use is {output.zBins[i]}"); + } + + var tileWords = output.tileResolution.x * output.tileResolution.y * output.wordsPerTile; + for (var tile = 0; tile < scene.viewCount * output.tileResolution.x * output.tileResolution.y; tile++) + { + for (var word = 0; word < output.wordsPerTile; word++) + { + var bits = output.tileMasks[tile * output.wordsPerTile + word]; + var validBits = math.clamp(ordered.Count - word * 32, 0, 32); + if (validBits < 32 && bits >> validBits != 0) + result.outside.Add($"tile {tile} word {word} has bits for items that do not exist: {bits:X8}"); + } + } + for (var i = scene.viewCount * tileWords; i < output.tileMasks.Length; i++) + { + if (output.tileMasks[i] != 0) + result.outside.Add($"tile mask word {i} past the tiles in use is {output.tileMasks[i]}"); + } + } + + // Rays and projections derived from the view-to-clip matrix itself, independently of how the jobs derive their + // view planes from it. View space has +z forward and the depth along a ray is its parameter. + readonly struct Camera + { + readonly bool m_Orthographic; + readonly double4x4 m_ViewToClip; + + public bool orthographic => m_Orthographic; + readonly double2 m_Screen; + + public Camera(ClusteringScene scene, int view) + { + m_Orthographic = scene.orthographic; + m_ViewToClip = scene.viewToClips[view]; + m_Screen = new double2(scene.screenSize.x, scene.screenSize.y); + } + + // Pixel position of a view-space point. + public double2 Project(double3 p) + { + var ndc = m_Orthographic + ? new double2(p.x * m_ViewToClip[0][0] + m_ViewToClip[3][0], p.y * m_ViewToClip[1][1] + m_ViewToClip[3][1]) + : new double2(p.x / p.z * m_ViewToClip[0][0] - m_ViewToClip[2][0], p.y / p.z * m_ViewToClip[1][1] - m_ViewToClip[2][1]); + return (ndc * 0.5 + 0.5) * m_Screen; + } + + // View-space ray through a pixel position, as origin + depth * direction. Perspective rays start at the camera, + // orthographic rays start in the camera plane and point along +z. + public void Ray(double px, double py, out double3 origin, out double3 direction) + { + var ndc = new double2(px, py) / m_Screen * 2 - 1; + if (m_Orthographic) + { + origin = new double3((ndc.x - m_ViewToClip[3][0]) / m_ViewToClip[0][0], (ndc.y - m_ViewToClip[3][1]) / m_ViewToClip[1][1], 0); + direction = new double3(0, 0, 1); + } + else + { + origin = 0; + direction = new double3((ndc.x + m_ViewToClip[2][0]) / m_ViewToClip[0][0], (ndc.y + m_ViewToClip[2][1]) / m_ViewToClip[1][1], 1); + } + } + } + + // The volume of one item in the view space of one view, in double precision. + readonly struct Volume + { + readonly ClusteringItemKind m_Kind; + readonly double3 m_Position; + readonly double3 m_Axis; + readonly double m_CosSq; + readonly double m_Range; + readonly double3x3 m_Basis; + readonly double3 m_Extents; + + public Volume(ClusteringScene scene, int view, ClusteringItem item) + { + var worldToView = (double4x4)scene.worldToViews[view]; + var flip = new double3(1, 1, -1); + m_Kind = item.kind; + m_Position = math.mul(worldToView, new double4((double3)item.position, 1)).xyz * flip; + m_Axis = math.normalize(math.mul(worldToView, new double4((double3)item.direction, 0)).xyz * flip); + var cos = math.cos(math.radians((double)item.spotAngle) * 0.5); + m_CosSq = cos * cos; + m_Range = item.range; + var rotation = reflectionProbeRotation ? new double3x3(new float3x3(item.rotation)) : double3x3.identity; + m_Basis = new double3x3( + math.mul(worldToView, new double4(rotation.c0, 0)).xyz * flip, + math.mul(worldToView, new double4(rotation.c1, 0)).xyz * flip, + math.mul(worldToView, new double4(rotation.c2, 0)).xyz * flip); + m_Extents = (double3)item.extents; + } + + // Depth interval [lo, hi] of origin + s * direction inside the volume for s in [s0, s1]; lo > hi if none. + // Boxes use the slab method. Spheres solve a quadratic. Cones solve the cone quadric and intersect the result + // with the sphere interval; the volume is convex, so its inside along a ray is one interval. + public (double, double) Hit(double3 origin, double3 direction, double s0, double s1) + { + if (m_Kind == ClusteringItemKind.Probe) + { + double lo = s0, hi = s1; + for (var k = 0; k < 3; k++) + { + var length = math.length(m_Basis[k]); + var axis = m_Basis[k] / length; + var extent = m_Extents[k] * length; + var offset = math.dot(origin - m_Position, axis); + var speed = math.dot(direction, axis); + if (speed == 0) + { + if (math.abs(offset) > extent) + return (1, 0); + continue; + } + var ta = (-extent - offset) / speed; + var tb = (extent - offset) / speed; + lo = math.max(lo, math.min(ta, tb)); + hi = math.min(hi, math.max(ta, tb)); + if (lo > hi) + return (1, 0); + } + return (lo, hi); + } + + var toCenter = m_Position - origin; + double dd = math.dot(direction, direction), da = math.dot(direction, toCenter), aa = math.dot(toCenter, toCenter); + var disc = da * da - dd * (aa - m_Range * m_Range); + if (disc < 0) + return (1, 0); + var sq = math.sqrt(disc); + var a0 = math.max((da - sq) / dd, s0); + var a1 = math.min((da + sq) / dd, s1); + if (a0 > a1 || m_Kind == ClusteringItemKind.Point) + return (a0, a1); + + // Along the ray, the inside of the cone can only begin or end at a root of the cone quadric + // ga s^2 + 2 gb s + gc = 0, where the ray meets the double cone, or where it crosses the plane through the + // vertex, which separates the two nappes. Sorting these candidates with the sphere interval bounds and + // testing each candidate and each midpoint between neighbors finds the inside interval exactly. The roots are + // computed as q / ga and gc / q, which keeps the single root when the ray is parallel to a cone line, where + // ga is 0. + double du = math.dot(direction, m_Axis), au = math.dot(toCenter, m_Axis); + double ga = du * du - m_CosSq * dd, gb = -du * au + m_CosSq * da, gc = au * au - m_CosSq * aa; + Span sorted = stackalloc double[6]; + var n = 0; + Insert(sorted, ref n, a0, a0, a1); + Insert(sorted, ref n, a1, a0, a1); + // A grazing ray can round the discriminant below 0; the extra candidates are harmless, InsideCone decides. + var root = math.sqrt(math.max(gb * gb - ga * gc, 0)); + var q = -(gb + (gb < 0 ? -root : root)); + if (q != 0) + { + Insert(sorted, ref n, q / ga, a0, a1); + Insert(sorted, ref n, gc / q, a0, a1); + } + if (du != 0) + Insert(sorted, ref n, au / du, a0, a1); + + double inLo = double.MaxValue, inHi = double.MinValue; + for (var i = 0; i < n; i++) + { + if (InsideCone(origin, direction, sorted[i])) + { + inLo = math.min(inLo, sorted[i]); + inHi = math.max(inHi, sorted[i]); + } + if (i + 1 < n && InsideCone(origin, direction, 0.5 * (sorted[i] + sorted[i + 1]))) + { + inLo = math.min(inLo, sorted[i]); + inHi = math.max(inHi, sorted[i + 1]); + } + } + return (inLo, inHi); + } + + static void Insert(Span sorted, ref int count, double value, double min, double max) + { + if (double.IsNaN(value) || value < min || value > max) + return; + var k = count++; + while (k > 0 && sorted[k - 1] > value) + { + sorted[k] = sorted[k - 1]; + k--; + } + sorted[k] = value; + } + + // Whether the point at depth s lies in the forward nappe of the cone. The small tolerance counts points on the + // surface as inside, which can only make the missing check stricter. + bool InsideCone(double3 origin, double3 direction, double s) + { + var q = origin + s * direction - m_Position; + var axial = math.dot(q, m_Axis); + return axial >= 0 && axial * axial - m_CosSq * math.dot(q, q) >= -1e-12; + } + + // Exact depth range of the whole volume, ignoring the near and far planes. + public (double, double) DepthExtent() + { + if (m_Kind == ClusteringItemKind.Probe) + { + var e = math.abs(m_Basis.c0.z) * m_Extents.x + math.abs(m_Basis.c1.z) * m_Extents.y + math.abs(m_Basis.c2.z) * m_Extents.z; + return (m_Position.z - e, m_Position.z + e); + } + if (m_Kind == ClusteringItemKind.Point) + return (m_Position.z - m_Range, m_Position.z + m_Range); + + // A spot volume reaches its depth extremes at the vertex or on the base circle, where the cone meets the + // sphere. The sphere cap goes further only when the view axis lies inside the cone, in which case the extreme + // is a full range away from the vertex. + var cos = math.sqrt(m_CosSq); + var baseCenter = m_Position + m_Axis * m_Range * cos; + var baseExtent = m_Range * math.sqrt(1 - m_CosSq) * math.sqrt(math.max(0, 1 - m_Axis.z * m_Axis.z)); + var lo = -m_Axis.z >= cos ? m_Position.z - m_Range : math.min(m_Position.z, baseCenter.z - baseExtent); + var hi = m_Axis.z >= cos ? m_Position.z + m_Range : math.max(m_Position.z, baseCenter.z + baseExtent); + return (lo, hi); + } + + // Whether the volume comes within k_TouchMargin pixels of the tile rectangle. Points known to be in the volume + // are tested first: the center of a point light or probe, or the vertex and two axis points of a spot light. + // This covers volumes smaller than a sample spacing and a spot light whose vertex touches a tile at a single + // point. Then the grown rectangle is sampled with rays on grids of 1/16 and 1/64 pixel. + public bool TouchesTile(Camera camera, int tx, int ty, int tileWidth, double near, double far) + { + var depthTolerance = 1e-5 * (math.length(m_Position) + m_Range + math.length(m_Extents) + math.abs(near)); + for (var i = 0; i < 3; i++) + { + if (m_Kind != ClusteringItemKind.Spot && i > 0) + break; + var p = m_Position + m_Axis * (m_Range * math.sqrt(m_CosSq) * i * 0.5); + if (p.z < near - depthTolerance || p.z > far + depthTolerance || (!camera.orthographic && p.z <= 0)) + continue; + var pixel = camera.Project(p); + if (math.all(pixel >= new double2(tx, ty) * tileWidth - k_TouchMargin) && math.all(pixel <= new double2(tx + 1, ty + 1) * tileWidth + k_TouchMargin)) + return true; + } + + foreach (var samplesPerPixel in new[] { 16, 64 }) + { + var size = tileWidth + 2 * k_TouchMargin; + var n = (int)math.ceil(size * samplesPerPixel); + for (var j = 0; j <= n; j++) + { + for (var i = 0; i <= n; i++) + { + camera.Ray(tx * tileWidth - k_TouchMargin + size * i / n, ty * tileWidth - k_TouchMargin + size * j / n, out var origin, out var direction); + var (lo, hi) = Hit(origin, direction, near, far); + if (lo <= hi) + return true; + } + } + } + return false; + } + } + + static float3 RandomDirection(ref Unity.Mathematics.Random rng) + { + const float a = 0.70710677f; + var special = new[] + { + new float3(0, 0, 1), new float3(0, 0, -1), new float3(1, 0, 0), new float3(-1, 0, 0), new float3(0, 1, 0), new float3(0, -1, 0), + new float3(a, 0, a), new float3(-a, 0, a), new float3(0, a, a), new float3(0, -a, a), new float3(a, 0, -a), new float3(0, a, -a), + new float3(a, a, 0), math.normalize(new float3(1, 1, 1)), math.normalize(new float3(-1, 1, 1)), + }; + return rng.NextInt(0, 2) == 0 ? special[rng.NextInt(0, special.Length)] : math.normalize(rng.NextFloat3(-1f, 1f) + new float3(0, 0, 1e-3f)); + } + + /// + /// Seeded random scenes: perspective or orthographic, one or two views, lens shift, and items biased towards the + /// degenerate configurations that broke the clustering jobs before: axis-aligned and 45 degree spot axes, vertices + /// on the view axis or near the near plane, cameras on the cone axis, cone edges along the view direction, and items + /// crossing the near and far planes. + /// + public static ClusteringScene RandomScene(ref Unity.Mathematics.Random rng, int2 screenSize, int maxItems) + { + var scene = new ClusteringScene + { + orthographic = rng.NextInt(0, 3) == 0, + viewCount = rng.NextInt(0, 4) == 0 ? 2 : 1, + screenSize = screenSize, + }; + var scale = rng.NextFloat(2f, 40f); + if (scene.orthographic) + { + scene.near = rng.NextInt(0, 3) == 0 ? -rng.NextFloat(0.1f, 20f) : rng.NextFloat(0.01f, 2f); + scene.far = scene.near + rng.NextFloat(5f, 200f); + } + else + { + scene.near = rng.NextFloat(0.01f, 2f); + scene.far = rng.NextInt(0, 4) == 0 ? rng.NextFloat(scene.near + 0.5f, 20f) : rng.NextFloat(50f, 5000f); + } + + var flip = float4x4.Scale(1, 1, -1); + var viewToWorld = rng.NextBool() + ? float4x4.identity + : float4x4.TRS(rng.NextFloat3(-50f, 50f), quaternion.EulerXYZ(rng.NextFloat3(-math.PI, math.PI)), 1f); + var aspect = (float)screenSize.x / screenSize.y * rng.NextFloat(0.8f, 1.25f); + var halfHeight = rng.NextFloat(1f, 30f); + var p11 = 1f / math.tan(math.radians(rng.NextFloat(20f, 120f)) * 0.5f); + for (var v = 0; v < scene.viewCount; v++) + { + var eye = v == 0 ? float3.zero : new float3(rng.NextFloat(0.02f, 0.08f), 0, 0); + scene.worldToViews[v] = math.mul(flip, math.inverse(math.mul(viewToWorld, float4x4.Translate(eye)))); + var shift = rng.NextInt(0, 3) == 0 || v == 1 ? rng.NextFloat2(-0.4f, 0.4f) : float2.zero; + scene.viewToClips[v] = scene.orthographic + ? ClusteringScene.Orthographic(halfHeight * aspect, halfHeight, shift, scene.near, scene.far) + : ClusteringScene.Perspective(p11 / aspect, p11, shift, scene.near, scene.far); + } + if (scene.viewCount == 1) + { + scene.worldToViews[1] = scene.worldToViews[0]; + scene.viewToClips[1] = scene.viewToClips[0]; + } + + var viewToWorldFlipped = math.mul(viewToWorld, flip); + var count = rng.NextInt(1, maxItems + 1); + for (var i = 0; i < count; i++) + { + var positionVS = new float3(rng.NextFloat(-1f, 1f) * scale, rng.NextFloat(-1f, 1f) * scale, rng.NextFloat(-0.3f, 1.2f) * scale); + switch (rng.NextInt(0, 8)) + { + case 0: positionVS.z = scene.near; break; + case 1: positionVS.z = scene.near * (1f + (rng.NextBool() ? 1f : -1f) * math.pow(10f, rng.NextFloat(-6f, -1f))); break; + case 2: positionVS.xy = 0; break; + case 3: positionVS = math.round(positionVS); break; + case 4: positionVS.z = scene.far * rng.NextFloat(0.9f, 1.1f); break; + } + + var kind = rng.NextInt(0, 10); + if (kind < 2) + { + var extents = rng.NextFloat3(0.05f, 1f) * scale * rng.NextFloat(0.1f, 1f); + if (rng.NextInt(0, 4) == 0) + extents = math.round(extents) + 0.5f; + var rotation = rng.NextInt(0, 3) == 0 ? quaternion.identity : quaternion.EulerXYZ(rng.NextFloat3(-math.PI, math.PI)); + scene.items.Add(ClusteringItem.Probe(math.transform(viewToWorldFlipped, new float3(positionVS.xy, -positionVS.z)), extents, rotation)); + continue; + } + + var range = rng.NextFloat(0.2f, 1.5f) * scale; + if (kind < 4) + { + scene.items.Add(ClusteringItem.Point(math.transform(viewToWorldFlipped, new float3(positionVS.xy, -positionVS.z)), range)); + continue; + } + + var directionVS = RandomDirection(ref rng); + if (rng.NextInt(0, 6) == 0) + positionVS = -directionVS * math.round(rng.NextFloat(0.5f, 0.9f) * range); + float spotAngle; + switch (rng.NextInt(0, 3)) + { + case 0: spotAngle = math.round(rng.NextFloat(1f, 179f) / 5f) * 5f; break; + case 1: spotAngle = 2f * math.degrees(math.acos(math.saturate(math.abs(directionVS.z)))); break; + default: spotAngle = rng.NextFloat(1f, 179f); break; + } + scene.items.Add(ClusteringItem.Spot( + math.transform(viewToWorldFlipped, new float3(positionVS.xy, -positionVS.z)), + math.rotate(viewToWorldFlipped, new float3(directionVS.xy, -directionVS.z)), + range, + math.clamp(spotAngle, 1f, 179f))); + } + return scene; + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs.meta new file mode 100644 index 00000000000..6057bf525ac --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringOracle.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d77e88cab17104a5989b830dcd178107 \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringTests.cs index 380eec13214..dd4cd30b5d5 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/LightClusteringTests.cs @@ -1,611 +1,177 @@ -// Unit tests for light clustering code used in Forward+ and Deferred+ rendering -// modes. +// Unit tests for light clustering code used in Forward+ and Deferred+ rendering modes. Each scene is checked against +// LightClusteringOracle: no light or probe may be missing from a tile or z-bin it reaches, and none may be in a tile or +// z-bin its volume stays clear of. +using System; using System.Collections.Generic; using NUnit.Framework; -using Unity.Collections; -using Unity.Jobs; using Unity.Mathematics; -using UnityEngine.Rendering.Universal.Internal; using UnityEngine.TestTools; namespace UnityEngine.Rendering.Universal.Tests { + [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] class LightClusteringTests { - [Description("The tiling job calculates an intersection between an XZ plane and the light volume to determine the range of tiles that the light affects. In the cases where this range falls completely outside of the screen, this test ensures that the ranges are clamped correctly to screen boundaries. If not tested, this bug affects the cone section of spot lights, the cap section of spot lights, and also point lights. This test was added due to UUM-84591.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_WhenLightVolumeIntersectionWithXZPlaneIsOutsideTheScreen_ZBinsAndTileMasksAreCorrect() - { - NativeArray lights = new(1, Allocator.TempJob); - // Light world transform: - // UnityEditor.TransformWorldPlacementJSON:{"position":{"x":3.0,"y":3.0,"z":0.0},"rotation":{"x":0.511572539806366,"y":0.3068491518497467,"z":-0.7767189145088196,"w":0.20210090279579163},"scale":{"x":1.0,"y":1.0,"z":1.0}} - lights[0] = new VisibleLight() - { - lightType = LightType.Spot, - finalColor = Color.white, - screenRect = new Rect(0, 0, 1, 1), - localToWorldMatrix = new Matrix4x4( - new Vector4(-0.394897342f, 0, -0.918725133f, 0), - new Vector4(0.627902389f, -0.729997516f, -0.269892514f, 0), - new Vector4(-0.670667171f, -0.683449626f, 0.288274288f, 0), - new Vector4(3, 3, 0, 1) - ), - range = 10, - spotAngle = 100, - intersectsNearPlane = true, - intersectsFarPlane = false, - }; - NativeArray probes = new(0, Allocator.TempJob); - NativeArray zBins = new(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); - NativeArray tileMasks = new (UniversalRenderPipeline.maxTileWords, Allocator.TempJob); + const float k_Diagonal = 0.57735026f; + const float k_Half = 0.70710677f; + static readonly int2 k_SmallScreen = new int2(64, 64); + static readonly int2 k_Screen = new int2(480, 270); - // Camera world transform: - // UnityEditor.TransformWorldPlacementJSON:{"position":{"x":-4.0,"y":1.0,"z":2.0},"rotation":{"x":0.32139381766319277,"y":0.663413941860199,"z":-0.3830222189426422,"w":0.5566704273223877},"scale":{"x":1.0,"y":1.0,"z":1.0}} - float4x4 worldToView = new float4x4( - new float4(-0.1736481f, 0.8528686f, -0.4924039f, 0f), - new float4(0f, 0.5f, 0.8660254f, 0f), - new float4(-0.9848078f, -0.1503837f, 0.08682406f, 0f), - new float4(1.275023f, 3.212242f, -3.009289f, 1f) - ); - var worldToViews = new Fixed2(worldToView, worldToView); - float4x4 viewToClip = new float4x4( - new float4(0.7968904f, 0f, 0f, 0f), - new float4(0f, 1.732051f, 0f, 0f), - new float4(0f, 0f, -1.0006f, -1f), - new float4(0f, 0f, -0.60018f, 0f) - ); - var viewToClips = new Fixed2(viewToClip, viewToClip); - int2 screenResolution = new(128, 128); - float nearPlane = 0.3f; - float farPlane = 1000f; + static ClusteringScene Perspective(float fovYDeg, float aspect, float near, float far, int2 screenSize, ClusteringItem itemVS) => + ClusteringScene.PerspectiveViewSpace(fovYDeg, aspect, near, far, screenSize, itemVS); - JobHandle handle = ForwardLights.ScheduleClusteringJobs( - false, - true, - lights, - probes, - zBins, - tileMasks, - worldToViews, - viewToClips, - 1, - screenResolution, - nearPlane, - farPlane, - false, - out int localLightCount, - out int directionalLightCount, - out int binCount, - out float zBinScale, - out float zBinOffset, - out int2 tileResolution, - out int actualTileWidth, - out int wordsPerTile - ); - JobHandle.ScheduleBatchedJobs(); - handle.Complete(); + static ClusteringScene Perspective(float p00, float p11, float2 lensShift, float near, float far, int2 screenSize, ClusteringItem itemVS) => + ClusteringScene.PerspectiveViewSpace(p00, p11, lensShift, near, far, screenSize, itemVS); - // Uncomment temporarily if the reference arrays need to be updated. - // Debug.Log(string.Join(",", zBins)); - // Debug.Log(string.Join(",", tileMasks)); + static ClusteringScene Orthographic(float halfWidth, float halfHeight, float near, float far, int2 screenSize, ClusteringItem itemVS) => + ClusteringScene.OrthographicViewSpace(halfWidth, halfHeight, near, far, screenSize, itemVS); - // If the following assertions fail, there isn't currently good - // tooling to visualize the difference. A 3D texture slice viewer - // can be built that would fix this issue. But the cost-benefit is - // not worth it at the moment, since the diff of a PR that fails - // this test can be enough to go on. - // - // Also, these assertions can fail if a change is made includes more - // false positives, i.e. lights contributing to _more_ clusters than - // expected due to increased conservatism, or lights contributing to - // _less_ clusters due increased accuracy. In either of these cases, - // it is up to the author of these code changes to update the - // expected values. - CollectionAssert.AreEqual(expectedZBins1, zBins); - CollectionAssert.AreEqual(expectedTileMasks1, tileMasks); + static TestCaseData Case(string name, string description, ClusteringScene scene) => + new TestCaseData(scene).SetName($"LightClustering_IsExact({name})").SetDescription(description); - lights.Dispose(); - probes.Dispose(); - zBins.Dispose(); - tileMasks.Dispose(); - } - - // Identity world-to-view, 90-degree FOV; tiling negates view Z, so view (x, y, z) is world (x, y, -z). - static bool PointLightCoversTile(float3 lightPositionVS, float range, int2 tile) + static IEnumerable ExactScenes() { - var lights = new NativeArray(1, Allocator.TempJob); - lights[0] = new VisibleLight() { - lightType = LightType.Point, - finalColor = Color.white, - screenRect = new Rect(0, 0, 1, 1), - localToWorldMatrix = new Matrix4x4( - new Vector4(1, 0, 0, 0), - new Vector4(0, 1, 0, 0), - new Vector4(0, 0, 1, 0), - new Vector4(lightPositionVS.x, lightPositionVS.y, -lightPositionVS.z, 1) - ), - range = range, - spotAngle = 0, - intersectsNearPlane = true, - intersectsFarPlane = false, - }; - var probes = new NativeArray(0, Allocator.TempJob); - var zBins = new NativeArray(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); - var tileMasks = new NativeArray(UniversalRenderPipeline.maxTileWords, Allocator.TempJob); - - var worldToView = float4x4.identity; - var worldToViews = new Fixed2(worldToView, worldToView); - - const float near = 0.5f; - const float far = 100f; - float p22 = -(far + near) / (far - near); - float p23 = -(2f * far * near) / (far - near); - var viewToClip = new float4x4( - new float4(1, 0, 0, 0), - new float4(0, 1, 0, 0), - new float4(0, 0, p22, -1), - new float4(0, 0, p23, 0) - ); - var viewToClips = new Fixed2(viewToClip, viewToClip); - int2 screenResolution = new(64, 64); - - JobHandle handle = ForwardLights.ScheduleClusteringJobs( - false, true, lights, probes, zBins, tileMasks, - worldToViews, viewToClips, 1, screenResolution, near, far, false, - out _, out _, out _, out _, out _, out int2 tileResolution, out _, out int wordsPerTile); - JobHandle.ScheduleBatchedJobs(); - handle.Complete(); - - int maskIndex = (tile.y * tileResolution.x + tile.x) * wordsPerTile; - bool covered = (tileMasks[maskIndex] & 1u) != 0u; - - lights.Dispose(); - probes.Dispose(); - zBins.Dispose(); - tileMasks.Dispose(); - return covered; - } - - [Description("A point light crossing the near plane covers the tile at its horizon extreme.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_PointLightCrossingNearPlane_CoversHorizonTileInFrontOfNear() - { - Assert.IsTrue( - PointLightCoversTile(new float3(1.6040f, -1.6087f, 0.8924f), 1.2312f, new int2(7, 2)), - "Tile (7,2) is covered by the light volume but is missing from the tile mask."); - } - - [Description("A point light above the frustum covers the edge tile row.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_PointLightOutsideFrustumVertically_CoversEdgeRowTile() - { - Assert.IsTrue( - PointLightCoversTile(new float3(-4.4307f, 7.2440f, 5.7363f), 1.9306f, new int2(0, 7)), - "Edge-row tile (0,7) is covered by the light volume but is missing from the tile mask."); - } + var scene = new ClusteringScene { near = 0.3f, far = 1000f, screenSize = new int2(128, 128) }; + scene.worldToViews[0] = scene.worldToViews[1] = new float4x4( + new float4(-0.1736481f, 0.8528686f, -0.4924039f, 0f), + new float4(0f, 0.5f, 0.8660254f, 0f), + new float4(-0.9848078f, -0.1503837f, 0.08682406f, 0f), + new float4(1.275023f, 3.212242f, -3.009289f, 1f)); + scene.viewToClips[0] = scene.viewToClips[1] = ClusteringScene.Perspective(0.7968904f, 1.732051f, float2.zero, scene.near, scene.far); + scene.items.Add(ClusteringItem.Spot(new float3(3f, 3f, 0f), new float3(-0.670667171f, -0.683449626f, 0.288274288f), 10f, 100f)); + yield return Case("SpotRangeOutsideScreenInXZPlane", "A spot light whose intersection with an XZ plane falls outside the screen (UUM-84591).", scene); + } - // Identity world-to-view; tiling negates view Z, so view (x, y, z) is world (x, y, -z). - static bool SpotLightCoversTile(float fovYDeg, float aspect, float near, float3 posVS, float3 dirVS, float range, float spotAngle, int2 tile, int2? screenSize = null) - { - var lights = new NativeArray(1, Allocator.TempJob); - lights[0] = new VisibleLight() + yield return Case("PointLightCrossingNearPlane", "A point light crossing the near plane.", + Perspective(1f, 1f, float2.zero, 0.5f, 100f, k_SmallScreen, ClusteringItem.Point(new float3(1.604f, -1.6087f, 0.8924f), 1.2312f))); + yield return Case("PointLightAboveFrustum", "A point light above the frustum reaching the top tile row.", + Perspective(1f, 1f, float2.zero, 0.5f, 100f, k_SmallScreen, ClusteringItem.Point(new float3(-4.4307f, 7.244f, 5.7363f), 1.9306f))); + yield return Case("PointLightInFrontOfCamera", "A point light in front of the camera.", + Perspective(1f, 1f, float2.zero, 0.5f, 100f, k_SmallScreen, ClusteringItem.Point(new float3(0.3f, 0.2f, 5f), 1.3f))); + yield return Case("PointLightCrossingFarPlane", "A point light crossing the far plane.", + Perspective(60f, 16f / 9f, 0.3f, 27f, k_Screen, ClusteringItem.Point(new float3(0.5f, 0.3f, 30f), 5f))); + yield return Case("PointLightCrossingNearPlaneOffCenter", "A point light crossing the near plane whose vertical extent on screen comes from its section with the near plane.", + Perspective(0.7515261f, 1.1239314f, new float2(-0.35771352f, 0.24809685f), 0.6553464f, 2306.9248f, new int2(250, 141), ClusteringItem.Point(new float3(-5.5001135f, -5.4904704f, 0.96593094f), 6.838029f))); + yield return Case("PointLightFarOffScreenNearCamera", "A point light so far to the side of a camera with a close near plane that its tile coordinates exceed the 16-bit range of the tile ranges.", + Perspective(60f, 16f / 9f, 0.01f, 1000f, k_Screen, ClusteringItem.Point(new float3(22f, 0f, 0.3f), 0.35f))); + yield return Case("PointLightBehindCamera", "A point light entirely behind the camera is in no tile or z-bin.", + Perspective(60f, 16f / 9f, 0.3f, 1000f, k_Screen, ClusteringItem.Point(new float3(0f, 0f, -5f), 2f))); + + yield return Case("SpotLightInFrontOfNearPlane", "A spot light in front of the near plane.", + Perspective(72.032f, 1.3333f, 0.412f, 1000f, k_SmallScreen, ClusteringItem.Spot(new float3(1.5852f, -1.4977f, 6.9015f), new float3(-0.1672f, -0.2562f, 0.952f), 2.227f, 75.974f))); + yield return Case("SpotLightCrossingNearPlane", "A spot light crossing the near plane.", + Perspective(58.88f, 1.3333f, 0.461f, 1000f, k_SmallScreen, ClusteringItem.Spot(new float3(0.447f, 1.0636f, 1.4462f), new float3(0.011f, -0.121f, 0.9926f), 2.017f, 112.675f))); + yield return Case("SpotSilhouetteOffScreenEdge", "A spot light whose silhouette leaves the screen.", + Perspective(86.3651f, 0.9666f, 0.357f, 1000f, k_SmallScreen, ClusteringItem.Spot(new float3(-0.008f, -0.1112f, -2.0052f), new float3(-0.9652f, -0.1627f, 0.2046f), 4.0016f, 66.8309f))); + yield return Case("SpotVertexInCameraPlane", "A spot light whose vertex lies in the camera plane (UUM-154016).", + Perspective(60f, 16f / 9f, 0.3f, 1000f, k_Screen, ClusteringItem.Spot(new float3(-4.8e-7f, -0.2f, 0f), new float3(3.7e-9f, 0f, 1f), 50f, 55f))); + yield return Case("SpotBehindCameraAlongViewAxis", "A spot light behind the camera whose axis is the view direction (UUM-159132).", + Perspective(60f, 989f / 485f, 0.3f, 1000f, new int2(989, 485), ClusteringItem.Spot(new float3(0.25f, 0f, -2f), new float3(0f, 0f, 1f), 6f, 30f))); + yield return Case("SpotAxisAt45DegreesInXZ", "A spot light whose axis is at exactly 45 degrees in the XZ plane.", + Perspective(0.89631605f, 1.0262334f, float2.zero, 0.11539972f, 1000f, k_Screen, ClusteringItem.Spot(new float3(0f, 0f, 12.25f), new float3(k_Half, 0f, k_Half), 40f, 90f))); + yield return Case("SpotAxisAlongViewDiagonal", "A spot light whose axis is the view-space diagonal (1, 1, 1).", + Perspective(0.44447416f, 0.85071206f, float2.zero, 0.78974074f, 1000f, k_Screen, ClusteringItem.Spot(new float3(-4.25f, 0.25f, 0f), new float3(k_Diagonal, k_Diagonal, k_Diagonal), 5f, 45f))); + yield return Case("SpotVertexOnNearPlane", "A wide spot light whose vertex lies on the near plane.", + Perspective(0.45082957f, 1.0431756f, float2.zero, 0.8158224f, 1000f, k_Screen, ClusteringItem.Spot(new float3(3f, -0.5f, 0.8158224f), new float3(0f, k_Half, k_Half), 6f, 110f))); + yield return Case("SpotVertexJustBehindNearPlane", "A nearly hemispherical spot light whose vertex lies just behind the near plane.", + Perspective(0.5678351f, 1.0830803f, float2.zero, 0.3802336f, 1000f, k_Screen, ClusteringItem.Spot(new float3(24.75f, -35.25f, 0.37797466f), new float3(k_Half, k_Half, 0f), 55f, 179f))); + yield return Case("SpotWithUnboundedNearPlaneSection", "A spot light whose section with the near plane has no finite extremes.", + Perspective(0.8330596f, 1.219217f, new float2(-0.2787532f, 0.22271621f), 0.50425756f, 1000f, k_Screen, ClusteringItem.Spot(new float3(0f, 0f, 0.25f), new float3(k_Diagonal, k_Diagonal, k_Diagonal), 10f, 109.47122f))); + yield return Case("SpotLightCrossingFarPlane", "A spot light crossing the far plane.", + Perspective(60f, 16f / 9f, 0.3f, 25f, k_Screen, ClusteringItem.Spot(new float3(0.5f, 0.3f, 20f), new float3(0f, 0f, 1f), 15f, 60f))); { - lightType = LightType.Spot, - finalColor = Color.white, - screenRect = new Rect(0, 0, 1, 1), - localToWorldMatrix = new Matrix4x4( - new Vector4(1, 0, 0, 0), - new Vector4(0, 1, 0, 0), - new Vector4(dirVS.x, dirVS.y, -dirVS.z, 0), - new Vector4(posVS.x, posVS.y, -posVS.z, 1) - ), - range = range, - spotAngle = spotAngle, - intersectsNearPlane = true, - intersectsFarPlane = false, - }; - var probes = new NativeArray(0, Allocator.TempJob); - var zBins = new NativeArray(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); - var tileMasks = new NativeArray(UniversalRenderPipeline.maxTileWords, Allocator.TempJob); - - var worldToView = float4x4.identity; - var worldToViews = new Fixed2(worldToView, worldToView); - - const float far = 1000f; - float p11 = 1f / math.tan(math.radians(fovYDeg) * 0.5f); - float p00 = p11 / aspect; - var viewToClip = new float4x4( - new float4(p00, 0, 0, 0), - new float4(0, p11, 0, 0), - new float4(0, 0, -(far + near) / (far - near), -1), - new float4(0, 0, -(2f * far * near) / (far - near), 0) - ); - var viewToClips = new Fixed2(viewToClip, viewToClip); - int2 screenResolution = screenSize ?? new int2(64, 64); - - JobHandle handle = ForwardLights.ScheduleClusteringJobs( - false, true, lights, probes, zBins, tileMasks, - worldToViews, viewToClips, 1, screenResolution, near, far, false, - out _, out _, out _, out _, out _, out int2 tileResolution, out _, out int wordsPerTile); - JobHandle.ScheduleBatchedJobs(); - handle.Complete(); - - int maskIndex = (tile.y * tileResolution.x + tile.x) * wordsPerTile; - bool covered = (tileMasks[maskIndex] & 1u) != 0u; + var scene = new ClusteringScene { near = 0.54576063f, far = 1000f, screenSize = new int2(160, 90) }; + scene.worldToViews[0] = scene.worldToViews[1] = new float4x4( + new float4(-0.1186f, -0.44585413f, 0.8872137f, 0f), + new float4(0.22589295f, 0.85797536f, 0.46135753f, 0f), + new float4(0.9669056f, -0.25513235f, 0.0010405704f, 0f), + new float4(19.057278f, -13.34542f, -38.808697f, 1f)); + scene.viewToClips[0] = scene.viewToClips[1] = ClusteringScene.Perspective(1.2988923f, 2.8259869f, new float2(0.19827574f, -0.04960227f), scene.near, scene.far); + scene.items.Add(ClusteringItem.Spot(new float3(30.4875f, 25.492296f, -1.2410641f), new float3(-0.11860001f, 0.22589296f, 0.9669056f), 33f, 179f)); + yield return Case("SpotBaseCircleAroundCamera", "A wide spot light whose base circle surrounds the camera in a side view.", scene); + } - lights.Dispose(); - probes.Dispose(); - zBins.Dispose(); - tileMasks.Dispose(); - return covered; - } + yield return Case("ReflectionProbeCrossingFarPlane", "A reflection probe crossing the far plane.", + Perspective(60f, 16f / 9f, 0.3f, 28f, k_Screen, ClusteringItem.Probe(new float3(20f, 0f, 30f), new float3(5f, 5f, 5f), quaternion.identity))); + yield return Case("ReflectionProbeBehindCamera", "A reflection probe entirely behind the camera is in no tile or z-bin.", + Perspective(60f, 16f / 9f, 0.3f, 1000f, k_Screen, ClusteringItem.Probe(new float3(0f, 0f, -5f), new float3(1f, 1f, 1f), quaternion.identity))); - [Description("A spot light in front of the near plane covers a tile inside its cone.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_SpotLightInFrontOfNear_CoversInteriorTile() - { - Assert.IsTrue( - SpotLightCoversTile(72.032f, 1.3333f, 0.412f, new float3(1.5852f, -1.4977f, 6.9015f), new float3(-0.1672f, -0.2562f, 0.9520f), 2.227f, 75.974f, new int2(4, 2)), - "Spot cone covers tile (4,2) but it is missing from the tile mask."); + yield return Case("OrthographicPointLightCentered", "An orthographic point light.", + Orthographic(4f, 4f, 0.5f, 100f, k_SmallScreen, ClusteringItem.Point(new float3(0.3f, 0.2f, 5f), 1.3f))); + yield return Case("OrthographicPointLightOffLeftEdge", "An orthographic point light partly off the left screen edge.", + Orthographic(4f, 4f, 0.5f, 100f, k_SmallScreen, ClusteringItem.Point(new float3(-5f, -3.5f, 5f), 1.1f))); + yield return Case("OrthographicPointLightAtNegativeDepth", "An orthographic point light at negative depth with a negative near plane.", + Orthographic(6f, 6f, -5f, 10f, k_SmallScreen, ClusteringItem.Point(new float3(0f, 0f, -2f), 1f))); + yield return Case("OrthographicPointLightCrossingNearPlane", "An orthographic point light crossing the near plane.", + Orthographic(8f, 4.5f, 1f, 100f, k_Screen, ClusteringItem.Point(new float3(0.5f, 0.3f, 0f), 2f))); + yield return Case("OrthographicSpotOffRightEdge", "An orthographic spot light off the right screen edge.", + Orthographic(0.5184f * 11.7982f, 11.7982f, 0.4803f, 1000f, k_SmallScreen, ClusteringItem.Spot(new float3(6.6041f, 6.1272f, 2.8334f), new float3(-0.4904f, 0.868f, -0.0783f), 2.6565f, 56.2812f))); + yield return Case("OrthographicSpotCrossingNearAndFarPlanes", "An orthographic spot light crossing the near and far planes.", + Orthographic(8f, 4.5f, 1f, 4f, k_Screen, ClusteringItem.Spot(new float3(-3f, 0.3f, -1f), new float3(k_Half, 0f, k_Half), 9f, 60f))); + yield return Case("OrthographicReflectionProbeOnTileBoundaries", "An orthographic axis-aligned reflection probe whose edges lie on tile boundaries.", + Orthographic(4f, 4f, 0.5f, 100f, k_SmallScreen, ClusteringItem.Probe(new float3(0f, 0f, 5f), new float3(1f, 2f, 1f), quaternion.identity))); } - [Description("A spot light crossing the near plane covers a tile inside its cone.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_SpotLightCrossingNear_CoversInteriorTile() + [TestCaseSource(nameof(ExactScenes))] + public void LightClustering_IsExact(ClusteringScene scene) { - Assert.IsTrue( - SpotLightCoversTile(58.880f, 1.3333f, 0.461f, new float3(0.4470f, 1.0636f, 1.4462f), new float3(0.0110f, -0.1210f, 0.9926f), 2.017f, 112.675f, new int2(4, 6)), - "Spot cone covers tile (4,6) but it is missing from the tile mask."); + var result = LightClusteringOracle.Check(scene); + if (result.failed) + Assert.Fail($"{result}{scene}"); } - [Description("A spot light whose vertex lies in the camera plane covers the tiles along both sides of its cone.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] + [Description("The horizon of a projected circle is missing, not a far-away point, when the camera is inside the ellipse.")] [Test] - public void LightClustering_SpotVertexInCameraPlane_CoversConeSideTiles() + public void LightClustering_ProjectedCircleHorizonAroundCamera_IsMissing() { - var posVS = new float3(-4.8e-7f, -0.2f, 0f); - var dirVS = new float3(3.7e-9f, 0f, 1f); - var screenSize = new int2(480, 270); - Assert.IsTrue( - SpotLightCoversTile(60f, 16f / 9f, 0.3f, posVS, dirVS, 50f, 55f, new int2(16, 6), screenSize), - "Spot cone covers tile (16,6) but it is missing from the tile mask."); - Assert.IsTrue( - SpotLightCoversTile(60f, 16f / 9f, 0.3f, posVS, dirVS, 50f, 55f, new int2(43, 6), screenSize), - "Spot cone covers tile (43,6) but it is missing from the tile mask."); + // A cone base circle facing the camera sideways, with the camera inside its projection onto the YZ plane. + TilingJob.GetProjectedCircleHorizon(new float2(-4.750001f, 2.279692E-09f), 32.998745f, new float2(1f, 0f), new float2(0f, 1f), out var uv1, out var uv2); + Assert.IsTrue(math.any(math.isnan(uv1)) && math.any(math.isnan(uv2)), $"Expected no horizon, got {uv1} and {uv2}."); } - [Description("A spot light whose silhouette leaves the screen does not cover the edge column.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] + [Description("Cone section points are accepted on or inside the cone up to its base, and rejected outside its angle, which degenerate sections can produce.")] [Test] - public void LightClustering_SpotSilhouetteOffScreenEdge_DoesNotOverCoverEdgeColumn() - { - Assert.IsFalse( - SpotLightCoversTile(86.3651f, 0.9666f, 0.3570f, new float3(-0.0080f, -0.1112f, -2.0052f), new float3(-0.9652f, -0.1627f, 0.2046f), 4.0016f, 66.8309f, new int2(0, 1)), - "Edge-column tile (0,1) is outside the spot cone but was marked (edge over-coverage)."); - } - - // Orthographic camera; half-width = aspect * orthoHalfHeight. - static bool OrthoSpotLightCoversTile(float orthoHalfHeight, float aspect, float near, float3 posVS, float3 dirVS, float range, float spotAngle, int2 tile) - { - var lights = new NativeArray(1, Allocator.TempJob); - lights[0] = new VisibleLight() - { - lightType = LightType.Spot, - finalColor = Color.white, - screenRect = new Rect(0, 0, 1, 1), - localToWorldMatrix = new Matrix4x4( - new Vector4(1, 0, 0, 0), - new Vector4(0, 1, 0, 0), - new Vector4(dirVS.x, dirVS.y, -dirVS.z, 0), - new Vector4(posVS.x, posVS.y, -posVS.z, 1) - ), - range = range, - spotAngle = spotAngle, - intersectsNearPlane = true, - intersectsFarPlane = false, - }; - var probes = new NativeArray(0, Allocator.TempJob); - var zBins = new NativeArray(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); - var tileMasks = new NativeArray(UniversalRenderPipeline.maxTileWords, Allocator.TempJob); - - var worldToView = float4x4.identity; - var worldToViews = new Fixed2(worldToView, worldToView); - - const float far = 1000f; - float p00 = 1f / (aspect * orthoHalfHeight); - float p11 = 1f / orthoHalfHeight; - var viewToClip = new float4x4( - new float4(p00, 0, 0, 0), - new float4(0, p11, 0, 0), - new float4(0, 0, -2f / (far - near), 0), - new float4(0, 0, -(far + near) / (far - near), 1) - ); - var viewToClips = new Fixed2(viewToClip, viewToClip); - int2 screenResolution = new(64, 64); - - JobHandle handle = ForwardLights.ScheduleClusteringJobs( - false, true, lights, probes, zBins, tileMasks, - worldToViews, viewToClips, 1, screenResolution, near, far, true, - out _, out _, out _, out _, out _, out int2 tileResolution, out _, out int wordsPerTile); - JobHandle.ScheduleBatchedJobs(); - handle.Complete(); - - int maskIndex = (tile.y * tileResolution.x + tile.x) * wordsPerTile; - bool covered = (tileMasks[maskIndex] & 1u) != 0u; - - lights.Dispose(); - probes.Dispose(); - zBins.Dispose(); - tileMasks.Dispose(); - return covered; - } - - [Description("An orthographic spot light off the right screen edge covers the edge tile.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] + public void LightClustering_ConeSectionPointCheck_RejectsPointsOutsideTheCone() + { + var vertex = new float3(1f, 2f, 3f); + var axis = math.normalize(new float3(0.3f, -0.2f, 1f)); + var halfAngle = math.radians(20f); + var cosHalfAngle = math.cos(halfAngle); + var sinHalfAngle = math.sin(halfAngle); + const float range = 10f; + var coneHeight = range * cosHalfAngle; + var tolerance = 1e-5f * (math.length(vertex) + range); + var side = math.normalize(math.cross(axis, new float3(1f, 0f, 0f))); + bool IsOnCone(float angle, float distance) => + TilingJob.IsOnCone(vertex + (math.cos(angle) * axis + math.sin(angle) * side) * distance, vertex, axis, cosHalfAngle, sinHalfAngle, coneHeight, tolerance); + + Assert.IsTrue(IsOnCone(halfAngle, 5f), "A point on the cone was rejected."); + Assert.IsTrue(IsOnCone(0f, 5f), "A point on the axis was rejected."); + Assert.IsFalse(IsOnCone(halfAngle + math.radians(10f), 5f), "A point outside the cone angle was accepted."); + Assert.IsFalse(IsOnCone(halfAngle, 0.5f * range / cosHalfAngle + range), "A point beyond the cone base was accepted."); + Assert.IsFalse(IsOnCone(math.PI - halfAngle, 5f), "A point on the opposite nappe was accepted."); + } + + [Description("Randomized check of light clustering on scenes biased towards degenerate configurations. The scenes depend on floating-point math that can differ between platforms, so this is not deterministic and is run manually. Configure it with URP_LIGHT_CLUSTERING_FUZZ_COUNT, URP_LIGHT_CLUSTERING_FUZZ_SEED and URP_LIGHT_CLUSTERING_FUZZ_MAX_ITEMS.")] + [Explicit("Randomized and not deterministic across platforms; run manually.")] [Test] - public void LightClustering_OrthographicSpotOffRightEdge_CoversEdgeTile() - { - Assert.IsTrue( - OrthoSpotLightCoversTile(11.7982f, 0.5184f, 0.4803f, new float3(6.6041f, 6.1272f, 2.8334f), new float3(-0.4904f, 0.868f, -0.0783f), 2.6565f, 56.2812f, new int2(7, 6)), - "Orthographic spot covers tile (7,6) but it is missing from the tile mask."); - } - - // Orthographic camera; returns whether the z-bin at view depth viewZ contains the light. - static bool OrthoPointLightCoversZBinAtDepth(float3 lightPositionVS, float range, float near, float far, float viewZ) - { - var lights = new NativeArray(1, Allocator.TempJob); - lights[0] = new VisibleLight() + public void LightClustering_RandomScenes_AreExact() + { + static int Read(string name, int fallback) => int.TryParse(Environment.GetEnvironmentVariable(name), out var value) ? value : fallback; + var seed = (uint)Read("URP_LIGHT_CLUSTERING_FUZZ_SEED", 1); + var count = Read("URP_LIGHT_CLUSTERING_FUZZ_COUNT", 1000); + var maxItems = Read("URP_LIGHT_CLUSTERING_FUZZ_MAX_ITEMS", 40); + var screenSizes = new[] { new int2(160, 90), new int2(250, 141), new int2(97, 203), new int2(64, 64) }; + var rng = new Unity.Mathematics.Random(seed); + for (var i = 0; i < count; i++) { - lightType = LightType.Point, - finalColor = Color.white, - screenRect = new Rect(0, 0, 1, 1), - localToWorldMatrix = new Matrix4x4( - new Vector4(1, 0, 0, 0), - new Vector4(0, 1, 0, 0), - new Vector4(0, 0, 1, 0), - new Vector4(lightPositionVS.x, lightPositionVS.y, -lightPositionVS.z, 1) - ), - range = range, - spotAngle = 0, - intersectsNearPlane = true, - intersectsFarPlane = false, - }; - var probes = new NativeArray(0, Allocator.TempJob); - var zBins = new NativeArray(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); - var tileMasks = new NativeArray(UniversalRenderPipeline.maxTileWords, Allocator.TempJob); - - var worldToView = float4x4.identity; - var worldToViews = new Fixed2(worldToView, worldToView); - - // Only the half-size and center terms are read by the tiling setup. - const float halfSize = 6f; - var viewToClip = new float4x4( - new float4(1f / halfSize, 0, 0, 0), - new float4(0, 1f / halfSize, 0, 0), - new float4(0, 0, -2f / (far - near), 0), - new float4(0, 0, -(far + near) / (far - near), 1) - ); - var viewToClips = new Fixed2(viewToClip, viewToClip); - int2 screenResolution = new(64, 64); - - JobHandle handle = ForwardLights.ScheduleClusteringJobs( - false, true, lights, probes, zBins, tileMasks, - worldToViews, viewToClips, 1, screenResolution, near, far, true, - out _, out _, out _, out float zBinScale, out float zBinOffset, out _, out _, out int wordsPerTile); - JobHandle.ScheduleBatchedJobs(); - handle.Complete(); - - // Orthographic z-bin index is linear in view-space Z (matches the shader). - int binIndex = (int)(viewZ * zBinScale + zBinOffset); - int stride = 2 + wordsPerTile; // 2 header words + bitmask words - bool covered = (zBins[binIndex * stride + 2] & 1u) != 0u; - - lights.Dispose(); - probes.Dispose(); - zBins.Dispose(); - tileMasks.Dispose(); - return covered; - } - - [Description("With a negative orthographic near plane, a light at negative depth is in its z-bin.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_OrthographicNegativeNearPlane_PointLightCoversZBinAtItsDepth() - { - Assert.IsTrue( - OrthoPointLightCoversZBinAtDepth(new float3(0f, 0f, -2f), 1f, -5f, 10f, -2f), - "Light at view-space Z -2 is missing from the z-bin at depth -2 (negative near plane)."); - } - - // Identity world-to-view, 64x64 screen (8x8 tiles), square view plane of half-size halfSize (at Z=1 for - // perspective); tiling negates view Z, so view (x, y, z) is world (x, y, -z). Returns item 0's tile coverage. - static bool[,] ComputeTileCoverage(NativeArray lights, NativeArray probes, bool orthographic, float halfSize) - { - var zBins = new NativeArray(UniversalRenderPipeline.maxZBinWords, Allocator.TempJob); - var tileMasks = new NativeArray(UniversalRenderPipeline.maxTileWords, Allocator.TempJob); - var worldToViews = new Fixed2(float4x4.identity, float4x4.identity); - - const float near = 0.5f; - const float far = 100f; - var viewToClip = orthographic - ? new float4x4( - new float4(1f / halfSize, 0, 0, 0), - new float4(0, 1f / halfSize, 0, 0), - new float4(0, 0, -2f / (far - near), 0), - new float4(0, 0, -(far + near) / (far - near), 1)) - : new float4x4( - new float4(1f / halfSize, 0, 0, 0), - new float4(0, 1f / halfSize, 0, 0), - new float4(0, 0, -(far + near) / (far - near), -1), - new float4(0, 0, -(2f * far * near) / (far - near), 0)); - var viewToClips = new Fixed2(viewToClip, viewToClip); - - JobHandle handle = ForwardLights.ScheduleClusteringJobs( - false, true, lights, probes, zBins, tileMasks, - worldToViews, viewToClips, 1, new int2(64, 64), near, far, orthographic, - out _, out _, out _, out _, out _, out int2 tileResolution, out _, out int wordsPerTile); - JobHandle.ScheduleBatchedJobs(); - handle.Complete(); - - var coverage = new bool[tileResolution.x, tileResolution.y]; - for (var y = 0; y < tileResolution.y; y++) - for (var x = 0; x < tileResolution.x; x++) - coverage[x, y] = (tileMasks[(y * tileResolution.x + x) * wordsPerTile] & 1u) != 0u; - - zBins.Dispose(); - tileMasks.Dispose(); - return coverage; - } - - static bool[,] ComputePointLightTileCoverage(float3 lightPositionVS, float range, bool orthographic, float halfSize) - { - var lights = new NativeArray(1, Allocator.TempJob); - lights[0] = new VisibleLight() - { - lightType = LightType.Point, - finalColor = Color.white, - screenRect = new Rect(0, 0, 1, 1), - localToWorldMatrix = Matrix4x4.Translate(new Vector3(lightPositionVS.x, lightPositionVS.y, -lightPositionVS.z)), - range = range, - spotAngle = 0, - intersectsNearPlane = false, - intersectsFarPlane = false, - }; - var probes = new NativeArray(0, Allocator.TempJob); - try - { - return ComputeTileCoverage(lights, probes, orthographic, halfSize); - } - finally - { - lights.Dispose(); - probes.Dispose(); + var scene = LightClusteringOracle.RandomScene(ref rng, screenSizes[i % screenSizes.Length], maxItems); + var result = LightClusteringOracle.Check(scene); + if (result.failed) + Assert.Fail($"Scene {i} (seed {seed}, max items {maxItems}):\n{result}{scene}"); } } - - static string FormatTiles(List tiles) => string.Join(", ", tiles.ConvertAll(t => $"({t.x},{t.y})")); - - // The orthographic footprint of a point light is a disk, so the exact set of tiles it overlaps is known. - [Description("An orthographic point light covers exactly the tiles its disk overlaps.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [TestCase(0.3f, 0.2f, 1.3f, TestName = "LightClustering_OrthographicPointLight_CoversExactlyItsDiskTiles(Centered)")] - [TestCase(-5f, -3.5f, 1.1f, TestName = "LightClustering_OrthographicPointLight_CoversExactlyItsDiskTiles(OffLeftEdge)")] - public void LightClustering_OrthographicPointLight_CoversExactlyItsDiskTiles(float x, float y, float range) - { - const float halfSize = 4f; - var coverage = ComputePointLightTileCoverage(new float3(x, y, 5f), range, true, halfSize); - - // A tile the disk only touches (zero-area overlap) may go either way, depending on float rounding. - const float tangentTolerance = 1e-4f; - var tileSize = 2f * halfSize / coverage.GetLength(0); - var missing = new List(); - var extra = new List(); - for (var ty = 0; ty < coverage.GetLength(1); ty++) - { - for (var tx = 0; tx < coverage.GetLength(0); tx++) - { - var tileMin = -halfSize + tileSize * new float2(tx, ty); - var closest = math.clamp(new float2(x, y), tileMin, tileMin + tileSize); - var distance = math.distance(closest, new float2(x, y)); - if (distance < range - tangentTolerance && !coverage[tx, ty]) missing.Add(new int2(tx, ty)); - if (distance > range + tangentTolerance && coverage[tx, ty]) extra.Add(new int2(tx, ty)); - } - } - - Assert.IsEmpty(missing, $"Tiles overlapped by the light are not covered: {FormatTiles(missing)}"); - Assert.IsEmpty(extra, $"Tiles outside the light are covered: {FormatTiles(extra)}"); - } - - [Description("A perspective point light covers no tile outside its projected screen-space bounds.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_PerspectivePointLight_CoversNoTileOutsideItsProjectedBounds() - { - const float halfSize = 1f; - var position = new float3(0.3f, 0.2f, 5f); - const float range = 1.3f; - var coverage = ComputePointLightTileCoverage(position, range, false, halfSize); - - // Tangent lines from the eye bound the sphere's projection on each axis. - float2 ProjectedTileBounds(float lateral, float tileCount) - { - var angle = math.atan2(lateral, position.z); - var halfAngle = math.asin(range / math.length(new float2(lateral, position.z))); - var ndc = math.tan(new float2(angle - halfAngle, angle + halfAngle)) / halfSize; - return math.floor((ndc * 0.5f + 0.5f) * tileCount); - } - var boundsX = ProjectedTileBounds(position.x, coverage.GetLength(0)); - var boundsY = ProjectedTileBounds(position.y, coverage.GetLength(1)); - - var extra = new List(); - for (var ty = 0; ty < coverage.GetLength(1); ty++) - for (var tx = 0; tx < coverage.GetLength(0); tx++) - if (coverage[tx, ty] && (tx < boundsX.x || tx > boundsX.y || ty < boundsY.x || ty > boundsY.y)) - extra.Add(new int2(tx, ty)); - - Assert.IsTrue(coverage[4, 4], "The tile containing the light center is not covered."); - Assert.IsEmpty(extra, $"Tiles outside the light's projected bounds are covered: {FormatTiles(extra)}"); - } - - // Horizontal hull edges lying exactly on tile row boundaries hit the 0/0 case of the edge-plane intersection. - [Description("An orthographic axis-aligned reflection probe with edges on tile boundaries covers no tile outside its bounds.")] - [UnityPlatform(include = new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.WindowsPlayer, RuntimePlatform.OSXEditor, RuntimePlatform.OSXPlayer })] - [Test] - public void LightClustering_OrthographicReflectionProbeOnTileBoundaries_CoversNoTileOutsideItsBounds() - { - const float halfSize = 4f; - var center = new float3(0f, 0f, 5f); - var extents = new float3(1f, 2f, 1f); - - var lights = new NativeArray(0, Allocator.TempJob); - var probes = new NativeArray(1, Allocator.TempJob); - probes[0] = new VisibleReflectionProbe() - { - bounds = new Bounds(new Vector3(center.x, center.y, -center.z), 2f * (Vector3)extents), - localToWorldMatrix = Matrix4x4.Translate(new Vector3(center.x, center.y, -center.z)), - }; - bool[,] coverage; - try - { - coverage = ComputeTileCoverage(lights, probes, true, halfSize); - } - finally - { - lights.Dispose(); - probes.Dispose(); - } - - // Closed bounds: a tile that only touches the probe along a tile boundary may be covered. - var tileCount = new float2(coverage.GetLength(0), coverage.GetLength(1)); - var boundsMin = math.ceil(((center.xy - extents.xy) / halfSize * 0.5f + 0.5f) * tileCount) - 1f; - var boundsMax = math.floor(((center.xy + extents.xy) / halfSize * 0.5f + 0.5f) * tileCount); - - var extra = new List(); - for (var ty = 0; ty < coverage.GetLength(1); ty++) - for (var tx = 0; tx < coverage.GetLength(0); tx++) - if (coverage[tx, ty] && (tx < boundsMin.x || tx > boundsMax.x || ty < boundsMin.y || ty > boundsMax.y)) - extra.Add(new int2(tx, ty)); - - Assert.IsTrue(coverage[3, 3], "A tile inside the probe is not covered."); - Assert.IsEmpty(extra, $"Tiles outside the probe bounds are covered: {FormatTiles(extra)}"); - } - - static readonly uint[] expectedZBins1 = - { - 0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,0,65535,1,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,65535,65535,0,0 - }; - - static readonly uint[] expectedTileMasks1 = - { - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; - } } From 34d36a42f266bb023017e1e315432a5142f13da0 Mon Sep 17 00:00:00 2001 From: Marta Malberti Date: Tue, 3 Nov 2026 10:35:21 +0000 Subject: [PATCH 12/61] [Port] [6000.7] [DOCG-9272] Custom 2D light and shadow material docs --- .../Documentation~/Input-Nodes.md | 6 +++ .../Documentation~/TableOfContents.md | 2 + .../active-shadow2d-light-node.md | 39 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 Packages/com.unity.shadergraph/Documentation~/active-shadow2d-light-node.md diff --git a/Packages/com.unity.shadergraph/Documentation~/Input-Nodes.md b/Packages/com.unity.shadergraph/Documentation~/Input-Nodes.md index daf3f96d532..599b71288e6 100644 --- a/Packages/com.unity.shadergraph/Documentation~/Input-Nodes.md +++ b/Packages/com.unity.shadergraph/Documentation~/Input-Nodes.md @@ -2,6 +2,12 @@ Supply shaders with essential data such as constants, mesh attributes, gradients, matrices, deformation, PBR parameters, scene details, and texture sampling options. +## 2D + +| **Topic** | **Description** | +|-----------|-----------------| +| [Active Shadow2D Light](active-shadow2d-light-node.md) | Outputs the position and radius of the 2D light that's casting the shadow, for use in Shadow2D shaders. | + ## Basic | **Topic** | **Description** | diff --git a/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md b/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md index a045b2ee288..7ac17455217 100644 --- a/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md +++ b/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md @@ -101,6 +101,8 @@ * [Slice Index / Cubemap Face](Slice-Index-Cubemap-Face-Node.md) * [Dropdown](Dropdown-Node.md) * [Input](Input-Nodes.md) + * 2D + * [Active Shadow2D Light](active-shadow2d-light-node.md) * Basic * [Boolean](Boolean-Node.md) * [Color](Color-Node.md) diff --git a/Packages/com.unity.shadergraph/Documentation~/active-shadow2d-light-node.md b/Packages/com.unity.shadergraph/Documentation~/active-shadow2d-light-node.md new file mode 100644 index 00000000000..4182541513d --- /dev/null +++ b/Packages/com.unity.shadergraph/Documentation~/active-shadow2d-light-node.md @@ -0,0 +1,39 @@ +--- +uid: active-shadow2d-light-node +--- + +# Active Shadow2D Light node + +The Active Shadow2D Light node outputs the position and radius of the 2D light that's currently casting the shadow. Use it in a Shadow2D shader graph to change the shape of a shadow based on the light, for example to make shadows longer as the light moves farther away. + +## Render pipeline compatibility + +| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** | +| -------------------- | ------------------------------------- | --------------------------------------------- | +| **Active Shadow2D Light** | Yes | No | + +This node is only available with the **Shadow Caster 2D** shader graph target. + +## Ports + +| **Name** | **Direction** | **Type** | **Description** | +|------|-----------|------|-------------| +| **Position** | Output | Vector 3 | The position of the light GameObject in world space. | +| **Radius** | Output | Float | The radius of a circle, centered on the light position, that contains the whole area the light affects. | + +## Generated code example + +The following example code represents one possible outcome of this node. + +```hlsl +void Unity_ShadowCaster2DLight(out float3 Position, out float Radius) +{ + Position = _LightPos; + Radius = _ShadowRadius; +} +``` + +## Additional resources + +- [Shadow2D shader graph reference for URP](https://docs.unity3d.com/Manual/urp/prebuilt-shader-graphs-urp-shadow2d.html) +- [Create a custom material for 2D shadows](https://docs.unity3d.com/Manual/urp/2d-shadow-custom-material.html) From a8de14b8fc7fd6205fa623ecd0e54e4644087515 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 3 Nov 2026 14:30:10 +0000 Subject: [PATCH 13/61] [Port] [6000.7] [UUM-153768] [URP] [HDRP] Run the material upgrade during a -batchmode -quit import --- .../AssetProcessors/MaterialPostProcessor.cs | 153 +++++++++--------- .../MaterialPostprocessor.cs | 67 ++++---- 2 files changed, 117 insertions(+), 103 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs index c309c4511f3..8a4868f7fbd 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/AssetProcessors/MaterialPostProcessor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using UnityEditor.Callbacks; using UnityEditor.Rendering.Analytics; using UnityEditor.Rendering.HighDefinition.Analytics; @@ -115,86 +116,92 @@ static void RegisterUpgraderReimport() EditorApplication.update += () => { if (Time.renderedFrameCount > 0) - { - if (!HDRenderPipeline.isReady) - return; - - bool reimportAllHDShaderGraphsTriggered = false; - bool reimportAllMaterialsTriggered = false; - bool fileExist = true; - // We check the file existence only once to avoid IO operations every frame. - if (s_NeedToCheckProjSettingExistence) - { - fileExist = System.IO.File.Exists(HDProjectSettings.filePath); - s_NeedToCheckProjSettingExistence = false; - } + UpgradeMaterialsIfNeeded(); + }; - //This method is called at opening and when HDRP package change (update of manifest.json) - int curMaterialVersion = HDProjectSettings.materialVersionForUpgrade; - bool scanMaterialsForUpgradeNeeded = (curMaterialVersion < MaterialPostprocessor.k_Migrations.Length) - || (HDProjectSettings.pluginSubTargetLastSeenMaterialVersionsSum < HDShaderUtils.GetHDPluginSubTargetMaterialVersionsSum()); + if (Application.isBatchMode && Environment.CommandLine.Contains("-quit")) + SynchronizationContext.Current?.Post(_ => UpgradeMaterialsIfNeeded(), null); + } - var curHDSubTargetVersion = HDProjectSettings.hdShaderGraphLastSeenVersion; - bool scanHDShaderGraphsForUpgradeNeeded = (curHDSubTargetVersion < MigrationDescription.LastVersion()) - || (HDProjectSettings.pluginSubTargetLastSeenSubTargetVersionsSum < HDShaderUtils.GetHDPluginSubTargetVersionsSum()); + static void UpgradeMaterialsIfNeeded() + { + if (!HDRenderPipeline.isReady) + return; - // First test if scan for shadergraph version upgrade might be needed (triggered through their importer) - // We do shadergraphs first as the HDMetaData object might need to be updated and the material update might depend - // on it. - // Note: this auto-update is disabled by default for now. - if (s_AutoReimportProjectShaderGraphsOnVersionUpdate && scanHDShaderGraphsForUpgradeNeeded) - { - string commandLineOptions = System.Environment.CommandLine; - bool inTestSuite = commandLineOptions.Contains("-testResults"); - if (!inTestSuite && fileExist && !Application.isBatchMode) - { - EditorUtility.DisplayDialog("HDRP ShaderGraph scan for upgrade", "The ShaderGraphs with HDRP SubTarget in your Project were created using an older version of the High Definition Render Pipeline (HDRP)." + - " Unity must upgrade them to be compatible with your current version of HDRP. \n" + - " Unity will re-import all of the HDRP ShaderGraphs in your project, save them to disk, and check them out in source control if needed.\n" + - " Please see the Material upgrade guide in the HDRP documentation for more information.", "OK"); - } + bool reimportAllHDShaderGraphsTriggered = false; + bool reimportAllMaterialsTriggered = false; + bool fileExist = true; + // We check the file existence only once to avoid IO operations every frame. + if (s_NeedToCheckProjSettingExistence) + { + fileExist = System.IO.File.Exists(HDProjectSettings.filePath); + s_NeedToCheckProjSettingExistence = false; + } - // When we open a project from scratch all the material have been converted and we don't need to do it two time. - // However if we update with an open editor from the package manager we must call reimport. - // As we can't know, we are always calling reimport resulting in unecessary work when opening a project. - ReimportAllHDShaderGraphs(); - reimportAllHDShaderGraphsTriggered = true; - } - // we do else here, as we want to first call SaveAssetsToDisk() for shadergraphs, as it updates the HDProjectSettings version sentinels - // (tocheck: it's probably safe to also do materials right after) - else if (scanMaterialsForUpgradeNeeded) - { - string commandLineOptions = System.Environment.CommandLine; - bool inTestSuite = commandLineOptions.Contains("-testResults"); - if (!inTestSuite && fileExist && !Application.isBatchMode) - { - EditorUtility.DisplayDialog("HDRP Material upgrade", "The Materials in your Project were created using an older version of the High Definition Render Pipeline (HDRP)." + - " Unity must upgrade them to be compatible with your current version of HDRP. \n" + - " Unity will re-import all of the Materials in your project, save the upgraded Materials to disk, and check them out in source control if needed.\n" + - " Please see the Material upgrade guide in the HDRP documentation for more information.", "OK"); - } + //This method is called at opening and when HDRP package change (update of manifest.json) + int curMaterialVersion = HDProjectSettings.materialVersionForUpgrade; + bool scanMaterialsForUpgradeNeeded = (curMaterialVersion < MaterialPostprocessor.k_Migrations.Length) + || (HDProjectSettings.pluginSubTargetLastSeenMaterialVersionsSum < HDShaderUtils.GetHDPluginSubTargetMaterialVersionsSum()); - // When we open a project from scratch all the material have been converted and we don't need to do it two time. - // However if we update with an open editor from the package manager we must call reimport. - // As we can't know, we are always calling reimport resulting in unecessary work when opening a project. - ReimportAllMaterials(); - reimportAllMaterialsTriggered = true; - } + var curHDSubTargetVersion = HDProjectSettings.hdShaderGraphLastSeenVersion; + bool scanHDShaderGraphsForUpgradeNeeded = (curHDSubTargetVersion < MigrationDescription.LastVersion()) + || (HDProjectSettings.pluginSubTargetLastSeenSubTargetVersionsSum < HDShaderUtils.GetHDPluginSubTargetVersionsSum()); - // Note: A reimport all above should really have gone through all .mat or .shadergraph, because the SaveAssetsToDisk() call will update - // our versions in HDProjectSettings on which we base the version change detection and trigger the scan for reimport. - // We can still have these two flags set at the same time, however, if the user multi-selects .mat and .shadergraph, - // as the MaterialPostProcessor.OnPostprocessAllAssets() will be called for both and set both of those flags if needed. - // This should be safe however since by the time we reach this point here, we already checked if we needed a re-import scan just - // above. - if (MaterialPostprocessor.s_NeedsSavingAssets) - { - MaterialPostprocessor.SaveAssetsToDisk(updateMaterialLastSeenVersions: reimportAllMaterialsTriggered, updateShaderGraphLastSeenVersions: reimportAllHDShaderGraphsTriggered); - reimportAllHDShaderGraphsTriggered = false; - reimportAllMaterialsTriggered = false; - } + // First test if scan for shadergraph version upgrade might be needed (triggered through their importer) + // We do shadergraphs first as the HDMetaData object might need to be updated and the material update might depend + // on it. + // Note: this auto-update is disabled by default for now. + if (s_AutoReimportProjectShaderGraphsOnVersionUpdate && scanHDShaderGraphsForUpgradeNeeded) + { + string commandLineOptions = System.Environment.CommandLine; + bool inTestSuite = commandLineOptions.Contains("-testResults"); + if (!inTestSuite && fileExist && !Application.isBatchMode) + { + EditorUtility.DisplayDialog("HDRP ShaderGraph scan for upgrade", "The ShaderGraphs with HDRP SubTarget in your Project were created using an older version of the High Definition Render Pipeline (HDRP)." + + " Unity must upgrade them to be compatible with your current version of HDRP. \n" + + " Unity will re-import all of the HDRP ShaderGraphs in your project, save them to disk, and check them out in source control if needed.\n" + + " Please see the Material upgrade guide in the HDRP documentation for more information.", "OK"); } - }; + + // When we open a project from scratch all the material have been converted and we don't need to do it two time. + // However if we update with an open editor from the package manager we must call reimport. + // As we can't know, we are always calling reimport resulting in unecessary work when opening a project. + ReimportAllHDShaderGraphs(); + reimportAllHDShaderGraphsTriggered = true; + } + // we do else here, as we want to first call SaveAssetsToDisk() for shadergraphs, as it updates the HDProjectSettings version sentinels + // (tocheck: it's probably safe to also do materials right after) + else if (scanMaterialsForUpgradeNeeded) + { + string commandLineOptions = System.Environment.CommandLine; + bool inTestSuite = commandLineOptions.Contains("-testResults"); + if (!inTestSuite && fileExist && !Application.isBatchMode) + { + EditorUtility.DisplayDialog("HDRP Material upgrade", "The Materials in your Project were created using an older version of the High Definition Render Pipeline (HDRP)." + + " Unity must upgrade them to be compatible with your current version of HDRP. \n" + + " Unity will re-import all of the Materials in your project, save the upgraded Materials to disk, and check them out in source control if needed.\n" + + " Please see the Material upgrade guide in the HDRP documentation for more information.", "OK"); + } + + // When we open a project from scratch all the material have been converted and we don't need to do it two time. + // However if we update with an open editor from the package manager we must call reimport. + // As we can't know, we are always calling reimport resulting in unecessary work when opening a project. + ReimportAllMaterials(); + reimportAllMaterialsTriggered = true; + } + + // Note: A reimport all above should really have gone through all .mat or .shadergraph, because the SaveAssetsToDisk() call will update + // our versions in HDProjectSettings on which we base the version change detection and trigger the scan for reimport. + // We can still have these two flags set at the same time, however, if the user multi-selects .mat and .shadergraph, + // as the MaterialPostProcessor.OnPostprocessAllAssets() will be called for both and set both of those flags if needed. + // This should be safe however since by the time we reach this point here, we already checked if we needed a re-import scan just + // above. + if (MaterialPostprocessor.s_NeedsSavingAssets) + { + MaterialPostprocessor.SaveAssetsToDisk(updateMaterialLastSeenVersions: reimportAllMaterialsTriggered, updateShaderGraphLastSeenVersions: reimportAllHDShaderGraphsTriggered); + reimportAllHDShaderGraphsTriggered = false; + reimportAllMaterialsTriggered = false; + } } } diff --git a/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs b/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs index 9ec3724db34..6e7ccecf1be 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/AssetPostProcessors/MaterialPostprocessor.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using UnityEditor.Callbacks; using UnityEditor.Rendering.Analytics; using UnityEditor.Rendering.Universal.Analytics; @@ -44,42 +45,48 @@ static void RegisterUpgraderReimport() { EditorApplication.update += () => { - if (GraphicsSettings.currentRenderPipeline is not UniversalRenderPipelineAsset universalRenderPipeline) - return; - if (Time.renderedFrameCount > 0) - { - bool fileExist = true; - // We check the file existence only once to avoid IO operations every frame. - if (s_NeedToCheckProjSettingExistence) - { - fileExist = System.IO.File.Exists(UniversalProjectSettings.filePath); - s_NeedToCheckProjSettingExistence = false; - } + UpgradeMaterialsIfNeeded(); + }; - //This method is called at opening and when URP package change (update of manifest.json) - var curUpgradeVersion = UniversalProjectSettings.materialVersionForUpgrade; + if (Application.isBatchMode && Environment.CommandLine.Contains("-quit")) + SynchronizationContext.Current?.Post(_ => UpgradeMaterialsIfNeeded(), null); + } - if (curUpgradeVersion != MaterialPostprocessor.k_Upgraders.Length) - { - string commandLineOptions = Environment.CommandLine; - bool inTestSuite = commandLineOptions.Contains("-testResults"); - bool isTemplate = EditorApplication.isCreateFromTemplate; - if (!inTestSuite && fileExist && !isTemplate) - { - EditorUtility.DisplayDialog("URP Material upgrade", "The Materials in your Project were created using an older version of the Universal Render Pipeline (URP)." + - " Unity must upgrade them to be compatible with your current version of URP. \n" + - " Unity will re-import all of the Materials in your project, save the upgraded Materials to disk, and check them out in source control if needed.\n" + - " Please see the Material upgrade guide in the URP documentation for more information.", "OK"); - } + static void UpgradeMaterialsIfNeeded() + { + if (GraphicsSettings.currentRenderPipeline is not UniversalRenderPipelineAsset universalRenderPipeline) + return; - ReimportAllMaterials(); - } + bool fileExist = true; + // We check the file existence only once to avoid IO operations every frame. + if (s_NeedToCheckProjSettingExistence) + { + fileExist = System.IO.File.Exists(UniversalProjectSettings.filePath); + s_NeedToCheckProjSettingExistence = false; + } - if (MaterialPostprocessor.s_NeedsSavingAssets) - MaterialPostprocessor.SaveAssetsToDisk(); + //This method is called at opening and when URP package change (update of manifest.json) + var curUpgradeVersion = UniversalProjectSettings.materialVersionForUpgrade; + + if (curUpgradeVersion != MaterialPostprocessor.k_Upgraders.Length) + { + string commandLineOptions = Environment.CommandLine; + bool inTestSuite = commandLineOptions.Contains("-testResults"); + bool isTemplate = EditorApplication.isCreateFromTemplate; + if (!inTestSuite && fileExist && !isTemplate && !Application.isBatchMode) + { + EditorUtility.DisplayDialog("URP Material upgrade", "The Materials in your Project were created using an older version of the Universal Render Pipeline (URP)." + + " Unity must upgrade them to be compatible with your current version of URP. \n" + + " Unity will re-import all of the Materials in your project, save the upgraded Materials to disk, and check them out in source control if needed.\n" + + " Please see the Material upgrade guide in the URP documentation for more information.", "OK"); } - }; + + ReimportAllMaterials(); + } + + if (MaterialPostprocessor.s_NeedsSavingAssets) + MaterialPostprocessor.SaveAssetsToDisk(); } } From f404e9f4dbb6f987574632b0cc1f868c14ad3fbd Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 3 Nov 2026 14:30:12 +0000 Subject: [PATCH 14/61] [Port] [6000.7] [MacOS] Non finite values in unified baker (UUM-146654) --- .../PathTracing/Shaders/LightmapIntegrationHelpers.hlsl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/LightmapIntegrationHelpers.hlsl b/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/LightmapIntegrationHelpers.hlsl index a5a2dc21f06..50e68a0d598 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/LightmapIntegrationHelpers.hlsl +++ b/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/LightmapIntegrationHelpers.hlsl @@ -86,8 +86,8 @@ bool GetExpandedSample(uint dispatchIndex, out uint localSampleOffset, out uint2 FetchGeomAttributes(hit, g_InstanceGeometryIndex, worldPosition, worldNormal, worldFaceNormal); worldPosition = mul(g_ShaderLocalToWorld, float4(worldPosition, 1)).xyz; - worldNormal = normalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldNormal)); - worldFaceNormal = normalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldFaceNormal)); + worldNormal = SafeNormalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldNormal)); + worldFaceNormal = SafeNormalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldFaceNormal)); return true; } } @@ -112,8 +112,8 @@ bool GetExpandedSample(uint dispatchIndex, inout float3 worldPosition, inout flo FetchGeomAttributes(hit, g_InstanceGeometryIndex, worldPosition, worldNormal, worldFaceNormal, uv1); worldPosition = mul(g_ShaderLocalToWorld, float4(worldPosition, 1)).xyz; - worldNormal = normalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldNormal)); - worldFaceNormal = normalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldFaceNormal)); + worldNormal = SafeNormalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldNormal)); + worldFaceNormal = SafeNormalize(mul((float3x3)g_ShaderLocalToWorldNormals, worldFaceNormal)); return true; } } From 00f4b390bc614be2feac64039ea870c58e2a7cd5 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 3 Nov 2026 14:30:12 +0000 Subject: [PATCH 15/61] [Port] [6000.7] [UUM-159594] Limit the compute ray tracing BVH to Mesh LOD 0 --- .../Common/GeometryPool/GeometryPool.cs | 7 ++-- .../Compute/ComputeRayTracingAccelStruct.cs | 38 ++++++++++++++----- .../UnifiedRayTracing/GeometryPoolTests.cs | 37 ++++++++++++++++++ 3 files changed, 70 insertions(+), 12 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Common/GeometryPool/GeometryPool.cs b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Common/GeometryPool/GeometryPool.cs index 79d521cda4c..3394ad35d34 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Common/GeometryPool/GeometryPool.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Common/GeometryPool/GeometryPool.cs @@ -473,6 +473,7 @@ private bool AllocateGeo(Mesh mesh, out int allocationHandle) for (int submeshIndex = 0; submeshIndex < mesh.subMeshCount; ++submeshIndex) { SubMeshDescriptor submeshDescriptor = mesh.GetSubMesh(submeshIndex); + int submeshIndexCount = (int)mesh.GetIndexCount(submeshIndex); var newMeshChunk = MeshChunk.Invalid; newMeshChunk.vertexAlloc = m_VertexAllocator.Allocate(submeshDescriptor.vertexCount); @@ -487,10 +488,10 @@ private bool AllocateGeo(Mesh mesh, out int allocationHandle) m_MaxVertCounts = newCapacity; } - newMeshChunk.indexAlloc = m_IndexAllocator.Allocate(submeshDescriptor.indexCount); + newMeshChunk.indexAlloc = m_IndexAllocator.Allocate(submeshIndexCount); if (!newMeshChunk.indexAlloc.valid) { - newMeshChunk.indexAlloc = m_IndexAllocator.GrowAndAllocate(submeshDescriptor.indexCount, GraphicsHelpers.MaxElementCount(sizeof(int)), out int oldCapacity, out int newCapacity); + newMeshChunk.indexAlloc = m_IndexAllocator.GrowAndAllocate(submeshIndexCount, GraphicsHelpers.MaxElementCount(sizeof(int)), out int oldCapacity, out int newCapacity); if (!newMeshChunk.indexAlloc.valid) throw new UnifiedRayTracingException($"Can't allocate a GraphicsBuffer bigger than {GraphicsHelpers.MaxGraphicsBufferSizeInGigaBytes:F1}GB", UnifiedRayTracingError.GraphicsBufferAllocationFailed); @@ -623,7 +624,7 @@ private void UpdateGeoGpuState(Mesh mesh, GeometryPoolHandle handle) AddIndexUpdateCommand( cmdBuffer, mesh.indexFormat, buffer, targetMeshChunk.indexAlloc, submeshDescriptor.firstVertex, - submeshDescriptor.indexStart, submeshDescriptor.indexCount, 0, + (int)mesh.GetIndexStart(submeshIndex), (int)mesh.GetIndexCount(submeshIndex), 0, m_GlobalIndexBuffer); meshChunkAllocationTable[submeshIndex] = targetMeshChunk.EncodeGPUEntry(); diff --git a/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Compute/ComputeRayTracingAccelStruct.cs b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Compute/ComputeRayTracingAccelStruct.cs index a3e736fa712..07f67e54afc 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Compute/ComputeRayTracingAccelStruct.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/Compute/ComputeRayTracingAccelStruct.cs @@ -323,13 +323,21 @@ void AllocateMeshBlas(Mesh mesh, int submeshIndex, MeshBlas blas) meshBuildInfo.baseVertex = 0; meshBuildInfo.triangleIndices = indexBuffer; meshBuildInfo.vertexCount = (uint)blas.blasVertices.block.count; - meshBuildInfo.triangleCount = (uint)submeshDescriptor.indexCount / 3; - meshBuildInfo.indicesStartOffset = submeshDescriptor.indexStart; + meshBuildInfo.triangleCount = mesh.GetIndexCount(submeshIndex) / 3; + meshBuildInfo.indicesStartOffset = (int)mesh.GetIndexStart(submeshIndex); meshBuildInfo.baseIndex = -submeshDescriptor.firstVertex; meshBuildInfo.indexFormat = mesh.indexFormat == IndexFormat.UInt32 ? RadeonRays.IndexFormat.Int32 : RadeonRays.IndexFormat.Int16; meshBuildInfo.vertexStride = 3; blas.buildInfo = meshBuildInfo; + if (IsEmpty(blas)) + { + blas.bvhInternalNodesAlloc = AllocateBlasInternalNodes(0); + blas.bvhLeafNodesAlloc = AllocateBlasLeafNodes(0); + blas.bvhBuilt = true; + return; + } + #if UNITY_EDITOR if (m_UseCpuBuild) { @@ -393,6 +401,11 @@ GraphicsBuffer LoadPositionBuffer(Mesh mesh, out int stride, out int offset) return buffer; } + static bool IsEmpty(Blas blas) + { + return blas is MeshBlas { buildInfo: { triangleCount: 0 } }; + } + void DeleteMeshBlas((int mesh, int subMeshIndex) geomKey, MeshBlas blas) { m_BlasInternalNodesAllocator.FreeAllocation(blas.bvhInternalNodesAlloc); @@ -559,9 +572,16 @@ void CheckProceduralBlasConsistency(CommandBuffer cmd, ProceduralBlas procedural void BuildTopLevelAccelStruct(CommandBuffer cmd, GraphicsBuffer scratchBuffer) { - var radeonRaysInstances = new RadeonRays.Instance[m_RadeonInstances.Count]; - int i = 0; + var nonEmptyInstances = new List(m_RadeonInstances.Count); foreach (var instance in m_RadeonInstances.Values) + { + if (!IsEmpty(instance.blas)) + nonEmptyInstances.Add(instance); + } + + var radeonRaysInstances = new RadeonRays.Instance[nonEmptyInstances.Count]; + int i = 0; + foreach (var instance in nonEmptyInstances) { if (instance.blas is MeshBlas meshBlas) { @@ -587,7 +607,7 @@ void BuildTopLevelAccelStruct(CommandBuffer cmd, GraphicsBuffer scratchBuffer) #if UNITY_EDITOR if (m_UseCpuBuild) - m_TopLevelAccelStruct = CpuBuildForTopLevelAccelStruct(cmd, radeonRaysInstances); + m_TopLevelAccelStruct = CpuBuildForTopLevelAccelStruct(cmd, nonEmptyInstances, radeonRaysInstances); else #endif m_TopLevelAccelStruct = m_RadeonRaysAPI.BuildSceneAccelStruct(cmd, m_BlasInternalNodesBuffer, radeonRaysInstances, scratchBuffer); @@ -704,11 +724,11 @@ void CpuBuildForBottomLevelAccelStruct(CommandBuffer cmd, Blas blas) } - TopLevelAccelStruct CpuBuildForTopLevelAccelStruct(CommandBuffer cmd, RadeonRays.Instance[] radeonRaysInstances) + TopLevelAccelStruct CpuBuildForTopLevelAccelStruct(CommandBuffer cmd, List instances, RadeonRays.Instance[] radeonRaysInstances) { - var prims = new GpuBvhPrimitiveDescriptor[m_RadeonInstances.Count]; + var prims = new GpuBvhPrimitiveDescriptor[instances.Count]; int i = 0; - foreach (var instance in m_RadeonInstances.Values) + foreach (var instance in instances) { Blas blas = instance.blas; AABB aabb = blas.aabbForCpuBuild; @@ -732,7 +752,7 @@ TopLevelAccelStruct CpuBuildForTopLevelAccelStruct(CommandBuffer cmd, RadeonRays i++; } - if (m_RadeonInstances.Count != 0) + if (instances.Count != 0) { var options = ConvertFlagsToCpuBuild(m_BuildFlags, true); diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/UnifiedRayTracing/GeometryPoolTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/UnifiedRayTracing/GeometryPoolTests.cs index bf29c20b9c2..cbb4c2b0c6e 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/UnifiedRayTracing/GeometryPoolTests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/UnifiedRayTracing/GeometryPoolTests.cs @@ -38,6 +38,24 @@ static Mesh CreateTriangleStripMesh(int vertexCount, float zOffset) return mesh; } + // LOD 0 is a strip of four triangles and LOD 1 a single triangle, both over the same six vertices. + static Mesh CreateTwoLevelMeshLodMesh() + { + var vertices = new Vector3[6]; + for (int i = 0; i < vertices.Length; ++i) + vertices[i] = new Vector3(i, i % 2, 0.0f); + + var indices = new[] { 0, 1, 2, 1, 2, 3, 2, 3, 4, 3, 4, 5, 0, 2, 4 }; + + var mesh = new Mesh { indexFormat = IndexFormat.UInt32 }; + mesh.vertices = vertices; + mesh.SetIndices(indices, MeshTopology.Triangles, 0); + mesh.lodCount = 2; + mesh.SetLods(new[] { new MeshLodRange(0, 12), new MeshLodRange(12, 3) }, 0); + mesh.UploadMeshData(false); + return mesh; + } + static void AssertPoolContainsMesh(GeometryPool pool, GeometryPoolHandle handle, Mesh mesh) { var meshChunk = pool.GetEntryGeomAllocation(handle).meshChunks[0]; @@ -108,5 +126,24 @@ public void Register_MeshExceedsInitialCapacity_GrowsAndPreservesExistingData() UnityEngine.Object.DestroyImmediate(secondMesh); } } + + [Test] + public void Register_MeshWithMeshLods_StoresOnlyLevelZero() + { + var mesh = CreateTwoLevelMeshLodMesh(); + var pool = new GeometryPool(GeometryPoolDesc.NewDefault(), m_Resources.geometryPoolKernels, m_Resources.copyBuffer); + try + { + Assert.IsTrue(pool.Register(mesh, out var handle)); + pool.SendGpuCommands(); + + AssertPoolContainsMesh(pool, handle, mesh); + } + finally + { + pool.Dispose(); + UnityEngine.Object.DestroyImmediate(mesh); + } + } } } From 71a5c2d6e917c89317abfc3ebc9f821b96e86527 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 3 Nov 2026 14:30:12 +0000 Subject: [PATCH 16/61] [Port] [6000.7] Render Pipeline Converter: Scan misses assets created or modified just before scanning (UUM-154992) --- .../Tools/Converter/SearchServiceUtils.cs | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/SearchServiceUtils.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/SearchServiceUtils.cs index 462c266c5fd..ea291143de8 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/SearchServiceUtils.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/SearchServiceUtils.cs @@ -17,6 +17,28 @@ public enum IndexingOptions // Set while a caller blocks the Editor, so searches have to finish before RunQueuedSearch returns public static bool synchronous { get; set; } + // Asset changes reach the index after a delay and are then applied in the background, and searches do not wait for them + static void WaitForIndexUpToDate(Action onIndexUpToDate) + { + if (IsIndexUpdatePending()) + EditorApplication.delayCall += () => WaitForIndexUpToDate(onIndexUpToDate); + else + onIndexUpToDate(); + } + + static bool IsIndexUpdatePending() + { + // The index defers its updates until play mode is exited + if (EditorApplication.isPlaying) + return false; + + var db = SearchDatabase.GetDefaultSearchDatabase(); + if (db.LoadingState == SearchDatabase.LoadState.Error || db.LoadingState == SearchDatabase.LoadState.Canceled) + return false; + + return SearchMonitor.pending || !db.ready || db.updating || db.needsUpdate; + } + public static void RunQueuedSearch( IndexingOptions neededOptions, List<(string query, string description)> contextSearchQueriesAndIds, @@ -111,7 +133,7 @@ void ProcessNextSearch() void OnSearchIndexReady() { - ProcessNextSearch(); + WaitForIndexUpToDate(ProcessNextSearch); } if (isDeepSearchEnabled != needsDeepSearch || isPackageIndexingEnabled != needsPackageIndexing) From 060664df4990f311b303d83af5e7ea70bb091277 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 4 Nov 2026 13:43:46 +0000 Subject: [PATCH 17/61] [Port] [6000.7] [UUM-158025] [URP] Only log unusable post-processing shaders when the effect is used --- .../Runtime/Passes/ColorGradingLutPass.cs | 21 +++--- .../PostProcess/BloomPostProcessPass.cs | 51 ++++++------- .../DepthOfFieldBokehProcessPass.cs | 17 ++--- .../DepthOfFieldGaussianPostProcessPass.cs | 26 +++---- .../PostProcess/FinalPostProcessPass.cs | 13 ++-- .../PostProcess/Fsr1UpscalePostProcessPass.cs | 13 ++-- .../LensFlareDataDrivenPostProcessPass.cs | 21 +++--- .../LensFlareScreenSpacePostProcessPass.cs | 15 ++-- .../PostProcess/MotionBlurPostProcessPass.cs | 17 ++--- .../PaniniProjectionPostProcessPass.cs | 17 ++--- .../ScalingSetupPostProcessPass.cs | 13 ++-- .../Passes/PostProcess/SmaaPostProcessPass.cs | 21 +++--- .../PostProcess/StopNanPostProcessPass.cs | 17 ++--- .../TemporalAntiAliasingPostProcessPass.cs | 17 ++--- .../Passes/PostProcess/UberPostProcessPass.cs | 13 ++-- .../PostProcess/UpscalerPostProcessPass.cs | 17 ++--- .../Runtime/PostProcessUtils.cs | 75 +++++++++++++------ 17 files changed, 186 insertions(+), 198 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ColorGradingLutPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ColorGradingLutPass.cs index e47f79b78df..8fdeb275622 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ColorGradingLutPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ColorGradingLutPass.cs @@ -13,8 +13,8 @@ public partial class ColorGradingLutPass : ScriptableRenderPass { const string k_InternalColorLutName = "_InternalColorGradingLut"; - readonly Material m_LutBuilderLdr; - readonly Material m_LutBuilderHdr; + readonly PostProcessMaterial m_LutBuilderLdr; + readonly PostProcessMaterial m_LutBuilderHdr; internal readonly GraphicsFormat m_HdrLutFormat; internal readonly GraphicsFormat m_LdrLutFormat; @@ -37,8 +37,8 @@ public ColorGradingLutPass(RenderPassEvent evt, PostProcessData data) profilingSampler = new ProfilingSampler("Blit Color LUT"); renderPassEvent = evt; - m_LutBuilderLdr = PostProcessUtils.LoadShader(data.shaders.lutBuilderLdrPS, passName); - m_LutBuilderHdr = PostProcessUtils.LoadShader(data.shaders.lutBuilderHdrPS, passName); + m_LutBuilderLdr = new PostProcessMaterial(data.shaders.lutBuilderLdrPS, passName); + m_LutBuilderHdr = new PostProcessMaterial(data.shaders.lutBuilderHdrPS, passName); // Warm up lut format as IsFormatSupported adds GC pressure... // UUM-41070: We require `Linear | Render` but with the deprecated FormatUsage this was checking `Blend` @@ -254,6 +254,9 @@ internal void Render(RenderGraph renderGraph, ContextContainer frameData, out Te UniversalCameraData cameraData = frameData.Get(); UniversalPostProcessingData postProcessingData = frameData.Get(); + bool hdrGrading = postProcessingData.gradingMode == ColorGradingMode.HighDynamicRange; + (hdrGrading ? m_LutBuilderHdr : m_LutBuilderLdr).Validate(); + this.ConfigureDescriptor(in postProcessingData, out var lutDesc, out var filterMode); #if ENABLE_VR && ENABLE_XR_MODULE @@ -295,11 +298,11 @@ internal void Render(RenderGraph renderGraph, ContextContainer frameData, out Te passData.internalColorLut = internalColorLut; builder.SetRenderAttachment(internalColorLut, 0, AccessFlags.WriteAll); - passData.lutBuilderLdr = m_LutBuilderLdr; - passData.lutBuilderHdr = m_LutBuilderHdr; + passData.lutBuilderLdr = m_LutBuilderLdr.material; + passData.lutBuilderHdr = m_LutBuilderHdr.material; passData.allowColorGradingACESHDR = m_AllowColorGradingACESHDR; passData.lutSize = postProcessingData.lutSize; - passData.hdrGrading = postProcessingData.gradingMode == ColorGradingMode.HighDynamicRange; + passData.hdrGrading = hdrGrading; // TODO RENDERGRAPH: culling? force culling off for testing builder.AllowPassCulling(false); @@ -329,8 +332,8 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer /// public void Cleanup() { - CoreUtils.Destroy(m_LutBuilderLdr); - CoreUtils.Destroy(m_LutBuilderHdr); + m_LutBuilderLdr.Dispose(); + m_LutBuilderHdr.Dispose(); #if ENABLE_VR && ENABLE_XR_MODULE m_QuadViewsColorLutHandle?.Release(); #endif diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/BloomPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/BloomPostProcessPass.cs index 50049f584e7..7827ec1ae6e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/BloomPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/BloomPostProcessPass.cs @@ -14,15 +14,14 @@ internal sealed class BloomPostProcessPass : PostProcessPass /// Generates bloom mipmap chain using dual filtering (downsample then upsample with tent filter) for efficient wide-radius bloom. static readonly ProfilingSampler k_ProfilingSamplerDual = ProfilingSampler.Create("Blit Bloom Mipmaps (Dual)", MarkerFlags.Default); - Material m_Material; - Material[] m_MaterialPyramid; + PostProcessMaterial m_Material; + PostProcessMaterial[] m_MaterialPyramid; // Cached bloom params from previous frame to avoid unnecessary material updates MaterialParams m_PrevParams; BloomMipPyramid m_MipPyramid; - bool m_IsValid; bool m_IsDependency; public BloomMipPyramid mipPyramid => m_MipPyramid; @@ -35,18 +34,13 @@ public BloomPostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.Bloom; - m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); + m_Material = new PostProcessMaterial(shader, passName); // Array for bloom pyramid materials. // Materials are references in the command buffer, so we need a separate material for each mip level. - m_MaterialPyramid = new Material[k_MaxPyramidSize]; + m_MaterialPyramid = new PostProcessMaterial[k_MaxPyramidSize]; for (uint i = 0; i < k_MaxPyramidSize; ++i) - m_MaterialPyramid[i] = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); - - // Check if the pass init was successful. - m_IsValid = m_Material != null; - for(int i = 0; i < k_MaxPyramidSize; i++) - m_IsValid &= m_MaterialPyramid[i] != null; + m_MaterialPyramid[i] = new PostProcessMaterial(shader, passName); m_MipPyramid = new BloomMipPyramid(k_MaxPyramidSize); @@ -55,9 +49,9 @@ public BloomPostProcessPass(Shader shader) public override void Dispose() { - CoreUtils.Destroy(m_Material); + m_Material.Dispose(); for(int i = 0; i < k_MaxPyramidSize; i++) - CoreUtils.Destroy(m_MaterialPyramid[i]); + m_MaterialPyramid[i].Dispose(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -69,7 +63,7 @@ public void Setup(bool runAsDependency) private class BloomPassData { internal Material material; - internal Material[] mipMaterials; + internal PostProcessMaterial[] mipMaterials; internal TextureHandle sourceTexture; @@ -78,13 +72,14 @@ private class BloomPassData public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - var bloom = volumeStack.GetComponent(); if (!bloom.IsActive() && !m_IsDependency) return; + // The pyramid materials use the same shader, so they are valid if m_Material is. + if (!m_Material.Validate()) + return; + UniversalResourceData resourceData = frameData.Get(); UniversalCameraData cameraData = frameData.Get(); @@ -120,18 +115,18 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer // Setting keywords can be somewhat expensive on low-end platforms. // Previous params are cached to avoid setting the same keywords every frame. bool paramsDirty = !m_PrevParams.Equals(ref newParams); - bool isParamsPropertySet = m_Material.HasProperty(ShaderConstants._Params); + bool isParamsPropertySet = m_Material.material.HasProperty(ShaderConstants._Params); if (paramsDirty || !isParamsPropertySet) { - m_Material.SetVector(ShaderConstants._Params, newParams.parameters); - m_Material.SetVector(ShaderConstants._Params2, newParams.parameters2); - CoreUtils.SetKeyword(m_Material, ShaderKeywordStrings.BloomHQ, newParams.highQualityFiltering); - CoreUtils.SetKeyword(m_Material, ShaderKeywordStrings._ENABLE_ALPHA_OUTPUT, newParams.enableAlphaOutput); + m_Material.material.SetVector(ShaderConstants._Params, newParams.parameters); + m_Material.material.SetVector(ShaderConstants._Params2, newParams.parameters2); + CoreUtils.SetKeyword(m_Material.material, ShaderKeywordStrings.BloomHQ, newParams.highQualityFiltering); + CoreUtils.SetKeyword(m_Material.material, ShaderKeywordStrings._ENABLE_ALPHA_OUTPUT, newParams.enableAlphaOutput); // These materials are duplicate just to allow different bloom blits to use different textures. for (uint i = 0; i < k_MaxPyramidSize; ++i) { - var materialPyramid = m_MaterialPyramid[i]; + var materialPyramid = m_MaterialPyramid[i].material; materialPyramid.SetVector(ShaderConstants._Params, newParams.parameters); CoreUtils.SetKeyword(materialPyramid, ShaderKeywordStrings.BloomHQ, newParams.highQualityFiltering); CoreUtils.SetKeyword(materialPyramid, ShaderKeywordStrings._ENABLE_ALPHA_OUTPUT, newParams.enableAlphaOutput); @@ -206,7 +201,7 @@ TextureHandle BloomGaussian(RenderGraph renderGraph, in TextureHandle source) using (var builder = renderGraph.AddUnsafePass(passName, out var passData, profilingSampler)) { passData.sourceTexture = source; - passData.material = m_Material; + passData.material = m_Material.material; passData.mipMaterials = m_MaterialPyramid; passData.mipPyramid = m_MipPyramid; @@ -271,7 +266,7 @@ TextureHandle BloomGaussian(RenderGraph renderGraph, in TextureHandle source) // gets overriden by the time the render func is executed. // Material is a reference, so all the blits would share the same material state in the cmdbuf. // NOTE: another option would be to use cmd.SetGlobalTexture(). - var upMaterial = data.mipMaterials[i]; + var upMaterial = data.mipMaterials[i].material; upMaterial.SetTexture(ShaderConstants._SourceTexLowMip, lowMip); Blitter.BlitCameraTexture(cmd, highMip, dst, loadAction, storeAction, upMaterial, ShaderPass.k_Upsample); @@ -290,7 +285,7 @@ TextureHandle BloomKawase(RenderGraph renderGraph, in TextureHandle source) using (var builder = renderGraph.AddUnsafePass(k_PassNameKawase, out var passData, k_ProfilingSamplerKawase)) { passData.sourceTexture = source; - passData.material = m_Material; + passData.material = m_Material.material; passData.mipMaterials = m_MaterialPyramid; passData.mipPyramid = m_MipPyramid; @@ -325,7 +320,7 @@ TextureHandle BloomKawase(RenderGraph renderGraph, in TextureHandle source) { TextureHandle src = ((i & 1) == 0) ? mipDownTextures[0] : mipUpTextures[0]; TextureHandle dst = ((i & 1) == 0) ? mipUpTextures[0] : mipDownTextures[0]; - Material mat = data.mipMaterials[i]; + Material mat = data.mipMaterials[i].material; Blitter.BlitCameraTexture(cmd, src, dst, loadAction, storeAction, mat, ShaderPass.k_Kawase); } @@ -344,7 +339,7 @@ TextureHandle BloomDual(RenderGraph renderGraph, in TextureHandle source) using (var builder = renderGraph.AddUnsafePass(k_PassNameDual, out var passData, k_ProfilingSamplerDual)) { passData.sourceTexture = source; - passData.material = m_Material; + passData.material = m_Material.material; passData.mipMaterials = m_MaterialPyramid; passData.mipPyramid = m_MipPyramid; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldBokehProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldBokehProcessPass.cs index f6e5c913e60..ca96eaf8ddd 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldBokehProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldBokehProcessPass.cs @@ -9,8 +9,7 @@ internal sealed class DepthOfFieldBokehPostProcessPass : PostProcessPass public const string k_TargetName = "CameraColorDepthOfFieldBokeh"; const int k_DownSample = 2; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; Vector4[] m_BokehKernel; int m_BokehHash; @@ -23,14 +22,12 @@ public DepthOfFieldBokehPostProcessPass(Shader shader) { this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.BokehDepthOfField; - m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); } public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class DoFBokehPassData @@ -58,9 +55,6 @@ private class DoFBokehPassData public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - var depthOfField = volumeStack.GetComponent(); if (!depthOfField.IsActive() || depthOfField.mode.value != DepthOfFieldMode.Bokeh) return; @@ -69,6 +63,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (cameraData.isSceneViewCamera) return; + if (!m_Material.Validate()) + return; + var postProcessingData = frameData.Get(); var resourceData = frameData.Get(); @@ -127,7 +124,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer passData.depthTexture = resourceData.cameraDepthTexture; builder.UseTexture(resourceData.cameraDepthTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; // Pass Textures passData.fullCoCTexture = fullCoCTexture; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldGaussianPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldGaussianPostProcessPass.cs index def16de768f..5f960bda1d6 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldGaussianPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/DepthOfFieldGaussianPostProcessPass.cs @@ -10,9 +10,8 @@ internal sealed class DepthOfFieldGaussianPostProcessPass : PostProcessPass public const string k_TargetName = "CameraColorDepthOfFieldGaussian"; const int k_DownSample = 2; - Material m_Material; - Material m_MaterialCoc; - bool m_IsValid; + PostProcessMaterial m_Material; + PostProcessMaterial m_MaterialCoc; Experimental.Rendering.GraphicsFormat m_CoCFormat; @@ -21,9 +20,8 @@ public DepthOfFieldGaussianPostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.GaussianDepthOfField; - m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); - m_MaterialCoc = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); - m_IsValid = m_Material != null && m_MaterialCoc != null; + m_Material = new PostProcessMaterial(shader, passName); + m_MaterialCoc = new PostProcessMaterial(shader, passName); // Depth of Field // @@ -40,9 +38,8 @@ public DepthOfFieldGaussianPostProcessPass(Shader shader) public override void Dispose() { - CoreUtils.Destroy(m_Material); - CoreUtils.Destroy(m_MaterialCoc); - m_IsValid = false; + m_Material.Dispose(); + m_MaterialCoc.Dispose(); } private class DoFGaussianPassData @@ -68,9 +65,6 @@ private class DoFGaussianPassData }; public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - var depthOfField = volumeStack.GetComponent(); if (!depthOfField.IsActive() || depthOfField.mode.value != DepthOfFieldMode.Gaussian) return; @@ -79,6 +73,10 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (cameraData.isSceneViewCamera) return; + // m_MaterialCoc uses the same shader, so it is valid if m_Material is. + if (!m_Material.Validate()) + return; + UniversalResourceData resourceData = frameData.Get(); var sourceTexture = resourceData.cameraColor; @@ -117,8 +115,8 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer passData.highQualitySamplingValue = depthOfField.highQualitySampling.value; passData.enableAlphaOutput = cameraData.isAlphaOutputEnabled; - passData.material = m_Material; - passData.materialCoC = m_MaterialCoc; + passData.material = m_Material.material; + passData.materialCoC = m_MaterialCoc.material; // Inputs passData.sourceTexture = sourceTexture; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs index 78a58884cd2..4f7bd3b90c3 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs @@ -10,9 +10,8 @@ internal sealed class FinalPostProcessPass : PostProcessPass /// Blits the final post-processed image to the camera target, applying FXAA, upscaling, or format conversion as the last rendering step. static readonly ProfilingSampler k_ProfilingSampler = ProfilingSampler.Create("Blit Final Post Processing", MarkerFlags.Default); - Material m_Material; + PostProcessMaterial m_Material; Texture2D[] m_FilmGrainTextures; - bool m_IsValid; public enum FilteringOperation { @@ -34,8 +33,7 @@ public FinalPostProcessPass(Shader shader, Texture2D[] filmGrainTextures) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = k_ProfilingSampler; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); m_FilmGrainTextures = filmGrainTextures; // Defaults @@ -48,8 +46,7 @@ public FinalPostProcessPass(Shader shader, Texture2D[] filmGrainTextures) public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -82,7 +79,7 @@ private class PostProcessingFinalBlitPassData } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) + if (!m_Material.Validate()) return; var tonemapping = volumeStack.GetComponent(); @@ -108,7 +105,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (m_RenderOverlayUI) builder.UseTexture(resourceData.overlayUITexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; passData.cameraData = cameraData; passData.tonemapping = tonemapping; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/Fsr1UpscalePostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/Fsr1UpscalePostProcessPass.cs index 9299750d8f2..bd8ccaa1ddd 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/Fsr1UpscalePostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/Fsr1UpscalePostProcessPass.cs @@ -8,8 +8,7 @@ internal sealed class Fsr1UpscalePostProcessPass : PostProcessPass { public const string k_TargetName = "CameraColorUpscaled"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; TextureDesc m_UpscaledDesc; @@ -18,8 +17,7 @@ public Fsr1UpscalePostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = new ProfilingSampler("Blit FSR Upscaling"); - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); // Default PostProcessUtils.MakeCompatible(ref m_UpscaledDesc); @@ -30,8 +28,7 @@ public Fsr1UpscalePostProcessPass(Shader shader) public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class PostProcessingFinalFSRScalePassData @@ -51,7 +48,7 @@ public void Setup(TextureDesc upscaledDesc) public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) + if (!m_Material.Validate()) return; var cameraData = frameData.Get(); @@ -70,7 +67,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer builder.SetRenderAttachment(destinationTexture, 0, AccessFlags.Write); passData.sourceTexture = sourceTexture; builder.UseTexture(sourceTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; passData.fsrInputSize = new Vector2(srcDesc.width, srcDesc.height); passData.fsrOutputSize = new Vector2(dstDesc.width, dstDesc.height); passData.enableAlphaOutput = cameraData.isAlphaOutputEnabled; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareDataDrivenPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareDataDrivenPostProcessPass.cs index 09724391942..3312180e913 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareDataDrivenPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareDataDrivenPostProcessPass.cs @@ -6,8 +6,7 @@ namespace UnityEngine.Rendering.Universal { internal sealed class LensFlareDataDrivenPostProcessPass : PostProcessPass { - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; const string k_passNameOcclusion = "Blit Lens Flare Occlusion"; @@ -16,14 +15,12 @@ public LensFlareDataDrivenPostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.LensFlareDataDriven; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); } public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class LensFlarePassData @@ -41,13 +38,13 @@ private class LensFlarePassData public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - var postProcessingData = frameData.Get(); if (LensFlareCommonSRP.Instance.IsEmpty() || !postProcessingData.supportDataDrivenLensFlare) return; + if (!m_Material.Validate()) + return; + var cameraData = frameData.Get(); var resourceData = frameData.Get(); @@ -55,7 +52,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer var destinationTexture = resourceData.cameraColor; // Reset keywords - m_Material.shaderKeywords = null; + m_Material.material.shaderKeywords = null; var desc = destinationTexture.GetDescriptor(renderGraph); @@ -76,7 +73,7 @@ void LensFlareDataDrivenComputeOcclusion(RenderGraph renderGraph, UniversalResou builder.UseTexture(occlusionHandle, AccessFlags.Write); passData.cameraData = cameraData; passData.viewport = cameraData.pixelRect; - passData.material = m_Material; + passData.material = m_Material.material; passData.width = (float)dstDesc.width; passData.height = (float)dstDesc.height; if (paniniProjection.IsActive()) @@ -171,7 +168,7 @@ void RenderLensFlareDataDriven(RenderGraph renderGraph, UniversalResourceData re passData.destinationTexture = destination; builder.UseTexture(destination, AccessFlags.Write); passData.cameraData = cameraData; - passData.material = m_Material; + passData.material = m_Material.material; passData.width = (float)srcDesc.width; passData.height = (float)srcDesc.height; passData.viewport.x = 0.0f; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareScreenSpacePostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareScreenSpacePostProcessPass.cs index 7de25810018..dfce83de3ad 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareScreenSpacePostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/LensFlareScreenSpacePostProcessPass.cs @@ -6,8 +6,7 @@ namespace UnityEngine.Rendering.Universal { internal sealed class LensFlareScreenSpacePostProcessPass : PostProcessPass { - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; // Post-processing main color-buffer texture desc. Can be different from downsampled bloom/flare textures. int m_ColorBufferWidth; @@ -19,8 +18,7 @@ public LensFlareScreenSpacePostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.LensFlareScreenSpace; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); // Default values m_ColorBufferWidth = 1; // Unknown at pipe/pass construction time. Safe default. Avoid division by zero. @@ -30,8 +28,7 @@ public LensFlareScreenSpacePostProcessPass(Shader shader) public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -59,10 +56,10 @@ private class LensFlareScreenSpacePassData public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) + if (!IsActive(volumeStack, frameData)) return; - if (!IsActive(volumeStack, frameData)) + if (!m_Material.Validate()) return; var lensFlareScreenSpace = volumeStack.GetComponent(); @@ -112,7 +109,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer passData.actualColorWidth = m_ColorBufferWidth; passData.actualColorHeight = m_ColorBufferHeight; passData.camera = cameraData.camera; - passData.material = m_Material; + passData.material = m_Material.material; passData.lensFlareScreenSpace = lensFlareScreenSpace; // NOTE: reference, assumed constant until executed. passData.downsample = downsample; passData.flareResultTmp = resultTmpTexture; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/MotionBlurPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/MotionBlurPostProcessPass.cs index 6aaf38a179c..1a1189b89df 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/MotionBlurPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/MotionBlurPostProcessPass.cs @@ -8,22 +8,19 @@ internal sealed class MotionBlurPostProcessPass : PostProcessPass { public const string k_TargetName = "CameraColorMotionBlur"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; public MotionBlurPostProcessPass(Shader shader) { this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.MotionBlur; - m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); } public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class MotionBlurPassData @@ -39,9 +36,6 @@ private class MotionBlurPassData } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if(!m_IsValid) - return; - // Disable MotionBlur in EditMode, so that editing remains clear and readable. // NOTE: HDRP does the same via CoreUtils::AreAnimatedMaterialsEnabled(). // Disable MotionBlurMode.CameraAndObjects on renderers that do not support motion vectors @@ -56,6 +50,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (cameraData.isSceneViewCamera) return; + if (!m_Material.Validate()) + return; + UniversalResourceData resourceData = frameData.Get(); TextureHandle motionVectorColor = resourceData.motionVectorColor; @@ -97,7 +94,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer Debug.Assert(cameraDepthTexture.IsValid(), "Camera depth texture is invalid. Per-camera motion blur requires a depth texture."); builder.UseTexture(cameraDepthTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; passData.passIndex = passIndex; passData.camera = cameraData.camera; passData.enableAlphaOutput = cameraData.isAlphaOutputEnabled; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/PaniniProjectionPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/PaniniProjectionPostProcessPass.cs index a8a4f77a60a..28928f051f4 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/PaniniProjectionPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/PaniniProjectionPostProcessPass.cs @@ -8,22 +8,19 @@ internal sealed class PaniniProjectionPostProcessPass : PostProcessPass { public const string k_TargetName = "CameraColorPaniniProjection"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; public PaniniProjectionPostProcessPass(Shader shader) { this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.PaniniProjection; - m_Material = PostProcessUtils.LoadShader(shader, passName, logLevel: LogType.Log); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); } public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class PaniniProjectionPassData @@ -35,9 +32,6 @@ private class PaniniProjectionPassData } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if(!m_IsValid) - return; - var paniniProjection = volumeStack.GetComponent(); if(!paniniProjection.IsActive()) @@ -47,6 +41,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (cameraData.isSceneViewCamera) return; + if (!m_Material.Validate()) + return; + UniversalResourceData resourceData = frameData.Get(); var sourceTexture = resourceData.cameraColor; var destinationTexture = PostProcessUtils.CreateCompatibleTexture(renderGraph, sourceTexture, k_TargetName, true, FilterMode.Bilinear); @@ -72,7 +69,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer builder.SetRenderAttachment(destinationTexture, 0, AccessFlags.Write); passData.sourceTexture = sourceTexture; builder.UseTexture(sourceTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; passData.paniniParams = new Vector4(viewExtents.x, viewExtents.y, paniniD, paniniS); passData.isPaniniGeneric = 1f - Mathf.Abs(paniniD) > float.Epsilon; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/ScalingSetupPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/ScalingSetupPostProcessPass.cs index 64801d7cf16..1f052c11aa7 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/ScalingSetupPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/ScalingSetupPostProcessPass.cs @@ -8,8 +8,7 @@ internal sealed class ScalingSetupPostProcessPass : PostProcessPass { public const string k_TargetName = "SetupUpscaling"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; HDROutputUtils.Operation m_HdrOperations; @@ -18,8 +17,7 @@ public ScalingSetupPostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = new ProfilingSampler("Setup Final Post Processing"); - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); // Defaults m_HdrOperations = HDROutputUtils.Operation.None; // HDR disabled. @@ -27,8 +25,7 @@ public ScalingSetupPostProcessPass(Shader shader) public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -50,7 +47,7 @@ private class PostProcessingFinalSetupPassData public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) + if (!m_Material.Validate()) return; var tonemapping = volumeStack.GetComponent(); @@ -81,7 +78,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer passData.sourceTexture = sourceTexture; builder.UseTexture(sourceTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; passData.cameraData = cameraData; passData.tonemapping = tonemapping; passData.hdrOperations = m_HdrOperations; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/SmaaPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/SmaaPostProcessPass.cs index 4a27b13f14a..b00353dc7b8 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/SmaaPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/SmaaPostProcessPass.cs @@ -9,8 +9,7 @@ internal sealed class SmaaPostProcessPass : PostProcessPass { public const string k_TargetName = "CameraColorSMAA"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; // Static resource textures for SMAA technique Texture2D m_AreaTexture; @@ -26,8 +25,7 @@ public SmaaPostProcessPass(Shader shader, Texture2D smaaAreaTexture, Texture2D s this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.SMAANeighborhoodBlend; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); m_AreaTexture = smaaAreaTexture; m_SearchTexture = smaaSearchTexture; @@ -42,8 +40,7 @@ public SmaaPostProcessPass(Shader shader, Texture2D smaaAreaTexture, Texture2D s public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class SMAASetupPassData @@ -67,13 +64,13 @@ private class SMAAPassData public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - var cameraData = frameData.Get(); if (cameraData.antialiasing != AntialiasingMode.SubpixelMorphologicalAntiAliasing) return; + if (!m_Material.Validate()) + return; + var resourceData = frameData.Get(); var sourceTexture = resourceData.cameraColor; @@ -109,7 +106,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer passData.stencilMask = (float)kStencilBit; passData.antialiasingQuality = cameraData.antialiasingQuality; - passData.material = m_Material; + passData.material = m_Material.material; builder.SetRenderAttachment(edgeTexture, 0, AccessFlags.Write); builder.SetRenderAttachmentDepth(edgeTextureStencil, AccessFlags.Write); @@ -138,7 +135,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer builder.SetRenderAttachmentDepth(edgeTextureStencil, AccessFlags.Read); passData.sourceTexture = edgeTexture; builder.UseTexture(edgeTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; builder.SetRenderFunc(static (SMAAPassData data, RasterGraphContext context) => { @@ -159,7 +156,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer builder.UseTexture(sourceTexture, AccessFlags.Read); passData.blendTexture = blendTexture; builder.UseTexture(blendTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; builder.SetRenderFunc(static (SMAAPassData data, RasterGraphContext context) => { diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/StopNanPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/StopNanPostProcessPass.cs index bd653d285f0..5238899826e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/StopNanPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/StopNanPostProcessPass.cs @@ -8,22 +8,19 @@ internal sealed class StopNanPostProcessPass : PostProcessPass { public const string k_TargetName = "CameraColorStopNaNs"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; public StopNanPostProcessPass(Shader shader) { this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.StopNaNs; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); } public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } private class StopNaNsPassData @@ -33,13 +30,13 @@ private class StopNaNsPassData } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - var cameraData = frameData.Get(); if (!cameraData.isStopNaNEnabled) return; + if (!m_Material.Validate()) + return; + var resourceData = frameData.Get(); var sourceTexture = resourceData.cameraColor; var destinationTexture = PostProcessUtils.CreateCompatibleTexture(renderGraph, sourceTexture, k_TargetName, true, FilterMode.Bilinear); @@ -50,7 +47,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer builder.SetRenderAttachment(destinationTexture, 0, AccessFlags.ReadWrite); passData.sourceTexture = sourceTexture; builder.UseTexture(sourceTexture, AccessFlags.Read); - passData.stopNaN = m_Material; + passData.stopNaN = m_Material.material; builder.SetRenderFunc(static (StopNaNsPassData data, RasterGraphContext context) => { var cmd = context.cmd; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/TemporalAntiAliasingPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/TemporalAntiAliasingPostProcessPass.cs index 9053ce1c004..ff1a2b7f79a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/TemporalAntiAliasingPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/TemporalAntiAliasingPostProcessPass.cs @@ -8,8 +8,7 @@ internal sealed class TemporalAntiAliasingPostProcessPass : PostProcessPass { public const string k_TargetName = "CameraColorTemporalAA"; - Material m_Material; - bool m_IsValid; + PostProcessMaterial m_Material; uint m_WarnCounter; public TemporalAntiAliasingPostProcessPass(Shader shader) @@ -17,23 +16,18 @@ public TemporalAntiAliasingPostProcessPass(Shader shader) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = null; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); m_WarnCounter = 0; } public override void Dispose() { - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - UniversalCameraData cameraData = frameData.Get(); var postProcessingData = frameData.Get(); if (postProcessingData.activeUpscaler != null && postProcessingData.activeUpscaler.isTemporal) @@ -50,6 +44,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer return; } + if (!m_Material.Validate()) + return; + UniversalResourceData resourceData = frameData.Get(); var sourceTexture = resourceData.cameraColor; @@ -60,7 +57,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer Debug.Assert(motionVectors.IsValid(), "MotionVectors are invalid. TAA requires a motion vector texture."); - TemporalAA.Render(renderGraph, m_Material, cameraData, sourceTexture, in cameraDepth, in motionVectors, destinationTexture); + TemporalAA.Render(renderGraph, m_Material.material, cameraData, sourceTexture, in cameraDepth, in motionVectors, destinationTexture); resourceData.cameraColor = destinationTexture; } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs index b1833e91a0b..d164ae632d4 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs @@ -7,7 +7,7 @@ namespace UnityEngine.Rendering.Universal { internal sealed class UberPostProcessPass : PostProcessPass { - Material m_Material; + PostProcessMaterial m_Material; Texture2D[] m_FilmGrainTextures; public enum FilteringOperation @@ -20,7 +20,6 @@ public enum FilteringOperation RTHandle m_UserLut; FilteringOperation m_FilteringOperation; HDROutputUtils.Operation m_HdrOperations; - bool m_IsValid; bool m_IsFinalPass; bool m_RequireSRGBConversionBlit; bool m_RenderOverlayUI; @@ -31,8 +30,7 @@ public UberPostProcessPass(Shader shader, Texture2D[] filmGrainTextures) this.renderPassEvent = RenderPassEvent.AfterRenderingPostProcessing - 1; this.profilingSampler = URPProfilingSamplers.UberPostProcess; - m_Material = PostProcessUtils.LoadShader(shader, passName); - m_IsValid = m_Material != null; + m_Material = new PostProcessMaterial(shader, passName); m_FilmGrainTextures = filmGrainTextures; // Defaults @@ -48,8 +46,7 @@ public UberPostProcessPass(Shader shader, Texture2D[] filmGrainTextures) public override void Dispose() { m_UserLut?.Release(); - CoreUtils.Destroy(m_Material); - m_IsValid = false; + m_Material.Dispose(); } public void Setup(Texture ditherTexture, @@ -102,7 +99,7 @@ private class UberPostPassData /// public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if(!m_IsValid) + if (!m_Material.Validate()) return; var colorLookup = volumeStack.GetComponent(); @@ -212,7 +209,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if(bloomTexture.IsValid()) builder.UseTexture(bloomTexture, AccessFlags.Read); - passData.material = m_Material; + passData.material = m_Material.material; passData.cameraData = cameraData; passData.useFastSRGBLinearConversion = postProcessingData.useFastSRGBLinearConversion; passData.requireSRGBConversionBlit = m_RequireSRGBConversionBlit; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UpscalerPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UpscalerPostProcessPass.cs index cec9118757d..deccc553c1d 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UpscalerPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UpscalerPostProcessPass.cs @@ -11,7 +11,7 @@ internal sealed class UpscalerPostProcessPass : PostProcessPass public const string k_UpscaledColorTargetName = "CameraColorUpscaled"; Texture2D[] m_BlueNoise16LTex; - Material m_UpscalerReactiveMaskMaterial; + PostProcessMaterial m_UpscalerReactiveMaskMaterial; bool m_IsValid; bool m_WarnedHardwareDrsTemporalUnsupported; @@ -25,24 +25,20 @@ public UpscalerPostProcessPass(Shader reactiveMaskShader, Texture2D[] blueNoise1 this.profilingSampler = null; // Use default name m_BlueNoise16LTex = blueNoise16LTex; - m_UpscalerReactiveMaskMaterial = PostProcessUtils.LoadShader(reactiveMaskShader, passName, logLevel: LogType.Log); + m_UpscalerReactiveMaskMaterial = new PostProcessMaterial(reactiveMaskShader, passName); - m_IsValid = m_BlueNoise16LTex != null && m_BlueNoise16LTex.Length > 0 - && m_UpscalerReactiveMaskMaterial != null; + m_IsValid = m_BlueNoise16LTex != null && m_BlueNoise16LTex.Length > 0; } public override void Dispose() { - CoreUtils.Destroy(m_UpscalerReactiveMaskMaterial); + m_UpscalerReactiveMaskMaterial.Dispose(); m_IsValid = false; } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { - if (!m_IsValid) - return; - UniversalPostProcessingData postProcessingData = frameData.Get(); if (postProcessingData.activeUpscaler == null) return; @@ -75,6 +71,9 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (Debug.isDebugBuild) m_WarnedHardwareDrsTemporalUnsupported = false; + if (!m_IsValid || !m_UpscalerReactiveMaskMaterial.Validate()) + return; + UniversalResourceData resourceData = frameData.Get(); var sourceTexture = resourceData.cameraColor; var srcDesc = sourceTexture.GetDescriptor(renderGraph); @@ -216,7 +215,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer { if (resourceData.cameraOpaqueTexture.IsValid()) { - io.reactiveMask = UpscalerReactiveMaskPass(renderGraph, frameData, m_UpscalerReactiveMaskMaterial, upscaler.reactiveMaskSource, upscalerOptions, io.enableTexArray); + io.reactiveMask = UpscalerReactiveMaskPass(renderGraph, frameData, m_UpscalerReactiveMaskMaterial.material, upscaler.reactiveMaskSource, upscalerOptions, io.enableTexArray); m_WarnedMissingOpaqueTexture = false; } else if (Debug.isDebugBuild && !m_WarnedMissingOpaqueTexture) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/PostProcessUtils.cs b/Packages/com.unity.render-pipelines.universal/Runtime/PostProcessUtils.cs index 885b914ec6c..625057f77d3 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/PostProcessUtils.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/PostProcessUtils.cs @@ -1,3 +1,4 @@ +using System; using UnityEngine.Experimental.Rendering; using UnityEngine.Rendering.RenderGraphModule; using System.Runtime.CompilerServices; // AggressiveInlining @@ -9,29 +10,6 @@ namespace UnityEngine.Rendering.Universal /// public static class PostProcessUtils { - /// - /// Creates a post-processing pass material from a shader. Shader is error checked for device support. - /// - /// Shader used for the material - /// Pass name for error messages. - /// LogType for the message if the shader is not supported. - /// A new Material instance using the provided shader. Null if the shader is not supported or it's missing. - internal static Material LoadShader(Shader shader, string passName = "", LogType logLevel = LogType.Warning) - { - if (shader == null) - { - Debug.LogError($"Missing shader (in '{passName}'). PostProcessing render passes will not execute. Check for missing reference in the Renderer and/or PostProcessData resources."); - return null; - } - else if (!shader.isSupported) - { - Debug.unityLogger.Log(logLevel, $"Shader '{shader.name}' is not supported or has been stripped from the build (in '{passName}'). PostProcessing render passes will not execute."); - return null; - } - - return CoreUtils.CreateEngineMaterial(shader); - } - /// /// Creates a texture compatible with post-processing effects. /// @@ -400,4 +378,55 @@ static class ShaderConstants public static readonly int _SourceSize = Shader.PropertyToID("_SourceSize"); } } + + /// + /// Helper material class for a post-processing materials. + /// Handles checks and logging in case the shader is missing, unsupported or stripped from the build. + /// + internal sealed class PostProcessMaterial : IDisposable + { + readonly Shader m_Shader; + readonly string m_PassName; + Material m_Material; + bool m_LoggedFailure; + + public Shader shader => m_Shader; + public Material material => m_Material; + public bool isValid => m_Material != null; + + public PostProcessMaterial(Shader shader, string passName) + { + m_Shader = shader; + m_PassName = passName; + + // Note: isSupported is also false when all variants of the shader were stripped from the build. + if (shader != null && shader.isSupported) + m_Material = CoreUtils.CreateEngineMaterial(shader); + } + + /// + /// Returns whether the material can be used, and logs the reason once if it can't. + /// + public bool Validate() + { + if (isValid) + return true; + + if (!m_LoggedFailure) + { + m_LoggedFailure = true; + if (m_Shader == null) + Debug.LogError($"Missing shader (in '{m_PassName}'). This post-processing pass will not execute. Check for missing reference in the Renderer and/or PostProcessData resources."); + else if (!m_Shader.isSupported) + Debug.LogWarning($"Shader '{m_Shader.name}' is not supported or has been stripped from the build (in '{m_PassName}'). This post-processing pass will not execute."); + } + return false; + } + + public void Dispose() + { + CoreUtils.Destroy(m_Material); + m_Material = null; + } + } } From f7b5688fe6eaccc67d2b9137586274f4dde1f9d4 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 4 Nov 2026 13:43:46 +0000 Subject: [PATCH 18/61] [Port] [6000.7] Fixed exposure clamp and regression fix --- .../Editor/Overrides/ExposureVolumeEditor.cs | 1 + .../Runtime/Overrides/ExposureVolume.cs | 11 ++++++++- .../Runtime/Passes/ExposurePass.cs | 23 +++++++++++-------- .../ShaderLibrary/GlobalIllumination.hlsl | 18 +++++++++++---- .../ShaderLibrary/ShaderGraphFunctions.hlsl | 3 ++- .../ShaderLibrary/UnityInput.hlsl | 7 ++++-- .../UniversalDOTSInstancing.hlsl | 2 -- 7 files changed, 44 insertions(+), 21 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/ExposureVolumeEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/ExposureVolumeEditor.cs index 3af01ce2f61..1bfba6e9d3e 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/ExposureVolumeEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/ExposureVolumeEditor.cs @@ -36,6 +36,7 @@ public override void OnInspectorGUI() if (m_Mode.value.intValue == (int)ExposureVolume.Mode.Fixed) { PropertyField(m_FixedExposure); + m_FixedExposure.value.floatValue = Mathf.Clamp(m_FixedExposure.value.floatValue, ExposureVolume.k_MinFixedExposure, ExposureVolume.k_MaxFixedExposure); } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/ExposureVolume.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/ExposureVolume.cs index 7fe1639ae31..b93d2c0edb3 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/ExposureVolume.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/ExposureVolume.cs @@ -28,11 +28,20 @@ public enum Mode /// [Tooltip("Specifies the method that is used to process exposure.")] public EnumParameter mode = new(Mode.Fixed); + // Largest EV where both 2^EV and 2^-EV are finite, normal floats + internal const float k_MinFixedExposure = -126f; + internal const float k_MaxFixedExposure = 126f; + /// - /// An exposure value for Cameras in this Volume, in EV units. + /// An exposure value for Cameras in this Volume, in EV units, clamped to the range [-126, 126]. /// This parameter is used only when is set. /// [Tooltip("An exposure value for Cameras in this Volume, in EV units.")] public FloatParameter fixedExposure = new(0f); + + internal float GetClampedFixedExposure() + { + return Mathf.Clamp(fixedExposure.value, k_MinFixedExposure, k_MaxFixedExposure); + } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ExposurePass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ExposurePass.cs index f3f1fa87634..75a635e7f55 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ExposurePass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/ExposurePass.cs @@ -30,26 +30,29 @@ private TextureHandle CreateTexture(RenderGraph renderGraph) public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) { + var cameraData = frameData.Get(); + var probe = cameraData.cameraType == CameraType.Reflection ? cameraData.camera.reflectionProbeRendered : null; + if (!GraphicsSettings.TryGetRenderPipelineSettings(out var exposureSetting) || !exposureSetting.UseExposure) + { + // This capture is not pre-exposed. Reset the probe's EV so it doesn't keep the value from an earlier + // capture made with exposure enabled, which would be applied once exposure is enabled again. + if (probe != null) + probe.exposureValue = 0f; return; + } var exposureVolume = VolumeManager.instance.stack.GetComponent(); if (exposureVolume.mode.value == ExposureVolume.Mode.Fixed) { - float exposureMultiplier = Mathf.Pow(2.0f, -exposureVolume.fixedExposure.value); + float fixedExposure = exposureVolume.GetClampedFixedExposure(); + float exposureMultiplier = Mathf.Pow(2.0f, -fixedExposure); var resourceData = frameData.Get(); - var cameraData = frameData.Get(); resourceData.exposureMultiplier = CreateTexture(renderGraph); - if (cameraData.cameraType == CameraType.Reflection) - { - var probe = cameraData.camera.reflectionProbeRendered; - if (probe != null) - { - probe.exposureValue = exposureVolume.fixedExposure.value; - } - } + if (probe != null) + probe.exposureValue = fixedExposure; using (var builder = renderGraph.AddRasterRenderPass("Set Fixed Exposure", out PassData passData)) { diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GlobalIllumination.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GlobalIllumination.hlsl index c3dc3aa1bb0..162b9575c9b 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GlobalIllumination.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GlobalIllumination.hlsl @@ -379,6 +379,14 @@ float CalculateProbeWeight(float3 positionWS, float4 probeBoxMin, float4 probeBo return saturate(min(weightDir.x, min(weightDir.y, weightDir.z))); } +// Per-object probes carry their capture exposure (EV) in the decode bias (z). +// 2^EV leaves fp16 range past 15 EV, so it is evaluated and applied in float. +URP_LIGHT_ACCUM3 DecodeExposedProbe(half4 encodedIrradiance, real4 decodeInstructions) +{ + float exposureMultiplier = SelectProbeExposureMultiplier(exp2((float)decodeInstructions.z)); + return exposureMultiplier * DecodeHDREnvironment(encodedIrradiance, decodeInstructions); +} + half CalculateProbeVolumeSqrMagnitude(float4 probeBoxMin, float4 probeBoxMax) { half3 maxToMin = half3(probeBoxMax.xyz - probeBoxMin.xyz); @@ -435,7 +443,7 @@ half3 CalculateIrradianceFromReflectionProbes(half3 reflectVector, float3 positi float4 scaleOffset0 = urp_ReflProbes_MipScaleOffset[probeIndex * 7 + (uint)mip0]; float4 scaleOffset1 = urp_ReflProbes_MipScaleOffset[probeIndex * 7 + (uint)mip1]; - float preExposure = urp_ReflProbes_ExposureMultipliers[probeIndex].x; + float preExposure = SelectProbeExposureMultiplier(urp_ReflProbes_ExposureMultipliers[probeIndex].x); half3 irradiance0 = half4(SAMPLE_TEXTURE2D_LOD(urp_ReflProbes_Atlas, sampler_LinearClamp, uv * scaleOffset0.xy + scaleOffset0.zw, 0.0)).rgb; half3 irradiance1 = half4(SAMPLE_TEXTURE2D_LOD(urp_ReflProbes_Atlas, sampler_LinearClamp, uv * scaleOffset1.xy + scaleOffset1.zw, 0.0)).rgb; irradiance += preExposure * weight * lerp(irradiance0, irradiance1, mipBlend); @@ -501,7 +509,7 @@ half3 CalculateIrradianceFromReflectionProbes(half3 reflectVector, float3 positi half4 encodedIrradiance = half4(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVector0, mip)); - irradiance += weightProbe0 * SelectProbeExposureMultiplier(unity_SpecCube0_Exposure.x) * DecodeHDREnvironment(encodedIrradiance, unity_SpecCube0_HDR); + irradiance += weightProbe0 * DecodeExposedProbe(encodedIrradiance, unity_SpecCube0_HDR); } // Sample the second reflection probe @@ -517,7 +525,7 @@ half3 CalculateIrradianceFromReflectionProbes(half3 reflectVector, float3 positi } half4 encodedIrradiance = half4(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube1, samplerunity_SpecCube1, reflectVector1, mip)); - irradiance += weightProbe1 * SelectProbeExposureMultiplier(unity_SpecCube1_Exposure.x) * DecodeHDREnvironment(encodedIrradiance, unity_SpecCube1_HDR); + irradiance += weightProbe1 * DecodeExposedProbe(encodedIrradiance, unity_SpecCube1_HDR); } #endif @@ -580,7 +588,7 @@ half3 GlossyEnvironmentReflection(half3 reflectVector, float3 positionWS, half p half mip = PerceptualRoughnessToMipmapLevel(perceptualRoughness); half4 encodedIrradiance = half4(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVector, mip)); - irradiance = SelectProbeExposureMultiplier(unity_SpecCube0_Exposure.x) * DecodeHDREnvironment(encodedIrradiance, unity_SpecCube0_HDR); + irradiance = DecodeExposedProbe(encodedIrradiance, unity_SpecCube0_HDR); } } @@ -605,7 +613,7 @@ half3 GlossyEnvironmentReflection(half3 reflectVector, half perceptualRoughness, half mip = PerceptualRoughnessToMipmapLevel(perceptualRoughness); half4 encodedIrradiance = half4(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVector, mip)); - irradiance = SelectProbeExposureMultiplier(unity_SpecCube0_Exposure.x) * DecodeHDREnvironment(encodedIrradiance, unity_SpecCube0_HDR); + irradiance = DecodeExposedProbe(encodedIrradiance, unity_SpecCube0_HDR); } return irradiance * occlusion; diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl index 1f690917deb..4d39fd69ed6 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderGraphFunctions.hlsl @@ -105,7 +105,8 @@ float3 shadergraph_LWReflectionProbe(float3 viewDir, float3 normalOS, float lod) #if USE_CLUSTER_LIGHT_LOOP return SAMPLE_TEXTURECUBE_LOD(_GlossyEnvironmentCubeMap, sampler_GlossyEnvironmentCubeMap, reflectVec, lod).rgb; #else - return DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVec, lod), unity_SpecCube0_HDR); + // The probe's capture exposure (EV) is carried in the decode bias (z) + return SelectProbeExposureMultiplier(exp2((float)unity_SpecCube0_HDR.z)) * DecodeHDREnvironment(SAMPLE_TEXTURECUBE_LOD(unity_SpecCube0, samplerunity_SpecCube0, reflectVec, lod), unity_SpecCube0_HDR); #endif } diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl index 30f527816a8..f4888b940b8 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UnityInput.hlsl @@ -102,12 +102,10 @@ float4 unity_SpecCube0_BoxMax; // w contains the blend distance float4 unity_SpecCube0_BoxMin; // w contains the lerp value float4 unity_SpecCube0_ProbePosition; // w is set to 1 for box projection float4 unity_SpecCube0_Rotation; -float4 unity_SpecCube0_Exposure; // Only the x value is used float4 unity_SpecCube1_BoxMax; // w contains the blend distance float4 unity_SpecCube1_BoxMin; // w contains the sign of (SpecCube0.importance - SpecCube1.importance) float4 unity_SpecCube1_ProbePosition; // w is set to 1 for box projection float4 unity_SpecCube1_Rotation; -float4 unity_SpecCube1_Exposure; // Only the x value is used // Lightmap block feature float4 unity_LightmapST; @@ -163,6 +161,11 @@ uint unity_LightProbeUsagePropertyEntry; // static-const fallback at parse time and miss the per-instance override. #define IsLightProbeSamplingEnabled() (unity_LightProbeUsage != 0u) +// The probe capture exposure (EV) is carried in unity_SpecCubeN_HDR.z. These keep the exposure multiplier (2^EV in x) +// available to custom shaders under its previous name, without extra per-draw data. +#define unity_SpecCube0_Exposure float4(exp2((float)unity_SpecCube0_HDR.z), 0.0, 0.0, 0.0) +#define unity_SpecCube1_Exposure float4(exp2((float)unity_SpecCube1_HDR.z), 0.0, 0.0, 0.0) + #if defined(USING_STEREO_MATRICES) CBUFFER_START(UnityStereoViewBuffer) float4x4 unity_StereoMatrixP[2]; diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UniversalDOTSInstancing.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UniversalDOTSInstancing.hlsl index b859a07599e..29184a8797d 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UniversalDOTSInstancing.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/UniversalDOTSInstancing.hlsl @@ -55,12 +55,10 @@ static const float4 unity_SpecCube0_BoxMax = float4(1,1,1,1); static const float4 unity_SpecCube0_BoxMin = float4(0,0,0,0); static const float4 unity_SpecCube0_ProbePosition = float4(0,0,0,0); static const float4 unity_SpecCube0_Rotation = float4(0,0,0,0); -static const float4 unity_SpecCube0_Exposure = float4(1,0,0,0); static const float4 unity_SpecCube1_BoxMax = float4(1,1,1,1); static const float4 unity_SpecCube1_BoxMin = float4(0,0,0,0); static const float4 unity_SpecCube1_ProbePosition = float4(0,0,0,0); static const float4 unity_SpecCube1_Rotation = float4(0,0,0,0); -static const float4 unity_SpecCube1_Exposure = float4(1,0,0,0); static const float4 unity_SpecCube1_HDR = float4(0,0,0,0); // Set up by BRG picking/selection code From 51315e851b19a98bdec92fad4e31859c1fbeb2fa Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 4 Nov 2026 13:43:47 +0000 Subject: [PATCH 19/61] [Port] [6000.7] [UUM-159743] Surface Cache: set uint uniforms with SetComputeIntParam --- .../Runtime/Lighting/SurfaceCache/SurfaceCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs index 233d98a5a69..9b5e39f6d28 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs @@ -947,7 +947,7 @@ static void Estimate(EstimationPassData data, UnsafeGraphContext graphCtx) cmd.SetComputeBufferParam(shader, kernelIdx, ShaderIDs._PunctualLights, punctualLightBuffer); cmd.SetComputeIntParam(shader, ShaderIDs._PunctualLightCount, punctualLightCount); cmd.SetComputeIntParam(shader, ShaderIDs._SamplesPerPunctualLight, (int)SamplesPerPunctualLight); - cmd.SetComputeFloatParam(shader, ShaderIDs._FrameIdx, data.FrameIdx); + cmd.SetComputeIntParam(shader, ShaderIDs._FrameIdx, (int)data.FrameIdx); cmd.SetComputeBufferParam(shader, kernelIdx, ShaderIDs._Samples, data.PunctualLightSamples); cmd.SetComputeBufferParam(shader, kernelIdx, ShaderIDs._MaterialEntries, data.World.GetMaterialListBuffer()); cmd.SetComputeTextureParam(shader, kernelIdx, ShaderIDs._AlbedoTextures, data.World.GetMaterialAlbedoTextures()); @@ -985,7 +985,7 @@ static void Estimate(EstimationPassData data, UnsafeGraphContext graphCtx) cmd.SetComputeIntParam(shader, ShaderIDs._MultiBounce, data.MultiBounce ? 1 : 0); cmd.SetComputeIntParam(shader, ShaderIDs._PatchWarping, data.PatchWarpingEnabled ? 1 : 0); cmd.SetComputeFloatParam(shader, ShaderIDs._VolumeVoxelMinSize, data.VolumeVoxelMinSize); - cmd.SetComputeFloatParam(shader, ShaderIDs._PunctualLightSampleCount, data.PunctualLightSampleCount); + cmd.SetComputeIntParam(shader, ShaderIDs._PunctualLightSampleCount, (int)data.PunctualLightSampleCount); cmd.SetComputeFloatParam(shader, ShaderIDs._ShortHysteresis, data.ShortHysteresis); cmd.SetComputeIntParam(shader, ShaderIDs._RingConfigOffset, (int)data.RingConfigOffset); cmd.SetComputeBufferParam(shader, kernelIdx, ShaderIDs._CellPatchIndices, data.CellPatchIndices); From c1b915de54b67ff70e1bd7513222f3441d6cb6d7 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 5 Nov 2026 19:18:47 +0000 Subject: [PATCH 20/61] [Port] [6000.7] [UUM-159072] Fix DebugUI UIntField clamping losing precision above 2^24 --- .../Runtime/Debugging/DebugUI.Fields.cs | 8 ++-- .../Tests/Editor/Debugging/DebugUITests.cs | 48 +++++++++++++++++++ 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs index c05f1f089b1..d37884d19d9 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/DebugUI.Fields.cs @@ -289,8 +289,8 @@ public class IntField : Field /// Validated value. public override int ValidateValue(int value) { - if (min != null) value = Mathf.Max(value, min()); - if (max != null) value = Mathf.Min(value, max()); + if (min != null) value = Math.Max(value, min()); + if (max != null) value = Math.Min(value, max()); return value; } @@ -386,8 +386,8 @@ public class UIntField : Field /// Validated value. public override uint ValidateValue(uint value) { - if (min != null) value = (uint)Mathf.Max(value, min()); - if (max != null) value = (uint)Mathf.Min(value, max()); + if (min != null) value = Math.Max(value, min()); + if (max != null) value = Math.Min(value, max()); return value; } diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging/DebugUITests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging/DebugUITests.cs index bb87bff1bee..d182a190c1e 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging/DebugUITests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/Debugging/DebugUITests.cs @@ -1,3 +1,6 @@ +#if ENABLE_UIELEMENTS_MODULE && UNITY_ENABLE_CHECKS +#define ENABLE_RENDERING_DEBUGGER_UI +#endif #if ENABLE_RENDERING_DEBUGGER_UI using NUnit.Framework; using UnityEngine.Rendering; @@ -63,6 +66,51 @@ public void RoundToPrecision_WithLargeValueAndRefValue_HandlesCorrectly() float result = DebugUI.DebugUIStepperHelper.RoundToPrecision(12345.0f, 100.0f); Assert.AreEqual(12345.0f, result, 0.01f); } + + [TestCase(-5, ExpectedResult = 10)] + [TestCase(15, ExpectedResult = 15)] + [TestCase(25, ExpectedResult = 20)] + public int IntField_ValidateValue_ClampsToMinMax(int value) + { + var field = new DebugUI.IntField { min = () => 10, max = () => 20 }; + return field.ValidateValue(value); + } + + [TestCase(int.MinValue, ExpectedResult = int.MinValue)] + [TestCase(int.MaxValue, ExpectedResult = int.MaxValue)] + [TestCase(123456789, ExpectedResult = 123456789)] + public int IntField_ValidateValue_PreservesValueWithinFullRange(int value) + { + var field = new DebugUI.IntField { min = () => int.MinValue, max = () => int.MaxValue }; + return field.ValidateValue(value); + } + + [TestCase(5u, ExpectedResult = 10u)] + [TestCase(15u, ExpectedResult = 15u)] + [TestCase(25u, ExpectedResult = 20u)] + public uint UIntField_ValidateValue_ClampsToMinMax(uint value) + { + var field = new DebugUI.UIntField { min = () => 10u, max = () => 20u }; + return field.ValidateValue(value); + } + + [TestCase(0u, ExpectedResult = 0u)] + [TestCase(uint.MaxValue, ExpectedResult = uint.MaxValue)] + [TestCase(123456789u, ExpectedResult = 123456789u)] + public uint UIntField_ValidateValue_PreservesValueWithinFullRange(uint value) + { + var field = new DebugUI.UIntField { min = () => 0u, max = () => uint.MaxValue }; + return field.ValidateValue(value); + } + + [TestCase(-5f, ExpectedResult = 10f)] + [TestCase(15.5f, ExpectedResult = 15.5f)] + [TestCase(25f, ExpectedResult = 20f)] + public float FloatField_ValidateValue_ClampsToMinMax(float value) + { + var field = new DebugUI.FloatField { min = () => 10f, max = () => 20f }; + return field.ValidateValue(value); + } } } #endif From 96effe38c99f832a71842c5ef69fba235241abbc Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 5 Nov 2026 19:18:47 +0000 Subject: [PATCH 21/61] [Port] [6000.7] Add "Always Refresh info message" in Surface Cache Volume Override --- .../Editor/Overrides/SurfaceCacheGIVolumeEditor.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs index 73288b6814e..c435738d673 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs @@ -116,10 +116,15 @@ public override void OnDisable() m_VolumeSerializedObject.Dispose(); m_VolumeSerializedObject = null; } + + base.OnDisable(); } public override void OnInspectorGUI() { + if (SceneView.lastActiveSceneView && !SceneView.lastActiveSceneView.sceneViewState.alwaysRefreshEnabled) + EditorGUILayout.HelpBox("Enable \"Always Refresh\" in the Scene View to see realtime updates in the Scene View.", MessageType.Info); + PropertyField(m_Enabled, s_State); if (showAdditionalProperties) From 854ebc5f385dca5c8512c64d5041e40ad3b670e8 Mon Sep 17 00:00:00 2001 From: Rose Hirigoyen Date: Thu, 5 Nov 2026 19:18:48 +0000 Subject: [PATCH 22/61] [Port] [6000.7] [UUM-147726] Make the cubemap render request test use its own URP asset --- .../Tests/Runtime/RuntimeTests.cs | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs index dae5a9e990b..cb48c0c2095 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs @@ -15,6 +15,8 @@ class RuntimeTests RenderPipelineAsset currentAssetGraphics; RenderPipelineAsset currentAssetQuality; RenderTexture m_Destination; + UniversalRenderPipelineAsset m_TestAsset; + UniversalRendererData m_TestRendererData; [SetUp] public void Setup() @@ -37,6 +39,16 @@ public void Cleanup() Object.DestroyImmediate(m_Destination); m_Destination = null; } + if (m_TestAsset != null) + { + Object.DestroyImmediate(m_TestAsset); + m_TestAsset = null; + } + if (m_TestRendererData != null) + { + Object.DestroyImmediate(m_TestRendererData); + m_TestRendererData = null; + } } static readonly (int tier, string textTier)[] k_ShadowResolutions = @@ -135,6 +147,15 @@ public IEnumerator RenderRequest_WithCubemapDestination_RendersIntoRequestedFace if ((SystemInfo.copyTextureSupport & CopyTextureSupport.DifferentTypes) == 0) Assert.Ignore("Render requests into a cubemap require CopyTextureSupport.DifferentTypes."); + // The active quality level can use a debug renderer that overwrites the camera color + m_TestRendererData = ScriptableObject.CreateInstance(); + m_TestRendererData.renderingMode = RenderingMode.Forward; + m_TestAsset = ScriptableObject.CreateInstance(); + m_TestAsset.m_RendererDataList[0] = m_TestRendererData; + QualitySettings.renderPipeline = m_TestAsset; + yield return null; + Assert.AreSame(m_TestAsset, GraphicsSettings.currentRenderPipeline, "The test URP asset is not active."); + camera.clearFlags = CameraClearFlags.SolidColor; camera.backgroundColor = Color.red; camera.cullingMask = 0; From c3a209e4e6ac180090b0ad2d4247b596f5212d20 Mon Sep 17 00:00:00 2001 From: Rose Hirigoyen Date: Thu, 5 Nov 2026 19:18:48 +0000 Subject: [PATCH 23/61] [Port] [6000.7] [UUM-139389] Untangle texture creation status from update count in Texture2DAtlas --- .../Runtime/AssemblyInfo.cs | 1 + .../Runtime/Textures/Texture2DAtlas.cs | 203 ++++++++--------- .../Tests/Editor/Texture2DAtlasTests.cs | 205 ++++++++++++++++++ .../Tests/Editor/Texture2DAtlasTests.cs.meta | 2 + 4 files changed, 312 insertions(+), 99 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs create mode 100644 Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.core/Runtime/AssemblyInfo.cs b/Packages/com.unity.render-pipelines.core/Runtime/AssemblyInfo.cs index edfff7d9c23..0e770b06597 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/AssemblyInfo.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/AssemblyInfo.cs @@ -4,6 +4,7 @@ [assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor")] [assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor.CLI")] [assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Runtime.Tests")] +[assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor.Tests")] [assembly: InternalsVisibleTo("Unity.GraphicTests.Performance.RPCore.Runtime")] [assembly: InternalsVisibleTo("Unity.GraphicTests.Performance.Universal.Runtime")] // access to internal ProfileIds diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Textures/Texture2DAtlas.cs b/Packages/com.unity.render-pipelines.core/Runtime/Textures/Texture2DAtlas.cs index 80b1827c814..8e44c16a4a6 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Textures/Texture2DAtlas.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Textures/Texture2DAtlas.cs @@ -213,18 +213,15 @@ private enum BlitType CubeTo2DOctahedralSingleChannel, } - /// - /// Texture is not on the GPU or is not up to date. - /// - private protected const int kGPUTexInvalid = 0; - /// - /// Texture Mip0 is on the GPU and up to date. - /// - private protected const int kGPUTexValidMip0 = 1; - /// - /// Texture and all mips are on the GPU and up to date. - /// - private protected const int kGPUTexValidMipAll = 2; + private enum GPUTextureState + { + // Texture is not on the GPU or is not up to date. + Invalid = 0, + // Texture Mip0 is on the GPU and up to date. + ValidMip0 = 1, + // Texture and all mips are on the GPU and up to date. + ValidMipAll = 2, + } /// /// The texture for the atlas. @@ -249,7 +246,8 @@ private enum BlitType bool m_IsAtlasTextureOwner = false; private AtlasAllocator m_AtlasAllocator = null; private Dictionary m_AllocationCache = new(); - private Dictionary m_IsGPUTextureUpToDate = new(); + private Dictionary m_GPUTextureStates = new(); + private Dictionary m_RTUpdateCounts = new(); private Dictionary m_TextureHashes = new(); static readonly Vector4 fullScaleOffset = new Vector4(1, 1, 0, 0); @@ -329,7 +327,9 @@ public void ResetAllocator() m_AtlasAllocator.Reset(); m_AllocationCache.Clear(); - m_IsGPUTextureUpToDate.Clear(); // mark all GPU textures as invalid. + m_GPUTextureStates.Clear(); // mark all GPU textures as invalid. + m_RTUpdateCounts.Clear(); + m_TextureHashes.Clear(); } /// @@ -347,7 +347,9 @@ public void ClearTarget(CommandBuffer cmd) Blitter.BlitQuad(cmd, Texture2D.blackTexture, fullScaleOffset, fullScaleOffset, mipLevel, true); } - m_IsGPUTextureUpToDate.Clear(); // mark all GPU textures as invalid. + m_GPUTextureStates.Clear(); // mark all GPU textures as invalid. + m_RTUpdateCounts.Clear(); + m_TextureHashes.Clear(); } /// @@ -439,14 +441,65 @@ private void Blit2DTexture(CommandBuffer cmd, Vector4 scaleOffset, Texture textu /// Texture has valid mip maps. private protected void MarkGPUTextureValid(TextureIdentifier identifier, bool mipAreValid = false) { - m_IsGPUTextureUpToDate[identifier] = (mipAreValid) ? kGPUTexValidMipAll : kGPUTexValidMip0; + m_GPUTextureStates[identifier] = (mipAreValid) ? GPUTextureState.ValidMipAll : GPUTextureState.ValidMip0; } /// /// Mark texture invalid on the GPU. /// /// Texture identifier. - private protected void MarkGPUTextureInvalid(TextureIdentifier identifier) => m_IsGPUTextureUpToDate[identifier] = kGPUTexInvalid; + private protected void MarkGPUTextureInvalid(TextureIdentifier identifier) + { + m_GPUTextureStates[identifier] = GPUTextureState.Invalid; + + m_RTUpdateCounts.Remove(identifier); + m_TextureHashes.Remove(identifier); + } + + // Describes our copy of the texture, not the source: false means the slot was never uploaded, or a + // re-layout or clear invalidated it, even when the source texture itself has not changed. + private bool IsGPUTextureValid(TextureIdentifier identifier, bool needMips) + { + if (!m_GPUTextureStates.TryGetValue(identifier, out var state)) + return false; + + return state == GPUTextureState.ValidMipAll || (!needMips && state == GPUTextureState.ValidMip0); + } + + private static int GetRenderTextureVersion(RenderTexture rtA, RenderTexture rtB) + { + if (rtA != null && rtB != null) + return HashCode.Combine(rtA.updateCount, rtB.updateCount); + + // At least one is a render texture, or the caller would not be on this path. + return (int)(rtA != null ? rtA.updateCount : rtB.updateCount); + } + + // Render textures carry a version, so a moved version is the signal that the source changed. A missing + // record means the slot was never filled or was emptied, which always needs an upload. + private bool NeedsRenderTextureUpload(TextureIdentifier identifier, int version, bool needMips) + { + if (!m_RTUpdateCounts.TryGetValue(identifier, out int recorded) || recorded != version) + { + m_RTUpdateCounts[identifier] = version; + return true; + } + + // The source has not moved, but our copy can still be stale after a re-layout or a clear. + return !IsGPUTextureValid(identifier, needMips); + } + + // Regular textures carry no version, so a changed import hash is the only signal that the source changed. + private bool NeedsTextureUpload(TextureIdentifier identifier, int textureHash, bool needMips) + { + if (!m_TextureHashes.TryGetValue(identifier, out int recorded) || recorded != textureHash) + { + m_TextureHashes[identifier] = textureHash; + return true; + } + + return !IsGPUTextureValid(identifier, needMips); + } /// /// Blit 2D texture into the atlas. @@ -659,6 +712,9 @@ public virtual bool AllocateTexture(CommandBuffer cmd, ref Vector4 scaleOffset, // texture is up to date MarkGPUTextureValid(instanceID, true); m_TextureHashes[instanceID] = CoreUtils.GetTextureHash(texture); + + if (texture is RenderTexture rt) + m_RTUpdateCounts[instanceID] = (int)rt.updateCount; } return allocated; @@ -707,7 +763,6 @@ public virtual bool AllocateTextureWithoutBlit(TextureIdentifier identifier, int scaleOffset.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height)); m_AllocationCache[identifier] = (scaleOffset, new Vector2Int(width, height)); MarkGPUTextureInvalid(identifier); // the texture data haven't been uploaded - m_TextureHashes[identifier] = -1; return true; } else @@ -850,42 +905,21 @@ internal Vector2Int GetCachedTextureSize(TextureIdentifier identifier) /// Source texture. /// Texture uses mips. /// True if texture needs update, false otherwise. + /// This call is not side effect free: it refreshes the cached render texture + /// update count as it compares it, so two consecutive calls do not necessarily return the same value. public virtual bool NeedsUpdate(Texture texture, bool needMips = false) { - RenderTexture rt = texture as RenderTexture; var key = GetTextureIdentifier(texture); - int textureHash = CoreUtils.GetTextureHash(texture); - // Update the render texture if needed - if (rt != null) - { - int updateCount; - if (m_IsGPUTextureUpToDate.TryGetValue(key, out updateCount)) - { - if (rt.updateCount != updateCount) - { - m_IsGPUTextureUpToDate[key] = (int)rt.updateCount; - return true; - } - } - else - { - m_IsGPUTextureUpToDate[key] = (int)rt.updateCount; - } - } - // In case the texture settings/import settings have changed, we need to update it - else if (m_TextureHashes.TryGetValue(key, out int hash) && hash != textureHash) - { - m_TextureHashes[key] = textureHash; - return true; - } - // For regular textures, values == 0 means that their GPU data needs to be updated (either because - // the atlas have been re-layouted or the texture have never been uploaded. We also check if the mips - // are valid for the texture if we need them - else if (m_IsGPUTextureUpToDate.TryGetValue(key, out var value)) - return value == kGPUTexInvalid || (needMips && value == kGPUTexValidMip0); + if (!m_AllocationCache.ContainsKey(key)) + return false; - return false; + // Render textures are versioned by updateCount, everything else by its import hash. The two paths are + // disjoint: a render texture is never hash checked, and a regular texture has no version to compare. + if (texture is RenderTexture rt) + return NeedsRenderTextureUpload(key, (int)rt.updateCount, needMips); + + return NeedsTextureUpload(key, CoreUtils.GetTextureHash(texture), needMips); } /// @@ -909,20 +943,21 @@ public virtual bool NeedsUpdate(int id, int updateCount, bool needMips) /// The update count. /// Texture uses mips. /// True if slot needs update, false otherwise. + /// This call is not side effect free: it refreshes the cached update count as it + /// compares it, so two consecutive calls do not necessarily return the same value. public virtual bool NeedsUpdate(TextureIdentifier identifier, int updateCount, bool needMips = false) { - int atlasUpdateCount; - if (m_IsGPUTextureUpToDate.TryGetValue(identifier, out atlasUpdateCount)) - { - if (updateCount != atlasUpdateCount) - { - m_IsGPUTextureUpToDate[identifier] = updateCount; - return true; - } - } - else + if (!m_AllocationCache.ContainsKey(identifier)) + return false; + + // Deliberately not NeedsRenderTextureUpload: callers of this overload upload outside the atlas, so it + // never learns which mip levels they wrote and cannot honour needMips or read a meaningful GPU state. + // A missing count is the only record that the slot was never filled, which is why + // MarkGPUTextureInvalid removes it. + if (!m_RTUpdateCounts.TryGetValue(identifier, out int recorded) || recorded != updateCount) { - m_IsGPUTextureUpToDate[identifier] = updateCount; + m_RTUpdateCounts[identifier] = updateCount; + return true; } return false; @@ -935,53 +970,22 @@ public virtual bool NeedsUpdate(TextureIdentifier identifier, int updateCount, b /// Source texture B. /// Texture uses mips. /// True if texture needs update, false otherwise. + /// This call is not side effect free: it refreshes the cached render texture + /// update count as it compares it, so two consecutive calls do not necessarily return the same value. public virtual bool NeedsUpdate(Texture textureA, Texture textureB, bool needMips = false) { RenderTexture rtA = textureA as RenderTexture; RenderTexture rtB = textureB as RenderTexture; var key = GetTextureIdentifier(textureA, textureB); - int textureHash = GetTextureHash(textureA, textureB); - // Update the render texture if needed + if (!m_AllocationCache.ContainsKey(key)) + return false; + + // Same disjoint split as the single texture overload, except the version has to describe both sources. if (rtA != null || rtB != null) - { - int updateCount; - if (m_IsGPUTextureUpToDate.TryGetValue(key, out updateCount)) - { - if (rtA != null && rtB != null && Math.Min(rtA.updateCount, rtB.updateCount) != updateCount) - { - m_IsGPUTextureUpToDate[key] = (int)Math.Min(rtA.updateCount, rtB.updateCount); - return true; - } - else if (rtA != null && rtA.updateCount != updateCount) - { - m_IsGPUTextureUpToDate[key] = (int)rtA.updateCount; - return true; - } - else if (rtB != null && rtB.updateCount != updateCount) - { - m_IsGPUTextureUpToDate[key] = (int)rtB.updateCount; - return true; - } - } - else - { - m_IsGPUTextureUpToDate[key] = textureHash; - } - } - // In case the texture settings/import settings have changed, we need to update it - else if (m_TextureHashes.TryGetValue(key, out int hash) && hash != textureHash) - { - m_TextureHashes[key] = textureHash; - return true; - } - // For regular textures, values == 0 means that their GPU data needs to be updated (either because - // the atlas have been re-layouted or the texture have never been uploaded. We also check if the mips - // are valid for the texture if we need them - else if (m_IsGPUTextureUpToDate.TryGetValue(key, out var value)) - return value == kGPUTexInvalid || (needMips && value == kGPUTexValidMip0); + return NeedsRenderTextureUpload(key, GetRenderTextureVersion(rtA, rtB), needMips); - return false; + return NeedsTextureUpload(key, GetTextureHash(textureA, textureB), needMips); } /// @@ -1056,6 +1060,7 @@ internal bool EnsureTextureSlot(out bool isUploadNeeded, ref Vector4 scaleBias, isUploadNeeded = true; scaleBias.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height)); m_AllocationCache.Add(key, (scaleBias, new Vector2Int(width, height))); + MarkGPUTextureInvalid(key); // the texture data haven't been uploaded return true; } } diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs new file mode 100644 index 00000000000..069eed87cb3 --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs @@ -0,0 +1,205 @@ +using NUnit.Framework; +using UnityEngine.Experimental.Rendering; + +namespace UnityEngine.Rendering.Tests +{ + // Covers the bookkeeping Texture2DAtlas does to decide whether a slot has to be re-uploaded. The cases that + // matter are the ones where the atlas invalidates a slot on its own: the source texture is untouched, so an + // update count alone cannot tell the atlas that its copy is gone. + class Texture2DAtlasTests + { + const int k_AtlasSize = 128; + const int k_TextureSize = 32; + + Texture2DAtlas m_Atlas; + RenderTexture m_RenderTexture; + + [SetUp] + public void SetUp() + { + m_Atlas = new Texture2DAtlas(k_AtlasSize, k_AtlasSize, GraphicsFormat.R8G8B8A8_UNorm, name: "Texture2DAtlas Tests", useMipMap: false); + + m_RenderTexture = new RenderTexture(k_TextureSize, k_TextureSize, 0) { hideFlags = HideFlags.HideAndDontSave }; + m_RenderTexture.Create(); + } + + [TearDown] + public void TearDown() + { + m_Atlas.Release(); + m_Atlas = null; + + m_RenderTexture.Release(); + Object.DestroyImmediate(m_RenderTexture); + m_RenderTexture = null; + } + + [Test, NUnit.Framework.Property("Jira", "UUM-139389")] + public void ReallocatedSlotNeedsUploadEvenThoughTheRenderTextureIsUnchanged() + { + var identifier = m_Atlas.GetTextureIdentifier(m_RenderTexture); + var scaleOffset = Vector4.zero; + + Assert.IsTrue(m_Atlas.AllocateTextureWithoutBlit(identifier, k_TextureSize, k_TextureSize, ref scaleOffset), + "The atlas should have room for the render texture."); + + m_Atlas.NeedsUpdate(m_RenderTexture); // Caches the current update count, as a frame using the cookie would. + + uint updateCountBeforeReallocation = m_RenderTexture.updateCount; + + // What PowerOfTwoTextureAtlas.ReserveSpace does when a cookie changes resolution: the slot is handed + // back to the allocator and reserved again. The render texture is untouched, so it is the atlas, not + // the source, that knows the slot is empty. + Assert.IsTrue(m_Atlas.AllocateTextureWithoutBlit(identifier, k_TextureSize, k_TextureSize, ref scaleOffset)); + + Assert.AreEqual(updateCountBeforeReallocation, m_RenderTexture.updateCount, + "Sanity check: nothing should have rendered into the render texture."); + + Assert.IsTrue(m_Atlas.NeedsUpdate(m_RenderTexture), + "The new slot holds no data yet, so it needs to be uploaded even though the update count is unchanged."); + } + + [Test, NUnit.Framework.Property("Jira", "UUM-139389")] + public void SlotStaysOutOfDateUntilItIsUploaded() + { + // Guards the fallback on the atlas' own view of the slot. The update count only answers "did the source + // change", so once it has been cached every later call compares equal and the answer has to come from + // somewhere else. Without the fallback this returns false while the slot is still empty. + var scaleOffset = Vector4.zero; + Assert.IsTrue(m_Atlas.AllocateTextureWithoutBlit(m_Atlas.GetTextureIdentifier(m_RenderTexture), k_TextureSize, k_TextureSize, ref scaleOffset)); + + Assert.IsTrue(m_Atlas.NeedsUpdate(m_RenderTexture), + "The slot has never been uploaded."); + + Assert.IsTrue(m_Atlas.NeedsUpdate(m_RenderTexture), + "Asking twice does not upload anything, so the slot is still empty and still needs an upload."); + } + + // The overload taking a raw update count is used by callers that render into the atlas themselves rather + // than going through a blit, so the atlas is never told the content landed. For those, the cached count is + // the only record that a slot holds anything, and it has to be dropped whenever the slot is emptied. + [Test, NUnit.Framework.Property("Jira", "UUM-139389")] + public void SlotWithCallerSuppliedUpdateCountNeedsUploadAfterReallocation() + { + var identifier = m_Atlas.GetTextureIdentifier(m_RenderTexture); + var scaleOffset = Vector4.zero; + const int constantUpdateCount = 7; // A decal that never changes: the count alone can never ask for an upload. + + Assert.IsTrue(m_Atlas.AllocateTextureWithoutBlit(identifier, k_TextureSize, k_TextureSize, ref scaleOffset)); + + Assert.IsTrue(m_Atlas.NeedsUpdate(identifier, constantUpdateCount), + "A freshly allocated slot holds nothing yet."); + + Assert.IsFalse(m_Atlas.NeedsUpdate(identifier, constantUpdateCount), + "Nothing changed since the upload, so the caller must not redraw the slot every frame."); + + // PowerOfTwoTextureAtlas.ReserveSpace on a resolution change, and RelayoutEntries, both hand the slot + // back to the allocator and reserve it again. The source is untouched, so the count is unchanged. + Assert.IsTrue(m_Atlas.AllocateTextureWithoutBlit(identifier, k_TextureSize / 2, k_TextureSize / 2, ref scaleOffset)); + + Assert.IsTrue(m_Atlas.NeedsUpdate(identifier, constantUpdateCount), + "The new slot is empty, so it needs an upload even though the caller's update count is unchanged."); + } + + [Test] + public void RegularTextureNeedsUploadWhileTheSlotIsEmpty() + { + // The non render texture path has no update count to compare, so the atlas' own view of the slot is the + // only thing that can ask for the upload. + var texture = new Texture2D(k_TextureSize, k_TextureSize) { hideFlags = HideFlags.HideAndDontSave }; + try + { + var scaleOffset = Vector4.zero; + Assert.IsTrue(m_Atlas.AllocateTextureWithoutBlit(m_Atlas.GetTextureIdentifier(texture), k_TextureSize, k_TextureSize, ref scaleOffset)); + + Assert.IsTrue(m_Atlas.NeedsUpdate(texture), + "The slot has never been uploaded."); + } + finally + { + Object.DestroyImmediate(texture); + } + } + + [Test] + public void SlotWithCallerSuppliedUpdateCountOutsideTheAtlasDoesNotNeedUpdate() + { + // Same reasoning as TextureOutsideTheAtlasDoesNotNeedUpdate: with no slot there is nothing to refresh, + // and the caller would otherwise render over whatever sits at the atlas origin. + Assert.IsFalse(m_Atlas.NeedsUpdate(m_Atlas.GetTextureIdentifier(m_RenderTexture), 7), + "An identifier the atlas has never allocated has no slot to refresh."); + } + + [Test] + public void TextureOutsideTheAtlasDoesNotNeedUpdate() + { + // Not an academic case: HDRP's LightCookieManager.Fetch2DCookie logs when a cookie is missing from the + // atlas but still calls NeedsUpdate, and IsCached leaves its scale-offset at zero on a miss. Reporting + // an update for a texture with no slot would blit it over the atlas origin, on top of another light's + // cookie, every frame the atlas is out of space. + Assert.IsFalse(m_Atlas.NeedsUpdate(m_RenderTexture), + "A texture the atlas has never allocated has no slot to refresh."); + } + + [Test] + public void UploadedSlotIsUpToDate() + { + // The other direction of SlotStaysOutOfDateUntilItIsUploaded: once the content lands the atlas has to + // stop asking, or every consumer re-uploads every frame. + var atlas = new FakeBlitAtlas(useMipMap: false); + try + { + var scaleOffset = Vector4.zero; + Assert.IsTrue(atlas.AllocateTextureWithoutBlit(atlas.GetTextureIdentifier(m_RenderTexture), k_TextureSize, k_TextureSize, ref scaleOffset)); + Assert.IsTrue(atlas.NeedsUpdate(m_RenderTexture), "The slot has never been uploaded."); + + atlas.BlitTexture(null, scaleOffset, m_RenderTexture, Vector4.zero); + + Assert.IsFalse(atlas.NeedsUpdate(m_RenderTexture), + "The slot holds the current content, so nothing needs re-uploading."); + } + finally + { + atlas.Release(); + } + } + + [Test] + public void SlotUploadedWithoutMipsNeedsUploadOnlyWhenMipsAreRequested() + { + // The mip levels are tracked separately from the slot itself, so a mip0-only upload still satisfies a + // caller that does not sample mips and still fails one that does. + var atlas = new FakeBlitAtlas(useMipMap: true); + try + { + var scaleOffset = Vector4.zero; + Assert.IsTrue(atlas.AllocateTextureWithoutBlit(atlas.GetTextureIdentifier(m_RenderTexture), k_TextureSize, k_TextureSize, ref scaleOffset)); + Assert.IsTrue(atlas.NeedsUpdate(m_RenderTexture), "The slot has never been uploaded."); + + atlas.BlitTexture(null, scaleOffset, m_RenderTexture, Vector4.zero, blitMips: false); + + Assert.IsFalse(atlas.NeedsUpdate(m_RenderTexture, needMips: false), + "Mip 0 is current and the caller does not need mips."); + Assert.IsTrue(atlas.NeedsUpdate(m_RenderTexture, needMips: true), + "Only mip 0 was uploaded, so a caller that samples mips still needs an upload."); + } + finally + { + atlas.Release(); + } + } + + // Stands in for a real blit: does the bookkeeping a blit would, without going through Blitter and therefore + // without an initialized render pipeline. PowerOfTwoTextureAtlas overrides BlitTexture the same way. + class FakeBlitAtlas : Texture2DAtlas + { + public FakeBlitAtlas(bool useMipMap) + : base(k_AtlasSize, k_AtlasSize, GraphicsFormat.R8G8B8A8_UNorm, name: "FakeBlitAtlas Tests", useMipMap: useMipMap) + { + } + + public override void BlitTexture(CommandBuffer cmd, Vector4 scaleOffset, Texture texture, Vector4 sourceScaleOffset, bool blitMips = true, TextureIdentifier overrideIdentifier = default) + => MarkGPUTextureValid(overrideIdentifier != default ? overrideIdentifier : GetTextureIdentifier(texture), blitMips); + } + } +} diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs.meta b/Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs.meta new file mode 100644 index 00000000000..3e372e3cb0a --- /dev/null +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/Texture2DAtlasTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: c383e779ecc7d4960b19b8f345cc3dcf \ No newline at end of file From 6a7428824be682f67eb1fc38e527462ed5c66d11 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 5 Nov 2026 19:18:49 +0000 Subject: [PATCH 24/61] [Port] [6000.7] DOCG-9337 Fix typo in Screen Space Lens Flare --- .../shared/lens-flare/reference-screen-space-lens-flare.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md index c9a62c95c4e..96783b8da15 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md @@ -16,7 +16,7 @@ Use the **Flares** settings to control regular flares, reversed flares and warpe | ----------------------- | ----------------- | ------------------------------------------------------------ | | **Regular Multiplier** | | Set the strength of regular flares. If the value is 0, HDRP doesn't calculate or render regular flares. The default is 1. | | **Reversed Multiplier** | | Set the strength of reversed flares. If the value is 0, HDRP doesn't calculate or render reversed flares. The default is 1. | -| **Warped Multipler** | | Set the strength of warped flares. If the value is 0, HDRP doesn't calculate or render warped flares. The default is 1. | +| **Warped Multiplier** | | Set the strength of warped flares. If the value is 0, HDRP doesn't calculate or render warped flares. The default is 1. | | | **Scale** | Scale the width (**x**) and height (**y**) of warped flares. The defaults are 1. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. | | **Samples** | | Set the number of times HDRP repeats the regular, reversed and warped flares. The range is 1 through 3. The default is 1. Increasing **Samples** has a big impact on performance. | | | **Sample Dimmer** | Set the strength of the lens flares HDRP adds if you set **Samples** to 2 or 3. The higher the value, the less intense the flares. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. | From dd5756b65f714885f26ff87ba6caee72e52f8c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simone=20Livieri=20=EF=BC=88Livieri=20Simone=20-=20?= =?UTF-8?q?=E3=83=AA=E3=83=93=E3=82=A8=E3=83=AA=20=E3=82=B7=E3=83=A2?= =?UTF-8?q?=E3=83=8D=EF=BC=89?= Date: Thu, 5 Nov 2026 19:18:49 +0000 Subject: [PATCH 25/61] [6000.7][HDRP Sample] Add missing IET framework dependencies --- .../Packages/com.unity.template.hd/package.json | 10 ++++++---- .../com.unity.template-hd/Packages/packages-lock.json | 4 +++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Templates/com.unity.template-hd/Packages/com.unity.template.hd/package.json b/Templates/com.unity.template-hd/Packages/com.unity.template.hd/package.json index 60f3f3b60e1..343f7e3a72b 100644 --- a/Templates/com.unity.template-hd/Packages/com.unity.template.hd/package.json +++ b/Templates/com.unity.template-hd/Packages/com.unity.template.hd/package.json @@ -7,13 +7,15 @@ "unity": "6000.7", "description": "This template utilizes the High Definition Render Pipeline. Making it a good starting point for people focused on high-end graphics that want to develop games for platforms that support Shader Model 5.0 (DX11 and above). \n\nBeyond being tuned for High End visuals this project includes\n▪ Shadergraph \n▪ Visual Effect Graph \n▪ Presets \n▪ Example content", "dependencies": { + "com.unity.collab-proxy": "2.13.6", "com.unity.cinemachine": "6.7.0", + "com.unity.ide.rider": "3.0.40", + "com.unity.ide.visualstudio": "2.0.28", "com.unity.inputsystem": "6.7.0", + "com.unity.learn.iet-framework": "6.0.7", + "com.unity.learn.iet-framework.authoring": "2.0.7", "com.unity.render-pipelines.high-definition": "17.7.0", "com.unity.timeline": "6.7.0", - "com.unity.ugui": "2.7.0", - "com.unity.ide.rider": "3.0.40", - "com.unity.ide.visualstudio": "2.0.28", - "com.unity.collab-proxy": "2.13.6" + "com.unity.ugui": "2.7.0" } } diff --git a/Templates/com.unity.template-hd/Packages/packages-lock.json b/Templates/com.unity.template-hd/Packages/packages-lock.json index 6afab516ba4..8c1303a20f2 100644 --- a/Templates/com.unity.template-hd/Packages/packages-lock.json +++ b/Templates/com.unity.template-hd/Packages/packages-lock.json @@ -198,7 +198,9 @@ "com.unity.ugui": "2.7.0", "com.unity.ide.rider": "3.0.40", "com.unity.ide.visualstudio": "2.0.28", - "com.unity.collab-proxy": "2.13.6" + "com.unity.collab-proxy": "2.13.6", + "com.unity.learn.iet-framework": "6.0.7", + "com.unity.learn.iet-framework.authoring": "2.0.7" } }, "com.unity.test-framework": { From 7e6926700509bc780724e106fd588d88258df3eb Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 5 Nov 2026 19:18:51 +0000 Subject: [PATCH 26/61] [Port] [6000.7] Render Pipeline Convertor - Failing to convert certain assets (UUM-151534) --- .../ReadonlyMaterialConverter.MaterialReferenceBuilder.cs | 2 +- .../Converter/BuiltInToHDRPReadonlyMaterialConverter.cs | 7 +++++++ .../Converter/BuiltInToURP2DReadonlyMaterialConverter.cs | 7 +++++++ .../2D/Converter/URP3DToURP2DReadonlyMaterialConverter.cs | 7 +++++++ .../Converters/BuiltInToURP3DReadonlyMaterialConverter.cs | 7 +++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs index 5026ecc9a56..750c2fbe1d0 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/ReadonlyMaterialConverter/ReadonlyMaterialConverter.MaterialReferenceBuilder.cs @@ -141,7 +141,7 @@ public static bool TryGetReferenceInfoFromType(Type type, out MaterialReferenceI foreach (var prop in type.GetProperties(flags)) { - if (!prop.CanRead) continue; + if (!prop.CanRead || prop.GetSetMethod(true) == null) continue; // skip read-only properties, e.g. Terrain.splatBaseMaterial if (prop.GetIndexParameters().Length > 0) continue; // skip indexers if (prop.PropertyType == typeof(Material) || prop.PropertyType == typeof(Material[])) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Tools/Converter/BuiltInToHDRPReadonlyMaterialConverter.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Tools/Converter/BuiltInToHDRPReadonlyMaterialConverter.cs index 1aee1bc2c3b..91cd316230a 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Tools/Converter/BuiltInToHDRPReadonlyMaterialConverter.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Tools/Converter/BuiltInToHDRPReadonlyMaterialConverter.cs @@ -18,6 +18,13 @@ internal class BuiltInToURP3DReadonlyMaterialConverter : ReadonlyMaterialConvert public override bool isEnabled => GraphicsSettings.currentRenderPipeline is HDRenderPipelineAsset; public override string isDisabledMessage => "Converter requires HDRP. Convert your project to HDRP to use this converter."; + public override void BeforeConvert() + { + // The replacement materials live in the global settings, which may not exist yet or be out of date + HDRenderPipelineGlobalSettings.Ensure(); + base.BeforeConvert(); + } + protected override Dictionary> materialMappings { get diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/BuiltInToURP2DReadonlyMaterialConverter.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/BuiltInToURP2DReadonlyMaterialConverter.cs index 5277689e34e..033e674c122 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/BuiltInToURP2DReadonlyMaterialConverter.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/BuiltInToURP2DReadonlyMaterialConverter.cs @@ -29,6 +29,13 @@ public override bool isEnabled public override string isDisabledMessage => "Converter requires URP with a 2D Renderer. Convert your project to URP to use this converter."; + public override void BeforeConvert() + { + // The replacement materials live in the global settings, which may not exist yet or be out of date + UniversalRenderPipelineGlobalSettings.Ensure(); + base.BeforeConvert(); + } + protected override Dictionary> materialMappings { get diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/URP3DToURP2DReadonlyMaterialConverter.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/URP3DToURP2DReadonlyMaterialConverter.cs index 7b2e5993eca..1f58365ec1d 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/URP3DToURP2DReadonlyMaterialConverter.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Converter/URP3DToURP2DReadonlyMaterialConverter.cs @@ -30,6 +30,13 @@ public override bool isEnabled public override string isDisabledMessage => "Converter requires URP with a 2D Renderer. Convert your project to URP to use this converter."; + public override void BeforeConvert() + { + // The replacement materials live in the global settings, which may not exist yet or be out of date + UniversalRenderPipelineGlobalSettings.Ensure(); + base.BeforeConvert(); + } + private bool m_Initialized = false; private void InitializeIfNeeded() diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/BuiltInToURP3DReadonlyMaterialConverter.cs b/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/BuiltInToURP3DReadonlyMaterialConverter.cs index 14cf7070182..b68119b5d18 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/BuiltInToURP3DReadonlyMaterialConverter.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Tools/Converters/BuiltInToURP3DReadonlyMaterialConverter.cs @@ -28,6 +28,13 @@ public override bool isEnabled } public override string isDisabledMessage => "Converter requires URP with an Universal Renderer. Convert your project to URP to use this converter."; + public override void BeforeConvert() + { + // The replacement materials live in the global settings, which may not exist yet or be out of date + UniversalRenderPipelineGlobalSettings.Ensure(); + base.BeforeConvert(); + } + protected override Dictionary> materialMappings { get From c0e1e2fb47b3080cfd3b55647fd26b4aefa98678 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:08 +0000 Subject: [PATCH 27/61] [Port] [6000.7] Fix filtered Scene View picking ignoring BatchRendererGroup objects --- .../BatchRendererGroupFilteredPickingTests.cs | 188 ++++++++++++++++++ ...hRendererGroupFilteredPickingTests.cs.meta | 2 + ...ing.SRP.Universal.Foundation.Editor.asmdef | 2 +- 3 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs.meta diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs new file mode 100644 index 00000000000..dc376208bfc --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs @@ -0,0 +1,188 @@ +using System; +using System.Collections; +using NUnit.Framework; +using Unity.Collections; +using Unity.Collections.LowLevel.Unsafe; +using Unity.Jobs; +using UnityEditor; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.TestTools; +using Object = UnityEngine.Object; + +unsafe class BatchRendererGroupFilteredPickingTests +{ + const int k_InstanceCount = 2; + const int k_WarmUpFrameCount = 10; + const int k_SizeOfPackedMatrix = 48; + const int k_ObjectToWorldByteOffset = 96; + const int k_WorldToObjectByteOffset = k_ObjectToWorldByteOffset + k_InstanceCount * k_SizeOfPackedMatrix; + const int k_InstanceDataByteSize = k_WorldToObjectByteOffset + k_InstanceCount * k_SizeOfPackedMatrix; + + static readonly Vector3 k_FrontAndBackOverlap = new Vector3(-0.125f, 0f, 0f); + static readonly Vector3 k_BackOnly = new Vector3(0.5f, 0f, 0f); + + struct PackedMatrix + { + public float c0, c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11; + + public PackedMatrix(Matrix4x4 m) + { + c0 = m.m00; c1 = m.m10; c2 = m.m20; + c3 = m.m01; c4 = m.m11; c5 = m.m21; + c6 = m.m02; c7 = m.m12; c8 = m.m22; + c9 = m.m03; c10 = m.m13; c11 = m.m23; + } + } + + SceneView m_SceneView; + bool m_PreviousAllowAsyncCompilation; + + GameObject m_Front; + GameObject m_Back; + + BatchRendererGroup m_BatchRendererGroup; + GraphicsBuffer m_InstanceData; + Material m_Material; + Material m_PickingMaterial; + BatchID m_BatchID; + BatchMeshID m_MeshID; + BatchMaterialID m_MaterialID; + + [SetUp] + public void SetUp() + { + m_PreviousAllowAsyncCompilation = ShaderUtil.allowAsyncCompilation; + ShaderUtil.allowAsyncCompilation = false; + + EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); + + m_Front = new GameObject("Front"); + m_Front.transform.position = new Vector3(-0.5f, 0f, 0f); + m_Back = new GameObject("Back"); + m_Back.transform.position = new Vector3(0.25f, 0f, 2f); + + m_Material = new Material(Shader.Find("Universal Render Pipeline/Unlit")); + m_PickingMaterial = new Material(Shader.Find("Hidden/Universal Render Pipeline/BRGPicking")); + + m_BatchRendererGroup = new BatchRendererGroup(OnPerformCulling, IntPtr.Zero); + m_BatchRendererGroup.SetEnabledViewTypes(new[] { BatchCullingViewType.Camera, BatchCullingViewType.Picking }); + m_BatchRendererGroup.SetPickingMaterial(m_PickingMaterial); + m_MeshID = m_BatchRendererGroup.RegisterMesh(Resources.GetBuiltinResource("Cube.fbx")); + m_MaterialID = m_BatchRendererGroup.RegisterMaterial(m_Material); + + m_InstanceData = new GraphicsBuffer(GraphicsBuffer.Target.Raw, k_InstanceDataByteSize / sizeof(int), sizeof(int)); + m_InstanceData.SetData(new[] { Matrix4x4.zero }, 0, 0, 1); + var objectToWorld = new[] { new PackedMatrix(m_Front.transform.localToWorldMatrix), new PackedMatrix(m_Back.transform.localToWorldMatrix) }; + var worldToObject = new[] { new PackedMatrix(m_Front.transform.worldToLocalMatrix), new PackedMatrix(m_Back.transform.worldToLocalMatrix) }; + m_InstanceData.SetData(objectToWorld, 0, k_ObjectToWorldByteOffset / k_SizeOfPackedMatrix, k_InstanceCount); + m_InstanceData.SetData(worldToObject, 0, k_WorldToObjectByteOffset / k_SizeOfPackedMatrix, k_InstanceCount); + + var metadata = new NativeArray(2, Allocator.Temp); + metadata[0] = new MetadataValue { NameID = Shader.PropertyToID("unity_ObjectToWorld"), Value = 0x80000000 | k_ObjectToWorldByteOffset }; + metadata[1] = new MetadataValue { NameID = Shader.PropertyToID("unity_WorldToObject"), Value = 0x80000000 | k_WorldToObjectByteOffset }; + m_BatchID = m_BatchRendererGroup.AddBatch(metadata, m_InstanceData.bufferHandle); + metadata.Dispose(); + + m_SceneView = EditorWindow.CreateWindow(); + m_SceneView.position = new Rect(EditorGUIUtility.GetMainWindowPosition().position, new Vector2(512, 512)); + m_SceneView.Focus(); + } + + [TearDown] + public void TearDown() + { + m_SceneView.Close(); + m_SceneView = null; + + m_BatchRendererGroup.Dispose(); + m_InstanceData.Dispose(); + Object.DestroyImmediate(m_PickingMaterial); + Object.DestroyImmediate(m_Material); + + ShaderUtil.allowAsyncCompilation = m_PreviousAllowAsyncCompilation; + } + + JobHandle OnPerformCulling(BatchRendererGroup rendererGroup, BatchCullingContext cullingContext, BatchCullingOutput cullingOutput, IntPtr userContext) + { + int alignment = UnsafeUtility.AlignOf(); + var output = (BatchCullingOutputDrawCommands*)cullingOutput.drawCommands.GetUnsafePtr(); + + output->drawCommands = (BatchDrawCommand*)UnsafeUtility.Malloc(UnsafeUtility.SizeOf() * k_InstanceCount, alignment, Allocator.TempJob); + output->drawRanges = (BatchDrawRange*)UnsafeUtility.Malloc(UnsafeUtility.SizeOf(), alignment, Allocator.TempJob); + output->visibleInstances = (int*)UnsafeUtility.Malloc(sizeof(int) * k_InstanceCount, alignment, Allocator.TempJob); + output->drawCommandPickingEntityIds = null; + output->instanceSortingPositions = null; + output->instanceSortingPositionFloatCount = 0; + output->drawCommandCount = k_InstanceCount; + output->drawRangeCount = 1; + output->visibleInstanceCount = k_InstanceCount; + + for (int i = 0; i < k_InstanceCount; ++i) + { + output->visibleInstances[i] = i; + output->drawCommands[i] = new BatchDrawCommand + { + visibleOffset = (uint)i, + visibleCount = 1, + batchID = m_BatchID, + materialID = m_MaterialID, + meshID = m_MeshID, + submeshIndex = 0, + splitVisibilityMask = 0xff, + flags = BatchDrawCommandFlags.None, + sortingPosition = 0 + }; + } + + output->drawRanges[0] = new BatchDrawRange + { + drawCommandsBegin = 0, + drawCommandsCount = k_InstanceCount, + filterSettings = new BatchFilterSettings { renderingLayerMask = 0xffffffff } + }; + + if (cullingContext.viewType == BatchCullingViewType.Picking) + { + output->drawCommandPickingEntityIds = (EntityId*)UnsafeUtility.Malloc(UnsafeUtility.SizeOf() * k_InstanceCount, alignment, Allocator.TempJob); + output->drawCommandPickingEntityIds[0] = m_Front.GetEntityId(); + output->drawCommandPickingEntityIds[1] = m_Back.GetEntityId(); + } + + return default; + } + + GameObject Pick(Vector3 worldPosition, GameObject[] filter) + { + GameObject picked = null; + + Action pick = null; + pick = _ => + { + picked = HandleUtility.PickGameObject(HandleUtility.WorldToGUIPoint(worldPosition), false, null, filter); + SceneView.duringSceneGui -= pick; + }; + SceneView.duringSceneGui += pick; + m_SceneView.SendEvent(EditorGUIUtility.CommandEvent("TestEvent")); + + return picked; + } + + [UnityTest] + public IEnumerator PickGameObject_WithFilter_OnlyPicksFilteredBatchRendererGroupDraws() + { + m_SceneView.LookAt(Vector3.zero, Quaternion.LookRotation(Vector3.forward, Vector3.up), 2f, true, true); + + for (int i = 0; i < k_WarmUpFrameCount && Pick(k_FrontAndBackOverlap, null) != m_Front; ++i) + { + m_SceneView.RepaintImmediately(); + yield return null; + } + + Assert.AreEqual(m_Front, Pick(k_FrontAndBackOverlap, null), "Unfiltered pick didn't return the front BatchRendererGroup object"); + Assert.AreEqual(m_Front, Pick(k_FrontAndBackOverlap, new[] { m_Front }), "Filtered pick didn't return the filtered BatchRendererGroup object"); + Assert.AreEqual(m_Back, Pick(k_FrontAndBackOverlap, new[] { m_Back }), "Excluded BatchRendererGroup object occluded the filtered one"); + Assert.IsNull(Pick(k_BackOnly, new[] { m_Front }), "Excluded BatchRendererGroup object was picked"); + } +} diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs.meta b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs.meta new file mode 100644 index 00000000000..8698ba80f74 --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/BatchRendererGroupFilteredPickingTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 8717b72790a64019b326c1d93e31311b diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/Unity.Testing.SRP.Universal.Foundation.Editor.asmdef b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/Unity.Testing.SRP.Universal.Foundation.Editor.asmdef index 3d33a7d8dfa..f620d88866a 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/Unity.Testing.SRP.Universal.Foundation.Editor.asmdef +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Test/Editor/Unity.Testing.SRP.Universal.Foundation.Editor.asmdef @@ -21,7 +21,7 @@ "Editor" ], "excludePlatforms": [], - "allowUnsafeCode": false, + "allowUnsafeCode": true, "overrideReferences": true, "precompiledReferences": [ "nunit.framework.dll" From 5b897ea3c1e133dcd45c583196c99a5b99308def Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:10 +0000 Subject: [PATCH 28/61] [Port] [6000.7] Bugfix: Small scale jitter broken in QRNG_KRONECKER --- .../Runtime/Sampling/QuasiRandom.hlsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Sampling/QuasiRandom.hlsl b/Packages/com.unity.render-pipelines.core/Runtime/Sampling/QuasiRandom.hlsl index fb88fe71731..36e7ea491dd 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Sampling/QuasiRandom.hlsl +++ b/Packages/com.unity.render-pipelines.core/Runtime/Sampling/QuasiRandom.hlsl @@ -168,11 +168,11 @@ struct QrngKronecker2D uint cranleyPattersonRot = cranleyPattersonSeed + 3646589397 * (dimension / 4); #ifdef QRNG_KRONECKER_ENHANCED_QUALITY // add small scale jitter as explained in paper - const float alphaJitter[] = { 2681146017, 685201898 }; + const uint alphaJitter[] = { 2681146017, 685201898 }; uint jitter = alphaJitter[dimension % 2] * shuffledSampleIndex; float amplitude = 0.05 * 0.78 / sqrt(2) * rsqrt(float(sampleIndex)); - cranleyPattersonRot += jitter * uint(amplitude); + cranleyPattersonRot += uint(jitter * amplitude); #endif // Kronecker sequence evaluation return UintToFloat01(cranleyPattersonRot + alphas[dimension % 4] * shuffledSampleIndex); From b29515dba958ab46e51755fd9d97b2117767c36e Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:10 +0000 Subject: [PATCH 29/61] [Port] [6000.7] [UUM-156468] [URP] Fix DBuffer decal error when an empty prepass is skipped --- .../Runtime/Passes/DepthNormalOnlyPass.cs | 4 +- .../Runtime/Passes/DepthOnlyPass.cs | 2 +- .../Runtime/UniversalRenderer.cs | 4 +- .../Runtime/UniversalRendererRenderGraph.cs | 100 ++++++--- .../Tests/Runtime/DecalTests.cs | 108 +++++++++ .../Tests/Runtime/SkippedPrepassTests.cs | 209 ++++++++++++++++++ .../Tests/Runtime/SkippedPrepassTests.cs.meta | 2 + 7 files changed, 394 insertions(+), 35 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthNormalOnlyPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthNormalOnlyPass.cs index 0c18a973ee6..f49056de03a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthNormalOnlyPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthNormalOnlyPass.cs @@ -21,8 +21,8 @@ public partial class DepthNormalOnlyPass : ScriptableRenderPass internal static readonly string k_CameraNormalsTextureName = "_CameraNormalsTexture"; private static readonly int s_CameraDepthTextureID = Shader.PropertyToID("_CameraDepthTexture"); - private static readonly int s_CameraNormalsTextureID = Shader.PropertyToID(k_CameraNormalsTextureName); - private static readonly int s_CameraRenderingLayersTextureID = Shader.PropertyToID("_CameraRenderingLayersTexture"); + internal static readonly int s_CameraNormalsTextureID = Shader.PropertyToID(k_CameraNormalsTextureName); + internal static readonly int s_CameraRenderingLayersTextureID = Shader.PropertyToID("_CameraRenderingLayersTexture"); // Publishes a valid default as the normals global, for the frames where this pass isn't recorded internal static void SetDefaultNormalsGlobalTexture(IBaseRenderGraphBuilder builder, TextureHandle defaultNormalsTexture) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthOnlyPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthOnlyPass.cs index b184018245d..87b7cf07c6b 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthOnlyPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DepthOnlyPass.cs @@ -18,7 +18,7 @@ public partial class DepthOnlyPass : ScriptableRenderPass // Statics private static readonly ShaderTagId k_ShaderTagId = new ShaderTagId("DepthOnly"); - private static readonly int s_CameraDepthTextureID = Shader.PropertyToID("_CameraDepthTexture"); + internal static readonly int s_CameraDepthTextureID = Shader.PropertyToID("_CameraDepthTexture"); /// /// Creates a new DepthOnlyPass instance. diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs index 415079ca2fb..e375bd4655c 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs @@ -728,7 +728,7 @@ public override void FinishRendering(CommandBuffer cmd) // Over time, more settings should be folded into these structs so that the recording methods are fully // decoupled from scattered state. - // Aggregates decisions regarding which rendering stages will actually execute this frame. Derived from + // Aggregates decisions regarding which rendering stages will actually execute this frame, and their targets. Derived from // camera settings, culling masks, shadow distance, and technique requirements (e.g. depth priming). struct RenderStages { @@ -737,6 +737,8 @@ struct RenderStages internal bool drawOpaquePass; internal bool drawTransparentPass; internal bool drawDeferredLightingPass; + + internal bool depthTextureProducedByPrepass; } // Aggregates texture and resource requirements declared by ScriptableRenderPasses and internal features. diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs index c21e0b0e081..d3c99c58bbd 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs @@ -905,13 +905,16 @@ internal override void OnRecordRenderGraph(RenderGraph renderGraph, ScriptableRe // * Similar reasoning as for drawShadowPasses - GBuffer is public frame data so custom passes that don't // respect opaqueLayerMask can draw to it (e.g. DecalGBufferRenderPass or custom gbuffer passes). drawDeferredLightingPass = cameraCullingMask != 0, + + // depthTextureProducedByPrepass: + // * The prepass produces the camera depth texture directly instead of it being copied from the depth attachment. + // If the prepass is not drawn, depth texture is cleared. + depthTextureProducedByPrepass = requirePrepassForTextures && !usesDeferredLighting && !useDepthPriming, }; // Only use a depth format when we do a prepass directly to the cameraDepthTexture, or if R32F color format is not supported. If we do depth priming (ie, prepass to the activeCameraDepth), we don't do a prepass to the texture. Instead, we do a copy from the primed attachment. - // The prepass must also actually execute (drawPrepass); if it's skipped due to empty layer masks, the cameraDepthTexture is never written by the prepass. - bool prepassToCameraDepthTexture = renderStages.drawPrepass && requirePrepassForTextures && !usesDeferredLighting && !useDepthPriming; - bool depthTextureIsDepthFormat = prepassToCameraDepthTexture || !PlatformAutoDetect.hasRenderToR32F; - bool requireCopyFromDepth = renderPassInputs.requiresDepthTexture && !prepassToCameraDepthTexture; + bool depthTextureIsDepthFormat = renderStages.depthTextureProducedByPrepass || !PlatformAutoDetect.hasRenderToR32F; + bool requireCopyFromDepth = renderPassInputs.requiresDepthTexture && !renderStages.depthTextureProducedByPrepass; // We configure this for the first camera of the stack and overlay camera will reuse create color/depth var // to pick the correct target, as if there is an intermediate texture, overlay cam should use them @@ -1156,7 +1159,7 @@ private void RecordCustomPassesWithDepthCopyAndMotion(RenderGraph renderGraph, U // During a partial prepass, we only render forward opaque objects that aren't rendered into the gbuffer. // This produces a set of partial depth & normal buffers that must be completed by the gbuffer pass later in the frame. // This allows us to produce complete depth & normals data before lighting takes place, but it isn't valid when custom - // passes require this data before the gbuffer pass finishes. + // passes require this data before the gbuffer pass finishes (see CalculateDepthCopySchedule). private static bool AllowPartialDepthNormalsPrepass(bool isDeferred, RenderPassInputSummary renderPassInputSummary, bool useDepthPriming) { bool requiresDepthAfterGbuffer = RenderPassEvent.AfterRenderingGbuffer <= renderPassInputSummary.requiresDepthTextureEarliestEvent; @@ -1218,7 +1221,7 @@ static private DepthCopySchedule CalculateDepthCopySchedule(RenderPassEvent earl return schedule; } - private DepthCopySchedule CalculateDepthCopySchedules(UniversalCameraData cameraData, in RenderPassInputSummary renderPassInputs, bool isDeferred, bool requiresDepthPrepass, bool hasFullPrepass) + private static DepthCopySchedule CalculateDepthCopySchedules(in RenderPassInputSummary renderPassInputs, bool depthTextureProducedByPrepass) { // Assume the depth texture is unused and no copy is needed until we determine otherwise DepthCopySchedule depth = DepthCopySchedule.None; @@ -1226,23 +1229,14 @@ private DepthCopySchedule CalculateDepthCopySchedules(UniversalCameraData camera // If the depth texture is read during the frame, determine when the copy should occur if (renderPassInputs.requiresDepthTexture) { - //The prepass will render directly to the depthTexture when not using depth priming. Therefore we don't need a copy in that case. - bool depthTextureRequiresCopy = isDeferred || (!requiresDepthPrepass || useDepthPriming); - - if (depthTextureRequiresCopy) + if (depthTextureProducedByPrepass) { - // A depth read before the GBuffer is served by a copy right after the prepass, so the prepass has - // to be a full one. A missing prepass (e.g. an empty camera culling mask) is not a bug: depth - // simply isn't available before the GBuffer in that case. - Debug.Assert(renderPassInputs.requiresDepthTextureEarliestEvent >= RenderPassEvent.AfterRenderingGbuffer - || !requiresDepthPrepass - || hasFullPrepass, "Doing a partial prepass when the full depth data is needed before 'AfterRenderingGBuffer'"); - - depth = CalculateDepthCopySchedule(renderPassInputs.requiresDepthTextureEarliestEvent); + // The prepass will render directly to the depthTexture when not using depth priming. Therefore we don't need a copy in that case. + depth = DepthCopySchedule.DuringPrepass; } else { - depth = DepthCopySchedule.DuringPrepass; + depth = CalculateDepthCopySchedule(renderPassInputs.requiresDepthTextureEarliestEvent); } } return depth; @@ -1279,15 +1273,10 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co RecordCustomRenderGraphPasses(renderGraph, RenderPassEvent.BeforeRenderingPrePasses); - bool isDepthOnlyPrepass = renderStages.drawPrepass && !renderPassInputs.requiresNormalsTexture; bool isDepthNormalPrepass = renderStages.drawPrepass && renderPassInputs.requiresNormalsTexture; - // The depth prepass is considered "full" (renders the entire scene, not a partial subset), when we either: - // - Have a depth only prepass (URP always renders the full scene in depth only mode) - // - Have a depth normals prepass that does not allow the partial prepass optimization - bool hasFullPrepass = isDepthOnlyPrepass || (isDepthNormalPrepass && !AllowPartialDepthNormalsPrepass(usesDeferredLighting, renderPassInputs, useDepthPriming)); - - var depthCopySchedule = CalculateDepthCopySchedules(cameraData, renderPassInputs, usesDeferredLighting, renderStages.drawPrepass, hasFullPrepass); + bool hasPartialPrepass = isDepthNormalPrepass && AllowPartialDepthNormalsPrepass(usesDeferredLighting, renderPassInputs, useDepthPriming); + var depthCopySchedule = CalculateDepthCopySchedules(renderPassInputs, renderStages.depthTextureProducedByPrepass); // Decide if & when to use GPU Occlusion Culling. // In deferred, do it during gbuffer laydown unless we are forced to do a *full* prepass by a render pass. @@ -1345,7 +1334,7 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co // There's no special copy logic for the camera normals texture, so we can set the global as long as we're not performing a partial prepass. // In the case of a partial prepass, the global will be set later by the gbuffer pass once it completes the data in the texture. - bool setGlobalTextures = isLastPass && hasFullPrepass; + bool setGlobalTextures = isLastPass && !hasPartialPrepass; if (isDepthNormalPrepass) { @@ -1356,7 +1345,7 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co { SetupRenderGraphCameraProperties(renderGraph, depthTarget); } - DepthNormalPrepassRender(renderGraph, renderPassInputs, depthTarget, batchLayerMask, setGlobalDepth, setGlobalTextures, !hasFullPrepass); + DepthNormalPrepassRender(renderGraph, renderPassInputs, depthTarget, batchLayerMask, setGlobalDepth, setGlobalTextures, hasPartialPrepass); // Restore camera properties for the rest of the render graph execution. if (resourceData.isActiveTargetBackBuffer) { @@ -1376,6 +1365,14 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co } } } + else + { + // When a required prepass is skipped due to not rendering any geometry, clear & publish the textures it would have produced. + TextureHandle cameraDepthTexture = renderStages.depthTextureProducedByPrepass ? resourceData.cameraDepthTexture : TextureHandle.nullHandle; + TextureHandle cameraNormalsTexture = renderPassInputs.requiresNormalsTexture && !usesDeferredLighting ? resourceData.cameraNormalsTexture : TextureHandle.nullHandle; + TextureHandle renderingLayersTexture = !usesDeferredLighting && m_RenderingLayerProvidesByDepthNormalPass ? resourceData.renderingLayersTexture : TextureHandle.nullHandle; + PublishPrepassGlobalTexturesPass.Render(renderGraph, cameraDepthTexture, cameraNormalsTexture, renderingLayersTexture); + } // After the prepass completes, we should copy depth if necessary and also render motion vectors. (they're expected to be available whenever depth is) // In the case where depth is rendered as part of the prepass and no copy is necessary, we still need to render motion vectors here to ensure they're available @@ -1397,7 +1394,8 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co m_DeferredLights.ResolveMixedLightingMode(lightData); // Once the mixed lighting mode has been discovered, we know how many MRTs we need for the gbuffer. // Subtractive mixed lighting requires shadowMask output, which is actually used to store unity_ProbesOcclusion values. - m_DeferredLights.CreateGbufferTextures(renderGraph, resourceData, cameraData, isDepthNormalPrepass); + // Render into the camera normals texture whenever normals are required, so it's produced even if the prepass is skipped. + m_DeferredLights.CreateGbufferTextures(renderGraph, resourceData, cameraData, renderPassInputs.requiresNormalsTexture); m_ValidationHandler.OnBeforeGBuffers(renderGraph, resourceData); @@ -1419,7 +1417,8 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co // When we have a partial depth normals prepass, we must wait until the gbuffer pass to set global textures. // In this case, the incoming global texture data is incomplete and the gbuffer pass is required to complete it. - bool setGlobalTextures = isDepthNormalPrepass && !hasFullPrepass; + // When the prepass is skipped, the gbuffer pass is the only producer of these textures. + bool setGlobalTextures = hasPartialPrepass || (!renderStages.drawPrepass && renderPassInputs.requiresNormalsTexture); #if ENABLE_VR && ENABLE_XR_MODULE // Draw the inset depth occluder only once before the first GBuffer sub-pass. // The near-plane depth values it writes persist into subsequent sub-passes because depth is never cleared or invalidated between them @@ -1645,7 +1644,7 @@ private void OnAfterRendering(RenderGraph renderGraph, bool applyPostProcessing) IUpscaler activeUpscaler = postProcessingData.activeUpscaler; bool requiresFinalPostUpscale = cameraData.resolvedUpscalerHash == UniversalRenderPipeline.k_UpscalerHash_FSR1 || (activeUpscaler != null && !activeUpscaler.isTemporal && !postProcessingData.activeUpscalerIsEmbedded); - + // When FXAA or scaling is active, we must perform an additional pass at the end of the frame for the following reasons: // 1. FXAA expects to be the last shader running on the image before it's presented to the screen. Since users are allowed // to add additional render passes after post processing occurs, we can't run FXAA until all of those passes complete as well. @@ -2268,4 +2267,43 @@ internal static void Render(RenderGraph graph, TextureHandle colorHandle, Textur } } + // Only publishes the textures that a prepass would normally publish, in the case where the actual prepass is not executed. + // Implemented as a single pass instead to avoid overhead from three separate passes if using RenderGraphUtils.SetGlobalTexture. + static class PublishPrepassGlobalTexturesPass + { + const string k_PassName = "Publish Prepass Global Textures"; + static readonly ProfilingSampler s_ProfilingSampler = new ProfilingSampler(k_PassName); + + private class PassData { } + + internal static void Render(RenderGraph graph, TextureHandle cameraDepthTexture, TextureHandle cameraNormalsTexture, TextureHandle renderingLayersTexture) + { + if (!cameraDepthTexture.IsValid() && !cameraNormalsTexture.IsValid() && !renderingLayersTexture.IsValid()) + return; + + using (var builder = graph.AddRasterRenderPass(k_PassName, out _, s_ProfilingSampler)) + { + if (cameraDepthTexture.IsValid()) + { + builder.UseTexture(cameraDepthTexture, AccessFlags.Read); + builder.SetGlobalTextureAfterPass(cameraDepthTexture, DepthOnlyPass.s_CameraDepthTextureID); + } + if (cameraNormalsTexture.IsValid()) + { + builder.UseTexture(cameraNormalsTexture, AccessFlags.Read); + builder.SetGlobalTextureAfterPass(cameraNormalsTexture, DepthNormalOnlyPass.s_CameraNormalsTextureID); + } + if (renderingLayersTexture.IsValid()) + { + builder.UseTexture(renderingLayersTexture, AccessFlags.Read); + builder.SetGlobalTextureAfterPass(renderingLayersTexture, DepthNormalOnlyPass.s_CameraRenderingLayersTextureID); + } + + builder.AllowGlobalStateModification(true); + + builder.SetRenderFunc(static (PassData _, RasterGraphContext _) => { }); + } + } + } + } diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/DecalTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/DecalTests.cs index 1127d6c4f92..754a13f3f68 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/DecalTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/DecalTests.cs @@ -1,4 +1,7 @@ +using System.Collections; +using System.Collections.Generic; using NUnit.Framework; +using UnityEngine.TestTools; namespace UnityEngine.Rendering.Universal.Tests { @@ -44,4 +47,109 @@ public void DecalDestroyEmptyChunk() Assert.AreEqual(1, m_EntityManager.chunkCount); } } + + // The DBuffer technique requires a prepass, which URP skips when the camera can't see any prepass layer. + class DecalDBufferSkippedPrepassTests + { + static readonly RenderingMode[] k_RenderingModes = { RenderingMode.Forward, RenderingMode.Deferred }; + + RenderPipelineAsset m_PreviousRenderPipelineAsset; + UniversalRenderPipelineAsset m_Asset; + readonly List m_Objects = new(); + Camera m_Camera; + UniversalAdditionalCameraData m_CameraData; + RenderTexture m_Destination; + + [UnityOneTimeSetUp] + public IEnumerator OneTimeSetUp() + { + m_PreviousRenderPipelineAsset = QualitySettings.renderPipeline; + + if (GraphicsSettings.currentRenderPipeline is not UniversalRenderPipelineAsset) + Assert.Ignore("These tests only run when URP is the active render pipeline."); + if (DecalRendererFeature.isGLDevice) + Assert.Ignore("The DBuffer technique is not supported with OpenGL."); + + // One renderer per rendering mode and decal layers setting, so the tests only need a single pipeline switch + var rendererDataList = new ScriptableRendererData[k_RenderingModes.Length * 2]; + for (int i = 0; i < rendererDataList.Length; ++i) + { + var decalFeature = ScriptableObject.CreateInstance(); + decalFeature.settings.technique = DecalTechniqueOption.DBuffer; + decalFeature.settings.dBufferSettings = new DBufferSettings(); + decalFeature.settings.decalLayers = i % 2 == 1; + m_Objects.Add(decalFeature); + + var rendererData = ScriptableObject.CreateInstance(); + rendererData.renderingMode = k_RenderingModes[i / 2]; + rendererData.rendererFeatures.Add(decalFeature); + m_Objects.Add(rendererData); + rendererDataList[i] = rendererData; + } + + m_Asset = ScriptableObject.CreateInstance(); + m_Asset.m_RendererDataList = rendererDataList; + m_Objects.Add(m_Asset); + QualitySettings.renderPipeline = m_Asset; + + var cameraGameObject = new GameObject("DBuffer Skipped Prepass Camera"); + m_Objects.Add(cameraGameObject); + m_Camera = cameraGameObject.AddComponent(); + m_Camera.enabled = false; + m_Camera.cullingMask = 0; + m_CameraData = cameraGameObject.AddComponent(); + + m_Destination = new RenderTexture(64, 64, 24); + m_Objects.Add(m_Destination); + + // Let the pipeline switch to the test asset + yield return null; + } + + [OneTimeTearDown] + public void OneTimeTearDown() + { + QualitySettings.renderPipeline = m_PreviousRenderPipelineAsset; + + foreach (var obj in m_Objects) + { + if (obj != null) + Object.DestroyImmediate(obj); + } + m_Objects.Clear(); + } + + static IEnumerable RenderCases() + { + foreach (var renderingMode in k_RenderingModes) + { + foreach (var depthPrimingMode in new[] { DepthPrimingMode.Disabled, DepthPrimingMode.Forced }) + { + foreach (bool decalLayers in new[] { false, true }) + { + string layers = decalLayers ? "Yes" : "No"; + yield return new TestCaseData(renderingMode, depthPrimingMode, decalLayers) + .SetName($"RenderWithEmptyCullingMask_DoesNotLogErrors({renderingMode}, DepthPriming:{depthPrimingMode}, DecalLayers:{layers})") + .Returns(null); + } + } + } + } + + [UnityTest, TestCaseSource(nameof(RenderCases))] + public IEnumerator RenderWithEmptyCullingMask_DoesNotLogErrors(RenderingMode renderingMode, DepthPrimingMode depthPrimingMode, bool decalLayers) + { + int rendererIndex = System.Array.IndexOf(k_RenderingModes, renderingMode) * 2 + (decalLayers ? 1 : 0); + ((UniversalRenderer)m_Asset.GetRenderer(rendererIndex)).depthPrimingMode = depthPrimingMode; + m_CameraData.SetRenderer(rendererIndex); + + RenderPipeline.SubmitRenderRequest(m_Camera, new RenderPipeline.StandardRequest { destination = m_Destination }); + + // Validation errors are logged from the render thread, so give it time to process the frame + yield return null; + yield return null; + + LogAssert.NoUnexpectedReceived(); + } + } } diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs new file mode 100644 index 00000000000..5a4a742278d --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs @@ -0,0 +1,209 @@ +using System.Collections; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEngine.Rendering.RenderGraphModule; +using UnityEngine.TestTools; + +namespace UnityEngine.Rendering.Universal.Tests +{ + // URP skips the prepass when the camera can't see any prepass layer. The textures it would have produced must still be + // published as globals, so that shaders sample the same textures that passes declare through the resource data. + class SkippedPrepassTests + { + class PrepassTexturesFeature : ScriptableRendererFeature + { + internal bool requireRenderingLayers; + internal CaptureGlobalsPass capturePass; + + public override void Create() + { + capturePass = new CaptureGlobalsPass(); + } + + public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData) + { + renderer.EnqueuePass(capturePass); + } + + internal override bool RequireRenderingLayers(bool isDeferred, bool needsGBufferAccurateNormals, out RenderingLayerUtils.Event atEvent, out RenderingLayerUtils.MaskSize maskSize) + { + atEvent = RenderingLayerUtils.Event.DepthNormalPrePass; + maskSize = RenderingLayerUtils.MaskSize.Bits8; + return requireRenderingLayers; + } + } + + // Records nothing, only compares the globals published by the prepass stage against the resource data + class CaptureGlobalsPass : ScriptableRenderPass + { + static readonly int k_CameraDepthTextureID = Shader.PropertyToID("_CameraDepthTexture"); + static readonly int k_CameraNormalsTextureID = Shader.PropertyToID("_CameraNormalsTexture"); + static readonly int k_CameraRenderingLayersTextureID = Shader.PropertyToID("_CameraRenderingLayersTexture"); + + internal readonly List mismatches = new(); + + public CaptureGlobalsPass() + { + renderPassEvent = RenderPassEvent.AfterRenderingPrePasses; + } + + public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) + { + var resourceData = frameData.Get(); + + CheckGlobal(renderGraph, k_CameraDepthTextureID, resourceData.cameraDepthTexture, "_CameraDepthTexture"); + CheckGlobal(renderGraph, k_CameraNormalsTextureID, resourceData.cameraNormalsTexture, "_CameraNormalsTexture"); + if (resourceData.renderingLayersTexture.IsValid()) + CheckGlobal(renderGraph, k_CameraRenderingLayersTextureID, resourceData.renderingLayersTexture, "_CameraRenderingLayersTexture"); + } + + void CheckGlobal(RenderGraph renderGraph, int propertyId, TextureHandle expected, string name) + { + if (renderGraph.GetGlobal(propertyId) != expected) + mismatches.Add(name); + } + } + + public enum PrepassState + { + Drawn, + SkippedByCullingMask, + SkippedByLayerMask, + } + + static readonly RenderingMode[] k_RenderingModes = { RenderingMode.Forward, RenderingMode.Deferred }; + const int k_PrepassLayer = 31; + + RenderPipelineAsset m_PreviousRenderPipelineAsset; + UniversalRenderPipelineAsset m_Asset; + readonly PrepassTexturesFeature[] m_Features = new PrepassTexturesFeature[k_RenderingModes.Length]; + readonly List m_Objects = new(); + Camera m_Camera; + UniversalAdditionalCameraData m_CameraData; + RenderTexture m_Destination; + + [UnityOneTimeSetUp] + public IEnumerator OneTimeSetUp() + { + m_PreviousRenderPipelineAsset = QualitySettings.renderPipeline; + + if (GraphicsSettings.currentRenderPipeline is not UniversalRenderPipelineAsset) + Assert.Ignore("These tests only run when URP is the active render pipeline."); + + // One renderer per rendering mode, so the tests only need a single pipeline switch + var rendererDataList = new ScriptableRendererData[k_RenderingModes.Length]; + for (int i = 0; i < k_RenderingModes.Length; ++i) + { + m_Features[i] = ScriptableObject.CreateInstance(); + m_Objects.Add(m_Features[i]); + + // A prepass restricted to a single layer can be skipped while opaque geometry stays visible + var rendererData = ScriptableObject.CreateInstance(); + rendererData.renderingMode = k_RenderingModes[i]; + rendererData.prepassLayerMask = 1 << k_PrepassLayer; + rendererData.rendererFeatures.Add(m_Features[i]); + m_Objects.Add(rendererData); + rendererDataList[i] = rendererData; + } + + m_Asset = ScriptableObject.CreateInstance(); + m_Asset.m_RendererDataList = rendererDataList; + m_Objects.Add(m_Asset); + QualitySettings.renderPipeline = m_Asset; + + var cameraGameObject = new GameObject("Skipped Prepass Camera"); + m_Objects.Add(cameraGameObject); + m_Camera = cameraGameObject.AddComponent(); + m_Camera.enabled = false; + m_CameraData = cameraGameObject.AddComponent(); + + m_Destination = new RenderTexture(64, 64, 24); + m_Objects.Add(m_Destination); + + // Let the pipeline switch to the test asset. Nothing may render during that frame in batchmode, so render once to + // make sure the pipeline exists. Creating it recreates the renderers, which would discard the per-test setup. + yield return null; + RenderPipeline.SubmitRenderRequest(m_Camera, new RenderPipeline.StandardRequest { destination = m_Destination }); + } + + [OneTimeTearDown] + public void OneTimeTearDown() + { + QualitySettings.renderPipeline = m_PreviousRenderPipelineAsset; + + foreach (var obj in m_Objects) + { + if (obj != null) + Object.DestroyImmediate(obj); + } + m_Objects.Clear(); + } + + // The drawn prepass cases check the expectations against the regular path + static IEnumerable PrepassCases() + { + foreach (var renderingMode in k_RenderingModes) + { + foreach (var prepassState in new[] { PrepassState.Drawn, PrepassState.SkippedByCullingMask, PrepassState.SkippedByLayerMask }) + { + // Deferred also skips the gbuffer pass with an empty culling mask, which leaves nothing to produce the normals + if (renderingMode == RenderingMode.Deferred && prepassState == PrepassState.SkippedByCullingMask) + continue; + + // Deferred ignores depth priming + var depthPrimingModes = renderingMode == RenderingMode.Deferred ? + new[] { DepthPrimingMode.Disabled } : new[] { DepthPrimingMode.Disabled, DepthPrimingMode.Forced }; + + foreach (var depthPrimingMode in depthPrimingModes) + { + foreach (bool depthInput in new[] { true, false }) + { + // Without a depth request, depth is only published when the prepass renders into the depth texture + if (!depthInput && (renderingMode == RenderingMode.Deferred || depthPrimingMode == DepthPrimingMode.Forced)) + continue; + + foreach (bool renderingLayers in new[] { false, true }) + { + string depth = depthInput ? "Yes" : "No"; + string layers = renderingLayers ? "Yes" : "No"; + yield return new TestCaseData(renderingMode, prepassState, depthPrimingMode, depthInput, renderingLayers) + .SetName($"PrepassGlobalTextures_MatchResourceData({renderingMode}, Prepass:{prepassState}, DepthPriming:{depthPrimingMode}, DepthInput:{depth}, RenderingLayers:{layers})"); + } + } + } + } + } + } + + [TestCaseSource(nameof(PrepassCases))] + public void PrepassGlobalTextures_MatchResourceData(RenderingMode renderingMode, PrepassState prepassState, DepthPrimingMode depthPrimingMode, bool depthInput, bool renderingLayers) + { + m_Camera.cullingMask = prepassState switch + { + PrepassState.SkippedByCullingMask => 0, + PrepassState.SkippedByLayerMask => ~(1 << k_PrepassLayer), + _ => ~0, + }; + + int rendererIndex = System.Array.IndexOf(k_RenderingModes, renderingMode); + ((UniversalRenderer)m_Asset.GetRenderer(rendererIndex)).depthPrimingMode = depthPrimingMode; + m_CameraData.SetRenderer(rendererIndex); + + var feature = m_Features[rendererIndex]; + var capturePass = feature.capturePass; + feature.requireRenderingLayers = renderingLayers; + capturePass.mismatches.Clear(); + capturePass.ConfigureInput(depthInput ? + ScriptableRenderPassInput.Depth | ScriptableRenderPassInput.Normal : ScriptableRenderPassInput.Normal); + + // Deferred produces the normals in the gbuffer pass + capturePass.renderPassEvent = renderingMode == RenderingMode.Deferred ? + RenderPassEvent.AfterRenderingGbuffer : RenderPassEvent.AfterRenderingPrePasses; + + RenderPipeline.SubmitRenderRequest(m_Camera, new RenderPipeline.StandardRequest { destination = m_Destination }); + + Assert.AreSame(capturePass, feature.capturePass, "The renderer was recreated during the render, discarding the test setup"); + Assert.IsEmpty(capturePass.mismatches, "Globals that don't match the resource data"); + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs.meta new file mode 100644 index 00000000000..ca11f41c85f --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SkippedPrepassTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: bed106e9b2bf4374cb998c7f735bf555 \ No newline at end of file From f8529847c3313433adc3ba14c8f00b660d322f8b Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:10 +0000 Subject: [PATCH 30/61] [Port] [6000.7] Objects using URP Lit materials are not rendered in the Player when Fast Build is enabled in Shader Build Settings (UUM-157641) --- .../Editor/ShaderScriptableStripper.cs | 2 +- .../Editor/ShaderScriptableStripperTests.cs | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs index aa8e6b2a1d1..7becb40a587 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs @@ -507,7 +507,7 @@ internal bool StripUnusedFeatures_BicubicLightmapSampling(ref IShaderScriptableS internal bool StripUnusedFeatures_ReflectionProbeRotation(ref IShaderScriptableStrippingData strippingData) { - if (strippingData.PassHasKeyword(m_ReflectionProbeRotation)) + if (strippingData.PassHasKeyword(m_ReflectionProbeRotation) && !strippingData.IsKeywordDynamic(m_ReflectionProbeRotation)) { bool useRotation = !strippingData.stripReflectionProbeRotationVariants; return useRotation != strippingData.IsKeywordEnabled(m_ReflectionProbeRotation); diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs index 66f5d965b66..59c32b3398c 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShaderScriptableStripperTests.cs @@ -837,6 +837,7 @@ public void TestStripUnusedFeatures(string shaderName) TestStripUnusedFeatures_DebugDisplay(shader); TestStripUnusedFeatures_ScreenCoordOverride(shader); + TestStripUnusedFeatures_ReflectionProbeRotation(shader); TestStripUnusedFeatures_PunctualLightShadows(shader); TestStripUnusedFeatures_FoveatedRendering(shader); TestStripUnusedFeatures_DeferredRendering(shader); @@ -922,6 +923,50 @@ public void TestStripUnusedFeatures_ScreenCoordOverride(Shader shader) helper.AreEqual(shader != null, helper.stripper.StripUnusedFeatures_ScreenCoordOverride(ref helper.data)); } + public void TestStripUnusedFeatures_ReflectionProbeRotation(Shader shader) + { + TestHelper helper; + + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = false; + helper.IsFalse(helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = false; + TestHelper.s_EnabledKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + TestHelper.s_PassKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + helper.IsFalse(helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = false; + TestHelper.s_PassKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + helper.AreEqual(shader != null, helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = true; + TestHelper.s_PassKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + helper.IsFalse(helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = true; + TestHelper.s_EnabledKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + TestHelper.s_PassKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + helper.AreEqual(shader != null, helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + + // A dynamic keyword resolves at runtime, so its single variant must be kept + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = false; + TestHelper.s_PassKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + TestHelper.s_DynamicKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + helper.IsFalse(helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + + helper = new TestHelper(shader, ShaderFeatures.None); + helper.data.stripReflectionProbeRotationVariants = true; + TestHelper.s_PassKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + TestHelper.s_DynamicKeywords = new List() {ShaderKeywordStrings.ReflectionProbeRotation}; + helper.IsFalse(helper.stripper.StripUnusedFeatures_ReflectionProbeRotation(ref helper.data)); + } + public void TestStripUnusedFeatures_PunctualLightShadows(Shader shader) { TestHelper helper; From e4a7dca8a29c0fc6ec3182473b8f97397fb15f6e Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:11 +0000 Subject: [PATCH 31/61] [Port] [6000.7] Make Surface Cache volume override warning about missing Renderer Feature --- .../Editor/Overrides/SurfaceCacheGIVolumeEditor.cs | 4 +++- .../Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs index c435738d673..99c4061b801 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs @@ -4,7 +4,7 @@ namespace UnityEditor.Rendering.Universal { [CustomEditor(typeof(SurfaceCacheGIVolumeOverride))] - internal class SurfaceCacheGIVolumeEditor : VolumeComponentEditor + internal class SurfaceCacheGIVolumeEditor : UniversalRenderPipelineVolumeComponentEditor { protected SurfaceCacheGIVolumeOverride.PresetQuality m_Quality; private bool m_QualityDirty = true; @@ -79,6 +79,8 @@ internal class SurfaceCacheGIVolumeEditor : VolumeComponentEditor public override void OnEnable() { + base.OnEnable(); + var o = new PropertyFetcher(serializedObject); m_Enabled = Unpack(o.Find(obj => obj.enabled)); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs index 800040f7620..ce27ddd6c78 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs @@ -8,6 +8,9 @@ namespace UnityEngine.Rendering.Universal /// [Serializable, VolumeComponentMenu("Lighting/Surface Cache Global Illumination")] [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] +#if SURFACE_CACHE_SUPPORTED || UNITY_EDITOR + [VolumeRequiresRendererFeatures(typeof(SurfaceCacheGIRendererFeature))] +#endif [DisplayInfo(name = "Surface Cache Global Illumination")] public class SurfaceCacheGIVolumeOverride : VolumeComponent { From 6d607e8bc0baf5f6c2b27665ef95f44db21cfb6a Mon Sep 17 00:00:00 2001 From: Rasmus Roenn Nielsen Date: Fri, 6 Nov 2026 00:21:11 +0000 Subject: [PATCH 32/61] [Backport] Bugfix: Enable support for GBUFFER_NORMALS_OCT mode in Surface Cache. --- .../RendererFeatures/SurfaceCacheGIRendererFeature/Debug.compute | 1 + .../ScreenResolveUpsampling.compute | 1 + 2 files changed, 2 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/Debug.compute b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/Debug.compute index b35e43b50f8..500ebb5a31d 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/Debug.compute +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/Debug.compute @@ -2,6 +2,7 @@ #pragma kernel VisualizeMono DISABLE_TEXTURE2D_X_ARRAY #pragma kernel VisualizeSinglePassStereoInstancing +#pragma multi_compile _ _GBUFFER_NORMALS_OCT #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl" diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/ScreenResolveUpsampling.compute b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/ScreenResolveUpsampling.compute index f50cb4f0a05..b5a70819d66 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/ScreenResolveUpsampling.compute +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/ScreenResolveUpsampling.compute @@ -2,6 +2,7 @@ #pragma kernel UpsampleMono DISABLE_TEXTURE2D_X_ARRAY #pragma kernel UpsampleSinglePassStereoInstancing +#pragma multi_compile _ _GBUFFER_NORMALS_OCT #define GROUP_SHARED_CACHE From 6afff780ec8bcdb21946757f72be0d3eb868bb7d Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:13 +0000 Subject: [PATCH 33/61] [Port] [6000.7] [UUM-147992][UUM-158701][7000.0] Fix sprite rendering with a custom MaterialPropertyBlock --- .../RenderSpriteBatchingFrameDebuggerTests.cs | 322 ++++++++++++++++++ ...erSpriteBatchingFrameDebuggerTests.cs.meta | 2 + 2 files changed, 324 insertions(+) create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs.meta diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs new file mode 100644 index 00000000000..f186521d5ee --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs @@ -0,0 +1,322 @@ +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using UnityEditor; +using UnityEditorInternal.FrameDebuggerInternal; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +// Captures Graphics.RenderSprite draws with the Frame Debugger to check how Sprites that share a +// MaterialPropertyBlock are batched, and reads the rendered pixels back to check what each Sprite drew. +[TestFixture] +class RenderSpriteBatchingFrameDebuggerTests +{ + const string k_UnlitMaterialPath = "Packages/com.unity.render-pipelines.universal/Runtime/Materials/Sprite-Unlit-Default.mat"; + const string k_MainTex = "_MainTex"; + const int k_TextureSize = 4; + + static readonly string[] k_TextureNames = { "BatchingRed", "BatchingGreen", "BatchingBlue", "BatchingYellow" }; + static readonly Color[] k_Colors = { Color.red, Color.green, Color.blue, Color.yellow }; + + struct CapturedDraw + { + public FrameEventType type; + public string mainTexName; + public int drawCallCount; + public int instanceCount; + public string breakCause; + + public override string ToString() + { + return type + " _MainTex=" + mainTexName + " drawCalls=" + drawCallCount + " instances=" + instanceCount + " cause=" + breakCause; + } + } + + GameObject m_CameraObject; + Camera m_Camera; + RenderTexture m_RenderTarget; + Material m_Material; + Texture2D[] m_Textures; + Sprite[] m_Sprites; + MaterialPropertyBlock m_Block; + SpriteMaskInteraction m_MaskInteraction; + bool m_PreviousSRPBatcherEnabled; + + [SetUp] + public void Setup() + { + m_PreviousSRPBatcherEnabled = GraphicsSettings.useScriptableRenderPipelineBatching; + GraphicsSettings.useScriptableRenderPipelineBatching = true; + + m_RenderTarget = new RenderTexture(256, 256, 24); + m_CameraObject = new GameObject("BatchingCamera"); + m_Camera = m_CameraObject.AddComponent(); + m_Camera.transform.position = new Vector3(0, 0, -10); + m_Camera.orthographic = true; + m_Camera.orthographicSize = 6; + m_Camera.allowHDR = false; + m_Camera.targetTexture = m_RenderTarget; + var cameraData = m_CameraObject.AddComponent(); + cameraData.SetRenderer(2); // 2D Renderer. See the list of Renderers in CommonAssets/UniversalRPAsset. + cameraData.renderType = CameraRenderType.Base; + cameraData.renderPostProcessing = false; + + m_Material = new Material(AssetDatabase.LoadAssetAtPath(k_UnlitMaterialPath)); + + m_Textures = new Texture2D[k_Colors.Length]; + m_Sprites = new Sprite[k_Colors.Length]; + for (int i = 0; i < k_Colors.Length; ++i) + { + m_Textures[i] = new Texture2D(k_TextureSize, k_TextureSize, TextureFormat.RGBA32, false) { name = k_TextureNames[i] }; + m_Textures[i].SetPixels(Enumerable.Repeat(k_Colors[i], k_TextureSize * k_TextureSize).ToArray()); + m_Textures[i].Apply(); + m_Sprites[i] = Sprite.Create(m_Textures[i], new Rect(0, 0, k_TextureSize, k_TextureSize), new Vector2(0.5f, 0.5f), k_TextureSize); + } + + RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering; + } + + [TearDown] + public void Cleanup() + { + RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering; + FrameDebuggerUtility.SetEnabled(false, -1); + + GraphicsSettings.useScriptableRenderPipelineBatching = m_PreviousSRPBatcherEnabled; + + if (m_Sprites != null) + { + for (int i = 0; i < m_Sprites.Length; ++i) + { + UnityEngine.Object.DestroyImmediate(m_Sprites[i]); + UnityEngine.Object.DestroyImmediate(m_Textures[i]); + } + } + + UnityEngine.Object.DestroyImmediate(m_Material); + UnityEngine.Object.DestroyImmediate(m_CameraObject); + if (m_RenderTarget != null) + { + m_RenderTarget.Release(); + UnityEngine.Object.DestroyImmediate(m_RenderTarget); + } + } + + void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera) + { + if (camera != m_Camera) + return; + + var renderParams = new RenderParams(m_Material) { matProps = m_Block }; + for (int i = 0; i < m_Sprites.Length; ++i) + { + var spriteParams = new SpriteParams(m_Sprites[i], Color.white, m_MaskInteraction); + var objectToWorld = Matrix4x4.Translate(new Vector3((i - 1.5f) * 2f, 0, 0)); + Graphics.RenderSprite(renderParams, spriteParams, 0, objectToWorld); + } + } + + static bool IsDrawEvent(FrameEventType type) => + type == FrameEventType.Mesh || + type == FrameEventType.DynamicBatch || + type == FrameEventType.DynamicGeometry || + type == FrameEventType.InstancedMesh || + type == FrameEventType.SRPBatch; + + void RenderUnderCapture() + { + FrameDebuggerUtility.EnterCapturingScope(); + m_Camera.Render(); + FrameDebuggerUtility.LeaveCapturingScope(); + } + + // Every draw event that uses the test material's shader, with the _MainTex it bound. + List CaptureSpriteDraws() + { + if (!FrameDebuggerUtility.locallySupported) + Assert.Ignore("Frame Debugger requires threaded rendering. Run with -force-gfx-mt."); + + // Warm-up: newly created materials need one render to become SRP Batcher compatible. + m_Camera.Render(); + + FrameDebuggerUtility.SetEnabled(true, -1); + RenderUnderCapture(); + + FrameDebuggerEvent[] events = FrameDebuggerUtility.GetFrameEvents(); + Assert.That(events, Is.Not.Null.And.Not.Empty, "No Frame Debugger events were captured."); + + string[] breakCauses = FrameDebuggerUtility.GetBatchBreakCauseStrings(); + string shaderName = m_Material.shader.name; + var draws = new List(); + for (int index = 0; index < events.Length; ++index) + { + if (!IsDrawEvent(events[index].m_Type)) + continue; + + FrameDebuggerUtility.limit = index + 1; + RenderUnderCapture(); + + var data = new FrameDebuggerEventData(); + FrameDebuggerUtility.GetFrameEventData(index, data); + if (data.m_RealShaderName != shaderName) + continue; + + var draw = new CapturedDraw + { + type = events[index].m_Type, + drawCallCount = data.m_DrawCallCount, + instanceCount = data.m_InstanceCount, + breakCause = breakCauses[data.m_BatchBreakCause], + }; + foreach (var texture in data.m_ShaderInfo.m_Textures) + { + if (texture.m_Name == k_MainTex) + draw.mainTexName = texture.m_TextureName; + } + + draws.Add(draw); + } + + // Otherwise an assertion that no draw has some type would pass on an empty capture. + Assert.That(draws, Is.Not.Empty, $"No draws of '{shaderName}' were captured among {events.Length} events."); + return draws; + } + + // Control: without a block the four Sprites take the SRP Batcher path. + [Test] + public void RenderSprite_WithoutMaterialPropertyBlock_IsSRPBatched() + { + m_Block = null; + m_MaskInteraction = SpriteMaskInteraction.None; + + var draws = CaptureSpriteDraws(); + + Assert.That(draws.Any(d => d.type == FrameEventType.SRPBatch), Is.True, "Expected the Sprites to be SRP batched:\n" + string.Join("\n", draws)); + } + + // A shared block gives every node custom props, which must keep the Sprites out of the SRP Batcher. + [Test] + public void RenderSprite_SharedMaterialPropertyBlock_IsNotSRPBatched( + [Values(SpriteMaskInteraction.None, SpriteMaskInteraction.VisibleOutsideMask)] SpriteMaskInteraction maskInteraction, + [Values] bool enableInstancing) + { + m_Block = new MaterialPropertyBlock(); + m_Block.SetFloat("_BatchProbe", 1f); + m_MaskInteraction = maskInteraction; + m_Material.enableInstancing = enableInstancing; + + var draws = CaptureSpriteDraws(); + + Assert.That(draws.Any(d => d.type == FrameEventType.SRPBatch), Is.False, "Sprites with a MaterialPropertyBlock were SRP batched:\n" + string.Join("\n", draws)); + } + + // One plain render, so nothing from an earlier render in the same frame is drawn again. + [Test] + public void RenderSprite_SharedMaterialPropertyBlock_DrawsEachSpriteWithItsOwnTexture( + [Values(SpriteMaskInteraction.None, SpriteMaskInteraction.VisibleOutsideMask)] SpriteMaskInteraction maskInteraction, + [Values] bool enableInstancing) + { + m_Block = new MaterialPropertyBlock(); + m_Block.SetFloat("_BatchProbe", 1f); + m_MaskInteraction = maskInteraction; + m_Material.enableInstancing = enableInstancing; + + Color[] cellColors = RenderAndReadCellColors(); + + string report = "Cell colours: " + string.Join(", ", cellColors); + for (int i = 0; i < k_Colors.Length; ++i) + Assert.That(IsApproximately(cellColors[i], k_Colors[i]), Is.True, $"Sprite {i} ({k_TextureNames[i]}) was drawn wrongly. " + report); + } + + // Control: without a block, with or without the SRP Batcher. + [Test] + public void RenderSprite_WithoutMaterialPropertyBlock_DrawsEachSpriteWithItsOwnTexture( + [Values(SpriteMaskInteraction.None, SpriteMaskInteraction.VisibleOutsideMask)] SpriteMaskInteraction maskInteraction, + [Values] bool useSRPBatcher, + [Values] bool enableInstancing) + { + m_Block = null; + m_MaskInteraction = maskInteraction; + m_Material.enableInstancing = enableInstancing; + GraphicsSettings.useScriptableRenderPipelineBatching = useSRPBatcher; + + Color[] cellColors = RenderAndReadCellColors(); + + string report = "Cell colours: " + string.Join(", ", cellColors); + for (int i = 0; i < k_Colors.Length; ++i) + Assert.That(IsApproximately(cellColors[i], k_Colors[i]), Is.True, $"Sprite {i} ({k_TextureNames[i]}) was drawn wrongly. " + report); + } + + // Replaces the four Sprites with four cut from the colour quadrants of one atlas texture. + void UseAtlasSprites() + { + for (int i = 0; i < m_Sprites.Length; ++i) + { + UnityEngine.Object.DestroyImmediate(m_Sprites[i]); + UnityEngine.Object.DestroyImmediate(m_Textures[i]); + m_Textures[i] = null; + } + + const int atlasSize = k_TextureSize * 2; + var atlas = new Texture2D(atlasSize, atlasSize, TextureFormat.RGBA32, false) { name = "BatchingAtlas", filterMode = FilterMode.Point }; + for (int i = 0; i < k_Colors.Length; ++i) + { + int x = (i % 2) * k_TextureSize; + int y = (i / 2) * k_TextureSize; + atlas.SetPixels(x, y, k_TextureSize, k_TextureSize, Enumerable.Repeat(k_Colors[i], k_TextureSize * k_TextureSize).ToArray()); + m_Sprites[i] = Sprite.Create(atlas, new Rect(x, y, k_TextureSize, k_TextureSize), new Vector2(0.5f, 0.5f), k_TextureSize); + } + + atlas.Apply(); + m_Textures[0] = atlas; + } + + // The texture in the batching key must not stop Sprites that share an atlas from dynamic batching. + [Test] + public void RenderSprite_SharedMaterialPropertyBlockSameAtlas_IsDynamicBatched( + [Values(SpriteMaskInteraction.None, SpriteMaskInteraction.VisibleOutsideMask)] SpriteMaskInteraction maskInteraction) + { + UseAtlasSprites(); + m_Block = new MaterialPropertyBlock(); + m_Block.SetFloat("_BatchProbe", 1f); + m_MaskInteraction = maskInteraction; + m_Material.enableInstancing = false; + + var draws = CaptureSpriteDraws(); + + // With graphics jobs the Frame Debugger can also record an empty draw event, which is not a batch. + int batchCount = draws.Count(d => d.drawCallCount > 0); + Assert.That(batchCount, Is.EqualTo(1), "Expected the atlas Sprites in one dynamic batch:\n" + string.Join("\n", draws)); + } + + static bool IsApproximately(Color actual, Color expected) + { + const float tolerance = 0.2f; + return Mathf.Abs(actual.r - expected.r) < tolerance && Mathf.Abs(actual.g - expected.g) < tolerance && Mathf.Abs(actual.b - expected.b) < tolerance; + } + + // The colour at the centre of each Sprite. + Color[] RenderAndReadCellColors() + { + m_Camera.Render(); + + var previous = RenderTexture.active; + RenderTexture.active = m_RenderTarget; + var readback = new Texture2D(m_RenderTarget.width, m_RenderTarget.height, TextureFormat.RGBA32, false); + readback.ReadPixels(new Rect(0, 0, m_RenderTarget.width, m_RenderTarget.height), 0, 0); + readback.Apply(); + RenderTexture.active = previous; + + float worldToPixels = m_RenderTarget.height / (2f * m_Camera.orthographicSize); + var colors = new Color[k_Colors.Length]; + for (int i = 0; i < k_Colors.Length; ++i) + { + int x = Mathf.RoundToInt(m_RenderTarget.width * 0.5f + (i - 1.5f) * 2f * worldToPixels); + colors[i] = readback.GetPixel(x, m_RenderTarget.height / 2); + } + + UnityEngine.Object.DestroyImmediate(readback); + return colors; + } +} diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs.meta b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs.meta new file mode 100644 index 00000000000..e47b462b99d --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Test/Editor/RenderSpriteBatchingFrameDebuggerTests.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 71bc3d7cea6849e0af201cc15cf2ca05 \ No newline at end of file From b4aa9b48d816c32df8468ac8707d1232bf62f24d Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:14 +0000 Subject: [PATCH 34/61] [Port] [6000.7] [UUM-138928] Fix editor crash from stack overflow when baking APV in large scenes --- .../Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs | 4 ++-- .../Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs | 4 ++-- .../Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs | 4 ++-- .../Editor/PathTracing/LightBakerStrangler.cs | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs index 4d4123d0ef5..95ca8d53747 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.RenderingLayers.cs @@ -127,8 +127,8 @@ static AccelStructAdapter BuildAccelerationStructure(out bool hasTerrains) Array.Fill(matIndices, renderer.component.renderingLayerMask); // repurpose the material id as we don't need it here var perSubMeshMask = new uint[subMeshCount]; Array.Fill(perSubMeshMask, GetInstanceMask(renderer.component.shadowCastingMode)); - Span perSubMeshOpaqueness = stackalloc bool[subMeshCount]; - perSubMeshOpaqueness.Fill(true); + var perSubMeshOpaqueness = new bool[subMeshCount]; + Array.Fill(perSubMeshOpaqueness, true); accelStruct.AddInstance(EntityId.ToULong(renderer.component.GetEntityId()), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1); } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs index 97e4d823a94..1b742047a4a 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.SkyOcclusion.cs @@ -221,8 +221,8 @@ static AccelStructAdapter BuildAccelerationStructure(out bool hasTerrains) var matIndices = GetMaterialIndices(renderer.component); var perSubMeshMask = new uint[subMeshCount]; Array.Fill(perSubMeshMask, GetInstanceMask(renderer.component.shadowCastingMode)); - Span perSubMeshOpaqueness = stackalloc bool[subMeshCount]; - perSubMeshOpaqueness.Fill(true); + var perSubMeshOpaqueness = new bool[subMeshCount]; + Array.Fill(perSubMeshOpaqueness, true); accelStruct.AddInstance(EntityId.ToULong(renderer.component.GetEntityId()), renderer.component, perSubMeshMask, matIndices, perSubMeshOpaqueness, 1); } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs index b99673082a8..7d6b3cf7f5e 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.VirtualOffset.cs @@ -149,8 +149,8 @@ static AccelStructAdapter BuildAccelerationStructure(int mask, out bool hasTerra int subMeshCount = mesh.subMeshCount; var maskAndMatDummy = new uint[subMeshCount]; System.Array.Fill(maskAndMatDummy, 0xFFFFFFFF); - Span perSubMeshOpaqueness = stackalloc bool[subMeshCount]; - perSubMeshOpaqueness.Fill(true); + var perSubMeshOpaqueness = new bool[subMeshCount]; + System.Array.Fill(perSubMeshOpaqueness, true); accelStruct.AddInstance(EntityId.ToULong(renderer.component.GetEntityId()), renderer.component, maskAndMatDummy, maskAndMatDummy, perSubMeshOpaqueness, 1); } diff --git a/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs b/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs index 0f524e66257..4f793a0dbb7 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/PathTracing/LightBakerStrangler.cs @@ -699,7 +699,7 @@ internal static InstanceHandle[] AddLODInstances(World world, CommandBuffer cmd, if ((lodBuildData.LodMask & currentLodLevel) == 0) continue; - Span currentLodMasks = stackalloc uint[lodBuildData.Masks.Length]; + var currentLodMasks = new uint[lodBuildData.Masks.Length]; GetCurrentLodInstanceMasks(pathtracingShader, lodBuildData.Masks, currentLodMasks); instanceHandles[i++] = world.AddInstance(lodBuildData.Mesh, lodBuildData.Materials, currentLodMasks, UnityComputeWorld.RenderingObjectLayer, lodBuildData.LocalToWorldMatrix, lodBuildData.Bounds, lodBuildData.IsStatic, lodBuildData.Filter, true); @@ -715,7 +715,7 @@ internal static InstanceHandle[] AddLODInstances(World world, CommandBuffer cmd, if ((lodZeroInstance.LodMask & currentLodLevel) != 0) continue; - Span lodZeroMasks = stackalloc uint[lodZeroInstance.Masks.Length]; + var lodZeroMasks = new uint[lodZeroInstance.Masks.Length]; GetLodZeroInstanceMasks(pathtracingShader, lodZeroInstance.Masks, lodZeroMasks); world.UpdateInstanceMask(lodZeroInstance.InstanceHandle, lodZeroMasks); From 2647d08a34c39a81089d57b770ec58544cba63cb Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:14 +0000 Subject: [PATCH 35/61] [Port] [6000.7] Prefabs linger in Surface Cache once you exit "prefab edit mode" (UUM-151920) --- .../SurfaceCacheWorldAdapter.cs | 16 +++- .../SurfaceCacheWorldAdapterTests.cs | 81 +++++++++++++++++++ 2 files changed, 94 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs index f12f0887cb6..262773b8f80 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs @@ -291,6 +291,16 @@ void UpdateMaterials(IReadOnlyList changed, SurfaceCacheWorld world) // and tracking. It is a lot of work and cost for little gain. } + // Preview scene objects (e.g. Prefab Mode) dispatch transform changes but never their destruction. + static bool IsInPreviewScene(Component component) + { +#if UNITY_EDITOR + return UnityEditor.SceneManagement.EditorSceneManager.IsPreviewSceneObject(component); +#else + return false; +#endif + } + interface IInstanceSource { TKey Key { get; } @@ -315,7 +325,7 @@ public MeshRendererSource(MeshRenderer renderer) public EntityId Key => _renderer.GetEntityId(); // In an open subscene the live-converted entities are the source of truth, not the authoring renderers. - public bool Visible => _renderer.enabled && _renderer.gameObject.activeInHierarchy && !_renderer.gameObject.scene.isSubScene && IsInGlobalIlluminationLOD(_renderer); + public bool Visible => _renderer.enabled && _renderer.gameObject.activeInHierarchy && !_renderer.gameObject.scene.isSubScene && !IsInPreviewScene(_renderer) && IsInGlobalIlluminationLOD(_renderer); // A renderer outside any LODGroup contributes, matching an entity without a MeshLODComponent. static bool IsInGlobalIlluminationLOD(MeshRenderer renderer) @@ -856,7 +866,7 @@ public void Refresh(Terrain terrain, SharedMaterialSet sharedMaterials, SurfaceC bool isRegistered = _slots.TryGetValue(id, out int slot); bool isInWorld = isRegistered && _inWorld[slot]; - bool shouldBeRegistered = terrain.isActiveAndEnabled && terrain.terrainData != null; + bool shouldBeRegistered = terrain.isActiveAndEnabled && terrain.terrainData != null && !IsInPreviewScene(terrain); bool matchesWorldFilter = (terrain.renderingLayerMask & renderingLayerMaskFilter) != 0; bool shouldBeInWorld = shouldBeRegistered && matchesWorldFilter; @@ -1134,7 +1144,7 @@ public void Refresh(Light light, SurfaceCacheWorld world, uint renderingLayerMas bool isRegistered = _slots.TryGetValue(id, out int slot); bool isInWorld = isRegistered && _inWorld[slot]; - bool shouldBeRegistered = light.isActiveAndEnabled && !light.bakingOutput.isBaked; + bool shouldBeRegistered = light.isActiveAndEnabled && !light.bakingOutput.isBaked && !IsInPreviewScene(light); bool matchesWorldFilter = ((uint)light.renderingLayerMask & renderingLayerMaskFilter) != 0; bool shouldBeInWorld = shouldBeRegistered && matchesWorldFilter; diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs index 378afa3c5be..ca5718d74ab 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs @@ -385,6 +385,34 @@ public void UpdateMeshRenderer_UnknownTransformChanged_RendererIsAdded() } } +#if UNITY_EDITOR + // Preview-scene objects (e.g. the Prefab Mode stage) are filtered out of type and destroy dispatch, but not out of transform dispatch. + [Test] + public void UpdateMeshRenderer_PreviewSceneTransformChanged_RendererIsNotAdded() + { + var env = CreateEnvironmentOrIgnore(); + var mesh = CreateQuadMesh(); + var previewScene = UnityEditor.SceneManagement.EditorSceneManager.NewPreviewScene(); + GameObject go = null; + try + { + go = CreateMeshRendererGameObject(mesh, out var renderer); + UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(go, previewScene); + + Update(env.Adapter, TransformChanges(renderer), env.World); + Assert.AreEqual(0, env.World.GetInstanceCount(), "A renderer in a preview scene should not be added to the world."); + } + finally + { + env.Dispose(); + UnityEditor.SceneManagement.EditorSceneManager.ClosePreviewScene(previewScene); + if (go != null) + Object.DestroyImmediate(go); + Object.DestroyImmediate(mesh); + } + } +#endif + [Test] public void Update_TransformChangedAndDestroyedInSameChangeSet_ObjectsAreRemoved() { @@ -750,6 +778,31 @@ public void UpdateLight_UnknownTransformChanged_LightIsAdded() } } +#if UNITY_EDITOR + [Test] + public void UpdateLight_PreviewSceneTransformChanged_LightIsNotAdded() + { + var env = CreateEnvironmentOrIgnore(); + var previewScene = UnityEditor.SceneManagement.EditorSceneManager.NewPreviewScene(); + GameObject lightGo = null; + try + { + lightGo = CreateLightGameObject(out var light); + UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(lightGo, previewScene); + + Update(env.Adapter, new SurfaceCacheWorldChangeSet { LightTransformChangedList = new Component[] { light } }, env.World); + Assert.AreEqual(0u, env.World.GetPunctualLightCount(), "A light in a preview scene should not be added to the world."); + } + finally + { + env.Dispose(); + UnityEditor.SceneManagement.EditorSceneManager.ClosePreviewScene(previewScene); + if (lightGo != null) + Object.DestroyImmediate(lightGo); + } + } +#endif + [Test] public void Update_NoGameObjectChanges_DoesNotAllocateGCMemory() { @@ -1238,6 +1291,34 @@ public void UpdateTerrain_UnknownTransformChanged_TerrainIsAdded() } } +#if UNITY_EDITOR + [Test] + public void UpdateTerrain_PreviewSceneTransformChanged_TerrainIsNotAdded() + { + var env = CreateEnvironmentOrIgnore(); + var previewScene = UnityEditor.SceneManagement.EditorSceneManager.NewPreviewScene(); + GameObject go = null; + TerrainData terrainData = null; + try + { + go = CreateTerrainGameObject(out var terrain, out terrainData); + UnityEngine.SceneManagement.SceneManager.MoveGameObjectToScene(go, previewScene); + + Update(env.Adapter, new SurfaceCacheWorldChangeSet { TerrainTransformChangedList = new Component[] { terrain } }, env.World); + Assert.AreEqual(0, env.World.GetInstanceCount(), "A terrain in a preview scene should not be added to the world."); + } + finally + { + env.Dispose(); + UnityEditor.SceneManagement.EditorSceneManager.ClosePreviewScene(previewScene); + if (go != null) + Object.DestroyImmediate(go); + if (terrainData != null) + Object.DestroyImmediate(terrainData); + } + } +#endif + [Test] public void UpdateTerrain_DisabledAfterAdd_TerrainIsRemoved() { From f7aed3447293d706d60dd90d4b75198634276349 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:17 +0000 Subject: [PATCH 36/61] [Port] [6000.7] Don't trace 1 pixel at a time for rays heading towards camera for URP SSR --- .../ShaderLibrary/ComputeScreenSpaceReflection.hlsl | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl index c4f729d2086..cc0132229ac 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl @@ -336,15 +336,16 @@ bool TraceScreenSpaceRayHiZ( // 'distFloor' can be smaller than the current distance 't'. // We can also safely ignore 'distBase'. - // If we hit the floor, it's always safe to jump there. - // If we are at (mipLevel != 0) and we are below the floor, we should not move. - t = hitFloor ? distFloor : (((mipLevel != 0) && belowFloor) ? t : distWall); + // If we are at (mipLevel != 0) and we are below the floor, we should not move, + // as jumping to the floor could skip intersections with finer cells. + // Otherwise, if we hit the floor, it's safe to jump there. + t = ((mipLevel != 0) && belowFloor) ? t : (hitFloor ? distFloor : distWall); rayPos.z = bounds.z; // Retain the depth of the potential intersection - // Warning: both rays towards the eye, and tracing behind objects has linear + // Warning: tracing behind objects has linear // rather than logarithmic complexity! This is due to the fact that we only store // the maximum value of depth, and not the min-max. - mipLevel += (hitFloor || belowFloor || rayTowardsEye) ? -1 : 1; + mipLevel += (hitFloor || belowFloor) ? -1 : 1; mipLevel = clamp(mipLevel, 0, maxMipLevel); // mipLevel = 0; From bf01572f2962d3246fa779e6a20b9f78616d080c Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 00:21:18 +0000 Subject: [PATCH 37/61] [Port] [6000.7] [UUM-158525] [ShaderGraph] Fix missing vertex input errors in UI Shader Graph previews --- .../com.unity.shadergraph/Editor/Drawing/PreviewManager.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs b/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs index 464bd4bdfde..b40a8de3c65 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs @@ -96,6 +96,10 @@ void SetupUITKPanelSettings() m_PreviewPanelSettings.clearDepthStencil = true; m_PreviewPanelSettings.isTransient = true; m_PreviewPanelSettings.disableNoThemeWarning = true; + // The graph may read any optional channel (UV1-3, Normal, Tangent). Enable them all so the panel's + // vertex layout always provides them (zero-filled), otherwise Metal logs "Missing vertex input". + m_PreviewPanelSettings.extraVertexChannels = ExtraVertexChannels.TexCoord1 | ExtraVertexChannels.TexCoord2 | + ExtraVertexChannels.TexCoord3 | ExtraVertexChannels.Normal | ExtraVertexChannels.Tangent; var root = m_PreviewPanelSettings.panel.visualTree; root.StretchToParentSize(); var previewElementUxml = Resources.Load("UXML/UITKMasterNodePreview"); From c9acfce240bf700a8dcc6357fce80ebc93ee7314 Mon Sep 17 00:00:00 2001 From: Robert Badea Date: Fri, 6 Nov 2026 13:59:09 +0000 Subject: [PATCH 38/61] [Port] [6000.7] [UUM-159962] [VFX] Fix Custom HLSL function body parsing with leading whitespace --- .../Blocks/Implementations/HLSL/HLSLParser.cs | 7 +-- .../AllTests/Editor/Tests/HLSLParserTest.cs | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs index 82b8c6170a2..02c045c901c 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs @@ -250,7 +250,8 @@ static HLSLFunction() public static IEnumerable Parse(IVFXAttributesManager attributesManager, string hlsl) { - var matches = s_FunctionParser.Matches(hlsl.Trim()); + string trimmedHLSL = hlsl.Trim(); + var matches = s_FunctionParser.Matches(trimmedHLSL); for (var i = 0; i < matches.Count; i++) { var match = matches[i]; @@ -258,8 +259,8 @@ public static IEnumerable Parse(IVFXAttributesManager attributesMa if (!isHidden) { var bodyStartIndex = match.Index + match.Length; - var bodyEndIndex = (i + 1) < matches.Count ? matches[i + 1].Index - 1 : hlsl.Length - 1; - var body = hlsl.Substring(bodyStartIndex, bodyEndIndex - bodyStartIndex + 1).TrimEnd(); + var bodyEndIndex = (i + 1) < matches.Count ? matches[i + 1].Index - 1 : trimmedHLSL.Length - 1; + var body = trimmedHLSL.Substring(bodyStartIndex, bodyEndIndex - bodyStartIndex + 1).TrimEnd(); yield return new HLSLFunction(attributesManager, match.Index, diff --git a/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/HLSLParserTest.cs b/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/HLSLParserTest.cs index c45c22f3fa1..6b348706a1f 100644 --- a/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/HLSLParserTest.cs +++ b/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/HLSLParserTest.cs @@ -500,6 +500,58 @@ public void HLSL_Many_Comments_HLSL_File() Assert.AreEqual("TotalTime", parameters[5].name); Assert.AreEqual(HLSLAccess.IN, parameters[5].access); } + + [TestCase("\n")] + [TestCase("\r\n")] + [TestCase(" ")] + [TestCase("\t")] + [TestCase("\n\n\n")] + [TestCase(" \n\t\n")] + [Test, Description("Covers issue UUM-158603")] + public void HLSL_Check_Leading_Whitespace(string leadingWhitespace) + { + // Arrange + string hlslCode = leadingWhitespace + + "float FloatFunction(in float value)\n" + + "{\n" + + " return value;\n" + + "}\n"; + + // Act + HLSLFunction function = HLSLFunction.Parse(this.attributesManager, hlslCode).Single(); + + // Assert + Assert.AreEqual("FloatFunction", function.name); + Assert.AreEqual(0, function.index); + Assert.AreEqual("{\n return value;\n}", function.body); + } + + [Test, Description("Covers issue UUM-158603")] + public void HLSL_Check_Leading_Whitespace_Multiple_Functions() + { + // Arrange + string hlslCode = + "\n\n" + + "float First(in float value)\n" + + "{\n" + + " return value;\n" + + "}\n" + + "\n" + + "float Second(in float value)\n" + + "{\n" + + " return value * 2;\n" + + "}\n"; + + // Act + HLSLFunction[] functions = HLSLFunction.Parse(this.attributesManager, hlslCode).ToArray(); + + // Assert + Assert.AreEqual(2, functions.Length); + Assert.AreEqual(0, functions[0].index); + Assert.AreEqual(51, functions[1].index); + Assert.AreEqual("{\n return value;\n}", functions[0].body); + Assert.AreEqual("{\n return value * 2;\n}", functions[1].body); + } } } #endif From 94bd7fef397adf456df10ca9ce85532a5d403142 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 23:20:19 +0000 Subject: [PATCH 39/61] [Port] [6000.7] Fix HDRP XR depth copy scale when RTHandle allocation exceeds viewport --- .../RenderPipeline/HDRenderPipeline.RenderGraph.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index d24fb91f7d8..949b12e7bc8 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -387,7 +387,7 @@ void RecordRenderGraph(RenderRequest renderRequest, // Copy and rescale depth buffer for XR devices if (hdCamera.xr.enabled && hdCamera.xr.copyDepth && depthBackBuffer.IsValid()) - CopyDepth(m_RenderGraph, hdCamera, prepassOutput.resolvedDepthBuffer, depthBackBuffer, true); + CopyDepth(m_RenderGraph, prepassOutput.resolvedDepthBuffer, depthBackBuffer, true); if (m_CurrentDebugDisplaySettings.data.historyBuffersView != -1) { @@ -778,7 +778,7 @@ class CopyXRDepthPassData public int passIndex; } - void CopyDepth(RenderGraph renderGraph, HDCamera hdCamera, in TextureHandle depthBuffer, in TextureHandle output, bool copyForXR) + void CopyDepth(RenderGraph renderGraph, in TextureHandle depthBuffer, in TextureHandle output, bool copyForXR) { string name = copyForXR ? "Copy XR Depth" : "Copy Depth"; var profileID = copyForXR ? HDProfileId.XRDepthCopy : HDProfileId.DuplicateDepthBuffer; @@ -789,8 +789,7 @@ void CopyDepth(RenderGraph renderGraph, HDCamera hdCamera, in TextureHandle dept builder.UseTexture(passData.depthBuffer, AccessFlags.Read); passData.output = output; builder.SetRenderAttachmentDepth(output, AccessFlags.Write); - passData.blitScaleBias = copyForXR ? new Vector2(hdCamera.actualWidth / hdCamera.finalViewport.width, hdCamera.actualHeight / hdCamera.finalViewport.height) - : RTHandles.rtHandleProperties.rtHandleScale; + passData.blitScaleBias = RTHandles.rtHandleProperties.rtHandleScale; passData.flipY = copyForXR; passData.passIndex = renderGraph.GetTextureDesc(depthBuffer).msaaSamples != MSAASamples.None ? 1 : 0; Debug.Assert(!(copyForXR && passData.passIndex != 0), "MSAA depth copies do not support XR scaling and Y-flipping."); @@ -1780,7 +1779,7 @@ TransparentPrepassOutput RenderTransparentPrepass(RenderGraph renderGraph, Culli renderQueueRange: GetTransparentRenderQueueRange(hdCamera, false))); // Copy depth buffer for refraction - CopyDepth(renderGraph, hdCamera, prepassOutput.depthBuffer, output.depthBufferPreRefraction, false); + CopyDepth(renderGraph, prepassOutput.depthBuffer, output.depthBufferPreRefraction, false); if (hasWater) { From d3d1f84d1b5e62833c851793b9dcc8ef19ef0c86 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 6 Nov 2026 23:20:24 +0000 Subject: [PATCH 40/61] [Port] [6000.7] [UUM-160178] [GI] Fix out-of-bounds access in probe occlusion light index mapping --- .../PathTracing/Shaders/ProbeOcclusionLightIndexMapping.compute | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/ProbeOcclusionLightIndexMapping.compute b/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/ProbeOcclusionLightIndexMapping.compute index 6ff80b1f591..bb7983dd6db 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/ProbeOcclusionLightIndexMapping.compute +++ b/Packages/com.unity.render-pipelines.core/Runtime/PathTracing/Shaders/ProbeOcclusionLightIndexMapping.compute @@ -12,7 +12,7 @@ uint g_ProbeCount; [numthreads(64,1,1)] void MapIndices(uint3 id : SV_DispatchThreadID) { - if (id.x >= g_MaxLightsPerProbe * g_ProbeCount) + if (id.x >= g_ProbeCount) return; for (uint i = 0; i < g_MaxLightsPerProbe; i++) From a9c17176b452688adad2d83d37eb4b326f34cd06 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Fri, 6 Nov 2026 23:20:24 +0000 Subject: [PATCH 41/61] [UUM-160598] Disable unstable Materials Playmode test --- .../GraphicTests/HDRP_PlayModeTests/FSR2PassLifetimeTests.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_PlayModeTests/FSR2PassLifetimeTests.cs b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_PlayModeTests/FSR2PassLifetimeTests.cs index a9bdd2a6b81..d9eb93bf61e 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_PlayModeTests/FSR2PassLifetimeTests.cs +++ b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_PlayModeTests/FSR2PassLifetimeTests.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using NUnit.Framework; using UnityEngine.TestTools; +using UnityEngine; namespace UnityEngine.Rendering.HighDefinition { @@ -67,6 +68,9 @@ public void TearDown() } [UnityTest] + [UnityPlatform(exclude = new RuntimePlatform[] { + RuntimePlatform.WindowsEditor // Disabled for Instability https://jira.unity3d.com/browse/UUM-160598 + })] public IEnumerator SwitchingPipelineAsset_DestroysFSR2Contexts() { var camera = m_CameraObject.GetComponent(); From 821139a7b9c7f26fb30fd9663611376a2169621d Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Sat, 7 Nov 2026 09:34:52 +0000 Subject: [PATCH 42/61] [Port] [6000.7] Fix DX12 define. --- .../com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl b/Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl index f0f4b05adf9..5efbc90a996 100644 --- a/Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl +++ b/Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl @@ -1026,7 +1026,7 @@ float ComputeTextureLOD(float3 duvw_dx, float3 duvw_dy, float3 duvw_dz, float sc return max(0.5f * log2(d * (scale * scale)) - bias, 0.0); } -#if defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) +#if defined(SHADER_API_D3D11) || defined(SHADER_API_DX12) || defined(SHADER_API_D3D11_9X) || defined(SHADER_API_XBOXONE) || defined(SHADER_API_PSSL) || defined(SHADER_API_METAL) #define MIP_COUNT_SUPPORTED 1 #endif // TODO: Bug workaround, switch defines GLCORE when it shouldn't From 6a87426813a9b4e353beb23003870e2849751a2d Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 9 Nov 2026 12:31:10 +0000 Subject: [PATCH 43/61] [Port] [6000.7] Ignore objects with materials that have no meta pass in SCGI --- .../SurfaceCacheWorldAdapter.cs | 48 ++++--------------- .../SurfaceCacheWorldAdapterTests.cs | 12 ++--- 2 files changed, 16 insertions(+), 44 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs index 262773b8f80..eb73d88a6ac 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheWorldAdapter.cs @@ -277,7 +277,6 @@ void UpdateMaterials(IReadOnlyList changed, SurfaceCacheWorld world) { var material = (Material)changed[i]; var matEntityId = material.GetEntityId(); - _sharedMaterials.RemoveMaterialMissingMetaPass(matEntityId); if (_sharedMaterials.IsReferenced(matEntityId)) { _sharedMaterials.Update(matEntityId, material, world); @@ -308,7 +307,6 @@ interface IInstanceSource Mesh Mesh { get; } uint RenderingLayerMask { get; } Matrix4x4 LocalToWorld { get; } - string OwnerName { get; } // May fill and return the given scratch list. Assignments outside subMeshCount are dropped. IReadOnlyList GetMaterials(List scratch, int subMeshCount); } @@ -355,8 +353,6 @@ public Mesh Mesh public Matrix4x4 LocalToWorld => _renderer.transform.localToWorldMatrix; - public string OwnerName => _renderer.gameObject.name; - public IReadOnlyList GetMaterials(List scratch, int subMeshCount) { _renderer.GetSharedMaterials(scratch); @@ -386,7 +382,6 @@ public EntityRecordSource(in SurfaceCacheEntityInstanceRecord record, SurfaceCac public uint RenderingLayerMask => _record.RenderingLayerMask; public Matrix4x4 LocalToWorld => _record.LocalToWorld; - public string OwnerName => _record.Key.ToString(); // Pads the producer's sparse assignments to one entry per submesh; unassigned ones stay null and are // masked out downstream. Out-of-range assignments are dropped rather than padded to, because @@ -639,7 +634,7 @@ void AddToWorld(int slot, in TSource source, Mesh mesh, SharedMaterialSet shared Span acquiredMatHandles = stackalloc MaterialHandle[mesh.subMeshCount]; Span acquiredMatIds = stackalloc EntityId[mesh.subMeshCount]; Span masks = stackalloc uint[mesh.subMeshCount]; - ResolveMaterialHandlesAndMasks(world, sharedMaterials, source, inputMats, acquiredMatHandles, acquiredMatIds, masks); + ResolveMaterialHandlesAndMasks(world, sharedMaterials, inputMats, acquiredMatHandles, acquiredMatIds, masks); var localToWorld = source.LocalToWorld; try @@ -685,7 +680,7 @@ void UpdateInWorld(int slot, in TSource source, Mesh mesh, SharedMaterialSet sha Span acquiredMatHandles = stackalloc MaterialHandle[mesh.subMeshCount]; Span acquiredMatIds = stackalloc EntityId[mesh.subMeshCount]; Span masks = stackalloc uint[mesh.subMeshCount]; - ResolveMaterialHandlesAndMasks(world, sharedMaterials, source, inputMats, acquiredMatHandles, acquiredMatIds, masks); + ResolveMaterialHandlesAndMasks(world, sharedMaterials, inputMats, acquiredMatHandles, acquiredMatIds, masks); world.UpdateInstanceMaterials(_handles[slot], acquiredMatHandles); world.UpdateInstanceMask(_handles[slot], masks); @@ -704,21 +699,15 @@ void UpdateInWorld(int slot, in TSource source, Mesh mesh, SharedMaterialSet sha ApplyTransform(slot, source.LocalToWorld, world); } - void ResolveMaterialHandlesAndMasks(SurfaceCacheWorld world, SharedMaterialSet sharedMaterials, in TSource source, IReadOnlyList inputMats, Span acquiredMaterialHandles, Span acquiredMaterialEntityIds, Span masks) + void ResolveMaterialHandlesAndMasks(SurfaceCacheWorld world, SharedMaterialSet sharedMaterials, IReadOnlyList inputMats, Span acquiredMaterialHandles, Span acquiredMaterialEntityIds, Span masks) { for (int i = 0; i < acquiredMaterialHandles.Length; i++) { Material inputMat = i < inputMats.Count ? inputMats[i] : null; - masks[i] = inputMat == null ? 0u : 1u; - - bool matIsSet = inputMat != null; - bool matIsSetAndHasMetaPass = matIsSet && inputMat.FindPass("Meta") != -1; - bool matIsUnsetOrNoMetaPass = !matIsSetAndHasMetaPass; - bool matIsSetAndNoMetaPass = matIsSet && matIsUnsetOrNoMetaPass; + bool matIsUnsetOrNoMetaPass = inputMat == null || inputMat.FindPass("Meta") == -1; - if (matIsSetAndNoMetaPass && sharedMaterials.AddMaterialMissingMetaPass(inputMat.GetEntityId())) - Debug.LogError($"The material '{inputMat.name}' used by '{source.OwnerName}' does not have a 'Meta' shader pass and cannot be used by Surface Cache Global Illumination. A fallback material will be used for this material instead.", inputMat); + masks[i] = matIsUnsetOrNoMetaPass ? 0u : 1u; // Acquiring the fallback even for unset materials buys the assumption that a handle always exists. var acquiredMat = inputMat; @@ -1021,7 +1010,7 @@ void AddToWorld(int slot, Terrain terrain, SharedMaterialSet sharedMaterials, Su Debug.Assert(terrainData != null); var inputMaterial = terrain.splatBaseMaterial; EntityId inputMatEntityId = inputMaterial != null ? inputMaterial.GetEntityId() : EntityId.None; - ResolveMaterialHandleAndMask(terrain, inputMaterial, inputMatEntityId, sharedMaterials, world, _fallbackMaterial, + ResolveMaterialHandleAndMask(inputMaterial, inputMatEntityId, sharedMaterials, world, _fallbackMaterial, out EntityId acquiredMatEntityId, out MaterialHandle matHandle, out uint mask); _handles[slot] = world.AddInstance(terrain, matHandle, mask, terrain.transform.localToWorldMatrix); @@ -1050,7 +1039,7 @@ void UpdateInWorld(int slot, Terrain terrain, bool transformChange, SharedMateri var inputMatEntityId = inputMat != null ? inputMat.GetEntityId() : EntityId.None; if (inputMatEntityId != _inputMaterialIds[slot]) { - ResolveMaterialHandleAndMask(terrain, inputMat, inputMatEntityId, sharedMaterials, world, _fallbackMaterial, + ResolveMaterialHandleAndMask(inputMat, inputMatEntityId, sharedMaterials, world, _fallbackMaterial, out EntityId acquiredMatEntityId, out MaterialHandle acquiredMatHandle, out uint mask); Span matHandles = stackalloc MaterialHandle[1] { acquiredMatHandle }; @@ -1087,17 +1076,11 @@ void RebuildInstance(int slot, SharedMaterialSet sharedMaterials, SurfaceCacheWo AddToWorld(slot, _components[slot], sharedMaterials, world); } - static void ResolveMaterialHandleAndMask(Terrain terrain, Material inputMat, EntityId inputMatEntityId, SharedMaterialSet sharedMaterials, SurfaceCacheWorld world, Material fallbackMaterial, out EntityId acquiredMatEntityId, out MaterialHandle acquiredMatHandle, out uint mask) + static void ResolveMaterialHandleAndMask(Material inputMat, EntityId inputMatEntityId, SharedMaterialSet sharedMaterials, SurfaceCacheWorld world, Material fallbackMaterial, out EntityId acquiredMatEntityId, out MaterialHandle acquiredMatHandle, out uint mask) { - mask = inputMat == null ? 0u : 1u; - - bool matIsSet = inputMat != null; - bool matIsSetAndHasMetaPass = matIsSet && inputMat.FindPass("Meta") != -1; - bool matIsUnsetOrNoMetaPass = !matIsSetAndHasMetaPass; - bool matIsSetAndNoMetaPass = matIsSet && matIsUnsetOrNoMetaPass; + bool matIsUnsetOrNoMetaPass = inputMat == null || inputMat.FindPass("Meta") == -1; - if (matIsSetAndNoMetaPass && sharedMaterials.AddMaterialMissingMetaPass(inputMatEntityId)) - Debug.LogError($"The material '{inputMat.name}' used by terrain '{terrain.gameObject.name}' does not have a 'Meta' shader pass and cannot be used by Surface Cache Global Illumination. A fallback material will be used for this material instead.", inputMat); + mask = matIsUnsetOrNoMetaPass ? 0u : 1u; // Using fallback material when there is no input material is redundant, but we do it anyway // because this buys us the simplifying assumption that we always have some material handle. @@ -1276,7 +1259,6 @@ struct Entry readonly Dictionary _entries = new(); readonly HashSet _pendingMetaPassEvals = new(); - readonly HashSet _materialsMissingMetaPass = new(); readonly Material _fallbackMaterial; public SharedMaterialSet(Material fallbackMaterial) @@ -1390,16 +1372,6 @@ public void Update(EntityId matEntityId, Material material, SurfaceCacheWorld wo } } - public bool AddMaterialMissingMetaPass(EntityId matEntityId) - { - return _materialsMissingMetaPass.Add(matEntityId); - } - - public void RemoveMaterialMissingMetaPass(EntityId matEntityId) - { - _materialsMissingMetaPass.Remove(matEntityId); - } - public bool IsReferenced(EntityId matEntityId) { return _entries.ContainsKey(matEntityId); diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs index ca5718d74ab..809c2a830df 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/SurfaceCache/SurfaceCacheWorldAdapterTests.cs @@ -1,7 +1,6 @@ #if SURFACE_CACHE_SUPPORTED || UNITY_EDITOR using System; -using System.Text.RegularExpressions; using NUnit.Framework; using Unity.Collections; using UnityEngine.PathTracing.Core; @@ -1895,23 +1894,24 @@ public void UpdateEntityInstance_SharedMaterialWithMeshRenderer_MaterialIsRefCou } const int k_ManyInstanceCount = 1000; - static readonly Regex k_MissingMetaPassError = new("does not have a 'Meta' shader pass"); - // The adapter keeps track of the materials it already reported, so a material shared by many instances must - // not turn into one log entry (and one formatted message allocation) per instance. [Test] - public void UpdateEntityInstance_ManyAddedWithMaterialMissingMetaPass_LogsErrorOnce() + public void UpdateEntityInstance_ManyAddedWithMaterialMissingMetaPass_AddsMaskedOutInstancesWithoutLogging() { var env = CreateEnvironmentOrIgnore(); var mesh = CreateQuadMesh(); var materialMissingMetaPass = CreateMaterialMissingMetaPass(); try { - LogAssert.Expect(LogType.Error, k_MissingMetaPassError); Update(env.Adapter, CreateEntityAddedChangeSet(mesh, materialMissingMetaPass), env.World); LogAssert.NoUnexpectedReceived(); Assert.AreEqual(k_ManyInstanceCount, env.World.GetInstanceCount()); + Assert.AreEqual(1, env.World.GetMaterialCount()); + foreach (var instance in env.World.GetAccelerationStructure().Instances.instances) + { + Assert.AreEqual(0u, instance.instanceMask); + } } finally { From 3f8da122cf29b922bed37185ad0ddaa4d50cacda Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 9 Nov 2026 12:31:13 +0000 Subject: [PATCH 44/61] [Port] [6000.7] VolumeProfileEditor - When editors are empty re-init the component list editor. --- .../Editor/Volume/VolumeProfileEditor.cs | 42 ++++++++++--------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileEditor.cs b/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileEditor.cs index ff76aa7d16f..222f9baffe6 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileEditor.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeProfileEditor.cs @@ -18,21 +18,6 @@ public sealed class VolumeProfileEditor : Editor void OnEnable() { componentList = new VolumeComponentListEditor(this); - if (VolumeManager.instance.isInitialized) - Init(); - } - - void Init() - { - var volumeProfile = target as VolumeProfile; - - if (volumeProfile == VolumeManager.instance.globalDefaultProfile) - { - componentList.SetIsGlobalDefaultVolumeProfile(true); - VolumeProfileUtils.EnsureAllOverridesForDefaultProfile(volumeProfile); - } - - componentList.Init(volumeProfile, serializedObject); } void OnDisable() @@ -43,15 +28,32 @@ void OnDisable() /// public override void OnInspectorGUI() { - if (componentList == null || componentList.asset == null) + if (!VolumeManager.instance.isInitialized) + { + EditorGUILayout.HelpBox("Volume Profiles require an active Scriptable Render Pipeline, but nothing has been rendered. Make sure Scene or Game View is in focus and no debug modes are active.", MessageType.Warning); + return; // Defer initialization until VolumeManager is initialized + } + + if (componentList == null) + componentList = new VolumeComponentListEditor(this); + + var volumeProfile = target as VolumeProfile; + + bool isDefaultVolumeProfile = volumeProfile == VolumeManager.instance.globalDefaultProfile; + + + bool initNeeded = componentList.asset == null || + (isDefaultVolumeProfile && (componentList.asset.components == null || componentList.asset.components.Count == 0)); + + if (initNeeded) { - if (!VolumeManager.instance.isInitialized) + if (isDefaultVolumeProfile) { - EditorGUILayout.HelpBox("Volume Profiles require an active Scriptable Render Pipeline, but nothing has been rendered. Make sure Scene or Game View is in focus and no debug modes are active.", MessageType.Warning); - return; // Defer initialization until VolumeManager is initialized + componentList.SetIsGlobalDefaultVolumeProfile(true); + VolumeProfileUtils.EnsureAllOverridesForDefaultProfile(volumeProfile); } - Init(); + componentList.Init(volumeProfile, serializedObject); } serializedObject.Update(); From 21e3bf30da07b7676a1d4e129a935b8fdb626a64 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 9 Nov 2026 12:31:13 +0000 Subject: [PATCH 45/61] [Port] [6000.7] UUM-160232: Add Surface Cache ray tracing normal bias setting --- .../Lighting/SurfaceCache/Estimation.compute | 20 +++++++++++++------ .../Lighting/SurfaceCache/SurfaceCache.cs | 5 +++++ .../Overrides/SurfaceCacheGIVolumeEditor.cs | 4 ++++ .../Overrides/SurfaceCacheGIVolumeOverride.cs | 8 ++++++++ .../SurfaceCacheGIRendererFeature.cs | 3 ++- 5 files changed, 33 insertions(+), 7 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute index 6328c88e7e1..00894a1d85f 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute @@ -58,6 +58,7 @@ uint _FrameIdx; uint _VolumeSpatialResolution; uint _VolumeCascadeCount; float _VolumeVoxelMinSize; +float _RayTracingNormalBias; uint _MultiBounce; uint _SampleCount; uint _WarmUpSampleMultiplier; @@ -151,14 +152,14 @@ void ProjectAndAccumulate(inout SphericalHarmonics::RGBL1 accumulator, float3 sa accumulator.l1s[2] += sampleRadiance * SphericalHarmonics::y1Constant * sampleDirection.x; } -float GetAdditionalRayOffset(float volumeVoxelMinSize) +float GetAdditionalRayOffset(float volumeVoxelMinSize, float rayTracingNormalBias) { // We currently use the OffsetRayOrigin() heuristic to offset ray origins to avoid self-intersections. While this // helps for Surface Cache it is not enough since the ray origins are relatively imprecise because they are derived // from output of the rasterizer (as opposed to being reconstructed via barycentrics). // We fix this by adding an additional offset. This offset is a percentage of the min voxel size to keep it // somewhat proportional to the scene scale. - return volumeVoxelMinSize * 0.001; + return volumeVoxelMinSize * 0.001 + rayTracingNormalBias; } void SamplePunctualLightBounceRadianceUniform( @@ -172,12 +173,13 @@ void SamplePunctualLightBounceRadianceUniform( StructuredBuffer lightSamples, uint lightSamplesLength, float volumeVoxelMinSize, + float rayTracingNormalBias, PatchUtil::PatchGeometry patchGeo, inout SphericalHarmonics::RGBL1 accumulator, inout bool gotValidSamples) { SphericalHarmonics::RGBL1 radianceAccumulator = (SphericalHarmonics::RGBL1)0; - const float3 reconnectionRayOrigin = OffsetRayOrigin(patchGeo.position, patchGeo.normal, GetAdditionalRayOffset(volumeVoxelMinSize)); + const float3 reconnectionRayOrigin = OffsetRayOrigin(patchGeo.position, patchGeo.normal, GetAdditionalRayOffset(volumeVoxelMinSize, rayTracingNormalBias)); uint validSampleCount = 0; for(uint sampleIdx = 0; sampleIdx < sampleCount; ++sampleIdx) @@ -262,12 +264,13 @@ void SamplePunctualLightBounceRadianceRIS( uint lightSamplesLength, uint candidateCount, float volumeVoxelMinSize, + float rayTracingNormalBias, PatchUtil::PatchGeometry patchGeo, inout SphericalHarmonics::RGBL1 accumulator, inout bool gotValidSamples) { SphericalHarmonics::RGBL1 radianceAccumulator = (SphericalHarmonics::RGBL1)0; - const float3 reconnectionRayOrigin = OffsetRayOrigin(patchGeo.position, patchGeo.normal, GetAdditionalRayOffset(volumeVoxelMinSize)); + const float3 reconnectionRayOrigin = OffsetRayOrigin(patchGeo.position, patchGeo.normal, GetAdditionalRayOffset(volumeVoxelMinSize, rayTracingNormalBias)); uint validSampleCount = 0; for(uint sampleIdx = 0; sampleIdx < sampleCount; ++sampleIdx) @@ -357,6 +360,7 @@ void SampleEmissiveTriangleRadiance( MaterialPoolParamSet matPoolParams, float emissiveTriangleIntensityMultiplier, float volumeVoxelMinSize, + float rayTracingNormalBias, PatchUtil::PatchGeometry patchGeo, inout SphericalHarmonics::RGBL1 accumulator, inout bool gotValidSamples) @@ -376,7 +380,7 @@ void SampleEmissiveTriangleRadiance( emissiveTriangleIntensityMultiplier, patchGeo.position, patchGeo.normal, - GetAdditionalRayOffset(volumeVoxelMinSize), + GetAdditionalRayOffset(volumeVoxelMinSize, rayTracingNormalBias), rng.GetSample(0).x, rng.GetSample(1)); @@ -411,11 +415,12 @@ void SampleEnvironmentAndDirectionalBounceAndMultiBounceRadiance( RWStructuredBuffer patchStatistics, CellPatchIndexBufferType cellPatchIndices, PatchUtil::VolumeParamSet volumeParams, + float rayTracingNormalBias, inout SphericalHarmonics::RGBL1 accumulator, inout bool gotValidSamples) { UnifiedRT::Ray ray; - ray.origin = OffsetRayOrigin(patchGeo.position, patchGeo.normal, GetAdditionalRayOffset(volumeParams.voxelMinSize)); + ray.origin = OffsetRayOrigin(patchGeo.position, patchGeo.normal, GetAdditionalRayOffset(volumeParams.voxelMinSize, rayTracingNormalBias)); ray.tMin = 0; ray.tMax = FLT_MAX; @@ -535,6 +540,7 @@ void Estimate(uint patchIdx : SV_DispatchThreadID, uint groupThreadIndex : SV_Gr _PatchStatistics, _CellPatchIndices, volumeParams, + _RayTracingNormalBias, radianceEstimate, gotValidSamples); @@ -554,6 +560,7 @@ void Estimate(uint patchIdx : SV_DispatchThreadID, uint groupThreadIndex : SV_Gr _PunctualLightSampleCount, _PunctualLightCandidateCount, _VolumeVoxelMinSize, + _RayTracingNormalBias, patchGeo, radianceEstimate, gotValidSamples); @@ -573,6 +580,7 @@ void Estimate(uint patchIdx : SV_DispatchThreadID, uint groupThreadIndex : SV_Gr matPoolParams, _EmissiveTriangleIntensityMultiplier, _VolumeVoxelMinSize, + _RayTracingNormalBias, patchGeo, radianceEstimate, gotValidSamples); diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs index 9b5e39f6d28..87464a92968 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/SurfaceCache.cs @@ -182,6 +182,7 @@ internal struct SurfaceCacheEstimationParameterSet public uint WarmUpSampleMultiplier; public uint PunctualLightCandidateCount; public bool DistanceFallback; + public float RayTracingNormalBias; } internal struct SurfaceCachePatchFilteringParameterSet @@ -423,6 +424,7 @@ private class EstimationPassData internal uint PunctualLightCandidateCount; internal uint VolumeSpatialResolution; internal float VolumeVoxelMinSize; + internal float RayTracingNormalBias; internal bool PatchWarpingEnabled; internal Vector3 VolumeTargetPos; internal GraphicsBuffer TraceScratchBuffer; @@ -520,6 +522,7 @@ internal static class ShaderIDs public static readonly int _MultiBounce = Shader.PropertyToID("_MultiBounce"); public static readonly int _VolumeVoxelMinSize = Shader.PropertyToID("_VolumeVoxelMinSize"); public static readonly int _PatchWarping = Shader.PropertyToID("_PatchWarping"); + public static readonly int _RayTracingNormalBias = Shader.PropertyToID("_RayTracingNormalBias"); public static readonly int _PunctualLightSampleCount = Shader.PropertyToID("_PunctualLightSampleCount"); public static readonly int _ShortHysteresis = Shader.PropertyToID("_ShortHysteresis"); public static readonly int _TemporalSmoothing = Shader.PropertyToID("_TemporalSmoothing"); @@ -808,6 +811,7 @@ private void RecordEstimation(RenderGraph renderGraph, uint frameIdx, SurfaceCac passData.WarmUpSampleMultiplier = _estimationParams.WarmUpSampleMultiplier; passData.PunctualLightCandidateCount = _estimationParams.PunctualLightCandidateCount; passData.VolumeVoxelMinSize = Volume.VoxelMinSize; + passData.RayTracingNormalBias = _estimationParams.RayTracingNormalBias; passData.PatchWarpingEnabled = Volume.PatchWarpingEnabled; passData.Zero = _zero; @@ -985,6 +989,7 @@ static void Estimate(EstimationPassData data, UnsafeGraphContext graphCtx) cmd.SetComputeIntParam(shader, ShaderIDs._MultiBounce, data.MultiBounce ? 1 : 0); cmd.SetComputeIntParam(shader, ShaderIDs._PatchWarping, data.PatchWarpingEnabled ? 1 : 0); cmd.SetComputeFloatParam(shader, ShaderIDs._VolumeVoxelMinSize, data.VolumeVoxelMinSize); + cmd.SetComputeFloatParam(shader, ShaderIDs._RayTracingNormalBias, data.RayTracingNormalBias); cmd.SetComputeIntParam(shader, ShaderIDs._PunctualLightSampleCount, (int)data.PunctualLightSampleCount); cmd.SetComputeFloatParam(shader, ShaderIDs._ShortHysteresis, data.ShortHysteresis); cmd.SetComputeIntParam(shader, ShaderIDs._RingConfigOffset, (int)data.RingConfigOffset); diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs index 99c4061b801..df6d869ee89 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Overrides/SurfaceCacheGIVolumeEditor.cs @@ -19,6 +19,7 @@ internal class SurfaceCacheGIVolumeEditor : UniversalRenderPipelineVolumeCompone protected SerializedDataParameter m_LightTransportRenderingLayerMask; protected SerializedDataParameter m_LightTransportWarmUpSampleMultiplier; protected SerializedDataParameter m_LightTransportPunctualLightCandidateCount; + protected SerializedDataParameter m_LightTransportRayTracingNormalBias; protected SerializedDataParameter m_PatchFilteringTemporalSmoothing; protected SerializedDataParameter m_PatchFilteringSpatialEnabled; @@ -52,6 +53,7 @@ internal class SurfaceCacheGIVolumeEditor : UniversalRenderPipelineVolumeCompone static GUIContent s_LightTransportBouncePatchAllocation = L10n.TextContent("Bounce Patch Allocation", "When enabled, new patches are allocated at ray hit locations when multi-bounce cache lookups fail", null, null); static GUIContent s_LightTransportSampleCount = L10n.TextContent("Sample Count", "Number of samples used for GI estimation. Higher values improve quality at performance cost.", null, null); static GUIContent s_LightTransportWarmUpSampleMultiplier = L10n.TextContent("Warm-up Sample Multiplier", "Boosts the initial sample count on newly revealed surfaces if needed. This stabilizes the image faster when geometry or camera is moving.", null, null); + static GUIContent s_LightTransportRayTracingNormalBias = L10n.TextContent("Ray Tracing Normal Bias", "Offsets ray origins along the surface normal, in world units. Increase this to fix dark artifacts when the ray tracing geometry differs from the rasterized geometry, for example when an object is rasterized with a less detailed mesh LOD, because ray tracing always uses mesh LOD 0. High values can cause light leaking.", null, null); static GUIContent s_LightTransportPunctualLightCandidateCount = L10n.TextContent("Punctual Light Candidate Count", "Number of punctual light candidates considered for each punctual light sample. Higher values reduce noise at a minor performance cost.", null, null); static GUIContent s_PatchFilteringTemporalSmoothing = L10n.TextContent("Temporal Smoothing", "Temporal smoothing for patch data. Higher values produce more stable results but slower response to lighting changes.", null, null); static GUIContent s_PatchFilteringSpatialEnabled = L10n.TextContent("Spatial Filtering", "Enables spatial filtering across patches. This reduces noise but may also increase leaking.", null, null); @@ -92,6 +94,7 @@ public override void OnEnable() m_LightTransportSampleCount = Unpack(o.Find(obj => obj.lightTransportSampleCount)); m_LightTransportWarmUpSampleMultiplier = Unpack(o.Find(obj => obj.lightTransportWarmupSampleMultiplier)); m_LightTransportPunctualLightCandidateCount = Unpack(o.Find(obj => obj.lightTransportPunctualLightCandidateCount)); + m_LightTransportRayTracingNormalBias = Unpack(o.Find(obj => obj.lightTransportRayTracingNormalBias)); m_PatchFilteringTemporalSmoothing = Unpack(o.Find(obj => obj.patchFilteringTemporalSmoothing)); m_PatchFilteringSpatialEnabled = Unpack(o.Find(obj => obj.patchFilteringSpatialEnabled)); m_PatchFilteringSpatialSampleCount = Unpack(o.Find(obj => obj.patchFilteringSpatialSampleCount)); @@ -172,6 +175,7 @@ public override void OnInspectorGUI() if (showAdditionalProperties) { PropertyField(m_LightTransportPunctualLightCandidateCount, s_LightTransportPunctualLightCandidateCount); + PropertyField(m_LightTransportRayTracingNormalBias, s_LightTransportRayTracingNormalBias); PropertyField(m_LightTransportRenderingLayerMask, s_RenderingLayerMask); PropertyField(m_LightTransportDefragCount, s_DefragCount); } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs index ce27ddd6c78..2dafb9ce54e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/SurfaceCacheGIVolumeOverride.cs @@ -82,6 +82,14 @@ public class SurfaceCacheGIVolumeOverride : VolumeComponent [Tooltip("Number of punctual light candidates considered for each punctual light sample. Higher values reduce noise at a minor performance cost.")] public ClampedIntParameter lightTransportPunctualLightCandidateCount = new ClampedIntParameter(k_Presets[(int)k_defaultPresetQuality].lightTransportPunctualLightCandidateCount, 1, 32); + /// + /// Offsets ray origins along the surface normal, in world units. Increase this to fix dark artifacts when the ray tracing geometry + /// differs from the rasterized geometry, for example when an object is rasterized with a less detailed mesh LOD, because ray tracing always uses mesh LOD 0. High values can cause light leaking. + /// + [AdditionalProperty] + [Tooltip("Offsets ray origins along the surface normal, in world units. Increase this to fix dark artifacts when the ray tracing geometry differs from the rasterized geometry, for example when an object is rasterized with a less detailed mesh LOD, because ray tracing always uses mesh LOD 0. High values can cause light leaking.")] + public MinFloatParameter lightTransportRayTracingNormalBias = new MinFloatParameter(0.0f, 0.0f); + // ============================ // Patch Filtering Parameters // ============================ diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs index f338b4589a4..b49bded8583 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/SurfaceCacheGIRendererFeature/SurfaceCacheGIRendererFeature.cs @@ -165,7 +165,8 @@ private static VolumeParameterSet GetVolumeParameters(SurfaceCacheGIVolumeOverri SampleCount = (uint)volumeOverride.lightTransportSampleCount.value, WarmUpSampleMultiplier = (uint)volumeOverride.lightTransportWarmupSampleMultiplier.value, PunctualLightCandidateCount = (uint)volumeOverride.lightTransportPunctualLightCandidateCount.value, - DistanceFallback = volumeOverride.volumeDistanceFallback.value + DistanceFallback = volumeOverride.volumeDistanceFallback.value, + RayTracingNormalBias = volumeOverride.lightTransportRayTracingNormalBias.value }, PatchFilteringParams = new SurfaceCachePatchFilteringParameterSet { From f79c1624ede8ecda57a5609376239806bffa4964 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Mon, 9 Nov 2026 12:31:13 +0000 Subject: [PATCH 46/61] [Port] [6000.7] UUM-160166: Fix Surface Cache punctual light reconnection ray direction --- .../Runtime/Lighting/SurfaceCache/Estimation.compute | 8 ++------ .../Runtime/Lighting/SurfaceCache/PathTracing.hlsl | 8 +++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute index 00894a1d85f..70f461cd285 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/Estimation.compute @@ -202,7 +202,6 @@ void SamplePunctualLightBounceRadianceUniform( lightSample.hitPos, lightSample.hitInstanceId, lightSample.hitPrimitiveIndex, - patchGeo.position, reconnectionRayOrigin, discardSample)) { @@ -216,8 +215,7 @@ void SamplePunctualLightBounceRadianceUniform( lights, lightSample, patchGeo.position, - patchGeo.normal, - reconnectionRayOrigin); + patchGeo.normal); validSampleCount++; ProjectAndAccumulate(radianceAccumulator, radianceSample.radianceOverDensity, radianceSample.direction); @@ -292,8 +290,7 @@ void SamplePunctualLightBounceRadianceRIS( lights, punctualLightSample, patchGeo.position, - patchGeo.normal, - reconnectionRayOrigin); + patchGeo.normal); // weight = targetVal / sourceDensity, and targetVal = Luminance(radiance), so // weight = Luminance(radiance / sourceDensity) = Luminance(radiance) / sourceDensity. @@ -319,7 +316,6 @@ void SamplePunctualLightBounceRadianceRIS( reservoir.lightSample.hitPos, reservoir.lightSample.hitInstanceId, reservoir.lightSample.hitPrimitiveIndex, - patchGeo.position, reconnectionRayOrigin, discardSample)) { diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/PathTracing.hlsl b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/PathTracing.hlsl index bca49f7caf6..3918481e6cd 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/PathTracing.hlsl +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/SurfaceCache/PathTracing.hlsl @@ -162,8 +162,7 @@ RadianceSample EvaluateUnshadowedPunctualLightSampleBounceRadiance( StructuredBuffer lights, PunctualLightSample punctualLightSample, float3 position, - float3 normal, - float3 reconnectionRayOrigin) + float3 normal) { RadianceSample result = (RadianceSample)0; @@ -171,7 +170,7 @@ RadianceSample EvaluateUnshadowedPunctualLightSampleBounceRadiance( const float planeDistance = dot(normal, punctualLightSample.hitPos - position); if (epsilon < planeDistance) // Light sample hit point must be "in front" of the patch. { - const float reconnectionDistance = distance(reconnectionRayOrigin, punctualLightSample.hitPos); + const float reconnectionDistance = distance(position, punctualLightSample.hitPos); const float reciprocalReconnectionDistance = rcp(reconnectionDistance); const PunctualLight light = lights[punctualLightSample.lightIndex]; @@ -225,7 +224,6 @@ bool RejectPunctualLightSample( float3 hitPos, uint hitInstanceId, uint hitPrimitiveIndex, - float3 position, float3 reconnectionRayOrigin, out bool discardSample) { @@ -233,7 +231,7 @@ bool RejectPunctualLightSample( UnifiedRT::Ray reconnectionRay; reconnectionRay.origin = reconnectionRayOrigin; - reconnectionRay.direction = normalize(hitPos - position); + reconnectionRay.direction = normalize(hitPos - reconnectionRayOrigin); reconnectionRay.tMin = 0; reconnectionRay.tMax = FLT_MAX; UnifiedRT::Hit reconnectionResult = TraceRayClosestHit(dispatchThreadIndex, groupThreadIndex, accelStruct, reconnectionRay); From 83c29e5c91e21b4b968c8f5fa4f0fb78e5998650 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 10 Nov 2026 09:27:14 +0000 Subject: [PATCH 47/61] [Port] [6000.7] [UUM-156479] Terrain: write rendering layers from the billboard and vertex-lit detail GBuffer passes --- .../Shaders/Nature/SpeedTree7Billboard.shader | 1 + .../Shaders/Terrain/TerrainDetailLit.shader | 2 + .../Terrain/WavingGrassBillboard.shader | 2 + .../Editor/GBufferRenderingLayersTests.cs | 65 +++++++++++++++++++ .../GBufferRenderingLayersTests.cs.meta | 11 ++++ 5 files changed, 81 insertions(+) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader index 8f54b62a2dd..5510965b6cc 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader @@ -113,6 +113,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree7 Billboard" #pragma multi_compile _ _EXPOSURE #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #pragma shader_feature_local EFFECT_BUMP #pragma shader_feature_local EFFECT_HUE_VARIATION diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLit.shader index 2c8a2b0dd9a..fe9b9958f20 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainDetailLit.shader @@ -84,10 +84,12 @@ Shader "Hidden/TerrainEngine/Details/UniversalPipeline/Vertexlit" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl" #pragma multi_compile_fragment _ _GBUFFER_NORMALS_OCT #pragma multi_compile_fragment _ _RENDER_PASS_ENABLED + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutput.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/SurfaceType.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Utils/ReceiveShadows.hlsl" diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader index 720f73f3d09..3e8b55375bb 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader @@ -95,6 +95,7 @@ Shader "Hidden/TerrainEngine/Details/UniversalPipeline/BillboardWavingDoublePass #pragma multi_compile_fragment _ _SCREEN_SPACE_IRRADIANCE #pragma multi_compile _ _EXPOSURE #include_with_pragmas "Packages/com.unity.render-pipelines.core/ShaderLibrary/FoveatedRenderingKeywords.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl" // ------------------------------------- // Unity defined keywords @@ -104,6 +105,7 @@ Shader "Hidden/TerrainEngine/Details/UniversalPipeline/BillboardWavingDoublePass //-------------------------------------- // GPU Instancing #pragma multi_compile_instancing + #pragma instancing_options renderinglayer #pragma vertex WavingGrassBillboardVert #pragma fragment LitPassFragmentGrass diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs new file mode 100644 index 00000000000..de217bba2a2 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs @@ -0,0 +1,65 @@ +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.Rendering; +using UnityEngine.Rendering.Universal; + +namespace UnityEditor.Rendering.Universal.Tests +{ + // With Rendering Layers enabled, deferred lighting only lights a pixel whose GBuffer rendering layers mask + // contains the light's layers. A GBuffer pass without the _WRITE_RENDERING_LAYERS variant leaves that mask + // unwritten, so what it draws takes whatever was there before, usually nothing, and goes unlit. + class GBufferRenderingLayersTests + { + const string k_ShaderFolder = "Packages/com.unity.render-pipelines.universal/Shaders"; + + [Test] + public void GBufferPassesDeclareWriteRenderingLayers() + { + var lightMode = new ShaderTagId("LightMode"); + var renderPipeline = new ShaderTagId("RenderPipeline"); + var checkedShaders = new HashSet(); + var missing = new List(); + + foreach (var guid in AssetDatabase.FindAssets("t:Shader", new[] { k_ShaderFolder })) + { + var path = AssetDatabase.GUIDToAssetPath(guid); + var shader = AssetDatabase.LoadAssetAtPath(path); + Assert.IsNotNull(shader, $"Failed to load shader at path '{path}'"); + + var data = ShaderUtil.GetShaderData(shader); + // Serialized subshaders only: the runtime list also holds the Fallback shader's subshaders. + for (int s = 0; s < data.SerializedSubshaderCount; ++s) + { + var subshader = data.GetSerializedSubshader(s); + // Shader Graph assets can carry subshaders for other pipelines, such as HDRP, which URP never selects. + // Untagged subshaders stay in: URP can select them. + var pipelineTag = subshader.FindTagValue(renderPipeline).name; + if (!string.IsNullOrEmpty(pipelineTag) && pipelineTag != "UniversalPipeline") + continue; + + for (int p = 0; p < subshader.PassCount; ++p) + { + var pass = subshader.GetPass(p); + if (pass.FindTagValue(lightMode).name != "UniversalGBuffer") + continue; + + checkedShaders.Add(path); + var keywords = ShaderUtil.GetPassKeywords(shader, new PassIdentifier((uint)s, (uint)p), ShaderType.Fragment); + if (!keywords.Any(k => k.name == ShaderKeywordStrings.WriteRenderingLayers)) + missing.Add($"{path} (subshader {s}, pass '{pass.Name}')"); + } + } + } + + Assert.That(checkedShaders, Does.Contain($"{k_ShaderFolder}/Lit.shader"), + "Found no GBuffer pass in Lit.shader; did the shader folder or the LightMode tag change?"); + Assert.That(missing, Is.Empty, + $"These GBuffer passes do not declare {ShaderKeywordStrings.WriteRenderingLayers}, so with Rendering Layers on in " + + "Deferred they leave the rendering layers target unwritten and deferred lighting skips them. Add " + + "#include_with_pragmas \"Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl\" " + + "to the pass:\n" + string.Join("\n", missing)); + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs.meta new file mode 100644 index 00000000000..0b8651424d9 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/GBufferRenderingLayersTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5d2ed4d1fc144e858d6c2ea194f8fe4e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 76b0c94a0ae9dcafa1e6bfdcdd3ac128f0ad2980 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 10 Nov 2026 09:27:15 +0000 Subject: [PATCH 48/61] [Port] [6000.7] [URP] [GSDET-1480] Make the 301 shadow-caster culling tests able to fail --- ...orwardRenderer_MainlightShadowOutput.asset | 1 + .../OutputURPTexture.cs | 25 +++++-- .../ShadowmapDepthBands.shader | 73 +++++++++++++++++++ .../ShadowmapDepthBands.shader.meta | 9 +++ ...ViewFrustumForShadowCasterCull_false.unity | 4 +- ...ForShadowCasterCull_noCascades_false.unity | 4 +- ...mForShadowCasterCull_noCascades_true.unity | 4 +- ...eViewFrustumForShadowCasterCull_true.unity | 4 +- 8 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader.meta diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ForwardRenderer_MainlightShadowOutput.asset b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ForwardRenderer_MainlightShadowOutput.asset index 218a266b159..dce03f6591e 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ForwardRenderer_MainlightShadowOutput.asset +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ForwardRenderer_MainlightShadowOutput.asset @@ -82,3 +82,4 @@ MonoBehaviour: m_EditorClassIdentifier: m_Active: 1 m_TextureType: 0 + m_DepthBandsShader: {fileID: 4800000, guid: f7ceb50ed8d774f3ca49b3ee8f6a3f09, type: 3} diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/OutputURPTexture.cs b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/OutputURPTexture.cs index de95f932fce..dd1d1168cad 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/OutputURPTexture.cs +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/OutputURPTexture.cs @@ -1,9 +1,9 @@ +using System; using UnityEngine; using UnityEngine.Rendering; -using UnityEngine.Rendering.Universal; using UnityEngine.Rendering.RenderGraphModule; using UnityEngine.Rendering.RenderGraphModule.Util; -using System; +using UnityEngine.Rendering.Universal; public class OutputURPTexture : ScriptableRendererFeature { @@ -17,9 +17,12 @@ enum TextureType class OutputURPTexturePass : ScriptableRenderPass { TextureType m_TextureType; - public OutputURPTexturePass(TextureType textureType) + Material m_DepthBandsMaterial; + + public OutputURPTexturePass(TextureType textureType, Material depthBandsMaterial) { m_TextureType = textureType; + m_DepthBandsMaterial = depthBandsMaterial; } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) @@ -38,18 +41,23 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer default: throw new ArgumentException("Doesn't handle texture type please exstend function to include the type.", "m_TextureType"); } - RenderGraphUtils.AddBlitPass(renderGraph, sourceTexture, resourceData.activeColorTexture, Vector2.one, Vector2.zero, passName: passName); - + + var blitParameters = new RenderGraphUtils.BlitMaterialParameters(sourceTexture, resourceData.activeColorTexture, m_DepthBandsMaterial, 0); + renderGraph.AddBlitPass(blitParameters, passName); } } [SerializeField] TextureType m_TextureType; + [SerializeField] + Shader m_DepthBandsShader; + Material m_DepthBandsMaterial; OutputURPTexturePass m_ScriptablePass; public override void Create() { - m_ScriptablePass = new OutputURPTexturePass(m_TextureType); + m_DepthBandsMaterial = CoreUtils.CreateEngineMaterial(m_DepthBandsShader); + m_ScriptablePass = new OutputURPTexturePass(m_TextureType, m_DepthBandsMaterial); m_ScriptablePass.renderPassEvent = RenderPassEvent.AfterRenderingSkybox; } @@ -57,4 +65,9 @@ public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingD { renderer.EnqueuePass(m_ScriptablePass); } + + protected override void Dispose(bool disposing) + { + CoreUtils.Destroy(m_DepthBandsMaterial); + } } diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader new file mode 100644 index 00000000000..90ac3988dac --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader @@ -0,0 +1,73 @@ +// Shows a shadow map as grey depth bands, brighter where a caster is closer to the light. +// It reads the map only through depth comparisons, as URP does when it samples shadows, so the +// output does not depend on how a graphics API exposes depth texels as colour. +Shader "Hidden/Test/ShadowmapDepthBands" +{ + SubShader + { + Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" } + ZWrite Off ZTest Always Blend Off Cull Off + + Pass + { + Name "ShadowmapDepthBands" + + HLSLPROGRAM + #pragma vertex Vert + #pragma fragment Frag + + #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" + + #define DEPTH_BAND_COUNT 16 + + TEXTURE2D_SHADOW(_BlitTexture); + SAMPLER_CMP(sampler_LinearClampCompare); + float4 _BlitScaleBias; + + struct Attributes + { + uint vertexID : SV_VertexID; + }; + + struct Varyings + { + float4 positionCS : SV_POSITION; + float2 texcoord : TEXCOORD0; + }; + + Varyings Vert(Attributes input) + { + Varyings output; + output.positionCS = GetFullScreenTriangleVertexPosition(input.vertexID); + output.texcoord = GetFullScreenTriangleTexCoord(input.vertexID) * _BlitScaleBias.xy + _BlitScaleBias.zw; + return output; + } + + float4 Frag(Varyings input) : SV_Target + { + float occludedBands = 0.0; + + [unroll] + for (int band = 0; band < DEPTH_BAND_COUNT; ++band) + { + // Distance from the light as a fraction of the shadow depth range, at the far edge of each band. + // The last one stops just short of the far plane, where empty texels are stored. + float distanceFromLight = min((band + 1.0) / DEPTH_BAND_COUNT, 0.9999); + #if UNITY_REVERSED_Z + float referenceDepth = 1.0 - distanceFromLight; + #else + float referenceDepth = distanceFromLight; + #endif + + // The comparison returns 1 when nothing in the shadow map is closer to the light than the reference + float lit = SAMPLE_TEXTURE2D_SHADOW(_BlitTexture, sampler_LinearClampCompare, float3(input.texcoord, referenceDepth)); + occludedBands += 1.0 - lit; + } + + float brightness = occludedBands / DEPTH_BAND_COUNT; + return float4(brightness, brightness, brightness, 1.0); + } + ENDHLSL + } + } +} diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader.meta b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader.meta new file mode 100644 index 00000000000..11dfd388b65 --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull/ShadowmapDepthBands.shader.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f7ceb50ed8d774f3ca49b3ee8f6a3f09 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_false.unity b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_false.unity index 4b852aae1bd..d0ba4d61cc0 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_false.unity +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_false.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9238d92d3541409001b71d34533d05edf92c7438e7dfc0a440d2bed63211aa76 -size 20839 +oid sha256:30567e4b027bf8113558dd4ae04b73239a56a3183773e516b6a57589a0aac2c5 +size 20831 diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_false.unity b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_false.unity index 43dba755fa1..238009fff85 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_false.unity +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_false.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3a5388c2d45de586bf0b873cd163c06186f6f82b4ec59026497d8be3e987cb52 -size 20839 +oid sha256:d664d3a39fc32cbcf892eb47786266c2d6f008c15ed3f5e393de76d505feff05 +size 20832 diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_true.unity b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_true.unity index 92ea4eb70f9..dcc6da8cfd3 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_true.unity +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_noCascades_true.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fdca9cb67acb9464c7acb33034cb4dc239b5c550e3cbeae1331697b50dd60119 -size 20839 +oid sha256:026b4ff77bcc5d1a8bead5c5ed02858a6fc09fa988b476c51732c54af568fe7c +size 20832 diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_true.unity b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_true.unity index efda71b3971..74b8697b3c5 100644 --- a/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_true.unity +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_Foundation/Assets/Scenes/301_useViewFrustumForShadowCasterCull_true.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9f27ad48cbe3517f0616fc3fb8fc43ee47769f487d5541326694cf7be741912f -size 20839 +oid sha256:28eb58485bf1c637eb8da9f286b2607341ce17cf650d2367c67c24f8d6f83652 +size 20831 From 10b16f4b9e02e4d4f95ccc969461e567c4f52473 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 10 Nov 2026 09:27:16 +0000 Subject: [PATCH 49/61] [Port] [6000.7] [UUM-158437] Fixed Medium quality soft shadows costing as much GPU time as High quality on Apple GPUs --- .../ShaderLibrary/Shadows.hlsl | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl index db833b9bf29..5d68c0254c7 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/Shadows.hlsl @@ -456,6 +456,18 @@ half SampleShadowmapFilteredRuntimeQuality(TEXTURE2D_SHADOW_PARAM(ShadowMap, sam wV *= 0.081632 * 0.081632; u = fetchCenter.x * texelSize.x + u * texelSize.x; v = fetchCenter.y * texelSize.y + v * texelSize.y; + half4 hwU = half4(wU); + half4 hwV = half4(wV); + + UNITY_UNROLL for (int j = 0; j < 4; j++) + { + half4 s; + s.x = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.x, v[j], shadowCoord.z))); + s.y = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.y, v[j], shadowCoord.z))); + s.z = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.z, v[j], shadowCoord.z))); + s.w = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.w, v[j], shadowCoord.z))); + attenuation += hwV[j] * dot(s, hwU); + } } else { @@ -464,17 +476,19 @@ half SampleShadowmapFilteredRuntimeQuality(TEXTURE2D_SHADOW_PARAM(ShadowMap, sam wV *= 0.16 * 0.16; u = fetchCenter.x * texelSize.x + u * texelSize.x; v = fetchCenter.y * texelSize.y + v * texelSize.y; - } - half4 hwU = half4(wU); - UNITY_UNROLL for (int j = 0; j < 4; j++) - { - half4 s; - s.x = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.x, v[j], shadowCoord.z))); - s.y = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.y, v[j], shadowCoord.z))); - s.z = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.z, v[j], shadowCoord.z))); - s.w = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.w, v[j], shadowCoord.z))); - attenuation += half(wV[j]) * dot(s, hwU); + half3 hwU = half3(wU.xyw); + half3 hwV = half3(wV.xyw); + float3 rowV = v.xyw; + + UNITY_UNROLL for (int j = 0; j < 3; j++) + { + half3 s; + s.x = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.x, rowV[j], shadowCoord.z))); + s.y = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.y, rowV[j], shadowCoord.z))); + s.z = half(SAMPLE_TEXTURE2D_SHADOW(ShadowMap, sampler_ShadowMap, float3(u.w, rowV[j], shadowCoord.z))); + attenuation += hwV[j] * dot(s, hwU); + } } } return attenuation; From d2d78d5dca610f62360419a6003659a7636e518a Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 10 Nov 2026 09:27:16 +0000 Subject: [PATCH 50/61] [Port] [6000.7] [UUM-154532] [HDRP] Fix Shader Graph LOD crossfade showing alpha-clipped LOD --- .../Editor/Material/ShaderGraph/SurfaceSubTarget.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs index ef59d323b19..cd7b36b87ed 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/SurfaceSubTarget.cs @@ -256,6 +256,10 @@ public override void GetFields(ref TargetFieldContext context) if (builtinData.depthOffset) context.AddField(HDStructFields.FragInputs.positionRWS); + // LOD crossfade dithering seeds from the per-pixel view vector + if (builtinData.supportLodCrossFade && !context.pass.IsRelatedToRaytracing()) + context.AddField(HDStructFields.FragInputs.positionRWS); + context.AddField(HDFields.CustomVelocity, systemData.customVelocity); context.AddField(HDFields.TessellationFactor, systemData.tessellation); From 1bc650aa2fc17654300a5bfe8dc75a625f807545 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 11 Nov 2026 04:42:56 +0000 Subject: [PATCH 51/61] [Port] [6000.7] [UUM-159486] Fix emission lost when converting Standard (Specular setup) materials to URP --- .../MaterialUpgraderDefinitions.cs | 44 ++++------- .../StandardMaterialUpgraderTest.cs | 76 +++++++++++++++++++ 2 files changed, 90 insertions(+), 30 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Tools/MaterialUpgrader/MaterialUpgraderDefinitions.cs b/Packages/com.unity.render-pipelines.universal/Editor/Tools/MaterialUpgrader/MaterialUpgraderDefinitions.cs index 38d3480b545..847c8cec10c 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/Tools/MaterialUpgrader/MaterialUpgraderDefinitions.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/Tools/MaterialUpgrader/MaterialUpgraderDefinitions.cs @@ -19,6 +19,15 @@ internal static void DisableKeywords(Material material) // LOD fade is now controlled by the render pipeline, and not the individual material, so disable it. material.DisableKeyword("LOD_FADE_CROSSFADE"); } + + internal static void UpdateEmissionMode(Material material) + { + if ((material.globalIlluminationFlags & (MaterialGlobalIlluminationFlags.BakedEmission | MaterialGlobalIlluminationFlags.RealtimeIndirectEmission)) != MaterialGlobalIlluminationFlags.None) + { + material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.RealtimeDirectEmission; + material.EnableKeyword("_EMISSION"); + } + } } /// @@ -180,7 +189,7 @@ public static void UpdateStandardMaterialKeywords(Material material) material.SetFloat("_AlphaClip", 1.0f); } - UpdateEmissionMode(material); + MaterialUpgradeUtils.UpdateEmissionMode(material); material.SetFloat("_WorkflowMode", 1.0f); CoreUtils.SetKeyword(material, "_OCCLUSIONMAP", material.GetTexture("_OcclusionMap")); @@ -206,6 +215,8 @@ public static void UpdateStandardSpecularMaterialKeywords(Material material) else material.SetFloat("_Smoothness", material.GetFloat("_Glossiness")); + MaterialUpgradeUtils.UpdateEmissionMode(material); + material.SetFloat("_WorkflowMode", 0.0f); CoreUtils.SetKeyword(material, "_OCCLUSIONMAP", material.GetTexture("_OcclusionMap")); CoreUtils.SetKeyword(material, "_METALLICSPECGLOSSMAP", material.GetTexture("_SpecGlossMap")); @@ -254,15 +265,6 @@ static void UpdateSurfaceTypeAndBlendMode(Material material) } } - private static void UpdateEmissionMode(Material material) - { - if ((material.globalIlluminationFlags & (MaterialGlobalIlluminationFlags.BakedEmission | MaterialGlobalIlluminationFlags.RealtimeIndirectEmission)) != MaterialGlobalIlluminationFlags.None) - { - material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.RealtimeDirectEmission; - material.EnableKeyword("_EMISSION"); - } - } - /// /// Constructor for the StandardUpgrader class. /// @@ -339,15 +341,6 @@ internal static void UpdateMaterialKeywords(Material material) MaterialUpgradeUtils.DisableKeywords(material); } - private static void UpdateEmissionMode(Material material) - { - if ((material.globalIlluminationFlags & (MaterialGlobalIlluminationFlags.BakedEmission | MaterialGlobalIlluminationFlags.RealtimeIndirectEmission)) != MaterialGlobalIlluminationFlags.None) - { - material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.RealtimeDirectEmission; - material.EnableKeyword("_EMISSION"); - } - } - private static void UpdateMaterialSpecularSource(Material material) { SpecularSource specSource = (SpecularSource)material.GetFloat("_SpecSource"); @@ -440,7 +433,7 @@ public ParticleUpgrader(string oldShaderName) /// public static void UpdateStandardSurface(Material material) { - UpdateEmissionMode(material); + MaterialUpgradeUtils.UpdateEmissionMode(material); UpdateSurfaceBlendModes(material); ParticleGUI.SetupMaterialWithColorMode(material); MaterialUpgradeUtils.DisableKeywords(material); @@ -453,7 +446,7 @@ public static void UpdateStandardSurface(Material material) /// public static void UpdateUnlit(Material material) { - UpdateEmissionMode(material); + MaterialUpgradeUtils.UpdateEmissionMode(material); UpdateSurfaceBlendModes(material); ParticleGUI.SetupMaterialWithColorMode(material); MaterialUpgradeUtils.DisableKeywords(material); @@ -494,15 +487,6 @@ static void FixEmissiveFlags(Material material) } } - private static void UpdateEmissionMode(Material material) - { - if ((material.globalIlluminationFlags & (MaterialGlobalIlluminationFlags.BakedEmission | MaterialGlobalIlluminationFlags.RealtimeIndirectEmission)) != MaterialGlobalIlluminationFlags.None) - { - material.globalIlluminationFlags |= MaterialGlobalIlluminationFlags.RealtimeDirectEmission; - material.EnableKeyword("_EMISSION"); - } - } - /// /// Updates the blending mode properties. /// diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/MaterialUpgrader/StandardMaterialUpgraderTest.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/MaterialUpgrader/StandardMaterialUpgraderTest.cs index 6de6707690a..2c67cc048ff 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/MaterialUpgrader/StandardMaterialUpgraderTest.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/MaterialUpgrader/StandardMaterialUpgraderTest.cs @@ -290,5 +290,81 @@ private static IEnumerable MaterialUpgradeCases() Assert.IsFalse(material.IsKeywordEnabled("_EMISSION")); } }; + + foreach (var testCase in EmissionUpgradeCases()) + yield return testCase; + } + + internal static IEnumerable EmissionUpgradeCases() + { + yield return new MaterialUpgradeTestCase() + { + name = "Given_BakedEmissionBuiltInMaterial_When_Upgrading_Then_TheMaterialURPDirectEmissionEnabled", + setup = material => + { + material.SetColor("_EmissionColor", Color.white); + material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.BakedEmission; + material.EnableKeyword("_EMISSION"); + }, + verify = material => + { + Assert.IsTrue((material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.BakedEmission) != 0); + Assert.IsTrue((material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.RealtimeDirectEmission) != 0); + Assert.IsTrue(material.IsKeywordEnabled("_EMISSION")); + } + }; + + yield return new MaterialUpgradeTestCase() + { + name = "Given_RealtimeEmissionBuiltInMaterial_When_Upgrading_Then_TheMaterialURPDirectEmissionEnabled", + setup = material => + { + material.SetColor("_EmissionColor", Color.white); + material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeIndirectEmission; + material.EnableKeyword("_EMISSION"); + }, + verify = material => + { + Assert.IsTrue((material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.RealtimeIndirectEmission) != 0); + Assert.IsTrue((material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.RealtimeDirectEmission) != 0); + Assert.IsTrue(material.IsKeywordEnabled("_EMISSION")); + } + }; + + yield return new MaterialUpgradeTestCase() + { + name = "Given_NoEmissionBuiltInMaterial_When_Upgrading_Then_TheMaterialURPDirectEmissionDisabled", + setup = material => + { + material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.EmissiveIsBlack; + material.DisableKeyword("_EMISSION"); + }, + verify = material => + { + Assert.IsTrue((material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.RealtimeDirectEmission) == 0); + Assert.IsFalse(material.IsKeywordEnabled("_EMISSION")); + } + }; + } +} + +[Category("Graphics Tools")] +class StandardSpecularMaterialUpgraderTest : MaterialUpgraderTestBase +{ + [OneTimeSetUp] + public override void OneTimeSetUp() + { + m_Upgrader = new StandardUpgrader("Standard (Specular setup)"); + } + + public StandardSpecularMaterialUpgraderTest() : base("Standard (Specular setup)", "Universal Render Pipeline/Lit") + { + } + + [Test] + [TestCaseSource(typeof(StandardMaterialUpgraderTest), nameof(StandardMaterialUpgraderTest.EmissionUpgradeCases))] + public void UpgradeStandardSpecularMaterial(MaterialUpgradeTestCase testCase) + { + UpgradeMaterial(testCase); } } From fcd508dd3a10605aeb1bb9f6c7f976dd61b01b39 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 11 Nov 2026 04:42:57 +0000 Subject: [PATCH 52/61] [Port] [6000.7] [UUM-159309] [APV] Fix NullReferenceException when rebaking with an unloaded scene --- .../Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs | 2 ++ .../Lighting/ProbeVolume/ProbeVolumeBakingSet.Editor.cs | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs index 294ac7e4a37..25b3ebc3fcb 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.Serialization.cs @@ -690,6 +690,8 @@ static void ExtractBakingCells() foreach (var data in loadedSceneDataList) { var cells = m_BakingSet.GetSceneCellIndexList(data.sceneGUID); + if (cells == null) + continue; var numberOfCells = cells.Count; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.Editor.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.Editor.cs index 26d59dae840..7c34b6c1bca 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.Editor.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.Editor.cs @@ -627,8 +627,10 @@ internal void EnsurePerSceneData(Scene scene, string sceneGuid) { var go = new GameObject("ProbeVolumePerSceneData"); go.hideFlags |= HideFlags.HideInHierarchy; - var perSceneData = go.AddComponent(); + + // Move before adding the component so OnEnable picks up the GUID of the target scene SceneManager.MoveGameObjectToScene(go, scene); + go.AddComponent(); } } } From 70da1b8646acbf88991f15fef4b81b8506ee8a4b Mon Sep 17 00:00:00 2001 From: Dan Miller Date: Wed, 11 Nov 2026 04:42:58 +0000 Subject: [PATCH 53/61] Update URP Standard/Indoors scene templates: APV baking sets, volume profiles, reflection probes --- .../SceneTemplates/Indoors.scenetemplate | 34 +- .../Editor/SceneTemplates/Indoors.unity | 4 +- .../Indoors Baking Set-Default.CellData.bytes | 3 + ...ors Baking Set-Default.CellData.bytes.meta | 7 + ... Baking Set-Default.CellOptionalData.bytes | 3 + ...ng Set-Default.CellOptionalData.bytes.meta | 7 + ...g Set-Default.CellProbeOcclusionData.bytes | 3 + ...-Default.CellProbeOcclusionData.bytes.meta | 7 + .../Indoors Baking Set.CellBricksData.bytes | 3 + ...doors Baking Set.CellBricksData.bytes.meta | 7 + .../Indoors Baking Set.CellSharedData.bytes | 3 + ...doors Baking Set.CellSharedData.bytes.meta | 7 + .../Indoors Baking Set.CellSupportData.bytes | 3 + ...oors Baking Set.CellSupportData.bytes.meta | 7 + .../Indoors/Indoors Baking Set.asset | 194 +++++-- .../Indoors/Indoors Volume Profile.asset | 456 +++++++++++++++ .../Indoors/Indoors Volume Profile.asset.meta | 8 + .../SceneTemplates/Indoors/LightingData.asset | Bin 21256 -> 20497 bytes .../Indoors/ReflectionProbe-0.exr | 4 +- .../Indoors/ReflectionProbe-0.exr.meta | 16 +- .../SceneTemplates/Standard.scenetemplate | 26 +- .../Editor/SceneTemplates/Standard.unity | 4 +- .../Standard/LightingData.asset | Bin 17800 -> 18401 bytes .../Standard/ReflectionProbe-0.exr | 4 +- .../Standard/ReflectionProbe-0.exr.meta | 3 + .../Standard/ReflectionProbe-1.exr | 3 + .../Standard/ReflectionProbe-1.exr.meta | 120 ++++ ...Standard Baking Set-Default.CellData.bytes | 3 + ...ard Baking Set-Default.CellData.bytes.meta | 7 + ... Baking Set-Default.CellOptionalData.bytes | 3 + ...ng Set-Default.CellOptionalData.bytes.meta | 7 + ...g Set-Default.CellProbeOcclusionData.bytes | 3 + ...-Default.CellProbeOcclusionData.bytes.meta | 7 + .../Standard Baking Set.CellBricksData.bytes | 3 + ...ndard Baking Set.CellBricksData.bytes.meta | 7 + .../Standard Baking Set.CellSharedData.bytes | 3 + ...ndard Baking Set.CellSharedData.bytes.meta | 7 + .../Standard Baking Set.CellSupportData.bytes | 3 + ...dard Baking Set.CellSupportData.bytes.meta | 7 + .../Standard/Standard Baking Set.asset | 261 +++++++++ .../Standard/Standard Baking Set.asset.meta | 8 + .../Standard/Standard Volume Profile.asset | 536 ++++++++++++++++++ .../Standard Volume Profile.asset.meta | 8 + 43 files changed, 1739 insertions(+), 70 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset.meta diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.scenetemplate b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.scenetemplate index 3ed37ca81fb..03c3a11695e 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.scenetemplate +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.scenetemplate @@ -14,37 +14,49 @@ MonoBehaviour: m_EditorClassIdentifier: templateScene: {fileID: 102900000, guid: 41b58a5346e82e4489f95a96a01905f4, type: 3} templateName: Indoors (URP) - description: A scene that works best with the Universal Render Pipeline. Contains - a camera, a directional light, a global volume with a selection of post processing - effects, baked ambient lighting and a baked reflection probe. + description: A scene that works best with the Universal Render Pipeline. Contains a camera, a directional light, a global volume with a selection of post processing effects, baked ambient lighting and a baked reflection probe. preview: {fileID: 7045967719960347874} dependencies: - dependency: {fileID: 112000000, guid: 695c65e91172db945bf049e595adcc66, type: 2} - instantiationMode: 0 + instantiationMode: 1 - dependency: {fileID: 2100000, guid: 761d8e1f988ed2345a28312145c79c6e, type: 2} instantiationMode: 0 - dependency: {fileID: 919132149155446097, guid: b9ae429aca254fa41966db24b9e53232, type: 3} instantiationMode: 0 - dependency: {fileID: 2100000, guid: 92f845725428c954b878da352f657fe5, type: 2} instantiationMode: 0 - - dependency: {fileID: 2100000, guid: 4f1ef37ae953c484bbc5d5e4049147e5, type: 2} - instantiationMode: 0 - - dependency: {fileID: 11400000, guid: afa2d039a61b9a44ab0eb7f1c138af34, type: 2} - instantiationMode: 0 - - dependency: {fileID: 919132149155446097, guid: b28fa67a0ff82c5478f27368dc627683, type: 3} + - dependency: {fileID: 4900000, guid: 4e56ea919713d47dbb73d97eb790b035, type: 3} instantiationMode: 0 - dependency: {fileID: 919132149155446097, guid: 4e8732d4875cc0647b52b55a218072b6, type: 3} instantiationMode: 0 - dependency: {fileID: 919132149155446097, guid: 1dbf28c1bb322474d981b2dc555e28b0, type: 3} instantiationMode: 0 - - dependency: {fileID: 2800000, guid: 32b23d5d74f3aee4f9364e34e2f59379, type: 3} - instantiationMode: 1 + - dependency: {fileID: 4900000, guid: 43608436e3f3e480a89899068f2840c6, type: 3} + instantiationMode: 0 + - dependency: {fileID: 11400000, guid: 6f5f3e944558b294093fde8026e4d36e, type: 2} + instantiationMode: 0 - dependency: {fileID: 2100000, guid: b34b07a45ba63ce47896c9e674f3a7a7, type: 2} instantiationMode: 0 - dependency: {fileID: 2100000, guid: c2e40fa84d53ccd428f640eac126b1fb, type: 2} instantiationMode: 0 - dependency: {fileID: 8900000, guid: e375ace14cc3b5b448ca85ba2455930c, type: 3} instantiationMode: 0 + - dependency: {fileID: 4900000, guid: 61d83ef24d5d3417ea922c5f7ffc0a53, type: 3} + instantiationMode: 0 + - dependency: {fileID: 4900000, guid: 14e5369f7abc34ccb9bc2a8adc489e8e, type: 3} + instantiationMode: 0 + - dependency: {fileID: 2800000, guid: 177b2538515c71b4a86aa1cad939807a, type: 2} + instantiationMode: 1 + - dependency: {fileID: 11400000, guid: 253e19dba0654715a6a9d067af07d8f5, type: 2} + instantiationMode: 0 + - dependency: {fileID: 2100000, guid: 4f1ef37ae953c484bbc5d5e4049147e5, type: 2} + instantiationMode: 0 + - dependency: {fileID: 919132149155446097, guid: b28fa67a0ff82c5478f27368dc627683, type: 3} + instantiationMode: 0 + - dependency: {fileID: 4900000, guid: bd6aa490af3a444eab1051042136cb7c, type: 3} + instantiationMode: 0 + - dependency: {fileID: 4900000, guid: 58b4c233f8e2f4e1bac1e5633ff84297, type: 3} + instantiationMode: 0 - dependency: {fileID: 2100000, guid: 31321ba15b8f8eb4c954353edc038b1d, type: 2} instantiationMode: 0 - dependency: {fileID: 919132149155446097, guid: 39857cfad1651644682ff5b772e6e697, type: 3} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.unity b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.unity index 8deebe13649..20f180ae5ce 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.unity +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e66005ae328f420d299af72e607cd6515ed5d6936a4cc135f3f4306de56d9084 -size 119587 +oid sha256:f0209b372ff67f291f495beb716885b2b860458df93367addc0c51576173fa75 +size 120460 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes new file mode 100644 index 00000000000..5551dc64862 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b73de9acc8d617e4718f5d84722ad687dd7a4d5e4f22e70316d13ca332c6df8a +size 524288 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes.meta new file mode 100644 index 00000000000..fe3b69fdfee --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 58b4c233f8e2f4e1bac1e5633ff84297 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes new file mode 100644 index 00000000000..cc37dc76a47 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:320fe49bffea1d33cc5e2815a974f4397879ce1f99d12001cbe29a4f551b1692 +size 524288 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes.meta new file mode 100644 index 00000000000..aab955a97c4 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellOptionalData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: bd6aa490af3a444eab1051042136cb7c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes new file mode 100644 index 00000000000..da09e165e75 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94fc2ea5e3483bb4d959ebae49f8725e280d3ed5cd4d0d0e90dfdc5ecaccc858 +size 131072 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes.meta new file mode 100644 index 00000000000..054e2472650 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set-Default.CellProbeOcclusionData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 43608436e3f3e480a89899068f2840c6 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes new file mode 100644 index 00000000000..3fa3fa8af42 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:aace93be58864bdd28a42097ffdce3ebc4cb7347874ff44ec6e574edc83f7909 +size 2128 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes.meta new file mode 100644 index 00000000000..2a9d08c1626 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellBricksData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 14e5369f7abc34ccb9bc2a8adc489e8e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes new file mode 100644 index 00000000000..a4e09503b99 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:92c3032e33b4202d6680a7f4c26d1e40fd8b1fc8f3510bb08a3a880d08ee6516 +size 32768 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes.meta new file mode 100644 index 00000000000..41d330e2f2d --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSharedData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4e56ea919713d47dbb73d97eb790b035 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes new file mode 100644 index 00000000000..85281cddee7 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bd75958bf690b0a7e80e639cfddc04cde710066539d64d434d46bc6bcb8dd2b5 +size 1048576 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes.meta new file mode 100644 index 00000000000..be32d1553d5 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.CellSupportData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 61d83ef24d5d3417ea922c5f7ffc0a53 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.asset b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.asset index cfce7af7520..4ed0766c911 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.asset +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Baking Set.asset @@ -12,6 +12,15 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 4881f9a2c4d568047b316028d20a8dca, type: 3} m_Name: Indoors Baking Set m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.ProbeVolumeBakingSet + m_SceneBakeData: + m_Keys: + - 41b58a5346e82e4489f95a96a01905f4 + m_Values: + - hasProbeVolume: 1 + bakeScene: 1 + bounds: + m_Center: {x: 0, y: 6.75, z: 0} + m_Extent: {x: 13.5, y: 6.75, z: 13.5} singleSceneMode: 0 dialogNoProbeVolumeInSetShown: 0 settings: @@ -37,38 +46,168 @@ MonoBehaviour: m_LightingScenarios: - Default cellDescs: - m_Keys: - m_Values: [] + m_Keys: 00000000060000000100000007000000i + m_Values: + - position: {x: -1, y: 0, z: -1} + index: 0 + probeCount: 2112 + minSubdiv: 0 + indexChunkCount: 5 + shChunkCount: 1 + bricksCount: 33 + indirectionEntryInfo: + - positionInBricks: {x: -9, y: 0, z: -9} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 10, y: 10, z: 10} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + - position: {x: -1, y: 0, z: 0} + index: 6 + probeCount: 2112 + minSubdiv: 0 + indexChunkCount: 5 + shChunkCount: 1 + bricksCount: 33 + indirectionEntryInfo: + - positionInBricks: {x: -9, y: 0, z: 0} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 10, y: 10, z: 10} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + - position: {x: 0, y: 0, z: -1} + index: 1 + probeCount: 2112 + minSubdiv: 0 + indexChunkCount: 5 + shChunkCount: 1 + bricksCount: 33 + indirectionEntryInfo: + - positionInBricks: {x: 0, y: 0, z: -9} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 10, y: 10, z: 10} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + - position: {x: 0, y: 0, z: 0} + index: 7 + probeCount: 2176 + minSubdiv: 0 + indexChunkCount: 5 + shChunkCount: 1 + bricksCount: 34 + indirectionEntryInfo: + - positionInBricks: {x: 0, y: 0, z: 0} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 10, y: 10, z: 10} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 m_SerializedPerSceneCellList: - sceneGUID: 41b58a5346e82e4489f95a96a01905f4 - cellList: + cellList: 00000000060000000100000007000000i cellSharedDataAsset: - m_AssetGUID: - m_StreamableAssetPath: - m_ElementSize: 0 + m_AssetGUID: 4e56ea919713d47dbb73d97eb790b035 + m_StreamableAssetPath: APVStreamingAssets/6f5f3e944558b294093fde8026e4d36e/4e56ea919713d47dbb73d97eb790b035.bytes + m_ElementSize: 8192 m_StreamableCellDescs: - m_Keys: - m_Values: [] - m_Asset: {fileID: 0} + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 8192 + elementCount: 1 + - offset: 16384 + elementCount: 1 + - offset: 24576 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 4e56ea919713d47dbb73d97eb790b035, type: 3} scenarios: - m_Keys: [] - m_Values: [] + m_Keys: + - Default + m_Values: + - sceneHash: 1267476725 + cellDataAsset: + m_AssetGUID: 58b4c233f8e2f4e1bac1e5633ff84297 + m_StreamableAssetPath: APVStreamingAssets/6f5f3e944558b294093fde8026e4d36e/58b4c233f8e2f4e1bac1e5633ff84297.bytes + m_ElementSize: 131072 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 131072 + elementCount: 1 + - offset: 262144 + elementCount: 1 + - offset: 393216 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 58b4c233f8e2f4e1bac1e5633ff84297, type: 3} + cellOptionalDataAsset: + m_AssetGUID: bd6aa490af3a444eab1051042136cb7c + m_StreamableAssetPath: APVStreamingAssets/6f5f3e944558b294093fde8026e4d36e/bd6aa490af3a444eab1051042136cb7c.bytes + m_ElementSize: 131072 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 131072 + elementCount: 1 + - offset: 262144 + elementCount: 1 + - offset: 393216 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: bd6aa490af3a444eab1051042136cb7c, type: 3} + cellProbeOcclusionDataAsset: + m_AssetGUID: 43608436e3f3e480a89899068f2840c6 + m_StreamableAssetPath: APVStreamingAssets/6f5f3e944558b294093fde8026e4d36e/43608436e3f3e480a89899068f2840c6.bytes + m_ElementSize: 32768 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 32768 + elementCount: 1 + - offset: 65536 + elementCount: 1 + - offset: 98304 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 43608436e3f3e480a89899068f2840c6, type: 3} cellBricksDataAsset: - m_AssetGUID: - m_StreamableAssetPath: - m_ElementSize: 0 + m_AssetGUID: 14e5369f7abc34ccb9bc2a8adc489e8e + m_StreamableAssetPath: APVStreamingAssets/6f5f3e944558b294093fde8026e4d36e/14e5369f7abc34ccb9bc2a8adc489e8e.bytes + m_ElementSize: 16 m_StreamableCellDescs: - m_Keys: - m_Values: [] - m_Asset: {fileID: 0} + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 33 + - offset: 528 + elementCount: 33 + - offset: 1056 + elementCount: 33 + - offset: 1584 + elementCount: 34 + m_Asset: {fileID: 4900000, guid: 14e5369f7abc34ccb9bc2a8adc489e8e, type: 3} cellSupportDataAsset: - m_AssetGUID: - m_StreamableAssetPath: - m_ElementSize: 0 + m_AssetGUID: 61d83ef24d5d3417ea922c5f7ffc0a53 + m_StreamableAssetPath: APVStreamingAssets/6f5f3e944558b294093fde8026e4d36e/61d83ef24d5d3417ea922c5f7ffc0a53.bytes + m_ElementSize: 262144 m_StreamableCellDescs: - m_Keys: - m_Values: [] - m_Asset: {fileID: 0} + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 262144 + elementCount: 1 + - offset: 524288 + elementCount: 1 + - offset: 786432 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 61d83ef24d5d3417ea922c5f7ffc0a53, type: 3} chunkSizeInBricks: 128 maxCellPosition: {x: 1, y: 1, z: 1} minCellPosition: {x: -1, y: 0, z: -1} @@ -120,12 +259,3 @@ MonoBehaviour: skyOcclusionShadingDirection: 0 useRenderingLayers: 0 renderingLayerMasks: [] - m_SceneBakeData: - m_Keys: - - 41b58a5346e82e4489f95a96a01905f4 - m_Values: - - hasProbeVolume: 1 - bakeScene: 1 - bounds: - m_Center: {x: 0, y: 6.75, z: 0} - m_Extent: {x: 13.5, y: 6.75, z: 13.5} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset new file mode 100644 index 00000000000..d21d3b0dc3c --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset @@ -0,0 +1,456 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-7382073005929846821 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac1e685d8f7565142b879339cd471764, type: 3} + m_Name: SurfaceCacheGIVolumeOverride + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.SurfaceCacheGIVolumeOverride + active: 1 + enabled: + m_OverrideState: 1 + m_Value: 1 + intensity: + m_OverrideState: 0 + m_Value: 1 + lightTransportMultiBounce: + m_OverrideState: 0 + m_Value: 1 + lightTransportBouncePatchAllocation: + m_OverrideState: 0 + m_Value: 0 + lightTransportSampleCount: + m_OverrideState: 1 + m_Value: 8 + patchFilteringTemporalSmoothing: + m_OverrideState: 1 + m_Value: 0.9 + patchFilteringSpatialFilterEnabled: + m_OverrideState: 0 + m_Value: 1 + patchFilteringSpatialSampleCount: + m_OverrideState: 1 + m_Value: 8 + patchFilteringSpatialRadius: + m_OverrideState: 1 + m_Value: 1.5 + patchFilteringPostTemporalEnabled: + m_OverrideState: 0 + m_Value: 1 + screenFilteringLookupSampleCount: + m_OverrideState: 1 + m_Value: 8 + screenFilteringDenoisingPassCount: + m_OverrideState: 1 + m_Value: 4 + volumeSize: + m_OverrideState: 1 + m_Value: 32 + volumeResolution: + m_OverrideState: 1 + m_Value: 64 + volumeCascadeCount: + m_OverrideState: 1 + m_Value: 2 + volumeDistanceFallback: + m_OverrideState: 0 + m_Value: 0 + advancedRenderingLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 0 + m_Bits: 4294967295 + advancedDefragCount: + m_OverrideState: 0 + m_Value: 2 + advancedPatchWarpingEnabled: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-6771307841775242726 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3} + m_Name: Bloom + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom + active: 1 + skipIterations: + m_OverrideState: 0 + m_Value: 1 + threshold: + m_OverrideState: 1 + m_Value: 1.5 + intensity: + m_OverrideState: 1 + m_Value: 0.3 + scatter: + m_OverrideState: 0 + m_Value: 0.7 + clamp: + m_OverrideState: 0 + m_Value: 65472 + tint: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + highQualityFiltering: + m_OverrideState: 0 + m_Value: 0 + filter: + m_OverrideState: 0 + m_Value: 0 + downscale: + m_OverrideState: 0 + m_Value: 0 + maxIterations: + m_OverrideState: 0 + m_Value: 6 + dirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + dirtIntensity: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &-6216216049755003977 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3} + m_Name: Tonemapping + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Tonemapping + active: 1 + mode: + m_OverrideState: 1 + m_Value: 2 + neutralHDRRangeReductionMode: + m_OverrideState: 0 + m_Value: 2 + acesPreset: + m_OverrideState: 0 + m_Value: 3 + hueShiftAmount: + m_OverrideState: 0 + m_Value: 0 + detectPaperWhite: + m_OverrideState: 0 + m_Value: 0 + paperWhite: + m_OverrideState: 0 + m_Value: 300 + detectBrightnessLimits: + m_OverrideState: 0 + m_Value: 1 + minNits: + m_OverrideState: 0 + m_Value: 0.005 + maxNits: + m_OverrideState: 0 + m_Value: 1000 +--- !u!114 &-5901950672042451765 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 221518ef91623a7438a71fef23660601, type: 3} + m_Name: WhiteBalance + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.WhiteBalance + active: 0 + temperature: + m_OverrideState: 1 + m_Value: 5 + tint: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &-4968281228506934450 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 70afe9e12c7a7ed47911bb608a23a8ff, type: 3} + m_Name: SplitToning + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.SplitToning + active: 1 + shadows: + m_OverrideState: 0 + m_Value: {r: 0.5294118, g: 0.5294118, b: 0.5294118, a: 1} + highlights: + m_OverrideState: 1 + m_Value: {r: 0.5294118, g: 0.5294118, b: 0.5294118, a: 1} + balance: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &-2619929595332285776 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5182da28fcdc1ac41a47126f0d404cf8, type: 3} + m_Name: ScreenSpaceAmbientOcclusionVolumeOverride + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ScreenSpaceAmbientOcclusionVolumeOverride + active: 1 + m_Mode: + m_OverrideState: 1 + m_Value: 1 + m_Quality: + m_OverrideState: 1 + m_Value: 2 + m_Intensity: + m_OverrideState: 1 + m_Value: 0.53 + m_Radius: + m_OverrideState: 1 + m_Value: 0.5 + m_DirectLightingStrength: + m_OverrideState: 1 + m_Value: 0 + m_FalloffDistance: + m_OverrideState: 1 + m_Value: 100 + m_SampleCount: + m_OverrideState: 1 + m_Value: 1 + m_Downsample: + m_OverrideState: 1 + m_Value: 0 + m_AfterOpaque: + m_OverrideState: 1 + m_Value: 0 + m_BlurQuality: + m_OverrideState: 1 + m_Value: 2 + m_Method: + m_OverrideState: 1 + m_Value: 1 + m_DepthSource: + m_OverrideState: 1 + m_Value: 1 + m_NormalQuality: + m_OverrideState: 1 + m_Value: 1 + m_MinimumRadiusInPixels: + m_OverrideState: 1 + m_Value: 40 + m_UseComputeShader: + m_OverrideState: 1 + m_Value: 1 + m_SpatialFilter: + m_OverrideState: 1 + m_Value: 0 + m_TemporalFilter: + m_OverrideState: 1 + m_Value: 1 + m_GhostingMitigation: + m_OverrideState: 1 + m_Value: 0.5 + m_HistoryLength: + m_OverrideState: 1 + m_Value: 0.9 + m_DirectionCount: + m_OverrideState: 1 + m_Value: 4 + m_StepCount: + m_OverrideState: 1 + m_Value: 6 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} + m_Name: Indoors Volume Profile + m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile + components: + - {fileID: -6216216049755003977} + - {fileID: -6771307841775242726} + - {fileID: -2619929595332285776} + - {fileID: -7382073005929846821} + - {fileID: 1264236773835230174} + - {fileID: 6900562599770674358} + - {fileID: -5901950672042451765} + - {fileID: -4968281228506934450} + - {fileID: 5922057254404597250} +--- !u!114 &1264236773835230174 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2274cd80d4e22254d98d0282578183e0, type: 3} + m_Name: ScreenSpaceReflectionVolumeSettings + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ScreenSpaceReflectionVolumeSettings + active: 1 + mode: + m_OverrideState: 1 + m_Value: 1 + reflectionStrength: + m_OverrideState: 1 + m_Value: 1 + clampReflectedColor: + m_OverrideState: 1 + m_Value: 0 + maxColorValue: + m_OverrideState: 1 + m_Value: 1 + resolution: + m_OverrideState: 1 + m_Value: 2 + upscalingMethod: + m_OverrideState: 1 + m_Value: 1 + marchingMethod: + m_OverrideState: 1 + m_Value: 1 + hitRefinementSteps: + m_OverrideState: 1 + m_Value: 5 + finalThicknessMultiplier: + m_OverrideState: 1 + m_Value: 0.16 + roughnessFilter: + m_OverrideState: 1 + m_Value: 2 + roughnessScale: + m_OverrideState: 1 + m_Value: 0 + minimumSmoothness: + m_OverrideState: 1 + m_Value: 0.5 + smoothnessFadeStart: + m_OverrideState: 1 + m_Value: 0.7 + normalFade: + m_OverrideState: 1 + m_Value: 0 + screenEdgeFadeDistance: + m_OverrideState: 1 + m_Value: 0.2 + reflectSky: + m_OverrideState: 1 + m_Value: 0 + maxRayLength: + m_OverrideState: 1 + m_Value: 30 + rayLengthFade: + m_OverrideState: 1 + m_Value: 1 + maxRaySteps: + m_OverrideState: 1 + m_Value: 32 + objectThickness: + m_OverrideState: 1 + m_Value: 0.01 + temporalFiltering: + m_OverrideState: 1 + m_Value: 1 + baseBlendFactor: + m_OverrideState: 1 + m_Value: 0.95 +--- !u!114 &5922057254404597250 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c01700fd266d6914ababb731e09af2eb, type: 3} + m_Name: DepthOfField + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.DepthOfField + active: 0 + mode: + m_OverrideState: 1 + m_Value: 1 + gaussianStart: + m_OverrideState: 1 + m_Value: 5 + gaussianEnd: + m_OverrideState: 1 + m_Value: 10 + gaussianMaxRadius: + m_OverrideState: 1 + m_Value: 1 + highQualitySampling: + m_OverrideState: 1 + m_Value: 0 + focusDistance: + m_OverrideState: 1 + m_Value: 10 + aperture: + m_OverrideState: 1 + m_Value: 5.6 + focalLength: + m_OverrideState: 1 + m_Value: 50 + bladeCount: + m_OverrideState: 1 + m_Value: 5 + bladeCurvature: + m_OverrideState: 1 + m_Value: 1 + bladeRotation: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &6900562599770674358 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3} + m_Name: ColorAdjustments + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ColorAdjustments + active: 1 + postExposure: + m_OverrideState: 1 + m_Value: 0.3 + contrast: + m_OverrideState: 0 + m_Value: 10 + colorFilter: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + hueShift: + m_OverrideState: 0 + m_Value: -5 + saturation: + m_OverrideState: 1 + m_Value: 15 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset.meta new file mode 100644 index 00000000000..6a25e7ca2d7 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/Indoors Volume Profile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 253e19dba0654715a6a9d067af07d8f5 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/LightingData.asset b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/LightingData.asset index 3f4d09769a6be8d53c13fb738bd053d7eb33c3ea..451c1e1d0c92e138f1e261dfb8ca5e4d492d1910 100644 GIT binary patch literal 20497 zcmc&+33yaR@_zx5kQEO=LAl0oA3`P^0g{_xl6-C4IlV{poF4iwnPezwfzWUqtL**+kRwb9}zLDfb=p91hVm zlmta-nxEKJi-=$Rik}cIM0>We=HDKo`H`23h=+3!ZfZf1VK-?0nF*N2>3{Pb|0WY9%E;DLo*frSy(E(O0$q z>nLppJ$dx>kU07Y;`-mCcho-&X?{&>Mj?ptZ|EJk7ioS?3!@MOyeU=Ko*v+(Nb_qN zLYf4RgbNc`rS z@h}5IK4U>fu(o~GM!!& zF+@3rf@2CCPA#=C$LVop+4Dx)J^2N0SC%&^k}?go=Q{j4~T1*_1i+qJe zJ|v1BjCW?|IkS8uV9|;AqD-e0SuhyI0_~AqsuiE)^kA^W93I%=xsyK*>Ji%W>9==1 z-+1A}>7#aR?e=c;=S}v_X}SN0XO5JI&-rMUbwuy8#b+zlPwn*4{yqMlM=Ex_dfVsy zRyKR>y%RaxpMK$B%A$zZ7M{Mb^OUN2md?ihD|pFzxWCza3rGB;v=z2cO@%d*Im<(|#YrJn?lWhr5U$Ne7?jDW?W0662+7bDK7_Z zAmbeV1qP(1nAB$(2=$LIaAs$_vM|R3Ge#6h&dSOw5}KZ$G1BfG>U6qcubd9Cs{F5- z@7UWUe7$CFH~Gw^(epb;HJ{taRyO&ODR=Z8pW0?zkLKk&Dl^=(zx>^-#cOAKA3SjG z45T2{XK48%VOvc?{F*k7Ad&F%Ru-g?Sv!dbinf}%d4S`w(+MlrJ>v>{A|+X0ovoAi zci0m%b@W49)3ywqICwX&+1el~sCIJ=rLk5cqj4dHR`Y^`I+mFG-MAaj*s_vO$Fs32;O_b;e=te#mIVy3>}ftCx|#-gN7A=E-R6K#nHc=D_^;HEDLn@M>f4_%-phDH6I zJ~$nBX-5C%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;fxbjeX!``?_hY6Pd>2rMezx@&U=z#V63OT)ZQl#_I*Dt8&bnWy3AK$q3z*0^Z zocGRKwM8|9IlZBxZ|^NPoL<7|&l(o@*wB0CN=|Q>e&yb48{fQ))8mHz=DqQ^Z#$dQ zUvzw+)wvUT(Aa1JY4C80xSP2lvGPmlem`*RJm zIX$^3zI4aJ&}dGdc=b^WS2Z=v;dJHPt6qHRrY_Z-4(`4C`6Xrh+jIKPH`Z@n(QRd% z)7!V@4hqj|n#buAAAPm|W9OGo;q;SLlfT*A|DVb6edV@0essm=(TkX$aKn2a&iu=V z4V;#)*lRub+K7|-wYme_{>t6B_q4W?id&z=>6-m{w|@8TfpMH3*f#RBCHtr@5>lgQ7G&|b`h mGGw(GHn?$cqvQQQQzDxj3brGEJo#PZJ+3FUW`;>a`ThkOCD+aX diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr index c872612512e..0c88598bd73 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cacc5d14182353fcb226bbc088acd0e54678deed0d830a8195e13b230c810f36 -size 163137 +oid sha256:7b7077fd117c1e707c983ee688e8cadc7eb15fb6b0d981c718e195fe1da88568 +size 198740 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr.meta index 1caf6b9ddf7..cb1d028cd83 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr.meta +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Indoors/ReflectionProbe-0.exr.meta @@ -53,7 +53,9 @@ TextureImporter: spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 alphaIsTransparency: 0 + spriteTessellationMethod: 0 spriteTessellationDetail: -1 + spriteGeometrySubdivision: -1 textureType: 0 textureShape: 2 singleChannelComponent: 0 @@ -80,19 +82,6 @@ TextureImporter: ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 - - serializedVersion: 4 - buildTarget: Switch - maxTextureSize: 2048 - resizeAlgorithm: 0 - textureFormat: -1 - textureCompression: 1 - compressionQuality: 50 - crunchedCompression: 0 - allowsAlphaSplitting: 0 - overridden: 0 - ignorePlatformSupport: 0 - androidETC2FallbackOverride: 0 - forceMaximumCompressionQuality_BC6H_BC7: 0 - serializedVersion: 4 buildTarget: Standalone maxTextureSize: 2048 @@ -128,3 +117,4 @@ TextureImporter: userData: assetBundleName: assetBundleVariant: + script: {fileID: 21037, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.scenetemplate b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.scenetemplate index 240945cca96..7b19a2e294b 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.scenetemplate +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.scenetemplate @@ -60,22 +60,34 @@ MonoBehaviour: m_EditorClassIdentifier: templateScene: {fileID: 102900000, guid: 5cae0d87369a2405eaa962b8d920b947, type: 3} templateName: Outdoors (URP) - description: A scene that works best with the Universal Render Pipeline. Contains - a camera, a directional light, a global volume with a selection of post processing - effects, baked ambient lighting and a baked reflection probe. + description: A scene that works best with the Universal Render Pipeline. Contains a camera, a directional light, a global volume with a selection of post processing effects, baked ambient lighting and a baked reflection probe. preview: {fileID: -1373669200098178741} dependencies: - dependency: {fileID: 2100000, guid: 761d8e1f988ed2345a28312145c79c6e, type: 2} instantiationMode: 0 + - dependency: {fileID: 8900000, guid: ef46356a1c3654827bb515882307f626, type: 3} + instantiationMode: 0 + - dependency: {fileID: 2800000, guid: 177b2538515c71b4a86aa1cad939807a, type: 2} + instantiationMode: 1 + - dependency: {fileID: 4900000, guid: a8531a7df4ec14312af90e8e52f63e0b, type: 3} + instantiationMode: 0 - dependency: {fileID: 2100000, guid: 4f1ef37ae953c484bbc5d5e4049147e5, type: 2} instantiationMode: 0 + - dependency: {fileID: 4900000, guid: 36688c221c53345f7882205002d6e346, type: 3} + instantiationMode: 0 + - dependency: {fileID: 4900000, guid: 21e094b847096426ba6b78b3b73acd1c, type: 3} + instantiationMode: 0 - dependency: {fileID: 112000000, guid: bbf92febd37eec24fa8da21f59ace918, type: 2} instantiationMode: 0 - - dependency: {fileID: 2800000, guid: 32b23d5d74f3aee4f9364e34e2f59379, type: 3} - instantiationMode: 1 + - dependency: {fileID: 4900000, guid: d153c8124e05a4d93b09cceffeefd574, type: 3} + instantiationMode: 0 + - dependency: {fileID: 11400000, guid: 280d73e807454e39a5a7ee4b4edf6259, type: 2} + instantiationMode: 0 + - dependency: {fileID: 4900000, guid: a53bcbe21e77c45a09117b778fcda9e1, type: 3} + instantiationMode: 0 - dependency: {fileID: 2100000, guid: c2e40fa84d53ccd428f640eac126b1fb, type: 2} instantiationMode: 0 - - dependency: {fileID: 11400000, guid: 103b0616690034ca1a309e958ed431fc, type: 2} + - dependency: {fileID: 11400000, guid: 50fd20061f8774740924093a4b690c30, type: 2} instantiationMode: 0 - dependency: {fileID: 8900000, guid: 42c8d975867dbb34299217c9b3a62677, type: 3} instantiationMode: 0 @@ -83,6 +95,8 @@ MonoBehaviour: instantiationMode: 0 - dependency: {fileID: 919132149155446097, guid: 39857cfad1651644682ff5b772e6e697, type: 3} instantiationMode: 0 + - dependency: {fileID: 4900000, guid: 1e2015c3d174f4dd681c5f3c1c1d3207, type: 3} + instantiationMode: 0 - dependency: {fileID: 2100000, guid: f96821bbefeea864b9b418af4b8615ac, type: 2} instantiationMode: 0 templatePipeline: {fileID: 11500000, guid: e353ed204c92da941bcf3116819f9b91, type: 3} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.unity b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.unity index 04479076bfd..0b3f49ffc4c 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.unity +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19827a05b9394cc094b59707708c368bc673d77816fcee6e86d79a01f2e2680c -size 53165 +oid sha256:926cffaf76d0afca5a5db08882764c05d8650cb066eab06c794e4f6f4cd1c8e6 +size 55250 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/LightingData.asset b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/LightingData.asset index 44787ffe8397356ee402245bf630017c20dc8915..476d8f17e7dab8d47adb6c65fd13d71c7bbd8ee4 100644 GIT binary patch literal 18401 zcmc&+33yb+vOa(;Mo<(5RK$U>gOCY?HJK!YKmrK~I|33X$$<<>X5!3*B&ax`Y$6vG zQ3MoF^g|?q2rd{F6+!SKAe-=5E(oHifLwU`@aK`{PyC9XDq0oo&1#x&brsErvcw`DESseSbC7UcPAY1IG{0gs}vKRsywHhM599vAR^#6Og>!H>RH z@o5_R0b)Fz;=u1mo=?+iPzVCkM@ftK3L+nmhlVuuBUv+ z7yYDveoAtT&GI^&V|&@X_E?Wc_iCxBUUy`Cro-!U#}|5ar^n%P+Kk*(w?4+6p6K*= z?amBcW)8~Gow{JPX}M`4MWLuS*PiF0cx=jGz0jNQ);&fw0!wwf(sd75Oi50GG1--= zYlHH#bhjhJo|9mA=enGZ3{O%x73yiv)-z*s(;d3gD=JEKCOMqC-EFEMPtP2vJ2Q2+ z?#AFMMiP5@w0LI@1fe@c|C8-`c_b5J`BVAa94eH<@<*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!mgmo2uGs-|>D zPllEYW5s8N?{?5`@1bbivc4(ZGLX%M-9gsun%Zdvvt2c9hI~`l(@m?R2h0JvtT`!i zFtXOl=OtL+NrM&}@I$o?wK?$pU zEm#cU6a$JQWpp*wQT@!tit3nabfhv_z9tO-)_xmxlQS_gUG=- z+MO%hBQg;VQH27nOQw6iwl7EHz#%bO74%}2c3~B+xs!HGd)jz`Z**m@+-aUX4ZZf@b>NWv-=bF@nmYKCQ)ks3`KQ@~ z;iM<)uAjQ8e&*S;PWjwZdj}ufcXD0Z%87NqTXo6cYu9bAYwH>q+&Au!Q{I_=WBr9Y zD(ZKAcHZPD75bZ|zRV!`qjRF9fJw|{PbVE)f2wR7Y1JK}OOP8>rU UCO#gKO0%CZg|6JpRlT(TKWv56g8%>k diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr index b92ab79d99c..e976c71d200 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fa9262ea63957ab378f44f031702bb1ae3d2c1ea3c68d7d7e32afd6659a68be1 -size 216109 +oid sha256:c428ae783a419d833f8f0b0a792f5ee800716fa7de81d717cf76bfde36094232 +size 214065 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr.meta index f785cee90c7..f1ecdbfdbea 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr.meta +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-0.exr.meta @@ -53,7 +53,9 @@ TextureImporter: spriteGenerateFallbackPhysicsShape: 1 alphaUsage: 1 alphaIsTransparency: 0 + spriteTessellationMethod: 0 spriteTessellationDetail: -1 + spriteGeometrySubdivision: -1 textureType: 0 textureShape: 2 singleChannelComponent: 0 @@ -115,3 +117,4 @@ TextureImporter: userData: assetBundleName: assetBundleVariant: + script: {fileID: 21037, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr new file mode 100644 index 00000000000..4f1118450a4 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ebd2858a96b79d456a99297ed7d12c8f409421b3087e7288ce3c63a62828f9e0 +size 163907 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr.meta new file mode 100644 index 00000000000..97df00e4e53 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/ReflectionProbe-1.exr.meta @@ -0,0 +1,120 @@ +fileFormatVersion: 2 +guid: ef46356a1c3654827bb515882307f626 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 13 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + flipGreenChannel: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMipmapLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 1 + seamlessCubemap: 1 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 2 + aniso: 0 + mipBias: 0 + wrapU: 1 + wrapV: 1 + wrapW: 1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationMethod: 0 + spriteTessellationDetail: -1 + spriteGeometrySubdivision: -1 + textureType: 0 + textureShape: 2 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + swizzle: 50462976 + cookieLightType: 0 + platformSettings: + - serializedVersion: 4 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 100 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + customData: + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spriteCustomMetadata: + entries: [] + nameFileIdTable: {} + mipmapLimitGroupName: + pSDRemoveMatte: 0 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 21037, guid: 0000000000000000e000000000000000, type: 0} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes new file mode 100644 index 00000000000..28780ed5a8c --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d32336cdaf6ee7cdcab668d3a360c7396b996fdb277d42d756726dbc3f5ecd53 +size 524288 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes.meta new file mode 100644 index 00000000000..976ece25c65 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a53bcbe21e77c45a09117b778fcda9e1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes new file mode 100644 index 00000000000..03fef38d031 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2cab3cc6fb2b5ec3ee51b968e4edd5b92d71d6a5acd7153fd645e0c242cbb498 +size 524288 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes.meta new file mode 100644 index 00000000000..be2677ad906 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellOptionalData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 36688c221c53345f7882205002d6e346 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes new file mode 100644 index 00000000000..8180abb59e3 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abb843474a64e2684fa4fc6b67d7b2b67817d083c0e4767ac6f4b6087b2fb276 +size 131072 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes.meta new file mode 100644 index 00000000000..8c43e82ff4d --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set-Default.CellProbeOcclusionData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1e2015c3d174f4dd681c5f3c1c1d3207 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes new file mode 100644 index 00000000000..1225a8357fb --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e7afd62bc7e4ef8ced37b85b2606b3f4b0cfb880d5ead207de4b02c853d10990 +size 1408 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes.meta new file mode 100644 index 00000000000..61e92a3fff2 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellBricksData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a8531a7df4ec14312af90e8e52f63e0b +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes new file mode 100644 index 00000000000..c1ca68a9681 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16cb66bbf91b1eb48b89e1533a3929d7e32ba62283f1dd066775be426ea6fba5 +size 32768 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes.meta new file mode 100644 index 00000000000..63423edc351 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSharedData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d153c8124e05a4d93b09cceffeefd574 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes new file mode 100644 index 00000000000..6f0343185c5 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:a45efb770f4611d4aa1192577e4b3a4b5d197bd2e74cc519e8f5b92bcb3008b3 +size 1048576 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes.meta new file mode 100644 index 00000000000..d2498cbcf72 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.CellSupportData.bytes.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 21e094b847096426ba6b78b3b73acd1c +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset new file mode 100644 index 00000000000..a71a71db4ed --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset @@ -0,0 +1,261 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4881f9a2c4d568047b316028d20a8dca, type: 3} + m_Name: Standard Baking Set + m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.ProbeVolumeBakingSet + m_SceneBakeData: + m_Keys: + - 5cae0d87369a2405eaa962b8d920b947 + m_Values: + - hasProbeVolume: 1 + bakeScene: 1 + bounds: + m_Center: {x: 0, y: 40.5, z: 0} + m_Extent: {x: 81, y: 40.5, z: 81} + singleSceneMode: 1 + dialogNoProbeVolumeInSetShown: 0 + settings: + m_Version: 1 + dilationSettings: + enableDilation: 0 + dilationDistance: 1 + dilationValidityThreshold: 0.25 + dilationIterations: 1 + squaredDistWeighting: 1 + virtualOffsetSettings: + useVirtualOffset: 1 + validityThreshold: 0.25 + outOfGeoOffset: 0.01 + searchMultiplier: 0.2 + rayOriginBias: -0.001 + collisionMask: + serializedVersion: 2 + m_Bits: 4294967291 + m_SceneGUIDs: + - 5cae0d87369a2405eaa962b8d920b947 + obsoleteScenesToNotBake: [] + m_LightingScenarios: + - Default + cellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - position: {x: -1, y: 0, z: -1} + index: 0 + probeCount: 1408 + minSubdiv: 0 + indexChunkCount: 91 + shChunkCount: 1 + bricksCount: 22 + indirectionEntryInfo: + - positionInBricks: {x: -27, y: 0, z: -27} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 28, y: 28, z: 28} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + - position: {x: -1, y: 0, z: 0} + index: 6 + probeCount: 1408 + minSubdiv: 0 + indexChunkCount: 91 + shChunkCount: 1 + bricksCount: 22 + indirectionEntryInfo: + - positionInBricks: {x: -27, y: 0, z: 0} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 28, y: 28, z: 28} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + - position: {x: 0, y: 0, z: -1} + index: 1 + probeCount: 1408 + minSubdiv: 0 + indexChunkCount: 91 + shChunkCount: 1 + bricksCount: 22 + indirectionEntryInfo: + - positionInBricks: {x: 0, y: 0, z: -27} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 28, y: 28, z: 28} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + - position: {x: 0, y: 0, z: 0} + index: 7 + probeCount: 1408 + minSubdiv: 0 + indexChunkCount: 91 + shChunkCount: 1 + bricksCount: 22 + indirectionEntryInfo: + - positionInBricks: {x: 0, y: 0, z: 0} + minSubdiv: 0 + minBrickPos: {x: 0, y: 0, z: 0} + maxBrickPosPlusOne: {x: 28, y: 28, z: 28} + hasMinMax: 1 + hasOnlyBiggerBricks: 0 + m_SerializedPerSceneCellList: + - sceneGUID: 5cae0d87369a2405eaa962b8d920b947 + cellList: 00000000060000000100000007000000i + cellSharedDataAsset: + m_AssetGUID: d153c8124e05a4d93b09cceffeefd574 + m_StreamableAssetPath: APVStreamingAssets/50fd20061f8774740924093a4b690c30/d153c8124e05a4d93b09cceffeefd574.bytes + m_ElementSize: 8192 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 8192 + elementCount: 1 + - offset: 16384 + elementCount: 1 + - offset: 24576 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: d153c8124e05a4d93b09cceffeefd574, type: 3} + scenarios: + m_Keys: + - Default + m_Values: + - sceneHash: -1333340397 + cellDataAsset: + m_AssetGUID: a53bcbe21e77c45a09117b778fcda9e1 + m_StreamableAssetPath: APVStreamingAssets/50fd20061f8774740924093a4b690c30/a53bcbe21e77c45a09117b778fcda9e1.bytes + m_ElementSize: 131072 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 131072 + elementCount: 1 + - offset: 262144 + elementCount: 1 + - offset: 393216 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: a53bcbe21e77c45a09117b778fcda9e1, type: 3} + cellOptionalDataAsset: + m_AssetGUID: 36688c221c53345f7882205002d6e346 + m_StreamableAssetPath: APVStreamingAssets/50fd20061f8774740924093a4b690c30/36688c221c53345f7882205002d6e346.bytes + m_ElementSize: 131072 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 131072 + elementCount: 1 + - offset: 262144 + elementCount: 1 + - offset: 393216 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 36688c221c53345f7882205002d6e346, type: 3} + cellProbeOcclusionDataAsset: + m_AssetGUID: 1e2015c3d174f4dd681c5f3c1c1d3207 + m_StreamableAssetPath: APVStreamingAssets/50fd20061f8774740924093a4b690c30/1e2015c3d174f4dd681c5f3c1c1d3207.bytes + m_ElementSize: 32768 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 32768 + elementCount: 1 + - offset: 65536 + elementCount: 1 + - offset: 98304 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 1e2015c3d174f4dd681c5f3c1c1d3207, type: 3} + cellBricksDataAsset: + m_AssetGUID: a8531a7df4ec14312af90e8e52f63e0b + m_StreamableAssetPath: APVStreamingAssets/50fd20061f8774740924093a4b690c30/a8531a7df4ec14312af90e8e52f63e0b.bytes + m_ElementSize: 16 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 22 + - offset: 352 + elementCount: 22 + - offset: 704 + elementCount: 22 + - offset: 1056 + elementCount: 22 + m_Asset: {fileID: 4900000, guid: a8531a7df4ec14312af90e8e52f63e0b, type: 3} + cellSupportDataAsset: + m_AssetGUID: 21e094b847096426ba6b78b3b73acd1c + m_StreamableAssetPath: APVStreamingAssets/50fd20061f8774740924093a4b690c30/21e094b847096426ba6b78b3b73acd1c.bytes + m_ElementSize: 262144 + m_StreamableCellDescs: + m_Keys: 00000000060000000100000007000000i + m_Values: + - offset: 0 + elementCount: 1 + - offset: 262144 + elementCount: 1 + - offset: 524288 + elementCount: 1 + - offset: 786432 + elementCount: 1 + m_Asset: {fileID: 4900000, guid: 21e094b847096426ba6b78b3b73acd1c, type: 3} + chunkSizeInBricks: 128 + maxCellPosition: {x: 1, y: 1, z: 1} + minCellPosition: {x: -1, y: 0, z: -1} + globalBounds: + m_Center: {x: 0, y: 40.5, z: 0} + m_Extent: {x: 81, y: 40.5, z: 81} + bakedSimplificationLevels: 3 + bakedMinDistanceBetweenProbes: 1 + bakedProbeOcclusion: 1 + bakedSkyOcclusionValue: 0 + bakedSkyShadingDirectionValue: 0 + bakedProbeOffset: {x: 0, y: 0, z: 0} + bakedMaskCount: 1 + bakedLayerMasks: + x: 4294967295 + y: 0 + z: 0 + w: 0 + maxSHChunkCount: 1 + L0ChunkSize: 65536 + L1ChunkSize: 32768 + L2TextureChunkSize: 32768 + ProbeOcclusionChunkSize: 32768 + sharedValidityMaskChunkSize: 8192 + sharedSkyOcclusionL0L1ChunkSize: 0 + sharedSkyShadingDirectionIndicesChunkSize: 0 + sharedDataChunkSize: 8192 + supportPositionChunkSize: 98304 + supportValidityChunkSize: 32768 + supportTouchupChunkSize: 32768 + supportLayerMaskChunkSize: 0 + supportOffsetsChunkSize: 98304 + supportDataChunkSize: 262144 + lightingScenario: Default + version: 2 + freezePlacement: 0 + probeOffset: {x: 0, y: 0, z: 0} + simplificationLevels: 3 + minDistanceBetweenProbes: 1 + renderersLayerMask: + serializedVersion: 2 + m_Bits: 4294967295 + minRendererVolumeSize: 0.1 + skyOcclusion: 0 + skyOcclusionBakingSamples: 2048 + skyOcclusionBakingBounces: 2 + skyOcclusionAverageAlbedo: 0.6 + skyOcclusionBackFaceCulling: 0 + skyOcclusionShadingDirection: 0 + useRenderingLayers: 0 + renderingLayerMasks: [] diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset.meta new file mode 100644 index 00000000000..325580d7dc9 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Baking Set.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 50fd20061f8774740924093a4b690c30 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset new file mode 100644 index 00000000000..da3b17c269b --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset @@ -0,0 +1,536 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-8789321230815744961 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d36880d8ecb6d4cf1bcf8af388612970, type: 3} + m_Name: FogVolumeComponent + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.FogVolumeComponent + active: 1 + volumetricFogAlbedo: + m_OverrideState: 1 + m_Value: {r: 0.6156863, g: 0.77254903, b: 0.77254903, a: 1} + volumetricFogEnabled: + m_OverrideState: 1 + m_Value: 1 + volumetricFogDensity: + m_OverrideState: 1 + m_Value: 0.002 + anisotropy: + m_OverrideState: 0 + m_Value: 0.9 + lightFilter: + m_OverrideState: 0 + m_Value: 0 + multipleScatteringIntensity: + m_OverrideState: 0 + m_Value: 0 + denoisingMode: + m_OverrideState: 0 + m_Value: 1 + volumetricLightingDensityCutoff: + m_OverrideState: 0 + m_Value: 0 + enableLightCookies: + m_OverrideState: 0 + m_Value: 1 + screenResolutionPercentage: + m_OverrideState: 0 + m_Value: 12.5 + volumeSliceCount: + m_OverrideState: 0 + m_Value: 64 + cutoffDistance: + m_OverrideState: 0 + m_Value: 64 + sliceDistributionUniformity: + m_OverrideState: 0 + m_Value: 0.75 + volumetricFogBaseHeight: + m_OverrideState: 0 + m_Value: 0 + volumetricFogMaximumHeight: + m_OverrideState: 0 + m_Value: 50 + maxFogDistance: + m_OverrideState: 0 + m_Value: 5000 +--- !u!114 &-7610648685792437266 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5182da28fcdc1ac41a47126f0d404cf8, type: 3} + m_Name: ScreenSpaceAmbientOcclusionVolumeOverride + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ScreenSpaceAmbientOcclusionVolumeOverride + active: 1 + m_Mode: + m_OverrideState: 1 + m_Value: 1 + m_Quality: + m_OverrideState: 1 + m_Value: 3 + m_Intensity: + m_OverrideState: 0 + m_Value: 1 + m_Radius: + m_OverrideState: 1 + m_Value: 0.3 + m_DirectLightingStrength: + m_OverrideState: 0 + m_Value: 0 + m_FalloffDistance: + m_OverrideState: 0 + m_Value: 100 + m_SampleCount: + m_OverrideState: 1 + m_Value: 1 + m_Downsample: + m_OverrideState: 1 + m_Value: 0 + m_AfterOpaque: + m_OverrideState: 0 + m_Value: 0 + m_BlurQuality: + m_OverrideState: 0 + m_Value: 2 + m_Method: + m_OverrideState: 0 + m_Value: 1 + m_DepthSource: + m_OverrideState: 0 + m_Value: 1 + m_NormalQuality: + m_OverrideState: 0 + m_Value: 1 + m_MinimumRadiusInPixels: + m_OverrideState: 0 + m_Value: 40 + m_UseComputeShader: + m_OverrideState: 1 + m_Value: 1 + m_SpatialFilter: + m_OverrideState: 0 + m_Value: 0 + m_TemporalFilter: + m_OverrideState: 1 + m_Value: 1 + m_GhostingMitigation: + m_OverrideState: 0 + m_Value: 0.5 + m_HistoryLength: + m_OverrideState: 0 + m_Value: 0.9 + m_DirectionCount: + m_OverrideState: 1 + m_Value: 2 + m_StepCount: + m_OverrideState: 1 + m_Value: 4 +--- !u!114 &-5778355958272495213 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2274cd80d4e22254d98d0282578183e0, type: 3} + m_Name: ScreenSpaceReflectionVolumeSettings + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ScreenSpaceReflectionVolumeSettings + active: 1 + mode: + m_OverrideState: 1 + m_Value: 1 + reflectionStrength: + m_OverrideState: 1 + m_Value: 1 + clampReflectedColor: + m_OverrideState: 1 + m_Value: 0 + maxColorValue: + m_OverrideState: 0 + m_Value: 1 + resolution: + m_OverrideState: 1 + m_Value: 2 + upscalingMethod: + m_OverrideState: 1 + m_Value: 1 + marchingMethod: + m_OverrideState: 1 + m_Value: 1 + hitRefinementSteps: + m_OverrideState: 1 + m_Value: 5 + finalThicknessMultiplier: + m_OverrideState: 1 + m_Value: 0.16 + roughnessFilter: + m_OverrideState: 1 + m_Value: 2 + roughnessScale: + m_OverrideState: 1 + m_Value: 0 + minimumSmoothness: + m_OverrideState: 1 + m_Value: 0.05 + smoothnessFadeStart: + m_OverrideState: 1 + m_Value: 0.1 + normalFade: + m_OverrideState: 1 + m_Value: 0 + screenEdgeFadeDistance: + m_OverrideState: 1 + m_Value: 0.2 + reflectSky: + m_OverrideState: 1 + m_Value: 0 + maxRayLength: + m_OverrideState: 1 + m_Value: 30 + rayLengthFade: + m_OverrideState: 0 + m_Value: 0 + maxRaySteps: + m_OverrideState: 1 + m_Value: 32 + objectThickness: + m_OverrideState: 1 + m_Value: 0.01 + temporalFiltering: + m_OverrideState: 1 + m_Value: 0 + baseBlendFactor: + m_OverrideState: 0 + m_Value: 0.95 +--- !u!114 &-4402360598047637561 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 06437c1ff663d574d9447842ba0a72e4, type: 3} + m_Name: ScreenSpaceLensFlare + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ScreenSpaceLensFlare + active: 1 + intensity: + m_OverrideState: 1 + m_Value: 0.5 + tintColor: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + bloomMip: + m_OverrideState: 1 + m_Value: 0 + firstFlareIntensity: + m_OverrideState: 0 + m_Value: 1 + secondaryFlareIntensity: + m_OverrideState: 0 + m_Value: 1 + warpedFlareIntensity: + m_OverrideState: 0 + m_Value: 1 + warpedFlareScale: + m_OverrideState: 0 + m_Value: {x: 1, y: 1} + samples: + m_OverrideState: 0 + m_Value: 1 + sampleDimmer: + m_OverrideState: 0 + m_Value: 0.5 + vignetteEffect: + m_OverrideState: 0 + m_Value: 1 + startingPosition: + m_OverrideState: 0 + m_Value: 1.25 + scale: + m_OverrideState: 0 + m_Value: 1.5 + streaksIntensity: + m_OverrideState: 1 + m_Value: 0.2 + streaksLength: + m_OverrideState: 0 + m_Value: 0.5 + streaksOrientation: + m_OverrideState: 0 + m_Value: 0 + streaksThreshold: + m_OverrideState: 0 + m_Value: 0.25 + resolution: + m_OverrideState: 0 + m_Value: 4 + chromaticAberrationIntensity: + m_OverrideState: 0 + m_Value: 0.5 +--- !u!114 &-2051006209472347410 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ac1e685d8f7565142b879339cd471764, type: 3} + m_Name: SurfaceCacheGIVolumeOverride + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.SurfaceCacheGIVolumeOverride + active: 1 + enabled: + m_OverrideState: 0 + m_Value: 1 + lightTransportMultiBounce: + m_OverrideState: 1 + m_Value: 1 + lightTransportBouncePatchAllocation: + m_OverrideState: 1 + m_Value: 1 + lightTransportSampleCount: + m_OverrideState: 1 + m_Value: 2 + patchFilteringTemporalSmoothing: + m_OverrideState: 1 + m_Value: 0.8 + patchFilteringSpatialFilterEnabled: + m_OverrideState: 1 + m_Value: 1 + patchFilteringSpatialSampleCount: + m_OverrideState: 1 + m_Value: 4 + patchFilteringSpatialRadius: + m_OverrideState: 1 + m_Value: 1 + patchFilteringPostTemporalEnabled: + m_OverrideState: 1 + m_Value: 1 + screenFilteringLookupSampleCount: + m_OverrideState: 1 + m_Value: 8 + screenFilteringDenoisingPassCount: + m_OverrideState: 0 + m_Value: 2 + volumeSize: + m_OverrideState: 0 + m_Value: 128 + volumeResolution: + m_OverrideState: 1 + m_Value: 48 + volumeCascadeCount: + m_OverrideState: 1 + m_Value: 4 + volumeDistanceFallback: + m_OverrideState: 1 + m_Value: 0 + advancedRenderingLayerMask: + m_OverrideState: 0 + m_Value: + serializedVersion: 0 + m_Bits: 4294967295 + advancedDefragCount: + m_OverrideState: 0 + m_Value: 2 + advancedPatchWarpingEnabled: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &-1410909798927354709 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 66f335fb1ffd8684294ad653bf1c7564, type: 3} + m_Name: ColorAdjustments + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.ColorAdjustments + active: 1 + postExposure: + m_OverrideState: 0 + m_Value: 0.1 + contrast: + m_OverrideState: 0 + m_Value: 0 + colorFilter: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + hueShift: + m_OverrideState: 0 + m_Value: 0 + saturation: + m_OverrideState: 1 + m_Value: 40 +--- !u!114 &-116156888068461481 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 221518ef91623a7438a71fef23660601, type: 3} + m_Name: WhiteBalance + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.WhiteBalance + active: 1 + temperature: + m_OverrideState: 0 + m_Value: -5 + tint: + m_OverrideState: 1 + m_Value: 10 +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3} + m_Name: Standard Volume Profile + m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile + components: + - {fileID: 2401797845609809424} + - {fileID: 4661747612401170006} + - {fileID: -7610648685792437266} + - {fileID: -2051006209472347410} + - {fileID: -5778355958272495213} + - {fileID: -1410909798927354709} + - {fileID: -116156888068461481} + - {fileID: 8510540365888270984} + - {fileID: -8789321230815744961} + - {fileID: -4402360598047637561} +--- !u!114 &2401797845609809424 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97c23e3b12dc18c42a140437e53d3951, type: 3} + m_Name: Tonemapping + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Tonemapping + active: 1 + mode: + m_OverrideState: 1 + m_Value: 2 + neutralHDRRangeReductionMode: + m_OverrideState: 0 + m_Value: 2 + acesPreset: + m_OverrideState: 0 + m_Value: 3 + hueShiftAmount: + m_OverrideState: 0 + m_Value: 0 + detectPaperWhite: + m_OverrideState: 0 + m_Value: 0 + paperWhite: + m_OverrideState: 0 + m_Value: 300 + detectBrightnessLimits: + m_OverrideState: 0 + m_Value: 1 + minNits: + m_OverrideState: 0 + m_Value: 0.005 + maxNits: + m_OverrideState: 0 + m_Value: 1000 +--- !u!114 &4661747612401170006 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3} + m_Name: Bloom + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom + active: 1 + skipIterations: + m_OverrideState: 0 + m_Value: 1 + threshold: + m_OverrideState: 1 + m_Value: 1.5 + intensity: + m_OverrideState: 1 + m_Value: 0.3 + scatter: + m_OverrideState: 0 + m_Value: 0.7 + clamp: + m_OverrideState: 0 + m_Value: 65472 + tint: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + highQualityFiltering: + m_OverrideState: 0 + m_Value: 0 + filter: + m_OverrideState: 0 + m_Value: 0 + downscale: + m_OverrideState: 0 + m_Value: 0 + maxIterations: + m_OverrideState: 0 + m_Value: 6 + dirtTexture: + m_OverrideState: 0 + m_Value: {fileID: 0} + dimension: 1 + dirtIntensity: + m_OverrideState: 0 + m_Value: 0 +--- !u!114 &8510540365888270984 +MonoBehaviour: + m_ObjectHideFlags: 3 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 70afe9e12c7a7ed47911bb608a23a8ff, type: 3} + m_Name: SplitToning + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.SplitToning + active: 1 + shadows: + m_OverrideState: 1 + m_Value: {r: 0.4433962, g: 0.4433962, b: 0.4433962, a: 1} + highlights: + m_OverrideState: 1 + m_Value: {r: 0.3529412, g: 0.3529412, b: 0.3529412, a: 1} + balance: + m_OverrideState: 0 + m_Value: 0 diff --git a/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset.meta b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset.meta new file mode 100644 index 00000000000..ab530ad91a0 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/SceneTemplates/Standard/Standard Volume Profile.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 280d73e807454e39a5a7ee4b4edf6259 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: From f9dbc77f9ffaf7fec8604815dc808ed1c91a8118 Mon Sep 17 00:00:00 2001 From: Arttu Peltonen Date: Wed, 11 Nov 2026 06:29:21 +0000 Subject: [PATCH 54/61] [Port] [6000.7] [UUM-160580] Keep prefab conversions when the converter opens closed scenes --- .../Tools/Converter/AssetsConverter.cs | 6 ++ .../Window/RenderPipelineConvertersEditor.cs | 5 +- .../Tools/Converters/ConvertersTests.cs | 67 +++++++++++++++++++ 3 files changed, 76 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs index 5cf8c7d8a20..f7574aed4ec 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/AssetsConverter.cs @@ -234,7 +234,11 @@ public Status Convert(IRenderPipelineConverterItem item, out string message) var scenePath = GetUnloadedScenePath(assetItem.GlobalObjectId); if (scenePath != null) + { + // Opening the scene unloads converted assets that are not saved, such as prefabs + AssetDatabase.SaveAssets(); (m_ScenesOpenedForConversion ??= new HashSet()).Add(scenePath); + } var obj = assetItem.LoadObject(); @@ -273,6 +277,8 @@ void SaveSceneOpenedForConversion(UnityEngine.Object obj) public virtual void AfterConvert() { + // A later converter can open scenes too + AssetDatabase.SaveAssets(); m_ScenesOpenedForConversion?.Clear(); } } diff --git a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.cs b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.cs index 51664b2147d..1dc22291a90 100644 --- a/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.cs +++ b/Packages/com.unity.render-pipelines.core/Editor-PrivateShared/Tools/Converter/Window/RenderPipelineConvertersEditor.cs @@ -525,14 +525,15 @@ void Convert(ClickEvent evt) EditorUtility.ClearProgressBar(); } + // Save before reloading the scene we started from, which unloads converted assets that are not saved + AssetDatabase.SaveAssets(); + // Checking if we have changed current scene. If we have we reload the old scene we started from if (!string.IsNullOrEmpty(currentScenePath) && currentScenePath != SceneManager.GetActiveScene().path) { EditorSceneManager.OpenScene(currentScenePath); } - AssetDatabase.SaveAssets(); - RefreshUI(); GraphicsToolUsageAnalytic.ActionPerformed(nameof(Convert), contextInfo.ToNestedColumn()); diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/ConvertersTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/ConvertersTests.cs index 963c394d10c..7c3bc99eec2 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/ConvertersTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Tools/Converters/ConvertersTests.cs @@ -606,6 +606,73 @@ public void Convert_SceneOpenedByEarlierConversion_DoesNotSaveUnrelatedEdits() } } + // Moves each object it converts to another layer, which unlike the name of a prefab root is kept on import + class LayerAssetsConverter : NoQueriesAssetsConverter + { + public const int convertedLayer = 4; + + protected override Status ConvertObject(UnityEngine.Object obj, StringBuilder message) + { + ((GameObject)obj).layer = convertedLayer; + EditorUtility.SetDirty(obj); + return Status.Success; + } + } + + // Returns the id of the prefab without keeping a reference to it, so that it can be unloaded + static string CreatePrefabAsset(string path) + { + var go = new GameObject("Prefab"); + var prefab = PrefabUtility.SaveAsPrefabAsset(go, path); + UnityEngine.Object.DestroyImmediate(go); + return GlobalObjectId.GetGlobalObjectIdSlow(prefab).ToString(); + } + + // Opening a scene, to convert an object in it or after the conversion, unloads converted prefabs that are not saved + [TestCase(true, TestName = "{m}(Prefab converted first)")] + [TestCase(false, TestName = "{m}(Prefab converted last)")] + public void Convert_PrefabAndObjectInClosedScene_KeepsThePrefabConversion(bool prefabFirst) + { + const string prefabPath = "Assets/ConverterPrefabBeforeClosedSceneTest.prefab"; + const string scenePath = "Assets/ConverterPrefabBeforeClosedSceneTest.unity"; + + try + { + var prefabGidString = CreatePrefabAsset(prefabPath); + + var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); + var go = new GameObject("Cube"); + Assert.IsTrue(EditorSceneManager.SaveScene(scene, scenePath)); + var sceneObjectGidString = GlobalObjectId.GetGlobalObjectIdSlow(go).ToString(); + + EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); + + var converter = new LayerAssetsConverter(); + var prefabItem = new RenderPipelineConverterAssetItem(prefabGidString); + var sceneObjectItem = AssetsConverter.CreateAssetItem(new SearchItem(sceneObjectGidString) { label = "/Cube" }); + + converter.BeforeConvert(); + if (prefabFirst) + Assert.AreEqual(Status.Success, converter.Convert(prefabItem, out _)); + Assert.AreEqual(Status.Success, converter.Convert(sceneObjectItem, out _)); + if (!prefabFirst) + Assert.AreEqual(Status.Success, converter.Convert(prefabItem, out _)); + converter.AfterConvert(); + + // Like returning to the scene the conversion started from + EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); + + Assert.AreEqual(LayerAssetsConverter.convertedLayer, AssetDatabase.LoadAssetAtPath(prefabPath).layer, + "Opening a scene during or after the conversion must not discard the conversion of a prefab."); + } + finally + { + EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); + AssetDatabase.DeleteAsset(prefabPath); + AssetDatabase.DeleteAsset(scenePath); + } + } + [Test] public void ParametricToFreeformLightUpgraderCreateItem_ObjectInClosedScene_CreatesItemFromSearchResult() { From d1507fd4519cf900861021e45aa0fe6d2f3a7290 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 11 Nov 2026 06:29:21 +0000 Subject: [PATCH 55/61] [Port] [6000.7] Ambient occlusion is lost after upgrading when the camera renders with a non-default Renderer that has the "Screen Space Ambient Occlusion" Renderer Feature (UUM-159977) --- .../UniversalRenderPipelineGlobalSettings.cs | 73 +++++++++-- ...creenSpaceAmbientOcclusionMigrationTest.cs | 118 +++++++++++++++++- 2 files changed, 182 insertions(+), 9 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineGlobalSettings.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineGlobalSettings.cs index 50e2634f3ed..96658bdb84f 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineGlobalSettings.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineGlobalSettings.cs @@ -324,11 +324,12 @@ static void MigrateScreenSpaceAmbientOcclusionToVolumeProfiles(UniversalRenderPi { // SSAO is now driven by the volume stack, so the renderer feature settings are no longer read. // The default profile goes first because a quality profile can reference that same asset. - MigrateScreenSpaceAmbientOcclusionToDefaultVolumeProfile(data); - MigrateScreenSpaceAmbientOcclusionToQualityVolumeProfiles(); + var reportedAssets = new HashSet(); + MigrateScreenSpaceAmbientOcclusionToDefaultVolumeProfile(data, reportedAssets); + MigrateScreenSpaceAmbientOcclusionToQualityVolumeProfiles(reportedAssets); } - static void MigrateScreenSpaceAmbientOcclusionToQualityVolumeProfiles() + static void MigrateScreenSpaceAmbientOcclusionToQualityVolumeProfiles(HashSet reportedAssets) { var migratedProfiles = new Dictionary(); foreach (var urpAsset in EnumerateQualityLevelPipelineAssets()) @@ -349,13 +350,14 @@ static void MigrateScreenSpaceAmbientOcclusionToQualityVolumeProfiles() continue; var ssaoOverride = profile.Add(overrides: true); + WarnIfRenderersHaveDifferentSettings(urpAsset, ssaoFeature, reportedAssets); CopyRendererFeatureSettingsToVolumeOverride(ssaoFeature, ssaoOverride); PersistVolumeOverride(profile, ssaoOverride); migratedProfiles.Add(profile, urpAsset); } } - static void MigrateScreenSpaceAmbientOcclusionToDefaultVolumeProfile(UniversalRenderPipelineGlobalSettings data) + static void MigrateScreenSpaceAmbientOcclusionToDefaultVolumeProfile(UniversalRenderPipelineGlobalSettings data, HashSet reportedAssets) { // The default profile is shared by every quality level, so it can only hold the active pipeline's settings var profile = GetOrCreateGraphicsSettings(data).volumeProfile; @@ -366,14 +368,17 @@ static void MigrateScreenSpaceAmbientOcclusionToDefaultVolumeProfile(UniversalRe if (profile.Has()) return; + var urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset; ScreenSpaceAmbientOcclusion ssaoFeature = null; - bool active = GraphicsSettings.currentRenderPipeline is UniversalRenderPipelineAsset urpAsset - && TryGetActiveScreenSpaceAmbientOcclusionFeature(urpAsset, out ssaoFeature); + bool active = urpAsset != null && TryGetActiveScreenSpaceAmbientOcclusionFeature(urpAsset, out ssaoFeature); var ssaoOverride = profile.Add(overrides: active); if (active) + { + WarnIfRenderersHaveDifferentSettings(urpAsset, ssaoFeature, reportedAssets); CopyRendererFeatureSettingsToVolumeOverride(ssaoFeature, ssaoOverride); + } PersistVolumeOverride(profile, ssaoOverride); } @@ -394,14 +399,66 @@ static IEnumerable EnumerateQualityLevelPipelineAs } static bool TryGetActiveScreenSpaceAmbientOcclusionFeature(UniversalRenderPipelineAsset urpAsset, out ScreenSpaceAmbientOcclusion ssaoFeature) + { + if (urpAsset.TryGetRendererData(urpAsset.m_DefaultRendererIndex, out var defaultRendererData) + && TryGetActiveScreenSpaceAmbientOcclusionFeature(defaultRendererData, out ssaoFeature)) + return true; + + // Cameras can render with any renderer of the asset, so fall back to the first one that has the feature + foreach (var rendererData in urpAsset.rendererDataList) + { + if (TryGetActiveScreenSpaceAmbientOcclusionFeature(rendererData, out ssaoFeature)) + return true; + } + + ssaoFeature = null; + return false; + } + + static bool TryGetActiveScreenSpaceAmbientOcclusionFeature(ScriptableRendererData rendererData, out ScreenSpaceAmbientOcclusion ssaoFeature) { ssaoFeature = null; - return urpAsset.TryGetRendererData(urpAsset.m_DefaultRendererIndex, out var rendererData) - && rendererData != null + return rendererData != null && rendererData.TryGetRendererFeature(out ssaoFeature) && ssaoFeature.isActive; } + static void WarnIfRenderersHaveDifferentSettings(UniversalRenderPipelineAsset urpAsset, ScreenSpaceAmbientOcclusion migratedFeature, HashSet reportedAssets) + { + if (!reportedAssets.Add(urpAsset)) + return; + + string migratedRendererName = null; + var skippedRendererNames = new List(); + foreach (var rendererData in urpAsset.rendererDataList) + { + if (!TryGetActiveScreenSpaceAmbientOcclusionFeature(rendererData, out var ssaoFeature)) + continue; + + if (ssaoFeature == migratedFeature) + migratedRendererName = rendererData.name; + else if (!HaveSameMigratedSettings(ssaoFeature, migratedFeature) && !skippedRendererNames.Contains(rendererData.name)) + skippedRendererNames.Add(rendererData.name); + } + + if (skippedRendererNames.Count == 0) + return; + + Debug.LogWarning($"URP: The pipeline asset '{urpAsset.name}' has renderers with different Screen Space Ambient Occlusion settings. " + + $"Only the settings of '{migratedRendererName}' were migrated to the volume override. If you need the others, add them to a volume manually.\n" + + $"Not migrated: '{string.Join("', '", skippedRendererNames)}'"); + } + + static bool HaveSameMigratedSettings(ScreenSpaceAmbientOcclusion a, ScreenSpaceAmbientOcclusion b) + { +#pragma warning disable CS0618 // Type or member is obsolete + var x = a.settings; + var y = b.settings; +#pragma warning restore CS0618 + return (x.Intensity, x.Radius, x.Falloff, x.DirectLightingStrength, x.Downsample, x.AfterOpaque, x.AOMethod, x.Source, x.NormalSamples, x.Samples, x.BlurQuality) + == (y.Intensity, y.Radius, y.Falloff, y.DirectLightingStrength, y.Downsample, y.AfterOpaque, y.AOMethod, y.Source, y.NormalSamples, y.Samples, y.BlurQuality); + } + static void PersistVolumeOverride(VolumeProfile profile, VolumeComponent volumeOverride) { // A profile that only lives in memory cannot hold the override as a sub-asset diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/URPGlobalSettingsMigrationTests/ScreenSpaceAmbientOcclusionMigrationTest.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/URPGlobalSettingsMigrationTests/ScreenSpaceAmbientOcclusionMigrationTest.cs index 3fe6e9ee6b0..80c9dda436c 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Editor/URPGlobalSettingsMigrationTests/ScreenSpaceAmbientOcclusionMigrationTest.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/URPGlobalSettingsMigrationTests/ScreenSpaceAmbientOcclusionMigrationTest.cs @@ -1,8 +1,10 @@ using System.Linq; +using System.Text.RegularExpressions; using NUnit.Framework; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; +using UnityEngine.TestTools; namespace UnityEditor.Rendering.Universal.Test.GlobalSettingsMigration { @@ -30,6 +32,11 @@ static ScreenSpaceAmbientOcclusion AddFeature(UniversalRenderPipelineAsset rende if (!renderPipelineAsset.TryGetRendererData(renderPipelineAsset.m_DefaultRendererIndex, out rendererData)) return null; + return AddFeature(rendererData, active); + } + + static ScreenSpaceAmbientOcclusion AddFeature(ScriptableRendererData rendererData, bool active) + { var feature = ScriptableObject.CreateInstance(); feature.SetActive(active); @@ -147,6 +154,97 @@ public bool IsMigrationCorrect(URPDefaultVolumeProfileSettings settings, out str } } + class ActiveRendererFeatureOnNonDefaultRenderer : IRenderPipelineGraphicsSettingsTestCase + { + private ScriptableRendererData[] m_PreviousRendererDataList; + private UniversalRendererData m_RendererData; + private ScreenSpaceAmbientOcclusion m_Feature; + + public void SetUp(UniversalRenderPipelineGlobalSettings globalSettingsAsset, UniversalRenderPipelineAsset renderPipelineAsset) + { + m_RendererData = ScriptableObject.CreateInstance(); + m_Feature = AddFeature(m_RendererData, active: true); + + m_PreviousRendererDataList = renderPipelineAsset.m_RendererDataList; + renderPipelineAsset.m_RendererDataList = m_PreviousRendererDataList.Append(m_RendererData).ToArray(); + + SeedGlobalSettings(globalSettingsAsset, CreateProfileAsset(k_ProfilePath)); + } + + public void TearDown(UniversalRenderPipelineGlobalSettings globalSettingsAsset, UniversalRenderPipelineAsset renderPipelineAsset) + { + renderPipelineAsset.m_RendererDataList = m_PreviousRendererDataList; + RemoveFeature(m_RendererData, m_Feature); + Object.DestroyImmediate(m_RendererData); + AssetDatabase.DeleteAsset(k_ProfilePath); + } + + public bool IsMigrationCorrect(URPDefaultVolumeProfileSettings settings, out string message) + { + if (!TryGetMigratedOverride(settings, out var ssao)) + { + message = "The default volume profile has no ambient occlusion override"; + return false; + } + + return HasCopiedFeatureSettings(ssao, out message); + } + } + + class ActiveRendererFeaturesWithDifferentSettings : IRenderPipelineGraphicsSettingsTestCase + { + const string k_FirstRendererName = "FirstSSAORenderer"; + const string k_SecondRendererName = "SecondSSAORenderer"; + const float k_SecondIntensity = 1.5f; + + private ScriptableRendererData[] m_PreviousRendererDataList; + private UniversalRendererData m_FirstRendererData; + private UniversalRendererData m_SecondRendererData; + private ScreenSpaceAmbientOcclusion m_FirstFeature; + private ScreenSpaceAmbientOcclusion m_SecondFeature; + + public void SetUp(UniversalRenderPipelineGlobalSettings globalSettingsAsset, UniversalRenderPipelineAsset renderPipelineAsset) + { + m_FirstRendererData = ScriptableObject.CreateInstance(); + m_FirstRendererData.name = k_FirstRendererName; + m_FirstFeature = AddFeature(m_FirstRendererData, active: true); + + m_SecondRendererData = ScriptableObject.CreateInstance(); + m_SecondRendererData.name = k_SecondRendererName; + m_SecondFeature = AddFeature(m_SecondRendererData, active: true); +#pragma warning disable CS0618 // Type or member is obsolete + m_SecondFeature.settings.Intensity = k_SecondIntensity; +#pragma warning restore CS0618 + + m_PreviousRendererDataList = renderPipelineAsset.m_RendererDataList; + renderPipelineAsset.m_RendererDataList = m_PreviousRendererDataList.Append(m_FirstRendererData).Append(m_SecondRendererData).ToArray(); + + SeedGlobalSettings(globalSettingsAsset, CreateProfileAsset(k_ProfilePath)); + LogAssert.Expect(LogType.Warning, new Regex($"Only the settings of '{k_FirstRendererName}' were migrated.*\nNot migrated: '{k_SecondRendererName}'$")); + } + + public void TearDown(UniversalRenderPipelineGlobalSettings globalSettingsAsset, UniversalRenderPipelineAsset renderPipelineAsset) + { + renderPipelineAsset.m_RendererDataList = m_PreviousRendererDataList; + RemoveFeature(m_FirstRendererData, m_FirstFeature); + RemoveFeature(m_SecondRendererData, m_SecondFeature); + Object.DestroyImmediate(m_FirstRendererData); + Object.DestroyImmediate(m_SecondRendererData); + AssetDatabase.DeleteAsset(k_ProfilePath); + } + + public bool IsMigrationCorrect(URPDefaultVolumeProfileSettings settings, out string message) + { + if (!TryGetMigratedOverride(settings, out var ssao)) + { + message = "The default volume profile has no ambient occlusion override"; + return false; + } + + return HasCopiedFeatureSettings(ssao, out message); + } + } + class OverrideAlreadyAuthored : IRenderPipelineGraphicsSettingsTestCase { const float k_AuthoredIntensity = 9f; @@ -330,6 +428,10 @@ public override bool IsMigrationCorrect(URPDefaultVolumeProfileSettings settings .SetName("When migrating an active ambient occlusion renderer feature, its settings are being transferred correctly"), new TestCaseData(new InactiveRendererFeature()) .SetName("When migrating an inactive ambient occlusion renderer feature, the override is added without overriding anything"), + new TestCaseData(new ActiveRendererFeatureOnNonDefaultRenderer()) + .SetName("When the active ambient occlusion renderer feature is on a non-default renderer, its settings are being transferred correctly"), + new TestCaseData(new ActiveRendererFeaturesWithDifferentSettings()) + .SetName("When several renderers have active ambient occlusion renderer features with different settings, the first one is transferred and a warning names the others"), new TestCaseData(new OverrideAlreadyAuthored()) .SetName("When the default volume profile already has an ambient occlusion override, the migration leaves it untouched"), new TestCaseData(new QualityProfileOfActiveRendererFeature()) @@ -343,7 +445,21 @@ public override bool IsMigrationCorrect(URPDefaultVolumeProfileSettings settings [Test, TestCaseSource(nameof(s_TestCaseDatas))] public void PerformMigration(IRenderPipelineGraphicsSettingsTestCase testCase) { - base.DoTest(testCase); + // The migration reads every renderer of the asset, so keep only the default one to control what it finds + var previousRendererDataList = m_Asset.m_RendererDataList; + var previousDefaultRendererIndex = m_Asset.m_DefaultRendererIndex; + m_Asset.m_RendererDataList = new[] { previousRendererDataList[previousDefaultRendererIndex] }; + m_Asset.m_DefaultRendererIndex = 0; + + try + { + base.DoTest(testCase); + } + finally + { + m_Asset.m_RendererDataList = previousRendererDataList; + m_Asset.m_DefaultRendererIndex = previousDefaultRendererIndex; + } } } } From 69473505446544d29c2d67ba393712d81b268730 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 12 Nov 2026 00:29:03 +0000 Subject: [PATCH 56/61] [Port] [6000.7] [UUM-158409] [URP 2D] Fix Shadow Caster 2D not following Sprite Skin flip --- .../ShadowShape2DProvider_SpriteSkin.cs | 15 ++- .../Tests/Runtime/ShadowCaster2DTests.cs | 108 ++++++++++++++++++ 2 files changed, 118 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/Providers/ShadowShape2DProvider_SpriteSkin.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/Providers/ShadowShape2DProvider_SpriteSkin.cs index 3fe86d5a868..1385bb7b75b 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/Providers/ShadowShape2DProvider_SpriteSkin.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/Providers/ShadowShape2DProvider_SpriteSkin.cs @@ -81,12 +81,17 @@ public override void OnInitialized(Component sourceComponent, ShadowShape2D pers public override void OnBeforeRender(Camera camera, Component sourceComponent, Bounds worldCullingBounds, ShadowShape2D persistantShadowShape) { SpriteSkin spriteSkin = (SpriteSkin)sourceComponent; - if (spriteSkin != null && spriteSkin.vertexDeformationHash != m_LastDeformedVertexHash) - { - SpriteRenderer spriteRenderer; - spriteSkin.TryGetComponent(out spriteRenderer); - persistantShadowShape.SetFlip(spriteRenderer.flipX, spriteRenderer.flipY); + if (spriteSkin == null) + return; + // Flipping does not deform the vertices, so it does not change vertexDeformationHash and has to be + // picked up every frame. A SpriteSkin whose bones do not move is not deformed again. + SpriteRenderer spriteRenderer; + spriteSkin.TryGetComponent(out spriteRenderer); + persistantShadowShape.SetFlip(spriteRenderer.flipX, spriteRenderer.flipY); + + if (spriteSkin.vertexDeformationHash != m_LastDeformedVertexHash) + { TryToSetPersistantShapeData(spriteSkin, persistantShadowShape, false); m_LastDeformedVertexHash = spriteSkin.vertexDeformationHash; } diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs index da84421001e..9704f62a007 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs @@ -1,5 +1,9 @@ #if U2D_ANIMATION_INSTALLED +using System.Collections; using NUnit.Framework; +using Unity.Collections; +using UnityEngine.TestTools; +using UnityEngine.U2D; using UnityEngine.U2D.Animation; namespace UnityEngine.Rendering.Universal.Tests @@ -7,6 +11,8 @@ namespace UnityEngine.Rendering.Universal.Tests class ShadowCaster2DTests { GameObject m_Obj; + Texture2D m_Texture; + Sprite m_Sprite; [SetUp] public void Setup() @@ -19,6 +25,10 @@ public void Setup() public void Cleanup() { Object.DestroyImmediate(m_Obj); + if (m_Sprite != null) + Object.DestroyImmediate(m_Sprite); + if (m_Texture != null) + Object.DestroyImmediate(m_Texture); } [Test] @@ -51,6 +61,104 @@ public void AddShadowCaster2DWithSpriteSkinWhenInactive() Assert.That(shadowCaster2D.shadowShape2DProvider, Is.Null); #endif } + +// ShadowCaster2D.shadowShape2DProvider is always null on Standalone. +#if UNITY_EDITOR + // A quad skinned to a single bone, built at runtime so the test needs no asset. + Sprite CreateSkinnedQuadSprite() + { + m_Texture = new Texture2D(4, 4); + m_Sprite = Sprite.Create(m_Texture, new Rect(0, 0, 4, 4), new Vector2(0.5f, 0.5f), 4, 0, SpriteMeshType.FullRect); + + m_Sprite.SetVertexCount(4); + using (var positions = new NativeArray(4, Allocator.Temp)) + using (var weights = new NativeArray(4, Allocator.Temp)) + using (var indices = new NativeArray(new ushort[] { 0, 1, 2, 2, 3, 0 }, Allocator.Temp)) + using (var bindPoses = new NativeArray(1, Allocator.Temp)) + { + var p = positions; + p[0] = new Vector3(-0.5f, -0.5f, 0); + p[1] = new Vector3(-0.5f, 0.5f, 0); + p[2] = new Vector3(0.5f, 0.5f, 0); + p[3] = new Vector3(0.5f, -0.5f, 0); + + var w = weights; + for (int i = 0; i < w.Length; ++i) + w[i] = new BoneWeight { boneIndex0 = 0, weight0 = 1 }; + + var b = bindPoses; + b[0] = Matrix4x4.identity; + + m_Sprite.SetVertexAttribute(VertexAttribute.Position, positions); + m_Sprite.SetVertexAttribute(VertexAttribute.BlendWeight, weights); + m_Sprite.SetIndices(indices); + m_Sprite.SetBindPoses(bindPoses); + } + + m_Sprite.SetBones(new[] + { + new SpriteBone { name = "root", position = Vector3.zero, rotation = Quaternion.identity, length = 1, parentId = -1 } + }); + + return m_Sprite; + } + + static void CallOnBeforeRender(ShadowCaster2D shadowCaster2D) + { + ShapeProviderUtility.CallOnBeforeRender(shadowCaster2D.shadowShape2DProvider, shadowCaster2D.shadowShape2DComponent, + shadowCaster2D.m_ShadowMesh, new Bounds(Vector3.zero, Vector3.one * 100), null); + } + + // UUM-158409: a SpriteSkin whose bones do not move is not deformed again, so the shadow has to + // pick up the SpriteRenderer flip without waiting for a new deformation. + [UnityTest] + public IEnumerator ShadowCaster2DWithSpriteSkin_FollowsFlipWhenBonesAreStill([Values(false, true)] bool forceCpuDeformation) + { + SpriteRenderer spriteRenderer = m_Obj.GetComponent(); + spriteRenderer.sprite = CreateSkinnedQuadSprite(); + + var bone = new GameObject("root"); + bone.transform.SetParent(m_Obj.transform, false); + + SpriteSkin spriteSkin = m_Obj.AddComponent(); + spriteSkin.forceCpuDeformation = forceCpuDeformation; + spriteSkin.SetRootTransform(bone.transform); + SpriteSkinState state = spriteSkin.SetBoneTransforms(new[] { bone.transform }); + Assert.That(state, Is.EqualTo(SpriteSkinState.Ready), "Test setup: the SpriteSkin must be valid for deformation."); + + ShadowCaster2D shadowCaster2D = m_Obj.AddComponent(); + Assert.That(shadowCaster2D.shadowShape2DProvider, Is.TypeOf(typeof(ShadowShape2DProvider_SpriteSkin))); + + // Let the first deformation land and the bones settle, so later frames do not deform again. + for (int i = 0; i < 5; ++i) + { + yield return null; + CallOnBeforeRender(shadowCaster2D); + } + Assert.That(spriteSkin.HasCurrentDeformedVertices(), Is.True, "Test setup: the SpriteSkin must have been deformed."); + + shadowCaster2D.m_ShadowMesh.GetFlip(out bool flipX, out bool flipY); + Assert.That(flipX, Is.False); + Assert.That(flipY, Is.False); + + spriteRenderer.flipX = true; + yield return null; + CallOnBeforeRender(shadowCaster2D); + + shadowCaster2D.m_ShadowMesh.GetFlip(out flipX, out flipY); + Assert.That(flipX, Is.True, "The shadow did not follow SpriteRenderer.flipX."); + Assert.That(flipY, Is.False); + + spriteRenderer.flipX = false; + spriteRenderer.flipY = true; + yield return null; + CallOnBeforeRender(shadowCaster2D); + + shadowCaster2D.m_ShadowMesh.GetFlip(out flipX, out flipY); + Assert.That(flipX, Is.False, "The shadow did not follow SpriteRenderer.flipX."); + Assert.That(flipY, Is.True, "The shadow did not follow SpriteRenderer.flipY."); + } +#endif } } #endif From e21d6d3f4d3e4de10d622baa7f145fa49bbb847f Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 12 Nov 2026 08:40:07 +0000 Subject: [PATCH 57/61] [Port] [6000.7] Reflection Probe throws NullReferenceException and Render Graph execution errors when trying to bake with Screen Space Reflections enabled (UUM-159262) --- .../ScreenSpaceReflectionRendererFeature.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/ScreenSpaceReflectionRendererFeature/ScreenSpaceReflectionRendererFeature.cs b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/ScreenSpaceReflectionRendererFeature/ScreenSpaceReflectionRendererFeature.cs index 1a8b63af0dc..8d1e8532ef3 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/ScreenSpaceReflectionRendererFeature/ScreenSpaceReflectionRendererFeature.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RendererFeatures/ScreenSpaceReflectionRendererFeature/ScreenSpaceReflectionRendererFeature.cs @@ -47,6 +47,10 @@ public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingD if (UniversalRenderer.IsOffscreenDepthTexture(universalCameraData)) return; + // Reflection probe captures don't need SSR. + if (universalCameraData.cameraType == CameraType.Reflection) + return; + // Only allow in preview cameras via the RenderRequest API (i.e. 'Cameras' overlay in scene view) // Don't allow regular preview cameras (i.e. thumbnails, material previews) if (universalCameraData.isPreviewCamera && !universalCameraData.camera.isProcessingRenderRequest) From 2699417b843cb2eeca3fd07abcb6d8bedcdfbec5 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 12 Nov 2026 08:40:09 +0000 Subject: [PATCH 58/61] [Port] [6000.7] [UUM-153597] [URP] Clear skipped-prepass textures in one render pass --- .../Runtime/UniversalRendererRenderGraph.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs index d3c99c58bbd..c7d500d133a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs @@ -526,7 +526,11 @@ void ClearCameraTargets(RenderGraph renderGraph, UniversalResourceData resourceD // The clear pass is only required if either color or depth needs clearing. var clearParams = GetClearCameraParams(cameraData); if (clearParams.mustClearColor || clearParams.mustClearDepth) - InitializeCameraTargetsPass.Render(renderGraph, resourceData.activeColorTexture, resourceData.activeDepthTexture); + { + InitializeCameraTargetsPass.Render(renderGraph, + clearParams.mustClearColor ? resourceData.activeColorTexture : TextureHandle.nullHandle, + clearParams.mustClearDepth ? resourceData.activeDepthTexture : TextureHandle.nullHandle); + } } void SetupTargetHandles(UniversalCameraData cameraData) @@ -2268,7 +2272,7 @@ internal static void Render(RenderGraph graph, TextureHandle colorHandle, Textur } // Only publishes the textures that a prepass would normally publish, in the case where the actual prepass is not executed. - // Implemented as a single pass instead to avoid overhead from three separate passes if using RenderGraphUtils.SetGlobalTexture. + // The textures are bound as attachments so they are all cleared through load actions in a single render pass. static class PublishPrepassGlobalTexturesPass { const string k_PassName = "Publish Prepass Global Textures"; @@ -2283,19 +2287,20 @@ internal static void Render(RenderGraph graph, TextureHandle cameraDepthTexture, using (var builder = graph.AddRasterRenderPass(k_PassName, out _, s_ProfilingSampler)) { + int colorIndex = 0; if (cameraDepthTexture.IsValid()) { - builder.UseTexture(cameraDepthTexture, AccessFlags.Read); + builder.SetRenderAttachmentDepth(cameraDepthTexture, AccessFlags.Write); builder.SetGlobalTextureAfterPass(cameraDepthTexture, DepthOnlyPass.s_CameraDepthTextureID); } if (cameraNormalsTexture.IsValid()) { - builder.UseTexture(cameraNormalsTexture, AccessFlags.Read); + builder.SetRenderAttachment(cameraNormalsTexture, colorIndex++, AccessFlags.Write); builder.SetGlobalTextureAfterPass(cameraNormalsTexture, DepthNormalOnlyPass.s_CameraNormalsTextureID); } if (renderingLayersTexture.IsValid()) { - builder.UseTexture(renderingLayersTexture, AccessFlags.Read); + builder.SetRenderAttachment(renderingLayersTexture, colorIndex++, AccessFlags.Write); builder.SetGlobalTextureAfterPass(renderingLayersTexture, DepthNormalOnlyPass.s_CameraRenderingLayersTextureID); } From b3a78f2107183798871373379c86b89633d6b0da Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 12 Nov 2026 14:35:11 +0000 Subject: [PATCH 59/61] [Port] [6000.7] Graphics/URP - [UUM-155833] - Fix multi-display support in URP 2D/3D (second try, faster) --- .../Runtime/2D/PixelPerfectCamera.cs | 6 +++-- .../2D/Rendergraph/Renderer2DRendergraph.cs | 9 +++---- .../Runtime/FrameData/UniversalCameraData.cs | 4 +++ .../Runtime/Passes/DrawScreenSpaceUIPass.cs | 8 +++--- .../Runtime/Passes/FinalBlitPass.cs | 4 +-- .../PostProcess/FinalPostProcessPass.cs | 2 +- .../Passes/PostProcess/UberPostProcessPass.cs | 2 +- .../Runtime/RenderingUtils.cs | 25 +++++++++++++++++-- .../Runtime/UniversalRenderPipelineCore.cs | 7 ++++-- .../Runtime/UniversalRendererRenderGraph.cs | 2 +- 10 files changed, 48 insertions(+), 21 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/PixelPerfectCamera.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/PixelPerfectCamera.cs index e19e770d276..e6c72acbb2e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/PixelPerfectCamera.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/PixelPerfectCamera.cs @@ -339,10 +339,12 @@ Vector2Int cameraRTSize get { var targetTexture = m_Camera.targetTexture; - return targetTexture == null ? new Vector2Int(Screen.width, Screen.height) : new Vector2Int(targetTexture.width, targetTexture.height); + return targetTexture == null ? screenRTSize : new Vector2Int(targetTexture.width, targetTexture.height); } } + Vector2Int screenRTSize => RenderingUtils.GetScreenBackbufferSize(m_Camera); + // Snap camera position to pixels using Camera.worldToCameraMatrix. void PixelSnap() { @@ -438,7 +440,7 @@ void OnGUI() } var targetTexture = m_Camera.targetTexture; - Vector2Int rtSize = targetTexture == null ? new Vector2Int(Screen.width, Screen.height) : new Vector2Int(targetTexture.width, targetTexture.height); + Vector2Int rtSize = targetTexture == null ? screenRTSize : new Vector2Int(targetTexture.width, targetTexture.height); if (rtSize.x < refResolutionX || rtSize.y < refResolutionY) { diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs index ed4ea3dbc36..50a117a3e06 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/Renderer2DRendergraph.cs @@ -396,11 +396,8 @@ ImportResourceSummary GetImportResourceSummary(RenderGraph renderGraph, Universa // pending Screen.SetMSAASamples request hasn't been applied yet (deferred reallocation). int numSamples = Screen.currentBackbufferMSAASamples; - //NOTE: Careful what you use here as many of the properties bake-in the camera rect so for example - //cameraData.cameraTargetDescriptor.width is the width of the rectangle but not the actual render target - //same with cameraData.camera.pixelWidth - output.importInfo.width = Screen.width; - output.importInfo.height = Screen.height; + output.importInfo.width = cameraData.backbufferWidth; + output.importInfo.height = cameraData.backbufferHeight; output.importInfo.volumeDepth = 1; output.importInfo.msaaSamples = numSamples; output.importInfo.format = cameraData.cameraTargetDescriptor.graphicsFormat; @@ -804,7 +801,7 @@ void CreateOffscreenUITexture(RenderGraph renderGraph, in RenderTextureDescripto UniversalResourceData resourceData = frameData.Get(); UniversalCameraData cameraData = frameData.Get(); TextureDesc textureDesc = new TextureDesc(descriptor); - DrawScreenSpaceUIPass.ConfigureOffscreenUITextureDesc(ref textureDesc); + DrawScreenSpaceUIPass.ConfigureOffscreenUITextureDesc(ref textureDesc, cameraData); RenderingUtils.ReAllocateHandleIfNeeded(ref s_OffscreenUIColorHandle, textureDesc, name: "_OverlayUITexture"); // Clear the texture to avoid stale data from previous frames diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/FrameData/UniversalCameraData.cs b/Packages/com.unity.render-pipelines.universal/Runtime/FrameData/UniversalCameraData.cs index 25fbbf4953a..7d2fcfae8a5 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/FrameData/UniversalCameraData.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/FrameData/UniversalCameraData.cs @@ -188,6 +188,10 @@ internal Matrix4x4 GetGPUProjectionMatrix(bool renderIntoTexture, int viewIndex public RenderTextureDescriptor cameraTargetDescriptor; internal RenderTargetInfo backbufferColor; internal RenderTargetInfo backbufferDepth; + + internal int backbufferWidth => backbufferColor.width; + internal int backbufferHeight => backbufferColor.height; + internal Rect pixelRect; internal bool useScreenCoordOverride; internal Vector4 screenSizeOverride; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DrawScreenSpaceUIPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DrawScreenSpaceUIPass.cs index b5080c5c2f7..740ded4120a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DrawScreenSpaceUIPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/DrawScreenSpaceUIPass.cs @@ -61,12 +61,12 @@ internal void Setup(UniversalCameraData cameraData) /// /// Get a descriptor for the required color texture for offscreen UI pass. /// - internal static void ConfigureOffscreenUITextureDesc(ref TextureDesc textureDesc) + internal static void ConfigureOffscreenUITextureDesc(ref TextureDesc textureDesc, UniversalCameraData cameraData) { textureDesc.format = GraphicsFormat.R8G8B8A8_SRGB; textureDesc.depthBufferBits = 0; - textureDesc.width = Screen.width; - textureDesc.height = Screen.height; + textureDesc.width = cameraData.backbufferWidth; + textureDesc.height = cameraData.backbufferHeight; // we dont need multisampling, and not explicitly setting this can violate validation layers on vulkan textureDesc.msaaSamples = MSAASamples.None; textureDesc.bindTextureMS = false; @@ -255,7 +255,7 @@ internal void RenderOffscreen(RenderGraph renderGraph, ContextContainer frameDat { UniversalCameraData cameraData = frameData.Get(); RenderTextureDescriptor depthDescriptor = cameraData.cameraTargetDescriptor; - ConfigureDepthDescriptor(ref depthDescriptor, depthStencilFormat, Screen.width, Screen.height); + ConfigureDepthDescriptor(ref depthDescriptor, depthStencilFormat, cameraData.backbufferWidth, cameraData.backbufferHeight); TextureHandle depthBuffer = UniversalRenderer.CreateRenderGraphTexture(renderGraph, depthDescriptor, "_OverlayUITexture_Depth", false); // Render uGUI and UIToolkit overlays diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/FinalBlitPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/FinalBlitPass.cs index cf79c9fa5cd..aedb359bbb1 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/FinalBlitPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/FinalBlitPass.cs @@ -103,8 +103,8 @@ private static void ExecutePass(RasterCommandBuffer cmd, PassData data, RTHandle if (cameraData.xr.enabled) isRenderToBackBufferTarget = new RenderTargetIdentifier(destination.nameID, 0, CubemapFace.Unknown, -1) == new RenderTargetIdentifier(cameraData.xr.renderTarget, 0, CubemapFace.Unknown, -1); #endif - var pixelRect = data.useFullScreenViewport ? new Rect(0f, 0f, Screen.width, Screen.height) : cameraData.pixelRect; - RenderingUtils.SetupOffscreenUIViewportParams(data.blitMaterialData.material, ref pixelRect, isRenderToBackBufferTarget); + var pixelRect = data.useFullScreenViewport ? new Rect(0f, 0f, cameraData.backbufferWidth, cameraData.backbufferHeight) : cameraData.pixelRect; + RenderingUtils.SetupOffscreenUIViewportParams(cameraData, data.blitMaterialData.material, ref pixelRect, isRenderToBackBufferTarget); if (isRenderToBackBufferTarget) cmd.SetViewport(pixelRect); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs index 4f7bd3b90c3..4e2ba27457a 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/FinalPostProcessPass.cs @@ -198,7 +198,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if (hdrColorEncoding) { PostProcessUtils.SetupHDROutput(material, cameraData.hdrDisplayInformation, cameraData.hdrDisplayColorGamut, data.tonemapping, data.hdrOperations, cameraData.rendersOverlayUI); - RenderingUtils.SetupOffscreenUIViewportParams(material, ref cameraData.pixelRect, cameraData.resolveFinalTarget); + RenderingUtils.SetupOffscreenUIViewportParams(cameraData, material, ref cameraData.pixelRect, cameraData.resolveFinalTarget); } material.SetVector(ShaderConstants._SourceSize, PostProcessUtils.CalcShaderSourceSize(sourceTextureHdl)); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs index d164ae632d4..366e7d6ee8e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/PostProcess/UberPostProcessPass.cs @@ -303,7 +303,7 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer if(PostProcessUtils.RequireHDROutput(cameraData)) { PostProcessUtils.SetupHDROutput(material, cameraData.hdrDisplayInformation, cameraData.hdrDisplayColorGamut, data.tonemapping, data.hdrOperations, cameraData.rendersOverlayUI); - RenderingUtils.SetupOffscreenUIViewportParams(material, ref cameraData.pixelRect, data.isActiveTargetBackBuffer); + RenderingUtils.SetupOffscreenUIViewportParams(cameraData, material, ref cameraData.pixelRect, data.isActiveTargetBackBuffer); } #if ENABLE_VR && ENABLE_XR_MODULE diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs b/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs index b7212b93d52..36cd92f4afe 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/RenderingUtils.cs @@ -222,12 +222,33 @@ internal static void SetScaleBiasRt(RasterCommandBuffer cmd, in UniversalCameraD cmd.SetGlobalVector(Shader.PropertyToID("_ScaleBiasRt"), scaleBiasRt); } - internal static void SetupOffscreenUIViewportParams(Material material, ref Rect pixelRect, bool isRenderToBackBufferTarget) + // Returns the size of the backbuffer the camera renders to, in pixels. + internal static Vector2Int GetScreenBackbufferSize(Camera camera) + { + // Screen.width/height only ever describe the main display, so cameras targeting a secondary + // display need to query that display instead. + // + // UUM-149562: on QNX and Embedded Linux the graphics backend still reports the main display's + // resolution for the backbuffer of a secondary display. Returning the secondary display's real + // resolution here would no longer match what the backend reports, the render pass would fail + // validation and the secondary display would stop rendering altogether. Falling back to the main + // display size keeps those platforms rendering as usual. Remove the platform exclusions + // above once the backend reports per-display backbuffer dimensions. +#if ENABLE_MULTIPLE_DISPLAYS && !UNITY_QNX && !UNITY_EMBEDDED_LINUX + int targetDisplay = camera.targetDisplay; + var displays = Display.displays; + if (targetDisplay > 0 && targetDisplay < displays.Length) + return new Vector2Int(displays[targetDisplay].renderingWidth, displays[targetDisplay].renderingHeight); +#endif + return new Vector2Int(Screen.width, Screen.height); + } + + internal static void SetupOffscreenUIViewportParams(UniversalCameraData cameraData, Material material, ref Rect pixelRect, bool isRenderToBackBufferTarget) { Vector4 offscreenUIViewportParams = new Vector4(0f, 0f, 1f, 1f); if (isRenderToBackBufferTarget) { - var rcpScreenSize = new Vector2(1f / Screen.width, 1f / Screen.height); + var rcpScreenSize = new Vector2(1f / cameraData.backbufferWidth, 1f / cameraData.backbufferHeight); offscreenUIViewportParams = new Vector4(pixelRect.x * rcpScreenSize.x, pixelRect.y * rcpScreenSize.y, pixelRect.width * rcpScreenSize.x, pixelRect.height * rcpScreenSize.y); } material.SetVector(ShaderPropertyId.offscreenUIViewportParams, offscreenUIViewportParams); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs index 2e084a3ea3f..a0a1858f18d 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs @@ -1535,12 +1535,14 @@ internal static void CreateBackbufferInfo(Camera camera, UniversalCameraData cam if (camera.targetTexture == null) { + Vector2Int backbufferSize = RenderingUtils.GetScreenBackbufferSize(camera); + // Describe the real backbuffer's live MSAA. UpdateCameraData later overrides this // with the XR eye texture properties when an XR pass is actually active. cameraData.backbufferColor = new RenderTargetInfo { - width = Screen.width, - height = Screen.height, + width = backbufferSize.x, + height = backbufferSize.y, volumeDepth = 1, msaaSamples = Screen.currentBackbufferMSAASamples, format = colorFormatProxy, @@ -1567,6 +1569,7 @@ internal static void CreateBackbufferInfo(Camera camera, UniversalCameraData cam } } } + internal static int GetIntermediateTexturesMSAA(UniversalCameraData cameraData, ScriptableRenderer renderer) { bool rendererSupportsMSAA = renderer != null && renderer.supportedRenderingFeatures.msaa; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs index c7d500d133a..d060c7c2647 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs @@ -2168,7 +2168,7 @@ void CreateOffscreenUITexture(RenderGraph renderGraph, TextureDesc descriptor) { UniversalResourceData resourceData = frameData.Get(); UniversalCameraData cameraData = frameData.Get(); - DrawScreenSpaceUIPass.ConfigureOffscreenUITextureDesc(ref descriptor); + DrawScreenSpaceUIPass.ConfigureOffscreenUITextureDesc(ref descriptor, cameraData); RenderingUtils.ReAllocateHandleIfNeeded(ref s_OffscreenUIColorHandle, descriptor, name: "_OverlayUITexture"); // Clear the texture to avoid stale data from previous frames From 6def058d8d9ba963e91f2ae58be78844373ac9a0 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 13 Nov 2026 11:55:24 +0000 Subject: [PATCH 60/61] [Port] [6000.7] [ShaderGraph][UUM-159528] Warn when a Screen Position node uses the removed Clip mode --- .../Input/Geometry/ScreenPositionNode.cs | 14 ++++ .../UnitTests/ScreenPositionNodeTests.cs | 84 +++++++++++++++++++ .../UnitTests/ScreenPositionNodeTests.cs.meta | 11 +++ 3 files changed, 109 insertions(+) create mode 100644 Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs create mode 100644 Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs.meta diff --git a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs index a4d1ef98ac1..f3274d0dca5 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Geometry/ScreenPositionNode.cs @@ -44,6 +44,20 @@ public Mode mode public ScreenSpaceType screenSpaceType => m_ScreenSpaceType; + internal const string k_ClipNotSupportedWarning = "Screen Position node: Clip mode is not supported, using Default instead."; + + public override void OnAfterDeserialize(string json) + { + base.OnAfterDeserialize(json); + + // Clip is no longer a Mode, and the dropdown already shows it as Default. + if (m_ScreenSpaceType == ScreenSpaceType.Clip) + { + Debug.LogWarning(k_ClipNotSupportedWarning); + m_ScreenSpaceType = ScreenSpaceType.Default; + } + } + private const int kOutputSlotId = 0; private const string kOutputSlotName = "Out"; diff --git a/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs b/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs new file mode 100644 index 00000000000..fe760dca5da --- /dev/null +++ b/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using NUnit.Framework; +using UnityEngine; +using UnityEditor.ShaderGraph.Serialization; + +namespace UnityEditor.ShaderGraph.UnitTests +{ + [TestFixture] + class ScreenPositionNodeTests + { + // Other fixtures in this assembly replace Debug.unityLogger.logHandler without restoring it, which hides logs from LogAssert + sealed class LogCapture : ILogHandler, IDisposable + { + readonly ILogHandler m_PreviousHandler; + + public readonly List<(LogType type, string message)> logs = new List<(LogType, string)>(); + + public LogCapture() + { + m_PreviousHandler = Debug.unityLogger.logHandler; + Debug.unityLogger.logHandler = this; + } + + public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args) + { + logs.Add((logType, string.Format(format, args))); + } + + public void LogException(Exception exception, UnityEngine.Object context) + { + logs.Add((LogType.Exception, exception.ToString())); + } + + public void Dispose() + { + Debug.unityLogger.logHandler = m_PreviousHandler; + } + } + + static ScreenPositionNode Load(ScreenSpaceType savedType, out List<(LogType type, string message)> logs) + { + // The Mode setter can no longer produce Clip, so write the stored field directly to mimic a saved graph. + var source = new ScreenPositionNode(); + var field = typeof(ScreenPositionNode).GetField("m_ScreenSpaceType", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.IsNotNull(field, "Expected the private field m_ScreenSpaceType on ScreenPositionNode."); + field.SetValue(source, savedType); + var json = MultiJson.Serialize(source); + + var node = new ScreenPositionNode(); + using (var capture = new LogCapture()) + { + MultiJson.Deserialize(node, json); + logs = capture.logs; + } + return node; + } + + [Test] + public void Deserialize_SavedClip_BecomesDefaultWithWarning() + { + var node = Load(ScreenSpaceType.Clip, out var logs); + + CollectionAssert.AreEqual(new[] { (LogType.Warning, ScreenPositionNode.k_ClipNotSupportedWarning) }, logs); + Assert.AreEqual(ScreenSpaceType.Default, node.screenSpaceType); + Assert.AreEqual(ScreenPositionNode.Mode.Default, node.mode); + } + + [TestCase(ScreenSpaceType.Default, ScreenPositionNode.Mode.Default)] + [TestCase(ScreenSpaceType.Raw, ScreenPositionNode.Mode.Raw)] + [TestCase(ScreenSpaceType.Center, ScreenPositionNode.Mode.Center)] + [TestCase(ScreenSpaceType.Tiled, ScreenPositionNode.Mode.Tiled)] + [TestCase(ScreenSpaceType.Pixel, ScreenPositionNode.Mode.Pixel)] + public void Deserialize_SavedMode_IsUnchanged(ScreenSpaceType savedType, ScreenPositionNode.Mode expected) + { + var node = Load(savedType, out var logs); + + CollectionAssert.IsEmpty(logs); + Assert.AreEqual(savedType, node.screenSpaceType); + Assert.AreEqual(expected, node.mode); + } + } +} diff --git a/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs.meta b/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs.meta new file mode 100644 index 00000000000..b0360ce4cb5 --- /dev/null +++ b/Packages/com.unity.shadergraph/Tests/Editor/UnitTests/ScreenPositionNodeTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7c1e5d0a9b3f4a62b8d41f6e2a90c357 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 41a6cb1534bc280d6a1108870dfe23520c9632d3 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Fri, 13 Nov 2026 11:55:25 +0000 Subject: [PATCH 61/61] [Port] [6000.7] Fix Clamp Color and Min Smoothness settings in URP SSR --- .../ShaderLibrary/ComputeScreenSpaceReflection.hlsl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl index cc0132229ac..5f90171446c 100644 --- a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/ComputeScreenSpaceReflection.hlsl @@ -379,7 +379,7 @@ float3 ClampAndSanitizeColor(float3 color) float3 clamped = scale * color; if (AnyIsNaN(clamped) || AnyIsInf(clamped)) return 0; - return color; + return clamped; } float4 ComputeSSR(Varyings input @@ -400,7 +400,7 @@ float4 ComputeSSR(Varyings input // If the smoothness is below our minimum, don't do any raymarching float perceptualSmoothness = SampleSmoothness(positionNDC); - UNITY_BRANCH if (perceptualSmoothness <= GetMinimumSmoothness()) + UNITY_BRANCH if (perceptualSmoothness < GetMinimumSmoothness()) { // Output the framebuffer color -> // avoids bleeding black/uninitialized texels into reflections when blurring.