From 2b47830c0dfc7e8e099fea9796d718777bf8f467 Mon Sep 17 00:00:00 2001 From: Jans Margevics Date: Tue, 20 Oct 2026 12:29:05 +0000 Subject: [PATCH 01/22] [Port] [6000.0] [UUM-155361] [UUM-157412] [HDRP] Re-enable 4012_MotionBlur_CameraOnly, fix ignore skipping all tests --- .../GraphicTests/HDRP_Graphics_Tests.cs | 15 +- .../Scene Settings Profile 1.asset | 540 ++++++++++++++++++ .../Scene Settings Profile 1.asset.meta | 8 + .../4012_MotionBlur_CameraOnly.unity | 4 +- .../ProjectSettings/EditorBuildSettings.asset | 3 + 5 files changed, 566 insertions(+), 4 deletions(-) create mode 100644 Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset create mode 100644 Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset.meta diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs index 47279efe8b7..e97283aa6c0 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs +++ b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs @@ -97,13 +97,24 @@ public void SetUpContext() [IgnoreGraphicsTest("4075_PhysicalCamera-gateFit", "Instability https://jira.unity3d.com/browse/UUM-100651", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsPlayer }, graphicsDeviceTypes: new GraphicsDeviceType[] { GraphicsDeviceType.Direct3D11 })] [IgnoreGraphicsTest("4075_PhysicalCamera-gateFit", "Unstable: https://jira.unity3d.com/browse/UUM-100651")] [IgnoreGraphicsTest( - "4060_CustomPostProcess|8207_InstancingAPIs|8212_Fullscreen|9700_CustomPass_FullScreen|9702_CustomPass_API|9703_SampleColorBuffer_InjectionPoints_Scaling|9931-ScreenCoordOverrideCustomPostProcess|1104_Unlit_Distortion_Compose|1206_Lit_Transparent_Distortion|1805_Depth_Pre_Post_Unlit|4012_MotionBlur_CameraOnly|4038_Bloom|5014_VolumetricCloudsBanding|9006_StencilUsage|9304_MotionVectorsPrecomputedAndCustomVelocity|9601_SkinnedMeshBatching-Off|9602_SkinnedMeshBatching-On|", + "4060_CustomPostProcess|8207_InstancingAPIs|8212_Fullscreen|9700_CustomPass_FullScreen|9702_CustomPass_API|9703_SampleColorBuffer_InjectionPoints_Scaling|9931-ScreenCoordOverrideCustomPostProcess|1104_Unlit_Distortion_Compose|1206_Lit_Transparent_Distortion|1805_Depth_Pre_Post_Unlit|4038_Bloom|5014_VolumetricCloudsBanding|9006_StencilUsage|9304_MotionVectorsPrecomputedAndCustomVelocity|9601_SkinnedMeshBatching-Off|9602_SkinnedMeshBatching-On", "Image difference when updating from GTF8 to GTF9", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor })] [IgnoreGraphicsTest( "4061_CustomPostProcessMotionVectors|2120_APV_Baking|2121_APV_Baking_Sky_Occlusion|2122_APV_Baking_Sky_Occlusion_And_Direction|2123_APV_Baking_Shadowmask|2405_EnlightenDynamicAreaLights|2106_GI_EmissionSG|3010_MipMapMode|3011_MipMapMode|3012_MipMapMode|1227_Lit_Planar_Triplanar_ObjectSpace|1705_Decals-stress-test|4110_DRS-FSR2-With-CustomPass|4111_DRS-DLSS-With-CustomPass|2319_Mixed_Cached_ShadowMap_Area", "Image difference when updating from GTF8 to GTF9", - runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.LinuxEditor })] + runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor })] + // XR reuses the non-XR reference images, so the XR job cannot be targeted on its own. + [IgnoreGraphicsTest( + "3006_TileCluster_Cluster$", + "Localized tile/cluster artifact in the XR playmode job: https://jira.unity3d.com/browse/UUM-144350", + runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsEditor }, + graphicsDeviceTypes: new GraphicsDeviceType[] { GraphicsDeviceType.Direct3D11, GraphicsDeviceType.Direct3D12 })] + [IgnoreGraphicsTest( + "3004_QuadOverdraw$", + "Disabled for instability: https://jira.unity3d.com/browse/UUM-134754", + runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsEditor }, + graphicsDeviceTypes: new GraphicsDeviceType[] { GraphicsDeviceType.Direct3D12 })] [UnityTest, SceneGraphicsTest(@"Assets/GraphicTests/Scenes/^[0-9]+")] [Timeout(450 * 1000)] // Set timeout to 450 sec. to handle complex scenes with many shaders (previous timeout was 300s) public IEnumerator Run(SceneGraphicsTestCase testCase) diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset new file mode 100644 index 00000000000..f9b4e72490a --- /dev/null +++ b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset @@ -0,0 +1,540 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &-7697336993926440278 +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: 0d7593b3a9277ac4696b20006c21dde2, type: 3} + m_Name: + m_EditorClassIdentifier: + active: 1 + skyType: + m_OverrideState: 1 + m_Value: 1 + cloudType: + m_OverrideState: 0 + m_Value: 0 + skyAmbientMode: + m_OverrideState: 1 + m_Value: 0 + windOrientation: + m_OverrideState: 0 + m_Value: 0 + windSpeed: + m_OverrideState: 0 + m_Value: 100 + fogType: + m_OverrideState: 1 + m_Value: 2 +--- !u!114 &-6413792784233250209 +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: 2150ee00179b2f4418ea8b21a7e98eea, type: 3} + m_Name: + m_EditorClassIdentifier: + active: 0 + colorMode: + m_OverrideState: 1 + m_Value: 1 + color: + m_OverrideState: 1 + m_Value: {r: 0.5, g: 0.5, b: 0.5, a: 1} + tint: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + density: + m_OverrideState: 1 + m_Value: 1 + maxFogDistance: + m_OverrideState: 1 + m_Value: 5000 + mipFogMaxMip: + m_OverrideState: 1 + m_Value: 0.5 + mipFogNear: + m_OverrideState: 1 + m_Value: 0 + mipFogFar: + m_OverrideState: 1 + m_Value: 1000 + fogDistance: + m_OverrideState: 1 + m_Value: 200 + fogBaseHeight: + m_OverrideState: 1 + m_Value: 0 + fogHeightAttenuation: + m_OverrideState: 1 + m_Value: 0.2 +--- !u!114 &-3990501575690934820 +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: da5ab44aadfb1804db5fd470983ac1b8, type: 3} + m_Name: LiftGammaGain + m_EditorClassIdentifier: + active: 0 + lift: + m_OverrideState: 0 + m_Value: {x: 1, y: 1, z: 1, w: 0} + gamma: + m_OverrideState: 0 + m_Value: {x: 1, y: 1, z: 1, w: 0} + gain: + m_OverrideState: 0 + m_Value: {x: 1, y: 1, z: 1, w: 0} +--- !u!114 &-2963969148509422956 +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: 7ddcec8a8eb2d684d833ac8f5d26aebd, type: 3} + m_Name: + m_EditorClassIdentifier: + active: 1 + maxShadowDistance: + m_OverrideState: 1 + m_Value: 500 + directionalTransmissionMultiplier: + m_OverrideState: 0 + m_Value: 1 + cascadeShadowSplitCount: + m_OverrideState: 1 + m_Value: 4 + cascadeShadowSplit0: + m_OverrideState: 1 + m_Value: 0.05 + cascadeShadowSplit1: + m_OverrideState: 1 + m_Value: 0.15 + cascadeShadowSplit2: + m_OverrideState: 1 + m_Value: 0.3 + cascadeShadowBorder0: + m_OverrideState: 1 + m_Value: 0 + cascadeShadowBorder1: + m_OverrideState: 1 + m_Value: 0 + cascadeShadowBorder2: + m_OverrideState: 1 + m_Value: 0 + cascadeShadowBorder3: + m_OverrideState: 1 + m_Value: 0 +--- !u!114 &-1977287653889231898 +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: aaa3b8214f75b354e9ba2caadd022259, type: 3} + m_Name: DepthOfField + m_EditorClassIdentifier: + active: 0 + quality: + m_OverrideState: 0 + m_Value: 1 + focusMode: + m_OverrideState: 1 + m_Value: 0 + focusDistance: + m_OverrideState: 1 + m_Value: 10 + focusDistanceMode: + m_OverrideState: 0 + m_Value: 0 + nearFocusStart: + m_OverrideState: 1 + m_Value: 0 + nearFocusEnd: + m_OverrideState: 1 + m_Value: 4 + farFocusStart: + m_OverrideState: 1 + m_Value: 10 + farFocusEnd: + m_OverrideState: 1 + m_Value: 20 + m_NearSampleCount: + m_OverrideState: 0 + m_Value: 5 + m_NearMaxBlur: + m_OverrideState: 0 + m_Value: 4 + m_FarSampleCount: + m_OverrideState: 0 + m_Value: 7 + m_FarMaxBlur: + m_OverrideState: 0 + m_Value: 8 + m_Resolution: + m_OverrideState: 0 + m_Value: 2 + m_HighQualityFiltering: + m_OverrideState: 0 + m_Value: 1 + m_PhysicallyBased: + m_OverrideState: 0 + m_Value: 0 +--- !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: Scene Settings Profile 1 + m_EditorClassIdentifier: + components: + - {fileID: -2963969148509422956} + - {fileID: -7697336993926440278} + - {fileID: 2523018487990756456} + - {fileID: -6413792784233250209} + - {fileID: 1906998338381081184} + - {fileID: -1977287653889231898} + - {fileID: -3990501575690934820} + - {fileID: 4496069717186440673} + - {fileID: 6271081758499213648} +--- !u!114 &1906998338381081184 +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: 59b6606ef2548734bb6d11b9d160bc7e, type: 3} + m_Name: HDRISky + m_EditorClassIdentifier: + active: 0 + rotation: + m_OverrideState: 1 + m_Value: 0 + skyIntensityMode: + m_OverrideState: 1 + m_Value: 0 + exposure: + m_OverrideState: 1 + m_Value: 0 + multiplier: + m_OverrideState: 1 + m_Value: 1 + upperHemisphereLuxValue: + m_OverrideState: 1 + m_Value: 5.2074246 + upperHemisphereLuxColor: + m_OverrideState: 1 + m_Value: {x: 0, y: 0, z: 0} + desiredLuxValue: + m_OverrideState: 1 + m_Value: 20000 + updateMode: + m_OverrideState: 1 + m_Value: 0 + updatePeriod: + m_OverrideState: 1 + m_Value: 0 + includeSunInBaking: + m_OverrideState: 1 + m_Value: 0 + hdriSky: + m_OverrideState: 1 + m_Value: {fileID: 8900000, guid: 614ae0372d7dfb847a1926990e89fa06, type: 3} + distortionMode: + m_OverrideState: 0 + m_Value: 0 + flowmap: + m_OverrideState: 0 + m_Value: {fileID: 0} + upperHemisphereOnly: + m_OverrideState: 0 + m_Value: 1 + scrollOrientation: + m_OverrideState: 0 + m_Value: + mode: 1 + customValue: 0 + additiveValue: 0 + multiplyValue: 1 + scrollSpeed: + m_OverrideState: 0 + m_Value: + mode: 1 + customValue: 100 + additiveValue: 0 + multiplyValue: 1 + enableBackplate: + m_OverrideState: 0 + m_Value: 0 + backplateType: + m_OverrideState: 0 + m_Value: 0 + groundLevel: + m_OverrideState: 0 + m_Value: 0 + scale: + m_OverrideState: 0 + m_Value: {x: 32, y: 32} + projectionDistance: + m_OverrideState: 0 + m_Value: 16 + plateRotation: + m_OverrideState: 0 + m_Value: 0 + plateTexRotation: + m_OverrideState: 0 + m_Value: 0 + plateTexOffset: + m_OverrideState: 0 + m_Value: {x: 0, y: 0} + blendAmount: + m_OverrideState: 0 + m_Value: 0 + shadowTint: + m_OverrideState: 0 + m_Value: {r: 0.5, g: 0.5, b: 0.5, a: 1} + pointLightShadow: + m_OverrideState: 0 + m_Value: 0 + dirLightShadow: + m_OverrideState: 0 + m_Value: 0 + rectLightShadow: + m_OverrideState: 0 + m_Value: 0 + m_SkyVersion: 1 + enableDistortion: + m_OverrideState: 0 + m_Value: 0 + procedural: + m_OverrideState: 0 + m_Value: 1 + scrollDirection: + m_OverrideState: 0 + m_Value: 0 + m_ObsoleteScrollSpeed: + m_OverrideState: 0 + m_Value: 1 +--- !u!114 &2523018487990756456 +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: 3df29e7cc05fbec4aa43e06ea875565d, type: 3} + m_Name: + m_EditorClassIdentifier: + active: 0 + rotation: + m_OverrideState: 1 + m_Value: 0 + skyIntensityMode: + m_OverrideState: 1 + m_Value: 0 + exposure: + m_OverrideState: 1 + m_Value: 0 + multiplier: + m_OverrideState: 1 + m_Value: 1 + upperHemisphereLuxValue: + m_OverrideState: 1 + m_Value: 1 + upperHemisphereLuxColor: + m_OverrideState: 0 + m_Value: {x: 0, y: 0, z: 0} + desiredLuxValue: + m_OverrideState: 1 + m_Value: 20000 + updateMode: + m_OverrideState: 1 + m_Value: 0 + updatePeriod: + m_OverrideState: 1 + m_Value: 0 + includeSunInBaking: + m_OverrideState: 1 + m_Value: 0 + sunSize: + m_OverrideState: 1 + m_Value: 0.04 + sunSizeConvergence: + m_OverrideState: 1 + m_Value: 5 + atmosphereThickness: + m_OverrideState: 1 + m_Value: 1 + skyTint: + m_OverrideState: 1 + m_Value: {r: 0.5, g: 0.5, b: 0.5, a: 1} + groundColor: + m_OverrideState: 1 + m_Value: {r: 0.369, g: 0.349, b: 0.341, a: 1} + enableSunDisk: + m_OverrideState: 1 + m_Value: 1 +--- !u!114 &4496069717186440673 +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: bcf384b154398e341b6b29969c078198, type: 3} + m_Name: MotionBlur + m_EditorClassIdentifier: + active: 1 + quality: + m_OverrideState: 0 + m_Value: 1 + intensity: + m_OverrideState: 1 + m_Value: 14 + maximumVelocity: + m_OverrideState: 0 + m_Value: 200 + minimumVelocity: + m_OverrideState: 0 + m_Value: 2 + cameraMotionBlur: + m_OverrideState: 0 + m_Value: 1 + specialCameraClampMode: + m_OverrideState: 0 + m_Value: 0 + cameraVelocityClamp: + m_OverrideState: 0 + m_Value: 0.05 + cameraTranslationVelocityClamp: + m_OverrideState: 0 + m_Value: 0.05 + cameraRotationVelocityClamp: + m_OverrideState: 1 + m_Value: 0.1 + depthComparisonExtent: + m_OverrideState: 0 + m_Value: 1 + m_SampleCount: + m_OverrideState: 0 + m_Value: 8 +--- !u!114 &6271081758499213648 +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: 953beb541740ddc499d005ee80c9ff29, type: 3} + m_Name: + m_EditorClassIdentifier: + active: 1 + quality: + m_OverrideState: 0 + m_Value: 1 + enabled: + m_OverrideState: 1 + m_Value: 1 + colorMode: + m_OverrideState: 1 + m_Value: 1 + color: + m_OverrideState: 1 + m_Value: {r: 0.5, g: 0.5, b: 0.5, a: 1} + tint: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + maxFogDistance: + m_OverrideState: 1 + m_Value: 5000 + mipFogMaxMip: + m_OverrideState: 1 + m_Value: 0.5 + mipFogNear: + m_OverrideState: 1 + m_Value: 0 + mipFogFar: + m_OverrideState: 1 + m_Value: 1000 + baseHeight: + m_OverrideState: 0 + m_Value: 0 + maximumHeight: + m_OverrideState: 0 + m_Value: 50 + meanFreePath: + m_OverrideState: 1 + m_Value: 200 + enableVolumetricFog: + m_OverrideState: 0 + m_Value: 0 + albedo: + m_OverrideState: 0 + m_Value: {r: 1, g: 1, b: 1, a: 1} + globalLightProbeDimmer: + m_OverrideState: 0 + m_Value: 1 + depthExtent: + m_OverrideState: 0 + m_Value: 64 + denoisingMode: + m_OverrideState: 0 + m_Value: 2 + anisotropy: + m_OverrideState: 0 + m_Value: 0 + sliceDistributionUniformity: + m_OverrideState: 0 + m_Value: 0.75 + m_FogControlMode: + m_OverrideState: 0 + m_Value: 0 + screenResolutionPercentage: + m_OverrideState: 0 + m_Value: 12.5 + volumeSliceCount: + m_OverrideState: 0 + m_Value: 64 + m_VolumetricFogBudget: + m_OverrideState: 0 + m_Value: 0.33 + m_ResolutionDepthRatio: + m_OverrideState: 0 + m_Value: 0.666 + directionalLightsOnly: + m_OverrideState: 0 + m_Value: 0 diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset.meta b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset.meta new file mode 100644 index 00000000000..eadb33f5d93 --- /dev/null +++ b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur/Scene Settings Profile 1.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 351bda579a52f4dd88800db027a38475 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4012_MotionBlur_CameraOnly.unity b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4012_MotionBlur_CameraOnly.unity index f83832424ff..909f481fa5c 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4012_MotionBlur_CameraOnly.unity +++ b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/Scenes/4x_PostProcessing/4012_MotionBlur_CameraOnly.unity @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a305a46d6da15de10f1ca1f33817308def497e546e10a094461f15ce33feed20 -size 29300 +oid sha256:ca0b38c8c29cd907815fceff507f801503977e84f22bf38d90648abbe91d023d +size 29691 diff --git a/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset b/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset index b583d64cfaf..58e887597f0 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset +++ b/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset @@ -554,6 +554,9 @@ EditorBuildSettings: - enabled: 1 path: Assets/GraphicTests/Scenes/4x_PostProcessing/4011_MotionBlur_PerObject.unity guid: bfedb7e76d6153a4896b9d61a8d826af + - enabled: 1 + path: Assets/GraphicTests/Scenes/4x_PostProcessing/4012_MotionBlur_CameraOnly.unity + guid: faeb14f82af77cc4fb9c88233f3c9a53 - enabled: 1 path: Assets/GraphicTests/Scenes/4x_PostProcessing/4013_TransparentAndOpaqueMotionVector.unity guid: ed84243e5c418844f87509bf80fdd919 From 866b23e502807365137018c3a490ab46b17bc6a8 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 20 Oct 2026 12:29:05 +0000 Subject: [PATCH 02/22] [Port] [6000.0] Remove the GC allocation check from the SRP image tests --- .../Editor/HDRP_TestSettings_Editor.cs | 3 --- .../TestRunner/HDRP_GraphicTestRunner.cs | 8 -------- .../TestRunner/HDRP_TestSettings.cs | 3 --- .../Runtime/UniversalGraphicsTestSettings.cs | 1 - .../Scripts/Runtime/UniversalGraphicsTests.cs | 7 ------- .../Assets/Test/Runtime/BuiltInGraphicsTests.cs | 16 ---------------- .../Assets/Test/Runtime/BuiltInGraphicsTests.cs | 16 ---------------- 7 files changed, 54 deletions(-) diff --git a/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/Editor/HDRP_TestSettings_Editor.cs b/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/Editor/HDRP_TestSettings_Editor.cs index 6261a2c87cd..3db6e12aa8a 100644 --- a/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/Editor/HDRP_TestSettings_Editor.cs +++ b/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/Editor/HDRP_TestSettings_Editor.cs @@ -22,7 +22,6 @@ public class HDRP_TestSettings_Editor : Editor SerializedProperty gpuDrivenCompatible; SerializedProperty waitForFrameCountMultiple; SerializedProperty frameCountMultiple; - SerializedProperty checkMemoryAllocation; SerializedProperty renderPipelineAsset; SerializedProperty forceCameraRenderDuringSetup; SerializedProperty containsVFX; @@ -39,7 +38,6 @@ void OnEnable() gpuDrivenCompatible = serializedObject.FindProperty("gpuDrivenCompatible"); waitForFrameCountMultiple = serializedObject.FindProperty("waitForFrameCountMultiple"); frameCountMultiple = serializedObject.FindProperty("frameCountMultiple"); - checkMemoryAllocation = serializedObject.FindProperty("checkMemoryAllocation"); renderPipelineAsset = serializedObject.FindProperty("renderPipelineAsset"); forceCameraRenderDuringSetup = serializedObject.FindProperty("forceCameraRenderDuringSetup"); containsVFX = serializedObject.FindProperty("containsVFX"); @@ -74,7 +72,6 @@ override public void OnInspectorGUI() } - EditorGUILayout.PropertyField(checkMemoryAllocation); EditorGUILayout.PropertyField(renderPipelineAsset); EditorGUILayout.PropertyField(forceCameraRenderDuringSetup); diff --git a/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs b/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs index 45e43d95e37..99a709abf0b 100644 --- a/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs +++ b/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_GraphicTestRunner.cs @@ -231,14 +231,6 @@ public static IEnumerator Run(SceneGraphicsTestCase testCase) { // Standard Test ImageAssert.AreEqual(testCase.ReferenceImage.Image, camera, settings?.ImageComparisonSettings, testCase.ReferenceImage.LoadMessage); - - // For some reason, tests on mac os have started failing with render graph enabled by default. - // Some tests have 400+ gcalloc in them. Unfortunately it's not reproductible outside of command line so it's impossible to debug. - // That's why we don't test on macos anymore. - if (settings.checkMemoryAllocation) - { - yield return ImageAssert.CheckGCAllocWithCallstack(camera, settings?.ImageComparisonSettings); - } } else { diff --git a/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs b/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs index 787303ab70c..e65edff9c70 100644 --- a/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs +++ b/Tests/SRPTests/Packages/com.unity.testing.hdrp/TestRunner/HDRP_TestSettings.cs @@ -39,9 +39,6 @@ public class HDRP_TestSettings : GraphicsTestSettings [Tooltip("Set the multiplier to increase the tolerance in AverageCorrectnessThreshold and PerPixelCorrectnessThreshold to account for slight changes due to float precision.")] public float xrThresholdMultiplier = 1.0f; - [Tooltip("When enabled, the tests fails if GC.Alloc are executed after a few frames during the tests.")] - public bool checkMemoryAllocation = true; - [Tooltip("Specifies the render pipeline asset used when executing the test.")] public RenderPipelineAsset renderPipelineAsset; diff --git a/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTestSettings.cs b/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTestSettings.cs index 9b96c1b6f73..fc8a70b064b 100644 --- a/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTestSettings.cs +++ b/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTestSettings.cs @@ -5,7 +5,6 @@ public class UniversalGraphicsTestSettings : GraphicsTestSettings public int WaitFrames = 0; public bool XRCompatible = true; public bool gpuDrivenCompatible = true; - public bool CheckMemoryAllocation = true; public bool Ignored; [System.Serializable] diff --git a/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTests.cs b/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTests.cs index 820f418e460..cbb8d657085 100644 --- a/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTests.cs +++ b/Tests/SRPTests/Packages/com.unity.testing.urp/Scripts/Runtime/UniversalGraphicsTests.cs @@ -180,13 +180,6 @@ public static IEnumerator RunGraphicsTest(SceneGraphicsTestCase testCase) #endif #endif - - if (settings == null || settings.CheckMemoryAllocation) - { - // Does it allocate memory when it renders what's on the main camera? - var mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); - yield return ImageAssert.CheckGCAllocWithCallstack(mainCamera, settings?.ImageComparisonSettings); - } } } } diff --git a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Assets/Test/Runtime/BuiltInGraphicsTests.cs b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Assets/Test/Runtime/BuiltInGraphicsTests.cs index e3d45c4f057..67a468eaa95 100644 --- a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Assets/Test/Runtime/BuiltInGraphicsTests.cs +++ b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Foundation/Assets/Test/Runtime/BuiltInGraphicsTests.cs @@ -57,22 +57,6 @@ public IEnumerator Run(GraphicsTestCase testCase) #endif ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings, testCase.ReferenceImagePathLog); - - // Does it allocate memory when it renders what's on the main camera? - bool allocatesMemory = false; - var mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); - - try - { - ImageAssert.AllocatesMemory(mainCamera, settings?.ImageComparisonSettings); - } - catch (AssertionException) - { - allocatesMemory = true; - } - - if (allocatesMemory) - Assert.Fail("Allocated memory when rendering what is on main camera"); } #if UNITY_EDITOR diff --git a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Assets/Test/Runtime/BuiltInGraphicsTests.cs b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Assets/Test/Runtime/BuiltInGraphicsTests.cs index e3d45c4f057..67a468eaa95 100644 --- a/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Assets/Test/Runtime/BuiltInGraphicsTests.cs +++ b/Tests/SRPTests/Projects/BuiltInGraphicsTest_Lighting/Assets/Test/Runtime/BuiltInGraphicsTests.cs @@ -57,22 +57,6 @@ public IEnumerator Run(GraphicsTestCase testCase) #endif ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), settings.ImageComparisonSettings, testCase.ReferenceImagePathLog); - - // Does it allocate memory when it renders what's on the main camera? - bool allocatesMemory = false; - var mainCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent(); - - try - { - ImageAssert.AllocatesMemory(mainCamera, settings?.ImageComparisonSettings); - } - catch (AssertionException) - { - allocatesMemory = true; - } - - if (allocatesMemory) - Assert.Fail("Allocated memory when rendering what is on main camera"); } #if UNITY_EDITOR From 2013245646539a08a53cae24d737e5ed7639d20b Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 20 Oct 2026 12:29:05 +0000 Subject: [PATCH 03/22] [Port] [6000.0] [UUM-156931][URP 2D][7000.0] Fix Point Light 2D losing its cookie on upgrade --- .../Runtime/2D/Light2D.cs | 5 +- .../Editor/Light2DCookieMigrationTests.cs | 118 ++++++++++++++++++ .../Light2DCookieMigrationTests.cs.meta | 12 ++ 3 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs index f14226783a6..6cbe5667dca 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs @@ -662,10 +662,9 @@ public void OnAfterDeserialize() if (m_ComponentVersion < ComponentVersions.Version_3) { #pragma warning disable CS0618 - if (m_LightType == LightType.Point && (object)m_DeprecatedPointLightCookieSprite != null) - { + if (m_LightType == LightType.Point) m_LightCookieSprite = m_DeprecatedPointLightCookieSprite; - } + m_DeprecatedPointLightCookieSprite = null; #pragma warning restore CS0618 } } diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs new file mode 100644 index 00000000000..73d31c128a3 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs @@ -0,0 +1,118 @@ +using System.Collections.Generic; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.Rendering.Universal; + +namespace UnityEditor.Rendering.Universal.Tests +{ + [TestFixture] + class Light2DCookieMigrationTests + { + const int k_Version2 = 2; + const int k_Version3 = 3; + + readonly List m_Created = new List(); + + Sprite CreateSprite(string name) + { + var texture = new Texture2D(4, 4); + var sprite = Sprite.Create(texture, new Rect(0, 0, 4, 4), Vector2.zero); + sprite.name = name; + m_Created.Add(texture); + m_Created.Add(sprite); + return sprite; + } + + Light2D CreatePointLight() + { + var go = new GameObject("Point Light 2D"); + m_Created.Add(go); + var light = go.AddComponent(); + light.lightType = Light2D.LightType.Point; + return light; + } + + // Writes the serialized state of an older light and deserializes it, which runs the OnAfterDeserialize upgrade. + static void DeserializeAsVersion(Light2D light, int componentVersion, Sprite lightCookieSprite, Sprite deprecatedPointLightCookieSprite) + { + var serializedObject = new SerializedObject(light); + serializedObject.FindProperty("m_ComponentVersion").intValue = componentVersion; + serializedObject.FindProperty("m_LightCookieSprite").objectReferenceValue = lightCookieSprite; + serializedObject.FindProperty("m_DeprecatedPointLightCookieSprite").objectReferenceValue = deprecatedPointLightCookieSprite; + serializedObject.ApplyModifiedPropertiesWithoutUndo(); + } + + static UnityEngine.Object GetSerializedReference(Light2D light, string propertyName) + { + return new SerializedObject(light).FindProperty(propertyName).objectReferenceValue; + } + + [TearDown] + public void TearDown() + { + foreach (var obj in m_Created) + { + if (obj != null) + UnityEngine.Object.DestroyImmediate(obj); + } + m_Created.Clear(); + } + + // UUM-156931: Version_3 data on this branch already holds the migrated cookie in m_LightCookieSprite. + [Test] + public void OnAfterDeserialize_Version3WithMigratedCookie_KeepsCookie() + { + var light = CreatePointLight(); + var cookie = CreateSprite("Cookie"); + + DeserializeAsVersion(light, k_Version3, cookie, null); + + Assert.AreEqual(cookie, light.lightCookieSprite, "The upgrade cleared a cookie that was already migrated."); + } + + // The Version_3 migration did not clear the deprecated field, so it can still hold the cookie from before a later change. + [Test] + public void OnAfterDeserialize_Version3WithStaleDeprecatedCookie_KeepsCookie() + { + var light = CreatePointLight(); + var cookie = CreateSprite("Cookie"); + + DeserializeAsVersion(light, k_Version3, cookie, CreateSprite("Stale Cookie")); + + Assert.AreEqual(cookie, light.lightCookieSprite, "The stale deprecated cookie replaced the current cookie."); + } + + [Test] + public void OnAfterDeserialize_Version2WithDeprecatedCookie_MigratesCookie() + { + var light = CreatePointLight(); + var cookie = CreateSprite("Cookie"); + + DeserializeAsVersion(light, k_Version2, null, cookie); + + Assert.AreEqual(cookie, light.lightCookieSprite, "The cookie in the deprecated field was not migrated."); + } + + [Test] + public void OnAfterDeserialize_Version2WithDeprecatedCookie_ClearsDeprecatedCookie() + { + var light = CreatePointLight(); + + DeserializeAsVersion(light, k_Version2, null, CreateSprite("Cookie")); + + Assert.IsNull(GetSerializedReference(light, "m_DeprecatedPointLightCookieSprite"), + "The deprecated cookie must be cleared so a later upgrade cannot apply it again."); + } + + // Before Version_3 a point light always used the deprecated cookie, so a sprite left from an earlier light type must not become its cookie. + [Test] + public void OnAfterDeserialize_Version2WithoutDeprecatedCookie_HasNoCookie() + { + var light = CreatePointLight(); + + DeserializeAsVersion(light, k_Version2, CreateSprite("Leftover Sprite"), null); + + Assert.IsTrue(light.lightCookieSprite == null, "A sprite the point light did not use became its cookie."); + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs.meta new file mode 100644 index 00000000000..b57eb087b4f --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Light2DCookieMigrationTests.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4c2585251ed5fc1b142778dc47ce7935 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleIdentifier: + assetBundleVariant: From a6c656a96e3e830cedc75a3ea7f57e293151651e Mon Sep 17 00:00:00 2001 From: Marta Malberti Date: Tue, 20 Oct 2026 12:29:05 +0000 Subject: [PATCH 04/22] [Port] [6000.0] docg 8142: Create docs pages for Artistic/Mask Shader Graph nodes --- .../Documentation~/hdrp-shader-graph-nodes.md | 1 + .../Surface-Gradient-Resolve-Normal-Node.md | 27 ++++++++ .../Documentation~/TableOfContents.md | 4 ++ .../Documentation~/URP-Sample-Buffer-Node.md | 63 +++++++++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 Packages/com.unity.shadergraph/Documentation~/Surface-Gradient-Resolve-Normal-Node.md create mode 100644 Packages/com.unity.shadergraph/Documentation~/URP-Sample-Buffer-Node.md diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdrp-shader-graph-nodes.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdrp-shader-graph-nodes.md index 779d9e56592..3ca10755fa6 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdrp-shader-graph-nodes.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/hdrp-shader-graph-nodes.md @@ -10,6 +10,7 @@ HDRP adds the following Shader Graph Nodes: * [HD Scene Color](https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/HD-Scene-Color-Node.html) * [HD Scene Depth](https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/HD-Scene-Depth-Node.html) * [HD Sample Buffer](https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/HD-Sample-Buffer-Node.html) +* [Surface Gradient Resolve Normal](https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/Surface-Gradient-Resolve-Normal-Node.html) * Eye Shader Graph utilities * [CirclePupilAnimation](https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/Circle-Pupil-Animation-Node.html) * [CorneaRefraction](https://docs.unity3d.com/Packages/com.unity.shadergraph@16.0/manual/Cornea-Refraction-Node.html) diff --git a/Packages/com.unity.shadergraph/Documentation~/Surface-Gradient-Resolve-Normal-Node.md b/Packages/com.unity.shadergraph/Documentation~/Surface-Gradient-Resolve-Normal-Node.md new file mode 100644 index 00000000000..e57115e9307 --- /dev/null +++ b/Packages/com.unity.shadergraph/Documentation~/Surface-Gradient-Resolve-Normal-Node.md @@ -0,0 +1,27 @@ +# Surface Gradient Resolve Normal node + +The Surface Gradient Resolve Normal node resolves a surface gradient into a world-space normal. It subtracts the surface gradient from the base normal and normalizes the result. + +## Render pipeline compatibility + +| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** | +| -------------------------------------- | ------------------------------------ | ------------------------------------------- | +| **Surface Gradient Resolve Normal** | No | Yes | + +## Ports + +| **Name** | **Direction** | **Type** | **Binding** | **Description** | +| -------------------- | ------------- | -------- | ----------- | -------------------------------------------------------------------------------- | +| **Normal** | Input | Vector 3 | None | The base normal vector to perturb, typically the vertex or geometric normal. | +| **SurfaceGradient** | Input | Vector 3 | None | The surface gradient that encodes the normal perturbation. | +| **NormalOutput** | Output | Vector 3 | None | The resolved perturbed normal, computed as `SafeNormalize(Normal - SurfaceGradient)`. | + +## Generated code example + +```hlsl +float3 NormalOutput = SafeNormalize(Normal - SurfaceGradient); +``` + +## Additional resources + +- [Surface Gradient-Based Normal Mapping Framework](https://jcgt.org/published/0009/03/04/) \ No newline at end of file diff --git a/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md b/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md index 4a82b2d65c4..79976611e5e 100644 --- a/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md +++ b/Packages/com.unity.shadergraph/Documentation~/TableOfContents.md @@ -166,6 +166,8 @@ * [Texture 2D Asset](Texture-2D-Asset-Node.md) * [Texture 3D Asset](Texture-3D-Asset-Node.md) * [Texture Size](Texture-Size-Node.md) + * Universal Render Pipeline + * [URP Sample Buffer](URP-Sample-Buffer-Node.md) * [Keyword](Keyword-Node.md) * [Material Quality](Material-Quality-Keyword-Node.md) * [Raytracing Quality](Raytracing-Quality-Keyword-Node.md) @@ -284,6 +286,8 @@ * [ScleraUVLocation](Sclera-UV-Location-Node.md) * Fabric * [ThreadMapDetail](ThreadMapDetail-Node.md) + * Surface Gradient + * [Surface Gradient Resolve Normal](Surface-Gradient-Resolve-Normal-Node.md) * Logic * [All](All-Node.md) * [And](And-Node.md) diff --git a/Packages/com.unity.shadergraph/Documentation~/URP-Sample-Buffer-Node.md b/Packages/com.unity.shadergraph/Documentation~/URP-Sample-Buffer-Node.md new file mode 100644 index 00000000000..2fb8bd5a70d --- /dev/null +++ b/Packages/com.unity.shadergraph/Documentation~/URP-Sample-Buffer-Node.md @@ -0,0 +1,63 @@ +# URP Sample Buffer node + +The URP Sample Buffer node samples a buffer directly from the camera. Use this node in a Fullscreen Shader Graph to access Universal Render Pipeline (URP) render buffers for post-processing effects. + +## Render pipeline compatibility + +| **Node** | **Universal Render Pipeline (URP)** | **High Definition Render Pipeline (HDRP)** | +| --------------------- | ----------------------------------- | ------------------------------------------ | +| **URP Sample Buffer** | Yes | No | + +## Ports + +| **Name** | **Direction** | **Type** | **Binding** | **Description** | +| ---------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | +| **UV** | Input | Vector 4 | Screen position | Input UV value. | +| **Output** | Output | Changes to one of the following depending on the **Source Buffer** you select:
• Vector 2
• Vector 3
• Vector 4 | None | Output value. | + +## Controls + +| **Name** | **Type** | **Options** | **Description** | +| ----------------- | --------- | ------------------------------------------------------------------------------ | ---------------------------------- | +| **Source Buffer** | Dropdown | • NormalWorldSpace
• MotionVectors
• BlitSource | Determines which buffer to sample. | + +The **Source Buffer** dropdown determines the type of the **Output** port: + +| **Source Buffer** | **Output type** | **Description** | +| -------------------- | --------------- | -------------------------------------------------------- | +| **NormalWorldSpace** | Vector 3 | World-space surface normals from the G-buffer. | +| **MotionVectors** | Vector 2 | Per-pixel motion vectors. | +| **BlitSource** | Vector 4 | RGBA color data from the post-process blit source. | + +## Generated code example + +The following example code represents one possible outcome of this node. + +**NormalWorldSpace:** + +```hlsl +float3 Unity_Universal_SampleBuffer_NormalWorldSpace_float(float2 uv) +{ + return SHADERGRAPH_SAMPLE_SCENE_NORMAL(uv); +} +``` + +**MotionVectors:** + +```hlsl +float2 Unity_Universal_SampleBuffer_MotionVectors_float(float2 uv) +{ + uint2 pixelCoords = uint2(uv * _ScreenSize.xy); + return LOAD_TEXTURE2D_X_LOD(_MotionVectorTexture, pixelCoords, 0).xy; +} +``` + +**BlitSource:** + +```hlsl +float4 Unity_Universal_SampleBuffer_BlitSource_float(float2 uv) +{ + uint2 pixelCoords = uint2(uv * _ScreenSize.xy); + return LOAD_TEXTURE2D_X_LOD(_BlitTexture, pixelCoords, 0); +} +``` From 3a95160bfe4a0f01821e8b301b8402de6c65cd8c Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 20 Oct 2026 12:29:05 +0000 Subject: [PATCH 05/22] [Port] [6000.0] [UUM-156028] Remove unused import to fix breakage on .NET 10 --- Packages/com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/Packages/com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs b/Packages/com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs index b72980df4e5..6cf76a7bd1d 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Util/GraphUtil.cs @@ -11,7 +11,6 @@ using UnityEditorInternal; using Debug = UnityEngine.Debug; using System.Reflection; -using System.Runtime.Remoting.Metadata.W3cXsd2001; using UnityEditor.ProjectWindowCallback; using UnityEditor.ShaderGraph.Internal; using UnityEngine; From 9560b4b1e257b7207d20cae5116126ed35631b78 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 20 Oct 2026 12:29:06 +0000 Subject: [PATCH 06/22] [Port] [6000.0] [UUM-154810] Give new Light2D components a default freeform shape --- .../Editor/2D/FreeformPathPresets.cs | 13 ------------- .../Editor/2D/Renderer2DMenus.cs | 2 +- .../Runtime/2D/Light2DAuthoring.cs | 5 ----- .../Runtime/2D/Light2DShape.cs | 2 +- .../Tests/Runtime/Light2DTests.cs | 13 +++++++++++++ 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/FreeformPathPresets.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/FreeformPathPresets.cs index 0af7b773c50..49346d9f25f 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/FreeformPathPresets.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/FreeformPathPresets.cs @@ -5,19 +5,6 @@ namespace UnityEditor.Rendering.Universal { internal static class FreeformPathPresets { - public static Vector3[] CreateSquare() - { - Vector3[] returnPath = new Vector3[4] - { - new Vector3(-0.5f, -0.5f), - new Vector3(0.5f, -0.5f), - new Vector3(0.5f, 0.5f), - new Vector3(-0.5f, 0.5f) - }; - - return returnPath; - } - public static Vector3[] CreateIsometricDiamond() { Vector3[] returnPath = new Vector3[4] diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs index d3c440aabb9..b71b71ed2f2 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DMenus.cs @@ -127,7 +127,7 @@ static bool CreateLightValidation() [MenuItem("GameObject/Light/Freeform Light 2D/Square", priority = CoreUtils.Sections.section3 + CoreUtils.Priorities.gameObjectMenuPriority + 4)] static void CreateSquareFreeformLight2D(MenuCommand menuCommand) { - CreateLight(menuCommand, Light2D.LightType.Freeform, FreeformPathPresets.CreateSquare()); + CreateLight(menuCommand, Light2D.LightType.Freeform); } [MenuItem("GameObject/Light/Freeform Light 2D/Circle", priority = CoreUtils.Sections.section3 + CoreUtils.Priorities.gameObjectMenuPriority + 5)] diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DAuthoring.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DAuthoring.cs index 7ce0ac31763..f0d709b128f 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DAuthoring.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DAuthoring.cs @@ -21,11 +21,6 @@ private void OnDrawGizmos() Gizmos.DrawIcon(transform.position, s_IconsPath + s_LightIconFileNames[(int)m_LightType], true); } - void Reset() - { - m_ShapePath = new Vector3[] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }; - } - internal List GetFalloffShape() { return LightUtility.GetOutlinePath(m_ShapePath, m_ShapeLightFalloffSize); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DShape.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DShape.cs index caab50fd9e6..f103e7245c8 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DShape.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DShape.cs @@ -7,7 +7,7 @@ public sealed partial class Light2D [SerializeField] float m_ShapeLightParametricRadius = 1.0f; [SerializeField] float m_ShapeLightFalloffSize = 0.50f; [SerializeField] Vector2 m_ShapeLightFalloffOffset = Vector2.zero; - [SerializeField] Vector3[] m_ShapePath = null; + [SerializeField] Vector3[] m_ShapePath = { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }; float m_PreviousShapeLightFalloffSize = -1; int m_PreviousShapeLightParametricSides = -1; diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Light2DTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Light2DTests.cs index c42f754acad..7579c5e19c6 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Light2DTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Light2DTests.cs @@ -141,6 +141,19 @@ public void CachedMeshDataIsOverriddenByRuntimeChanges() Assert.AreNotEqual(triangleCount, light.lightMesh.vertices.Length); } + // UUM-154810: a Freeform light created from script, with no SetShapePath call, + // must start with the default square instead of a null path. + [Test] + public void FreeformLightCreatedFromScriptHasDefaultShape() + { + var light = m_TestObjectCached.AddComponent(); + light.lightType = Light2D.LightType.Freeform; + + Assert.DoesNotThrow(() => light.UpdateMesh(true)); + Assert.AreEqual(new[] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }, light.shapePath); + Assert.Greater(light.lightMesh.vertexCount, 0); + } + [Test] public void EnsureShapeMeshGenerationDoesNotOverflowAllocation() { From 5ebccf730029d47d25ec79ca7a40113034124e74 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 22 Oct 2026 02:16:51 +0000 Subject: [PATCH 07/22] [Port] [6000.0] Fix shader variant mismatch when additional light shadows disabled in URP with 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 4314d3941cf..abc03c4ebef 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs @@ -673,11 +673,11 @@ bool SetupForEmptyRendering(bool stripShadowsOffVariants, bool shadowsEnabled, U if (!stripShadowsOffVariants) return false; - shadowData.isKeywordAdditionalLightShadowsEnabled = true; m_CreateEmptyShadowmap = true; useNativeRenderPass = false; m_SetKeywordForEmptyShadowmap = shadowsEnabled; + shadowData.isKeywordAdditionalLightShadowsEnabled = m_SetKeywordForEmptyShadowmap; // Even though there are not real-time shadows, the lights might be using shadowmasks, // which is why we need to update the shadow parameters, for example so shadow strength can be used. From 452992bf47cea8e218c0062e34e1a9b31d67818f Mon Sep 17 00:00:00 2001 From: Jans Margevics Date: Thu, 22 Oct 2026 02:16:51 +0000 Subject: [PATCH 08/22] [Port] [6000.0] [UUM-155363] [HDRP] Add 9006_StencilUsage reference images and re-enable test --- .../HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs | 2 +- .../HDRP_Tests/ProjectSettings/EditorBuildSettings.asset | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs index e97283aa6c0..8b0869eb86f 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs +++ b/Tests/SRPTests/Projects/HDRP_Tests/Assets/GraphicTests/HDRP_Graphics_Tests.cs @@ -97,7 +97,7 @@ public void SetUpContext() [IgnoreGraphicsTest("4075_PhysicalCamera-gateFit", "Instability https://jira.unity3d.com/browse/UUM-100651", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsPlayer }, graphicsDeviceTypes: new GraphicsDeviceType[] { GraphicsDeviceType.Direct3D11 })] [IgnoreGraphicsTest("4075_PhysicalCamera-gateFit", "Unstable: https://jira.unity3d.com/browse/UUM-100651")] [IgnoreGraphicsTest( - "4060_CustomPostProcess|8207_InstancingAPIs|8212_Fullscreen|9700_CustomPass_FullScreen|9702_CustomPass_API|9703_SampleColorBuffer_InjectionPoints_Scaling|9931-ScreenCoordOverrideCustomPostProcess|1104_Unlit_Distortion_Compose|1206_Lit_Transparent_Distortion|1805_Depth_Pre_Post_Unlit|4038_Bloom|5014_VolumetricCloudsBanding|9006_StencilUsage|9304_MotionVectorsPrecomputedAndCustomVelocity|9601_SkinnedMeshBatching-Off|9602_SkinnedMeshBatching-On", + "4060_CustomPostProcess|8207_InstancingAPIs|8212_Fullscreen|9700_CustomPass_FullScreen|9702_CustomPass_API|9703_SampleColorBuffer_InjectionPoints_Scaling|9931-ScreenCoordOverrideCustomPostProcess|1104_Unlit_Distortion_Compose|1206_Lit_Transparent_Distortion|1805_Depth_Pre_Post_Unlit|4038_Bloom|5014_VolumetricCloudsBanding|9304_MotionVectorsPrecomputedAndCustomVelocity|9601_SkinnedMeshBatching-Off|9602_SkinnedMeshBatching-On", "Image difference when updating from GTF8 to GTF9", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.WindowsEditor, RuntimePlatform.LinuxEditor })] [IgnoreGraphicsTest( diff --git a/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset b/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset index 58e887597f0..aa359306150 100644 --- a/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset +++ b/Tests/SRPTests/Projects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset @@ -887,6 +887,9 @@ EditorBuildSettings: - enabled: 1 path: Assets/GraphicTests/Scenes/9x_Other/9005_AfterPostProcess.unity guid: 2bb5d28daf3968e40aad1ae3211c2e9d + - enabled: 1 + path: Assets/GraphicTests/Scenes/9x_Other/9006_StencilUsage.unity + guid: 1071e9c62adc8224da7d53cc6680ecab - enabled: 1 path: Assets/GraphicTests/Scenes/9x_Other/9007_CameraAlphaComposition.unity guid: 9bdb6076c41f9d64099cfd338b8f4c8b From ed9f1feb9e3ec2b4ae6cb69746094f046208e346 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Thu, 22 Oct 2026 02:16:51 +0000 Subject: [PATCH 09/22] [Port] [6000.0] UUM-134256: Fixed "Default" being added to Enum values in ShaderGraph --- .../Material/Decal/ShaderGraph/DecalSubTarget.cs | 4 ++-- .../Material/ShaderGraph/HDSubShaderUtilities.cs | 12 ++++++------ .../ShaderGraph/Targets/UniversalDecalSubTarget.cs | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs index dc4ee23b8da..f6c1501960e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/Decal/ShaderGraph/DecalSubTarget.cs @@ -148,8 +148,8 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera overrideReferenceName = "_DecalMeshBiasType", floatType = FloatType.Enum, value = (int)DecalMeshDepthBiasType.DepthBias, - enumNames = { "Depth Bias", "View Bias" }, - enumValues = { (int)DecalMeshDepthBiasType.DepthBias, (int)DecalMeshDepthBiasType.ViewBias }, + enumNames = new() { "Depth Bias", "View Bias" }, + enumValues = new() { (int)DecalMeshDepthBiasType.DepthBias, (int)DecalMeshDepthBiasType.ViewBias }, hidden = true }); diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs index 13dc23de4de..69dc406abe2 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDSubShaderUtilities.cs @@ -187,8 +187,8 @@ public static void AddBlendingStatesShaderProperties( overrideReferenceName = kTransparentCullMode, floatType = FloatType.Enum, value = (int)transparentCullMode, - enumNames = { "Front", "Back" }, - enumValues = { (int)TransparentCullMode.Front, (int)TransparentCullMode.Back }, + enumNames = new() { "Front", "Back" }, + enumValues = new() { (int)TransparentCullMode.Front, (int)TransparentCullMode.Back }, hidden = true, overrideHLSLDeclaration = true, hlslDeclarationOverride = HLSLDeclaration.DoNotDeclare, @@ -242,8 +242,8 @@ public static void AddTessellationShaderProperties(PropertyCollector collector, overrideReferenceName = kTessellationMode, floatType = FloatType.Enum, value = (int)tessellationMode, - enumNames = { "None", "Phong" }, - enumValues = { (int)TessellationMode.None, (int)TessellationMode.Phong }, + enumNames = new() { "None", "Phong" }, + enumValues = new() { (int)TessellationMode.None, (int)TessellationMode.Phong }, hidden = true, overrideHLSLDeclaration = true, hlslDeclarationOverride = HLSLDeclaration.DoNotDeclare, @@ -270,7 +270,7 @@ public static void AddDoubleSidedProperty(PropertyCollector collector, DoubleSid collector.AddToggleProperty("_DoubleSidedEnable", mode != DoubleSidedMode.Disabled); collector.AddShaderProperty(new Vector1ShaderProperty { - enumNames = { "Flip", "Mirror", "None" }, // values will be 0, 1 and 2 + enumNames = new() { "Flip", "Mirror", "None" }, // values will be 0, 1 and 2 floatType = FloatType.Enum, overrideReferenceName = "_DoubleSidedNormalMode", hidden = true, @@ -288,7 +288,7 @@ public static void AddDoubleSidedProperty(PropertyCollector collector, DoubleSid }); collector.AddShaderProperty(new Vector1ShaderProperty { - enumNames = { "Auto", "On", "Off" }, // values will be 0, 1 and 2 + enumNames = new() { "Auto", "On", "Off" }, // values will be 0, 1 and 2 floatType = FloatType.Enum, overrideReferenceName = "_DoubleSidedGIMode", hidden = true, diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalDecalSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalDecalSubTarget.cs index fd5888d7b4f..c5c27cd0af1 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalDecalSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalDecalSubTarget.cs @@ -165,8 +165,8 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera displayName = "DecalMesh BiasType", floatType = FloatType.Enum, value = (int)DecalMeshDepthBiasType.DepthBias, - enumNames = { "Depth Bias", "View Bias" }, - enumValues = { (int)DecalMeshDepthBiasType.DepthBias, (int)DecalMeshDepthBiasType.ViewBias }, + enumNames = new() { "Depth Bias", "View Bias" }, + enumValues = new() { (int)DecalMeshDepthBiasType.DepthBias, (int)DecalMeshDepthBiasType.ViewBias }, hidden = true }); From 02396bc5fcfae36e50fa3ccf0cacdbd0c0eb16a3 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Sun, 25 Oct 2026 16:04:42 +0000 Subject: [PATCH 10/22] [Port] [6000.0] [UUM-152935] Move ShadowCasterPath into its own file --- .../Editor/2D/Shadows/ShadowCaster2DEditor.cs | 35 -------- .../Editor/2D/Shadows/ShadowCasterPath.cs | 40 +++++++++ .../2D/Shadows/ShadowCasterPath.cs.meta | 11 +++ .../Tests/Editor/ShadowCasterPathUndoTests.cs | 88 +++++++++++++++++++ .../Editor/ShadowCasterPathUndoTests.cs.meta | 11 +++ 5 files changed, 150 insertions(+), 35 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs.meta create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCaster2DEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCaster2DEditor.cs index 77f7f23dd1a..948f62dd0a8 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCaster2DEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCaster2DEditor.cs @@ -5,41 +5,6 @@ namespace UnityEditor.Rendering.Universal { - internal class ShadowCasterPath : ScriptablePath - { - internal Bounds GetBounds() - { - ShadowCaster2D shadowCaster = (ShadowCaster2D)owner; - Renderer m_Renderer = shadowCaster.GetComponent(); - if (m_Renderer != null) - { - return m_Renderer.bounds; - } - else - { - Collider2D collider = shadowCaster.GetComponent(); - if (collider != null) - return collider.bounds; - } - - return new Bounds(shadowCaster.transform.position, shadowCaster.transform.lossyScale); - } - - public override void SetDefaultShape() - { - Clear(); - Bounds bounds = GetBounds(); - - AddPoint(new ControlPoint(bounds.min)); - AddPoint(new ControlPoint(new Vector3(bounds.min.x, bounds.max.y))); - AddPoint(new ControlPoint(bounds.max)); - AddPoint(new ControlPoint(new Vector3(bounds.max.x, bounds.min.y))); - - base.SetDefaultShape(); - } - } - - [CustomEditor(typeof(ShadowCaster2D))] [CanEditMultipleObjects] internal class ShadowCaster2DEditor : PathComponentEditor diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs new file mode 100644 index 00000000000..151bd41d2b9 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs @@ -0,0 +1,40 @@ +using UnityEditor.Rendering.Universal.Path2D; +using UnityEngine; +using UnityEngine.Rendering.Universal; + +namespace UnityEditor.Rendering.Universal +{ + internal class ShadowCasterPath : ScriptablePath + { + internal Bounds GetBounds() + { + ShadowCaster2D shadowCaster = (ShadowCaster2D)owner; + Renderer m_Renderer = shadowCaster.GetComponent(); + if (m_Renderer != null) + { + return m_Renderer.bounds; + } + else + { + Collider2D collider = shadowCaster.GetComponent(); + if (collider != null) + return collider.bounds; + } + + return new Bounds(shadowCaster.transform.position, shadowCaster.transform.lossyScale); + } + + public override void SetDefaultShape() + { + Clear(); + Bounds bounds = GetBounds(); + + AddPoint(new ControlPoint(bounds.min)); + AddPoint(new ControlPoint(new Vector3(bounds.min.x, bounds.max.y))); + AddPoint(new ControlPoint(bounds.max)); + AddPoint(new ControlPoint(new Vector3(bounds.max.x, bounds.min.y))); + + base.SetDefaultShape(); + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs.meta b/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs.meta new file mode 100644 index 00000000000..2d6eaffd155 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Shadows/ShadowCasterPath.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: ed17b2030a89468485d8e1addb1a9e49 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs new file mode 100644 index 00000000000..4413369d25b --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs @@ -0,0 +1,88 @@ +using System.Collections; +using System.Collections.Generic; +using NUnit.Framework; +using UnityEngine; +using UnityEngine.TestTools; + +namespace UnityEditor.Rendering.Universal.Tests +{ + // UUM-152935: undoing a ShadowCaster2D shape edit in Play mode logged + // "No script asset for ShadowCasterPath. Check that the definition is in a file of the same name." + // ShadowCasterPath is a ScriptableObject, so Unity needs a MonoScript for it, which needs a file of the same name. + class ShadowCasterPathUndoTests + { + // Serialized so it survives the domain reload on exiting Play mode, which runs before the assert. + [SerializeField] + List m_MissingScriptWarnings = new List(); + + void OnLogMessage(string message, string stackTrace, LogType type) + { + if (message.Contains("No script asset for")) + m_MissingScriptWarnings.Add(message); + } + + static ShadowCasterPath CreateShadowCasterPath() + { + var path = ScriptableObject.CreateInstance(); + path.hideFlags = HideFlags.HideAndDontSave; + return path; + } + + [Test] + public void ShadowCasterPath_HasMonoScript() + { + var path = CreateShadowCasterPath(); + try + { + var script = MonoScript.FromScriptableObject(path); + Assert.IsNotNull(script, "ShadowCasterPath has no MonoScript."); + Assert.AreEqual(typeof(ShadowCasterPath), script.GetClass()); + } + finally + { + UnityEngine.Object.DestroyImmediate(path); + } + } + + [UnityTest] + public IEnumerator UndoShadowCasterPathInPlayMode_DoesNotWarnAboutMissingScript() + { + return UndoShadowCasterPathInPlayMode(false); + } + + [UnityTest] + public IEnumerator UndoRedoShadowCasterPathInPlayMode_DoesNotWarnAboutMissingScript() + { + return UndoShadowCasterPathInPlayMode(true); + } + + IEnumerator UndoShadowCasterPathInPlayMode(bool redo) + { + yield return new EnterPlayMode(); + + var path = CreateShadowCasterPath(); + m_MissingScriptWarnings.Clear(); + Application.logMessageReceived += OnLogMessage; + try + { + Undo.IncrementCurrentGroup(); + Undo.RegisterCompleteObjectUndo(path, "Edit Shadow Caster Shape"); + Undo.FlushUndoRecordObjects(); + Undo.IncrementCurrentGroup(); + Undo.PerformUndo(); + if (redo) + Undo.PerformRedo(); + } + finally + { + Application.logMessageReceived -= OnLogMessage; + Undo.ClearUndo(path); + UnityEngine.Object.DestroyImmediate(path); + } + + yield return new ExitPlayMode(); + + Assert.IsEmpty(m_MissingScriptWarnings); + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs.meta new file mode 100644 index 00000000000..4dcf7e5aa13 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCasterPathUndoTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7c3e1a5d9b2f4e8a6d0c4b1f3a92e57d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From 34f5a22416b7a05a6214a41a10305c3b4e781f06 Mon Sep 17 00:00:00 2001 From: Chris Chu Date: Mon, 26 Oct 2026 14:16:05 +0000 Subject: [PATCH 11/22] [Port] [6000.0] [UUM-147033] Fix 2D collider shadow flicker across Editor views --- .../Runtime/2D/Shadows/ShadowCaster2D.cs | 11 +- .../ShadowShape2DProvider_Collider.cs | 15 ++ .../2D/Shadows/ShadowProvider/ShadowMesh2D.cs | 11 + .../ShadowProvider/ShadowShape2DProvider.cs | 8 + .../ShadowCaster2DColliderCullingTests.cs | 201 ++++++++++++++++++ ...ShadowCaster2DColliderCullingTests.cs.meta | 11 + ...derPipelines.Universal.Editor.Tests.asmdef | 8 +- 7 files changed, 263 insertions(+), 2 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowCaster2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowCaster2D.cs index 97f3761784a..98cabb77824 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowCaster2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowCaster2D.cs @@ -484,7 +484,16 @@ public void Update() } if(m_ShadowMesh != null) - m_ShadowMesh.UpdateBoundingSphere(transform); + { + // The shadow mesh is culled to the last camera that rendered, so a provider that knows the + // whole shape's bounds sizes the sphere instead. Then IsLit does not depend on the camera. + if (m_ShadowCastingSource == ShadowCastingSources.ShapeProvider && + m_ShadowShape2DProvider != null && m_ShadowShape2DComponent != null && + m_ShadowShape2DProvider.TryGetWorldBounds(m_ShadowShape2DComponent, out var worldBounds)) + m_ShadowMesh.SetBoundingSphere(worldBounds, transform.position.z); + else + m_ShadowMesh.UpdateBoundingSphere(transform); + } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/Providers/ShadowShape2DProvider_Collider.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/Providers/ShadowShape2DProvider_Collider.cs index 2565b080a5e..513d2b02225 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/Providers/ShadowShape2DProvider_Collider.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/Providers/ShadowShape2DProvider_Collider.cs @@ -354,6 +354,21 @@ public override void OnPersistantDataCreated(Component sourceComponent, ShadowSh m_LastColliderSpace = Matrix4x4.identity; } + internal override bool TryGetWorldBounds(Component sourceComponent, out Bounds worldBounds) + { + var collider = sourceComponent as Collider2D; + if (collider == null || !collider.isActiveAndEnabled || collider.shapeCount == 0) + { + worldBounds = default; + return false; + } + + // Read every time rather than cached. A cache keyed on the pose would keep bounds that were + // read before Physics2D synced a move. + worldBounds = collider.bounds; + return true; + } + public override void OnBeforeRender(Component sourceComponent, Bounds worldCullingBounds, ShadowShape2D persistantShadowShape) { Collider2D collider = (Collider2D)sourceComponent; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs index 3d5899d5b44..1397a90cd78 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs @@ -415,5 +415,16 @@ public void UpdateBoundingSphere(Transform transform) m_BoundingSphere = new BoundingSphere(center, radius); } + + // Sets the bounding sphere from world bounds. Only the x and y extents size it, so the bounds' + // z depth cannot inflate it. The center's z is given by the caller. + internal void SetBoundingSphere(Bounds worldBounds, float z) + { + var center = new Vector3(worldBounds.center.x, worldBounds.center.y, z); + var extents = worldBounds.extents; + var radius = new Vector2(extents.x, extents.y).magnitude; + + m_BoundingSphere = new BoundingSphere(center, radius); + } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowShape2DProvider.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowShape2DProvider.cs index 80b18e26f0d..c3efb2c19a2 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowShape2DProvider.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowShape2DProvider.cs @@ -41,6 +41,14 @@ public virtual void Enabled(Component sourceComponent, ShadowShape2D persistan /// An instance of ShadowShape2D that is used by the ShadowCaster2D public virtual void Disabled(Component sourceComponent, ShadowShape2D persistantShadowShape) {} + // World bounds of the whole source shape, independent of any camera's culling. When this returns + // true, the ShadowCaster2D sizes its bounding sphere from them instead of from the (culled) shadow mesh. + internal virtual bool TryGetWorldBounds(Component sourceComponent, out Bounds worldBounds) + { + worldBounds = default; + return false; + } + /// /// Called for each component on a ShadowCaster2D's GameObject. Returns true if the provided component is the data source of the ShadowShapeProvider. /// diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs new file mode 100644 index 00000000000..568a182f73b --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs @@ -0,0 +1,201 @@ +#if USING_PHYSICS2D +using NUnit.Framework; +using UnityEngine; +using UnityEngine.Rendering.Universal; + +namespace UnityEditor.Rendering.Universal.Tests +{ + /// + /// UUM-147033: a ShadowCaster2D whose casting source is a Collider2D must keep one bounding sphere + /// whichever camera rendered last. + /// + /// Every camera shares the caster's shadow mesh, and ShadowShape2DProvider_Collider2D culls that mesh + /// to the bounds of the camera being rendered. ShadowCaster2D.Update used to size the bounding sphere + /// from the culled mesh, and IsLit tests lights against that sphere. So after a small camera (the + /// Game view, or the Inspector preview camera) the sphere shrank, and the next view skipped the shadow + /// for lights outside it. In the Editor this showed as shadows that flicker between views. + /// + [TestFixture] + class ShadowCaster2DColliderCullingTests + { + const float k_Tolerance = 0.01f; + + GameObject m_GameObject; + + [TearDown] + public void TearDown() + { + Object.DestroyImmediate(m_GameObject); + } + + static Vector2[] Box(float centerX, float centerY) + { + return new[] + { + new Vector2(centerX - 1, centerY - 1), new Vector2(centerX + 1, centerY - 1), + new Vector2(centerX + 1, centerY + 1), new Vector2(centerX - 1, centerY + 1) + }; + } + + // Two separate boxes, like the far ends of a tilemap collider. Two shapes are needed, because the + // provider culls whole shapes, so a single box is never trimmed. + static PolygonCollider2D AddTwoBoxCollider(GameObject gameObject, float leftX, float rightX) + { + var collider = gameObject.AddComponent(); + collider.pathCount = 2; + collider.SetPath(0, Box(leftX, 0)); + collider.SetPath(1, Box(rightX, 0)); + return collider; + } + + static ShadowCaster2D AddColliderCaster(GameObject gameObject, Component collider) + { + var caster = gameObject.AddComponent(); + caster.shadowCastingSource = ShadowCaster2D.ShadowCastingSources.ShapeProvider; + caster.shadowShape2DComponent = collider; + caster.shadowShape2DProvider = new ShadowShape2DProvider_Collider2D(); + caster.m_ForceShadowMeshRebuild = true; + caster.Update(); + return caster; + } + + static void RenderWithCullingBounds(ShadowCaster2D caster, Bounds cullingBounds) + { + ShapeProviderUtility.CallOnBeforeRender(caster.shadowShape2DProvider, caster.shadowShape2DComponent, caster.m_ShadowMesh, cullingBounds); + caster.Update(); + } + + static void AssertSameSphere(BoundingSphere expected, BoundingSphere actual) + { + Assert.That(actual.radius, Is.EqualTo(expected.radius).Within(k_Tolerance), + $"The bounding sphere changed with the last camera's culling bounds (center {actual.position}, radius {actual.radius}; " + + $"expected center {expected.position}, radius {expected.radius}). IsLit then rejects lights the other views still need."); + Assert.That(Vector3.Distance(actual.position, expected.position), Is.LessThan(k_Tolerance), + $"The bounding sphere center moved to {actual.position} (expected {expected.position})."); + } + + static void AssertCovers(BoundingSphere sphere, Vector2 point) + { + var distance = Vector2.Distance(new Vector2(sphere.position.x, sphere.position.y), point); + Assert.That(distance, Is.LessThanOrEqualTo(sphere.radius + k_Tolerance), + $"The bounding sphere (center {sphere.position}, radius {sphere.radius}) does not cover {point}."); + } + + [Test] + public void ColliderShadowCaster_BoundingSphere_DoesNotDependOnLastCameraCullingBounds() + { + m_GameObject = new GameObject("UUM-147033 Caster"); + var collider = AddTwoBoxCollider(m_GameObject, -20, 20); + var caster = AddColliderCaster(m_GameObject, collider); + + // A camera that sees the whole collider, like a zoomed-out Scene view. + RenderWithCullingBounds(caster, new Bounds(Vector3.zero, new Vector3(100, 100, 1000))); + var fullSphere = caster.boundingSphere; + + // A small camera that sees only the left box, like the Game view or the Inspector preview. + RenderWithCullingBounds(caster, new Bounds(new Vector3(-20, 0, 0), new Vector3(4, 4, 1000))); + AssertSameSphere(fullSphere, caster.boundingSphere); + + // The sphere covers both boxes. The radius is sqrt(21^2 + 1^2) plus the polygon skin radius. + Assert.That(Vector2.Distance(fullSphere.position, Vector2.zero), Is.LessThan(k_Tolerance), $"Center is {fullSphere.position}."); + Assert.That(fullSphere.radius, Is.GreaterThanOrEqualTo(21f)); + } + + [Test] + public void ColliderShadowCaster_OffsetFromOrigin_BoundingSphereUnchangedWhenViewMissesCollider() + { + m_GameObject = new GameObject("UUM-147033 Offset Caster"); + var collider = AddTwoBoxCollider(m_GameObject, 100, 140); + var caster = AddColliderCaster(m_GameObject, collider); + + // A view at the GameObject origin that sees none of the collider. The provider empties the mesh, + // but the sphere must still cover both boxes. + var missView = new Bounds(Vector3.zero, new Vector3(10, 10, 1000)); + RenderWithCullingBounds(caster, missView); + var missSphere = caster.boundingSphere; + Assert.That(Vector2.Distance(missSphere.position, new Vector2(120, 0)), Is.LessThan(k_Tolerance), $"Center is {missSphere.position}."); + Assert.That(missSphere.radius, Is.GreaterThanOrEqualTo(21f)); + + RenderWithCullingBounds(caster, new Bounds(new Vector3(120, 0, 0), new Vector3(100, 100, 1000))); + AssertSameSphere(missSphere, caster.boundingSphere); + + RenderWithCullingBounds(caster, new Bounds(new Vector3(140, 0, 0), new Vector3(4, 4, 1000))); + AssertSameSphere(missSphere, caster.boundingSphere); + + RenderWithCullingBounds(caster, missView); + AssertSameSphere(missSphere, caster.boundingSphere); + } + + [Test] + public void ColliderShadowCaster_RotatedRigidbody_BoundingSphereCoversRotatedShapes() + { + m_GameObject = new GameObject("UUM-147033 Rotated Caster"); + m_GameObject.transform.SetPositionAndRotation(new Vector3(5, 5, 0), Quaternion.Euler(0, 0, 90)); + var body = m_GameObject.AddComponent(); + body.bodyType = RigidbodyType2D.Kinematic; + var collider = AddTwoBoxCollider(m_GameObject, 10, 50); + var caster = AddColliderCaster(m_GameObject, collider); + + RenderWithCullingBounds(caster, new Bounds(new Vector3(5, 35, 0), new Vector3(100, 100, 1000))); + var fullSphere = caster.boundingSphere; + + // Rotating by 90 degrees about (5,5) moves the boxes at local x=10 and x=50 to world (5,15) and (5,55). + foreach (var center in new[] { new Vector2(5, 15), new Vector2(5, 55) }) + foreach (var corner in Box(center.x, center.y)) + AssertCovers(fullSphere, corner); + + // A small view on the lower box only. + RenderWithCullingBounds(caster, new Bounds(new Vector3(5, 15, 0), new Vector3(4, 4, 1000))); + AssertSameSphere(fullSphere, caster.boundingSphere); + } + + [Test] + public void ColliderShadowCaster_DisabledOrEmptyCollider_FallsBackWithoutExceptions() + { + m_GameObject = new GameObject("UUM-147033 Disabled Caster"); + var collider = AddTwoBoxCollider(m_GameObject, -20, 20); + var caster = AddColliderCaster(m_GameObject, collider); + var provider = caster.shadowShape2DProvider; + var wholeView = new Bounds(Vector3.zero, new Vector3(100, 100, 1000)); + RenderWithCullingBounds(caster, wholeView); + Assert.That(provider.TryGetWorldBounds(collider, out _), Is.True, "An enabled collider with shapes gives bounds."); + + collider.enabled = false; + Assert.DoesNotThrow(() => RenderWithCullingBounds(caster, wholeView)); + Assert.That(provider.TryGetWorldBounds(collider, out _), Is.False, "A disabled collider gives no bounds."); + + // Re-enabled with no shapes, like a TilemapCollider2D merged into a CompositeCollider2D. + collider.enabled = true; + collider.pathCount = 0; + Assert.DoesNotThrow(() => RenderWithCullingBounds(caster, wholeView)); + Assert.That(provider.TryGetWorldBounds(collider, out _), Is.False, "A collider with no shapes gives no bounds."); + + // Shapes come back: the bounds are read again, not reused from before. + collider.pathCount = 1; + collider.SetPath(0, Box(60, 0)); + Assert.DoesNotThrow(() => RenderWithCullingBounds(caster, new Bounds(new Vector3(60, 0, 0), new Vector3(100, 100, 1000)))); + Assert.That(provider.TryGetWorldBounds(collider, out var bounds), Is.True); + Assert.That(Vector2.Distance(bounds.center, new Vector2(60, 0)), Is.LessThan(k_Tolerance), $"Bounds center is {bounds.center}."); + Assert.That(Vector2.Distance(caster.boundingSphere.position, new Vector2(60, 0)), Is.LessThan(k_Tolerance)); + } + + [Test] + public void ColliderShadowCaster_NullProviderOrComponent_DoesNotThrow() + { + m_GameObject = new GameObject("UUM-147033 Null Caster"); + var collider = AddTwoBoxCollider(m_GameObject, -20, 20); + var caster = AddColliderCaster(m_GameObject, collider); + + caster.shadowShape2DComponent = null; + Assert.DoesNotThrow(() => caster.Update(), "Null component"); + + caster.shadowShape2DComponent = collider; + caster.shadowShape2DProvider = null; + Assert.DoesNotThrow(() => caster.Update(), "Null provider"); + + caster.shadowShape2DComponent = null; + Assert.DoesNotThrow(() => caster.Update(), "Null provider and component"); + } + } +} +#endif diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs.meta new file mode 100644 index 00000000000..abb02b3aad1 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/ShadowCaster2DColliderCullingTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7c1e4a9b3f2d4e6a8b5c0d9e1f2a3b47 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Unity.RenderPipelines.Universal.Editor.Tests.asmdef b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Unity.RenderPipelines.Universal.Editor.Tests.asmdef index 96f828baf9a..4b0bba957b3 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Editor/Unity.RenderPipelines.Universal.Editor.Tests.asmdef +++ b/Packages/com.unity.render-pipelines.universal/Tests/Editor/Unity.RenderPipelines.Universal.Editor.Tests.asmdef @@ -24,6 +24,12 @@ "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.modules.physics2d", + "expression": "0.0.0", + "define": "USING_PHYSICS2D" + } + ], "noEngineReferences": false } \ No newline at end of file From 5058c2eb16e30cd6f9592668b53b799db18a99a4 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 27 Oct 2026 22:57:04 +0000 Subject: [PATCH 12/22] [Port] [6000.0] Fix passes never merging once a native pass exceeds the tile storage limit --- .../Runtime/RenderGraph/Compiler/PassesData.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs index 4d3e715be9c..6c338171306 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs @@ -824,6 +824,10 @@ public static PassBreakAudit CanMerge(CompilerContextData contextData, int activ static bool TotalAttachmentsSizeExceedPixelStorageLimit(CompilerContextData contextData, ref NativePassData nativePass, ref FixedAttachmentArray attachmentsToTryAdding) { + // A merge that adds no attachment cannot grow the tile footprint, so it can never exceed the limit + if (attachmentsToTryAdding.size == 0) + return false; + // TODO: We are currently only checking for iOS GPU Family 1 to 3 since the storage size is much more restricted (16 bytes for Family 1 and 32 for Family 2 & 3). // This is temporary. Later on, we should check all iOS GPU Families but also Android (Vulkan) to avoid the same potential restrictions. if (Application.platform == RuntimePlatform.IPhonePlayer && SystemInfo.maxTiledPixelStorageSize <= 32) From a9c32f0311a9e007bd33121da2a1278f99c9457b Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 27 Oct 2026 22:57:04 +0000 Subject: [PATCH 13/22] [Port] [6000.0] [6000.3] [URP] [ShaderGraph] [UUM-155529] Fix LOD Cross Fade include leaking into other Shader Graphs imported in the same session --- .../Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs | 2 +- .../Editor/ShaderGraph/Targets/UniversalTarget.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs index b3460eebf15..a0d688405f7 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalLitSubTarget.cs @@ -432,7 +432,7 @@ public static PassDescriptor Forward( pragmas = pragmas ?? CorePragmas.Forward, // NOTE: SM 2.0 only GL defines = new DefineCollection() { CoreDefines.UseFragmentFog }, keywords = new KeywordCollection() { keywords }, - includes = LitIncludes.Forward, + includes = new IncludeCollection { LitIncludes.Forward }, // Custom Interpolator Support customInterpolators = CoreCustomInterpDescriptors.Common diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs index 23ddc579448..b1f212f7fcb 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs @@ -1158,7 +1158,7 @@ public static PassDescriptor MotionVectors(UniversalTarget target) pragmas = CorePragmas.MotionVectors, defines = new DefineCollection(), keywords = new KeywordCollection(), - includes = CoreIncludes.MotionVectors, + includes = new IncludeCollection { CoreIncludes.MotionVectors }, // Custom Interpolator Support customInterpolators = CoreCustomInterpDescriptors.Common From 782166e45f0fcb5c4f905d1ab6a38ec95eda688a Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 27 Oct 2026 22:57:05 +0000 Subject: [PATCH 14/22] [Port] [6000.0] [UUM-137732] Fix APV probe placement on Vulkan with AMD GPUs --- .../Editor/Lighting/ProbeVolume/VoxelizeScene.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/VoxelizeScene.hlsl b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/VoxelizeScene.hlsl index b64a75118c6..7690ea91fc0 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/VoxelizeScene.hlsl +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/VoxelizeScene.hlsl @@ -23,7 +23,7 @@ CBUFFER_END #define unity_ObjectToWorld _TreeInstanceToWorld[unity_InstanceID] #endif -RWTexture3D _Output : register(u4); +RWTexture3D _Output : register(u4); float3 _OutputSize; float3 _VolumeWorldOffset; float3 _VolumeSize; From 9488d2a72f65489db91c141585f3a80df2fb0584 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 27 Oct 2026 22:57:05 +0000 Subject: [PATCH 15/22] [Port] [6000.0] [UUM-157948] [URP] [7000.0] Fix RenderGraph sample errors when no depth buffer exists --- .../RendererList/RendererListRenderFeature.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Samples~/URPRenderGraphSamples/RendererList/RendererListRenderFeature.cs b/Packages/com.unity.render-pipelines.universal/Samples~/URPRenderGraphSamples/RendererList/RendererListRenderFeature.cs index decc8904fa6..f2c8845151e 100644 --- a/Packages/com.unity.render-pipelines.universal/Samples~/URPRenderGraphSamples/RendererList/RendererListRenderFeature.cs +++ b/Packages/com.unity.render-pipelines.universal/Samples~/URPRenderGraphSamples/RendererList/RendererListRenderFeature.cs @@ -97,7 +97,10 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer // Setup as a render target via UseTextureFragment and UseTextureFragmentDepth, which are the equivalent of using the old cmd.SetRenderTarget(color,depth) builder.SetRenderAttachment(resourceData.activeColorTexture, 0); - builder.SetRenderAttachmentDepth(resourceData.activeDepthTexture, AccessFlags.Write); + + // The active depth texture is not valid when the renderer has no depth buffer. + if (resourceData.activeDepthTexture.IsValid()) + builder.SetRenderAttachmentDepth(resourceData.activeDepthTexture, AccessFlags.Write); // Assign the ExecutePass function to the render pass delegate, which will be called by the render graph when executing the pass builder.SetRenderFunc((PassData data, RasterGraphContext context) => ExecutePass(data, context)); From f75ff27d08be5a0c21de12963ae7300ad17a0159 Mon Sep 17 00:00:00 2001 From: Chris Chu Date: Wed, 28 Oct 2026 05:19:04 +0000 Subject: [PATCH 16/22] [Port] [6000.0] [UUM-149925] Clear the shadow mesh when a shape source has no geometry --- .../2D/Shadows/ShadowProvider/ShadowMesh2D.cs | 11 ++-- .../Tests/Runtime/ShadowCaster2DTests.cs | 56 +++++++++++++++++++ .../Tests/Runtime/ShadowCaster2DTests.cs.meta | 11 ++++ ...erPipelines.Universal.Runtime.Tests.asmdef | 11 +++- 4 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs create mode 100644 Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs.meta diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs index 1397a90cd78..ee0997cf8e8 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Shadows/ShadowProvider/ShadowMesh2D.cs @@ -318,8 +318,11 @@ bool AreDegenerateVertices(NativeArray vertices) public override void SetShape(NativeArray vertices, NativeArray indices, ShadowShape2D.OutlineTopology outlineTopology, ShadowShape2D.WindingOrder windingOrder = ShadowShape2D.WindingOrder.Clockwise, bool allowTrimming = true, bool createInteriorGeometry = false) { - if (AreDegenerateVertices(vertices)) + if (AreDegenerateVertices(vertices) || indices == null || indices.Length == 0) + { + m_Mesh?.Clear(); return; + } if (m_TrimEdge == k_TrimEdgeUninitialized) m_TrimEdge = m_InitialTrim; @@ -333,12 +336,6 @@ public override void SetShape(NativeArray vertices, NativeArray in if (m_Mesh == null) m_Mesh = new Mesh(); - if (indices.Length == 0) - { - m_Mesh.Clear(); - return; - } - if (outlineTopology == ShadowShape2D.OutlineTopology.Triangles) { NativeArray newVertices; diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs new file mode 100644 index 00000000000..da84421001e --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs @@ -0,0 +1,56 @@ +#if U2D_ANIMATION_INSTALLED +using NUnit.Framework; +using UnityEngine.U2D.Animation; + +namespace UnityEngine.Rendering.Universal.Tests +{ + class ShadowCaster2DTests + { + GameObject m_Obj; + + [SetUp] + public void Setup() + { + m_Obj = new GameObject(); + m_Obj.AddComponent(); + } + + [TearDown] + public void Cleanup() + { + Object.DestroyImmediate(m_Obj); + } + + [Test] + public void AddShadowCaster2DWithSpriteSkin() + { + m_Obj.AddComponent(); + ShadowCaster2D shadowCaster2D = m_Obj.AddComponent(); + +// ShadowCaster2D.shadowShape2DProvider is always null on Standalone. +#if UNITY_EDITOR + Assert.That(shadowCaster2D.shadowShape2DProvider, Is.TypeOf(typeof(ShadowShape2DProvider_SpriteSkin))); +#else + Assert.That(shadowCaster2D.shadowShape2DProvider, Is.Null); +#endif + } + + [Test] + public void AddShadowCaster2DWithSpriteSkinWhenInactive() + { + m_Obj.AddComponent(); + m_Obj.SetActive(false); + ShadowCaster2D shadowCaster2D = m_Obj.AddComponent(); + Assert.That(shadowCaster2D.shadowShape2DProvider, Is.Null); + + m_Obj.SetActive(true); +// ShadowCaster2D.shadowShape2DProvider is always null on Standalone. +#if UNITY_EDITOR + Assert.That(shadowCaster2D.shadowShape2DProvider, Is.TypeOf(typeof(ShadowShape2DProvider_SpriteSkin))); +#else + Assert.That(shadowCaster2D.shadowShape2DProvider, Is.Null); +#endif + } + } +} +#endif diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs.meta b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs.meta new file mode 100644 index 00000000000..a7db3171516 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/ShadowCaster2DTests.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cf9e72a1bdd854b65a42b0d13738efcd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Unity.RenderPipelines.Universal.Runtime.Tests.asmdef b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Unity.RenderPipelines.Universal.Runtime.Tests.asmdef index 13cdbdae9cf..502762ff501 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Unity.RenderPipelines.Universal.Runtime.Tests.asmdef +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/Unity.RenderPipelines.Universal.Runtime.Tests.asmdef @@ -7,7 +7,8 @@ "GUID:0acc523941302664db1f4e527237feb3", "GUID:516a5277b8c3b4f4c8cc86b77b1591ff", "GUID:d8b63aba1907145bea998dd612889d6b", - "GUID:df380645f10b7bc4b97d4f5eb6303d95" + "GUID:df380645f10b7bc4b97d4f5eb6303d95", + "GUID:41524c21c95e5fe4dbc5b48bd21995a4" ], "includePlatforms": [], "excludePlatforms": [], @@ -20,6 +21,12 @@ "defineConstraints": [ "UNITY_INCLUDE_TESTS" ], - "versionDefines": [], + "versionDefines": [ + { + "name": "com.unity.2d.animation", + "expression": "1.0.0", + "define": "U2D_ANIMATION_INSTALLED" + } + ], "noEngineReferences": false } \ No newline at end of file From ee324780548046bd5d020389152317927eedf05c Mon Sep 17 00:00:00 2001 From: Sebastien Dalgo Date: Fri, 30 Oct 2026 02:23:52 +0000 Subject: [PATCH 17/22] [Port] [6000.0] [UUM-159140 Save URP asset before build --- .../Editor/ShaderBuildPreprocessor.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs index 858934da750..9e5a0a8cb4c 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs @@ -403,8 +403,12 @@ private static void GetEveryShaderFeatureAndUpdateURPAssets(List // Update the Prefiltering settings for this URP asset urpAsset.UpdateShaderKeywordPrefiltering(ref spd); - // Mark the asset dirty so it can be serialized once the build is finished - EditorUtility.SetDirty(urpAsset); + if (!AssetDatabase.IsAssetImportWorkerProcess()) + { + // Save the asset before build + EditorUtility.SetDirty(urpAsset); + AssetDatabase.SaveAssetIfDirty(urpAsset); + } } } } @@ -461,8 +465,12 @@ ref ssaoRendererFeatures // Update the Prefiltering settings for this URP asset urpAsset.UpdateShaderKeywordPrefiltering(ref spd); - // Mark the asset dirty so it can be serialized once the build is finished - EditorUtility.SetDirty(urpAsset); + if (!AssetDatabase.IsAssetImportWorkerProcess()) + { + // Save the asset before build + EditorUtility.SetDirty(urpAsset); + AssetDatabase.SaveAssetIfDirty(urpAsset); + } // Clean up ssaoRendererFeatures.Clear(); From b8207e93928ea16a901493fa423cd51d90602df8 Mon Sep 17 00:00:00 2001 From: Yohann Vaast Date: Fri, 30 Oct 2026 02:23:52 +0000 Subject: [PATCH 18/22] [Port] [6000.0] [UUM-158401] [SRP] Apply the native subpass limit to native subpasses, not Render Graph passes --- .../RenderGraph/Compiler/PassesData.cs | 23 +++- .../NativePassCompilerRenderGraphTests.cs | 101 ++++++++++++++++++ 2 files changed, 120 insertions(+), 4 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs index 6c338171306..aa9b2b3737e 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs @@ -582,12 +582,18 @@ public SubPassFlags GetSubPassFlagForMerging() throw new Exception("SubPassFlag for merging can not be determined if native pass doesn't have a depth attachment"); } + // Depth attachment is always at index 0. + return GetSubPassFlagForMerging(fragments[0].accessFlags); + } + + // Same as above, from the access flags of the native pass depth attachment. + static SubPassFlags GetSubPassFlagForMerging(AccessFlags depthAccessFlags) + { // Only do this for mobile using Vulkan. #if (PLATFORM_ANDROID) if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Vulkan) { - // Depth attachment is always at index 0. - return (fragments[0].accessFlags.HasFlag(AccessFlags.Write)) ? SubPassFlags.None : SubPassFlags.ReadOnlyDepth; + return (depthAccessFlags.HasFlag(AccessFlags.Write)) ? SubPassFlags.None : SubPassFlags.ReadOnlyDepth; } else { @@ -812,8 +818,9 @@ public static PassBreakAudit CanMerge(CompilerContextData contextData, int activ return new PassBreakAudit(PassBreakReason.AttachmentLimitReached, passIdToMerge); } + // The limit is on native subpasses: graph passes merged into the same native subpass don't count. bool canMergeNativeSubPass = CanMergeNativeSubPass(contextData, nativePass, passToMerge); - if (!canMergeNativeSubPass && nativePass.numGraphPasses + 1 > NativePassCompiler.k_MaxSubpass) + if (!canMergeNativeSubPass && nativePass.numNativeSubPasses + 1 > NativePassCompiler.k_MaxSubpass) { return new PassBreakAudit(PassBreakReason.SubPassLimitReached, passIdToMerge); } @@ -963,8 +970,16 @@ static bool CanMergeNativeSubPass(CompilerContextData contextData, NativePassDat } } + // If the native pass gets its depth attachment from this merge, TryMerge adds it first and updates + // the flags of the existing subpasses, the last one included (see AddDepthAttachmentFirstDuringMerge) + SubPassFlags lastPassFlags = lastPass.flags; + if (passToMerge.fragmentInfoHasDepth && !nativePass.hasDepth) + { + lastPassFlags |= GetSubPassFlagForMerging(contextData.fragmentData[passToMerge.firstFragment].accessFlags); + } + // last check for flags - return flags == lastPass.flags; + return flags == lastPassFlags; } // Try to merge the new graph pass into the last native sub pass or create a new one in the current native pass. diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs index 86eaf46c9b2..d6b1c2d47cd 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs @@ -538,6 +538,107 @@ public void NativeSubPassesLimitNotExceeded() Assert.AreEqual(Rendering.RenderGraphModule.NativeRenderPassCompiler.PassBreakReason.SubPassLimitReached, passes[0].breakAudit.reason); } + [Test] + public void NativeSubPassesLimitIgnoresGraphPassesMergedIntoSameSubPass() + { + var g = AllocateRenderGraph(); + var renderTargets = ImportAndCreateBuffers(g); + + // More graph passes than the native subpasses limit, all using the same attachments so they share a single native subpass + for (int i = 0; i < Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass + 2; i++) + { + using (var builder = g.AddRasterRenderPass($"TestPass_{i}", out var passData)) + { + builder.SetRenderAttachmentDepth(renderTargets.extraDepthBuffer, AccessFlags.Write); + builder.SetRenderAttachment(renderTargets.extraBuffers[0], 0, AccessFlags.Write); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { }); + builder.AllowPassCulling(false); + } + } + + // Different color attachment, so this graph pass needs a second native subpass + using (var builder = g.AddRasterRenderPass("TestPass_NewSubPass", out var passData)) + { + builder.SetRenderAttachmentDepth(renderTargets.extraDepthBuffer, AccessFlags.Write); + builder.SetRenderAttachment(renderTargets.extraBuffers[1], 0, AccessFlags.Write); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { }); + builder.AllowPassCulling(false); + } + + var result = g.CompileNativeRenderGraph(g.ComputeGraphHash()); + var passes = result.contextData.GetNativePasses(); + + Assert.AreEqual(1, passes.Count); + Assert.AreEqual(Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass + 3, passes[0].numGraphPasses); + Assert.AreEqual(2, passes[0].numNativeSubPasses); + } + + [Test] + public void NativeSubPassesLimitReachedWithMultipleGraphPassesPerSubPass() + { + var g = AllocateRenderGraph(); + var renderTargets = ImportAndCreateBuffers(g); + + // Two graph passes per native subpass, alternating the color attachment so that each pair needs a new native subpass, + // one pair more than the native subpasses limit + for (int i = 0; i < 2 * (Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass + 1); i++) + { + using (var builder = g.AddRasterRenderPass($"TestPass_{i}", out var passData)) + { + builder.SetRenderAttachmentDepth(renderTargets.extraDepthBuffer, AccessFlags.Write); + builder.SetRenderAttachment(renderTargets.extraBuffers[(i / 2) % 2], 0, AccessFlags.Write); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { }); + builder.AllowPassCulling(false); + } + } + + var result = g.CompileNativeRenderGraph(g.ComputeGraphHash()); + var passes = result.contextData.GetNativePasses(); + + Assert.AreEqual(2, passes.Count); + Assert.AreEqual(2 * Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass, passes[0].numGraphPasses); + Assert.AreEqual(Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass, passes[0].numNativeSubPasses); + Assert.AreEqual(Rendering.RenderGraphModule.NativeRenderPassCompiler.PassBreakReason.SubPassLimitReached, passes[0].breakAudit.reason); + Assert.AreEqual(2, passes[1].numGraphPasses); + Assert.AreEqual(1, passes[1].numNativeSubPasses); + } + + [Test] + public void NativeSubPassesLimitNotExceededWhenMergedPassAddsDepth() + { + var g = AllocateRenderGraph(); + var renderTargets = ImportAndCreateBuffers(g); + + // As many graph passes as the native subpasses limit, without depth and alternating the color attachment, so one native subpass each + for (int i = 0; i < Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass; i++) + { + using (var builder = g.AddRasterRenderPass($"TestPass_{i}", out var passData)) + { + builder.SetRenderAttachment(renderTargets.extraBuffers[i % 2], 0, AccessFlags.Write); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { }); + builder.AllowPassCulling(false); + } + } + + // Same color attachment as the last native subpass, but this graph pass brings the depth attachment of the native pass, + // which changes the flags of the existing native subpasses when merged + using (var builder = g.AddRasterRenderPass("TestPass_AddsDepth", out var passData)) + { + builder.SetRenderAttachmentDepth(renderTargets.extraDepthBuffer, AccessFlags.Write); + builder.SetRenderAttachment(renderTargets.extraBuffers[(Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass - 1) % 2], 0, AccessFlags.Write); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext context) => { }); + builder.AllowPassCulling(false); + } + + var result = g.CompileNativeRenderGraph(g.ComputeGraphHash()); + var passes = result.contextData.GetNativePasses(); + + foreach (var pass in passes) + { + Assert.LessOrEqual(pass.numNativeSubPasses, Rendering.RenderGraphModule.NativeRenderPassCompiler.NativePassCompiler.k_MaxSubpass); + } + } + [Test] public void AllocateFreeInMergedPassesWorks() { From 4e5d135e91fbb4e28e653dd4c5763a035913e4e0 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Wed, 4 Nov 2026 02:07:00 +0000 Subject: [PATCH 19/22] [Port] [6000.0] [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 | 69 +++++++++++++++++-- 3 files changed, 89 insertions(+), 11 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 71d5d6e55f7..1805e25d21b 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 @@ -53,7 +53,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, Renderer2DData 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 7b1b03a7cca..c2372964375 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 @@ -81,6 +81,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; @@ -355,10 +375,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 { @@ -373,9 +390,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; + ImportResourceSummary importSummary = GetImportResourceSummary(renderGraph, cameraData); if (m_CreateColorTexture) @@ -412,7 +431,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 d708515ed32..1ead87c90cf 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, @@ -97,6 +98,7 @@ public void SetUp() public void TearDown() { RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering; + m_ProbePass.requiresIntermediateTexture = false; if (m_RendererData != null) Renderer2DDepthUsageTests.SetUseDepthStencilBuffer(m_RendererData, m_PreviousUseDepthStencilBuffer); @@ -126,13 +128,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] @@ -146,6 +179,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() { @@ -171,6 +220,9 @@ class BackbufferDepthProbePass : ScriptableRenderPass { public bool recorded; public bool backBufferDepthIsValid; + public bool activeDepthIsValid; + public bool activeDepthIsBackBufferDepth; + public bool activeColorIsBackBuffer; public BackbufferDepthProbePass() { @@ -184,6 +236,9 @@ public void Reset() { recorded = false; backBufferDepthIsValid = false; + activeDepthIsValid = false; + activeDepthIsBackBufferDepth = false; + activeColorIsBackBuffer = false; } public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData) @@ -192,6 +247,10 @@ public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer recorded = true; backBufferDepthIsValid = resourceData.backBufferDepth.IsValid(); + activeDepthIsValid = resourceData.activeDepthTexture.IsValid(); + // TextureHandle has no equality operator on this branch, so check which target the active depth resolves to + activeDepthIsBackBufferDepth = activeDepthIsValid && resourceData.activeDepthID == UniversalResourceData.ActiveID.BackBuffer; + activeColorIsBackBuffer = resourceData.isActiveTargetBackBuffer; } } } From c2850f2a18b111b9a03be492389177028ab8a250 Mon Sep 17 00:00:00 2001 From: Reach Platform Support Date: Tue, 10 Nov 2026 13:38:42 +0000 Subject: [PATCH 20/22] [Port] [6000.0] 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 14927479808c11f447ba8a5b120c1437cae158a1 Mon Sep 17 00:00:00 2001 From: Rose Hirigoyen Date: Wed, 11 Nov 2026 22:00:38 +0000 Subject: [PATCH 21/22] [Port] [6000.0] [UUM-147726] Fix render requests to cubemaps rendering nothing --- .../Runtime/UniversalRenderPipeline.cs | 4 + .../Tests/Runtime/RuntimeTests.cs | 115 ++++++++++++++++++ 2 files changed, 119 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs index 5fcb4b12888..646b5840cc8 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs @@ -562,6 +562,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 1bca05b7aa3..094a19bd1e8 100644 --- a/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs +++ b/Packages/com.unity.render-pipelines.universal/Tests/Runtime/RuntimeTests.cs @@ -12,6 +12,9 @@ class RuntimeTests Camera camera; RenderPipelineAsset currentAssetGraphics; RenderPipelineAsset currentAssetQuality; + RenderTexture m_Destination; + UniversalRenderPipelineAsset m_TestAsset; + UniversalRendererData m_TestRendererData; [SetUp] public void Setup() @@ -28,6 +31,22 @@ 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; + } + if (m_TestAsset != null) + { + Object.DestroyImmediate(m_TestAsset); + m_TestAsset = null; + } + if (m_TestRendererData != null) + { + Object.DestroyImmediate(m_TestRendererData); + m_TestRendererData = null; + } } // When URP pipeline is active, lightsUseLinearIntensity must match active color space. @@ -49,6 +68,102 @@ 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."); + + if (GraphicsSettings.GetRenderPipelineSettings().enableRenderCompatibilityMode) + Assert.Ignore("This test covers render requests into a cubemap with Render Graph enabled."); + + // 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; + + 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 bb4377155804664ec97abe0538cac0a72634d0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GeunHee=20Park=20=EF=BC=88=EB=B0=95=EA=B7=BC=ED=9D=AC=20-?= =?UTF-8?q?=20=E6=9C=B4=E6=A0=B9=E5=B8=8C=EF=BC=89?= Date: Sun, 22 Nov 2026 20:30:09 +0000 Subject: [PATCH 22/22] [Port] [6000.0] [Core] Fix bad type on DebugOccluder shader causing warning at build --- .../RenderPipelineResources/GPUDriven/DebugOccluder.shader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/GPUDriven/DebugOccluder.shader b/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/GPUDriven/DebugOccluder.shader index 24149a67fb8..f4ad6b52e37 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/GPUDriven/DebugOccluder.shader +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderPipelineResources/GPUDriven/DebugOccluder.shader @@ -29,7 +29,7 @@ Shader "Hidden/Core/DebugOccluder" return output; } - float GetOutputColor(float occluderValue) + float4 GetOutputColor(float occluderValue) { float value = saturate((occluderValue - _ValidRange.x) * _ValidRange.y); return float4(value.xxx, 1);