From c02e760529a866e575d09f99316cbbc029641786 Mon Sep 17 00:00:00 2001 From: Pablo Bayarri Romar Date: Tue, 19 May 2026 08:35:06 +0000 Subject: [PATCH 01/38] Use VFS-aware file reads in ShaderGraph importers to support long paths (UUM-120311) --- .../Editor/Importers/ShaderGraphImporter.cs | 2 +- .../Editor/Importers/ShaderGraphImporterEditor.cs | 2 +- .../Editor/Importers/ShaderSubGraphImporter.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs b/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs index ae53e7ef3cc..cd94d88fbb5 100644 --- a/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs +++ b/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs @@ -504,7 +504,7 @@ internal static string GetShaderText(string path, out List configuredTextures, AssetCollection assetCollection, out GraphData graph) { - var textGraph = File.ReadAllText(path, Encoding.UTF8); + var textGraph = FileUtilities.ReadAllTextUTF8(path); graph = new GraphData { messageManager = new MessageManager(), diff --git a/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporterEditor.cs b/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporterEditor.cs index a8affe50e5e..9409cec0adc 100644 --- a/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporterEditor.cs +++ b/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporterEditor.cs @@ -25,7 +25,7 @@ public override void OnInspectorGUI() { GraphData GetGraphData(AssetImporter importer) { - var textGraph = File.ReadAllText(importer.assetPath, Encoding.UTF8); + var textGraph = FileUtilities.ReadAllTextUTF8(importer.assetPath); var graphObject = CreateInstance(); graphObject.hideFlags = HideFlags.HideAndDontSave; bool isSubGraph; diff --git a/Packages/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs b/Packages/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs index bc4907b071a..daccda2e4a7 100644 --- a/Packages/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs +++ b/Packages/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs @@ -78,7 +78,7 @@ public override void OnImportAsset(AssetImportContext ctx) var subGraphPath = ctx.assetPath; var subGraphGuid = AssetDatabase.AssetPathToGUID(subGraphPath); graphAsset.assetGuid = subGraphGuid; - var textGraph = File.ReadAllText(subGraphPath, Encoding.UTF8); + var textGraph = FileUtilities.ReadAllTextUTF8(subGraphPath); var messageManager = new MessageManager(); var graphData = new GraphData { From 6cc25774203a6334a6156e910e0d3faa9b5e8d04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nanho=20Lee=20=EF=BC=88=EC=9D=B4=EB=82=9C=ED=98=B8?= =?UTF-8?q?=EF=BC=89?= Date: Tue, 19 May 2026 18:10:06 +0000 Subject: [PATCH 02/38] [Port] [6000.4] Stable Light Index Tracking using dataIndex in HDRP --- .../Light/HDGpuLightsBuilder.LightLoop.cs | 31 ++++++++-------- .../Light/HDShadowRequestUpdateJob.cs | 18 +++++----- .../Runtime/Lighting/Shadow/HDShadowAtlas.cs | 36 ++++++++++++++++--- .../Lighting/Shadow/HDShadowManager.cs | 22 +++++++----- .../HDRenderPipeline.LightLoop.cs | 4 +-- 5 files changed, 73 insertions(+), 38 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs index 64dc5fbacb1..dd78d84f97f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDGpuLightsBuilder.LightLoop.cs @@ -600,6 +600,7 @@ internal unsafe void UpdateShadowRequestsAndCalculateShadowIndices( ref HDShadowRequest shadowRequest = ref requestStorageUnsafe.ElementAt(shadowRequestHandle.storageIndexForRequestIndex); int additionalLightDataIndex = directionalUpdateInfo.additionalLightDataIndex; int lightIndex = directionalUpdateInfo.lightIndex; + int dataIndex = visibleLights.visibleLightEntityDataIndices[lightIndex]; Vector2 viewportSize = directionalUpdateInfo.viewportSize; VisibleLight* visibleLightPtr = visibleLightsArrayPtr + lightIndex; ref VisibleLight visibleLight = ref UnsafeUtility.AsRef(visibleLightPtr); @@ -619,7 +620,7 @@ internal unsafe void UpdateShadowRequestsAndCalculateShadowIndices( SetDirectionalRequestSettings(ref shadowRequest, shadowRequestHandle, visibleLight, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, shadowRequest.cullingSplit.deviceProjectionMatrix, viewportSize, - lightIndex, directionalShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, dataIndex, directionalShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); shadowRequest.shouldUseCachedShadowData = false; shadowRequest.shouldRenderCachedComponent = true; @@ -640,7 +641,6 @@ internal unsafe void UpdateShadowRequestsAndCalculateShadowIndices( shadowRequest.cullingSplit.deviceProjectionYFlip = _ProjMatrix; } - int dataIndex = visibleLights.visibleLightEntityDataIndices[lightIndex]; HDAdditionalLightData additionalLightData = lightEntities.hdAdditionalLightData[dataIndex]; if (needToUpdateCachedContent && hdCamera.camera.cameraType != CameraType.Reflection) { @@ -669,7 +669,7 @@ internal unsafe void UpdateShadowRequestsAndCalculateShadowIndices( SetDirectionalRequestSettings(ref shadowRequest, shadowRequestHandle, visibleLight, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, shadowRequest.cullingSplit.deviceProjectionMatrix, viewportSize, - lightIndex, directionalShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, directionalShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } @@ -786,7 +786,7 @@ internal static unsafe void UpdateCachedSpotShadowRequestsAndResolutionRequests( SetSpotRequestSettings(ref shadowRequest, shadowRequestHandle, spotUpdateInfo.visibleLight, 0f, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, shadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, shadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); hasUpdatedRequestData = true; shadowRequest.shouldUseCachedShadowData = false; @@ -812,7 +812,7 @@ internal static unsafe void UpdateCachedSpotShadowRequestsAndResolutionRequests( SetSpotRequestSettings(ref shadowRequest, shadowRequestHandle, spotUpdateInfo.visibleLight, 0f, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, shadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, shadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } } @@ -853,7 +853,7 @@ internal static unsafe void UpdateDynamicSpotShadowRequestsAndResolutionRequests SetSpotRequestSettings(ref shadowRequest, shadowRequestHandle, spotUpdateInfo.visibleLight, 0f, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, shadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, shadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } } @@ -958,7 +958,7 @@ internal static Vector3 GetPositionFromVisibleLight(in VisibleLight visibleLight [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void SetDirectionalRequestSettings(ref HDShadowRequest shadowRequest, HDShadowRequestHandle shadowRequestHandle, in VisibleLight visibleLight, Vector3 cameraPos, - Matrix4x4 invViewProjection, in Matrix4x4 projection, in Matrix4x4 devProjMatrix, Vector2 viewportSize, int lightIndex, HDShadowFilteringQuality filteringQuality, + Matrix4x4 invViewProjection, in Matrix4x4 projection, in Matrix4x4 devProjMatrix, Vector2 viewportSize, int lightIndex, int dataIndex, HDShadowFilteringQuality filteringQuality, in HDAdditionalLightDataUpdateInfo additionalLightData, int shaderConfigCameraRelativeRendering, NativeList frustumPlanesStorage) { MakeViewAndViewProjectionCameraRelative(ref shadowRequest, ref invViewProjection, shaderConfigCameraRelativeRendering, cameraPos); @@ -972,7 +972,7 @@ internal static void SetDirectionalRequestSettings(ref HDShadowRequest shadowReq float baseBias = GetBaseBias(filteringQuality == HDShadowFilteringQuality.High, 0.0f); SetCommonShadowRequestSettings(ref shadowRequest, shadowRequestHandle, cameraPos, invViewProjection, projection, - viewportSize, lightIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, + viewportSize, lightIndex, dataIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, ShadowMapType.CascadedDirectional, zBufferParam, softnessAndRangeScale.x, position, baseBias, true, false); @@ -1004,7 +1004,7 @@ internal static void SetDirectionalRequestSettings(ref HDShadowRequest shadowReq [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void SetAreaRequestSettings(ref HDShadowRequest shadowRequest, HDShadowRequestHandle shadowRequestHandle, in VisibleLight visibleLight, float forwardOffset, - Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, + Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, int dataIndex, HDAreaShadowFilteringQuality areaFilteringQuality, in HDAdditionalLightDataUpdateInfo additionalLightData, int shaderConfigCameraRelativeRendering, NativeList frustumPlanesStorage) @@ -1019,7 +1019,7 @@ internal static void SetAreaRequestSettings(ref HDShadowRequest shadowRequest, float baseBias = GetBaseBias(areaFilteringQuality == HDAreaShadowFilteringQuality.High, softness); SetCommonShadowRequestSettings(ref shadowRequest, shadowRequestHandle, cameraPos, invViewProjection, projection, - viewportSize, lightIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, + viewportSize, lightIndex, dataIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, ShadowMapType.AreaLightAtlas, zBufferParam, softness, position, baseBias, false, true); @@ -1035,7 +1035,7 @@ internal static void SetAreaRequestSettings(ref HDShadowRequest shadowRequest, [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void SetSpotRequestSettings(ref HDShadowRequest shadowRequest, HDShadowRequestHandle shadowRequestHandle, in VisibleLight visibleLight, float forwardOffset, - Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, + Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, int dataIndex, HDShadowFilteringQuality filteringQuality, in HDAdditionalLightDataUpdateInfo additionalLightData, int shaderConfigCameraRelativeRendering, NativeList frustumPlanesStorage) @@ -1060,7 +1060,7 @@ internal static void SetSpotRequestSettings(ref HDShadowRequest shadowRequest, float baseBias = GetBaseBias(filteringQuality == HDShadowFilteringQuality.High, softness); SetCommonShadowRequestSettings(ref shadowRequest, shadowRequestHandle, cameraPos, invViewProjection, projection, - viewportSize, lightIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, + viewportSize, lightIndex, dataIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, ShadowMapType.PunctualAtlas, zBufferParam, softness, position, baseBias, hasOrthoMatrix, true); } @@ -1068,7 +1068,7 @@ internal static void SetSpotRequestSettings(ref HDShadowRequest shadowRequest, [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void SetPointRequestSettings(ref HDShadowRequest shadowRequest, HDShadowRequestHandle shadowRequestHandle, in VisibleLight visibleLight, - Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, + Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, int dataIndex, HDShadowFilteringQuality filteringQuality, in HDAdditionalLightDataUpdateInfo additionalLightData, int shaderConfigCameraRelativeRendering, NativeList frustumPlanesStorage) @@ -1082,14 +1082,14 @@ internal static void SetPointRequestSettings(ref HDShadowRequest shadowRequest, float baseBias = GetBaseBias(filteringQuality == HDShadowFilteringQuality.High, softness); SetCommonShadowRequestSettings(ref shadowRequest, shadowRequestHandle, cameraPos, invViewProjection, projection, - viewportSize, lightIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, + viewportSize, lightIndex, dataIndex, additionalLightData, shaderConfigCameraRelativeRendering, frustumPlanesStorage, ShadowMapType.PunctualAtlas, zBufferParam, softness, position, baseBias, false, true); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void SetCommonShadowRequestSettings(ref HDShadowRequest shadowRequest, - HDShadowRequestHandle shadowRequestHandle, Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, + HDShadowRequestHandle shadowRequestHandle, Vector3 cameraPos, Matrix4x4 invViewProjection, Matrix4x4 projection, Vector2 viewportSize, int lightIndex, int dataIndex, in HDAdditionalLightDataUpdateInfo additionalLightData, int shaderConfigCameraRelativeRendering, NativeList frustumPlanesStorage, ShadowMapType shadowMapType, float4 zBufferParam, float softness, Vector3 position, float baseBias, bool hasOrthoMatrix, bool zClip) { @@ -1102,6 +1102,7 @@ internal static void SetCommonShadowRequestSettings(ref HDShadowRequest shadowRe shadowRequest.shadowToWorld = invViewProjection.transpose; shadowRequest.zClip = zClip; shadowRequest.lightIndex = lightIndex; + shadowRequest.dataIndex = dataIndex; // We don't allow shadow resize for directional cascade shadow shadowRequest.shadowMapType = shadowMapType; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDShadowRequestUpdateJob.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDShadowRequestUpdateJob.cs index b0321d3ea32..4650b79af5d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDShadowRequestUpdateJob.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Light/HDShadowRequestUpdateJob.cs @@ -323,7 +323,7 @@ public void UpdateCachedPointShadowRequestsAndResolutionRequests() HDGpuLightsBuilder.SetPointRequestSettings(ref shadowRequest, shadowRequestHandle, in pointUpdateInfo.visibleLight, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); hasUpdatedRequestData = true; shadowRequest.shouldUseCachedShadowData = false; @@ -344,7 +344,7 @@ public void UpdateCachedPointShadowRequestsAndResolutionRequests() HDGpuLightsBuilder.SetPointRequestSettings(ref shadowRequest, shadowRequestHandle, in pointUpdateInfo.visibleLight, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } } @@ -370,7 +370,7 @@ public void UpdateDynamicPointShadowRequestsAndResolutionRequests() HDGpuLightsBuilder.SetPointRequestSettings(ref shadowRequest, shadowRequestHandle, in pointUpdateInfo.visibleLight, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } @@ -407,7 +407,7 @@ public void UpdateCachedSpotShadowRequestsAndResolutionRequests() HDGpuLightsBuilder.SetSpotRequestSettings(ref shadowRequest, shadowRequestHandle, spotUpdateInfo.visibleLight, 0f, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); hasUpdatedRequestData = true; shadowRequest.shouldUseCachedShadowData = false; @@ -428,7 +428,7 @@ public void UpdateCachedSpotShadowRequestsAndResolutionRequests() HDGpuLightsBuilder.SetSpotRequestSettings(ref shadowRequest, shadowRequestHandle, spotUpdateInfo.visibleLight, 0f, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } } @@ -454,7 +454,7 @@ public void UpdateDynamicSpotShadowRequestsAndResolutionRequests() HDGpuLightsBuilder.SetSpotRequestSettings(ref shadowRequest, shadowRequestHandle, spotUpdateInfo.visibleLight, 0f, worldSpaceCameraPos, shadowRequest.cullingSplit.invViewProjection, shadowRequest.cullingSplit.projection, viewportSize, - lightIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); + lightIndex, additionalLightDataIndex, punctualShadowFilteringQuality, updateInfo, shaderConfigCameraRelativeRendering, frustumPlanesStorage); } } @@ -487,7 +487,7 @@ public void UpdateCachedAreaShadowRequestsAndResolutionRequests(NativeList visibleLightEntityDataIndices; } private void SetCommonRenderPassData(RenderShadowMapsCommonPassData passData, in IUnsafeRenderGraphBuilder builder, RenderGraph renderGraph, in ShaderVariablesGlobal globalCBData) @@ -429,7 +430,10 @@ private static void ResetDepthState(CommandBuffer cmd) } public static Vector4[] frustumPlanesScratchpad = new Vector4[HDShadowRequest.frustumPlanesCount]; - internal unsafe TextureHandle RenderShadowMaps(RenderGraph renderGraph, ScriptableRenderContext renderContext, CullingResults cullResults, in ShaderVariablesGlobal globalCBData, FrameSettings frameSettings, string shadowPassName) + internal unsafe TextureHandle RenderShadowMaps( + RenderGraph renderGraph, ScriptableRenderContext renderContext, + CullingResults cullResults, NativeArray visibleLightEntityDataIndices, + in ShaderVariablesGlobal globalCBData, FrameSettings frameSettings, string shadowPassName) { TextureHandle atlasTexture; @@ -442,6 +446,7 @@ internal unsafe TextureHandle RenderShadowMaps(RenderGraph renderGraph, Scriptab passData.shadowDrawSettings = new ShadowDrawingSettings(cullResults, 0); passData.shadowDrawSettings.useRenderingLayerMaskTest = frameSettings.IsEnabled(FrameSettingsField.LightLayers); passData.renderContext = renderContext; + passData.visibleLightEntityDataIndices = visibleLightEntityDataIndices; builder.SetRenderFunc( static (RenderShadowMapsPassData data, UnsafeGraphContext ctx) => @@ -460,9 +465,27 @@ internal unsafe TextureHandle RenderShadowMaps(RenderGraph renderGraph, Scriptab Vector4[] planesScratchpad = frustumPlanesScratchpad; + var cullResults = data.shadowDrawSettings.cullingResults; + var visibleLightCount = cullResults.visibleLights.Length; + // Build mapping from stable dataIndex to current light index. + // Allocated per-pass (not shared) to remain RenderGraph-compliant and avoid + // implicit dependencies if the execution model changes. + var dataIndexToCurrentLightIndex = new NativeHashMap(visibleLightCount, Allocator.Temp); + + for (int i = 0; i < visibleLightCount; ++i) + { + int dataIndex = data.visibleLightEntityDataIndices[i]; + if (dataIndex >= 0) + dataIndexToCurrentLightIndex[dataIndex] = i; + } + foreach (var shadowRequestHandle in data.shadowRequests) { ref var shadowRequest = ref requestStorageUnsafe.ElementAt(shadowRequestHandle.storageIndexForShadowRequest); + + if (!dataIndexToCurrentLightIndex.TryGetValue(shadowRequest.dataIndex, out int currentCorrectIndex)) + continue; + var commonState = CommonPerShadowRequestUpdate(natCmd, data, shadowRequest, shadowRequestHandle, ref planesScratchpad, ref frustumPlanesStorageUnsafe); if (commonState.shouldSkipRequest) continue; @@ -482,7 +505,7 @@ internal unsafe TextureHandle RenderShadowMaps(RenderGraph renderGraph, Scriptab if (!commonState.mixedInDynamicAtlas) CoreUtils.DrawFullScreen(natCmd, data.clearMaterial, null, 0); - data.shadowDrawSettings.lightIndex = shadowRequest.lightIndex; + data.shadowDrawSettings.lightIndex = currentCorrectIndex; data.shadowDrawSettings.splitIndex = shadowRequest.cullingSplit.splitIndex; //TODO(ddebaets) as the shadowDrawSettings are modified in this loop, we generate this RL very last minute @@ -491,6 +514,8 @@ internal unsafe TextureHandle RenderShadowMaps(RenderGraph renderGraph, Scriptab natCmd.DrawRendererList(rl); } + dataIndexToCurrentLightIndex.Dispose(); + ResetDepthState(natCmd); }); @@ -739,14 +764,17 @@ internal TextureHandle BlurShadows(RenderGraph renderGraph) return m_ShadowMapOutput; } } - internal TextureHandle RenderShadows(RenderGraph renderGraph, ScriptableRenderContext renderContext, CullingResults cullResults, in ShaderVariablesGlobal globalCB, FrameSettings frameSettings, string shadowPassName) + internal TextureHandle RenderShadows( + RenderGraph renderGraph, ScriptableRenderContext renderContext, + CullingResults cullResults, NativeArray visibleLightEntityDataIndices, + in ShaderVariablesGlobal globalCB, FrameSettings frameSettings, string shadowPassName) { if (m_ShadowRequests.Length == 0) { return renderGraph.defaultResources.defaultShadowTexture; } - RenderShadowMaps(renderGraph, renderContext, cullResults, globalCB, frameSettings, shadowPassName); + RenderShadowMaps(renderGraph, renderContext, cullResults, visibleLightEntityDataIndices, globalCB, frameSettings, shadowPassName); if (m_BlurAlgorithm == BlurAlgorithm.EVSM) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs index f10a5d64f70..f78e7a7ec41 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs @@ -195,6 +195,7 @@ internal struct HDShadowRequest // TODO: Remove these field once scriptable culling is here (currently required by ScriptableRenderContext.DrawShadows) public int lightIndex; + public int dataIndex; // end public float normalBias; @@ -298,6 +299,7 @@ public void InitDefault() zClip = default; shadowMapType = ShadowMapType.PunctualAtlas; lightIndex = default; + dataIndex = HDLightRenderDatabase.InvalidDataIndex; normalBias = default; worldTexelSize = default; slopeBias = default; @@ -1226,7 +1228,7 @@ public int GetShadowRequestCount() { return m_ShadowRequestCount; } - + internal void GetUnmanageDataForComputeCullingSplitsJob(ref HDShadowManagerDataForComputeCullingSplitsJob shadowManagerData) { shadowManagerData.requestCount = GetShadowRequestCount(); @@ -1373,7 +1375,11 @@ internal static ShadowResult ReadShadowResult(in ShadowResult shadowResult, IUns return result; } - internal void RenderShadows(RenderGraph renderGraph, ScriptableRenderContext renderContext, in ShaderVariablesGlobal globalCB, HDCamera hdCamera, CullingResults cullResults, ref ShadowResult result) + internal void RenderShadows( + RenderGraph renderGraph, ScriptableRenderContext renderContext, + in ShaderVariablesGlobal globalCB, HDCamera hdCamera, + CullingResults cullResults, NativeArray visibleLightEntityIndices, + ref ShadowResult result) { InvalidateAtlasOutputs(); @@ -1382,15 +1388,15 @@ internal void RenderShadows(RenderGraph renderGraph, ScriptableRenderContext ren (hdCamera.frameSettings.IsEnabled(FrameSettingsField.OpaqueObjects) || hdCamera.frameSettings.IsEnabled(FrameSettingsField.TransparentObjects))) { // Punctual - result.cachedPunctualShadowResult = cachedShadowManager.punctualShadowAtlas.RenderShadows(renderGraph, renderContext, cullResults, globalCB, hdCamera.frameSettings, "Render Cached Punctual Lights Shadow Maps"); + result.cachedPunctualShadowResult = cachedShadowManager.punctualShadowAtlas.RenderShadows(renderGraph, renderContext, cullResults, visibleLightEntityIndices, globalCB, hdCamera.frameSettings, "Render Cached Punctual Lights Shadow Maps"); BlitCachedShadows(renderGraph, ShadowMapType.PunctualAtlas); - result.punctualShadowResult = m_Atlas.RenderShadows(renderGraph, renderContext, cullResults, globalCB, hdCamera.frameSettings, "Render Punctual Lights Shadow Maps"); + result.punctualShadowResult = m_Atlas.RenderShadows(renderGraph, renderContext, cullResults, visibleLightEntityIndices, globalCB, hdCamera.frameSettings, "Render Punctual Lights Shadow Maps"); if (ShaderConfig.s_AreaLights == 1) { - cachedShadowManager.areaShadowAtlas.RenderShadowMaps(renderGraph, renderContext, cullResults, globalCB, hdCamera.frameSettings, "Render Cached Area Lights Shadow Maps"); + cachedShadowManager.areaShadowAtlas.RenderShadowMaps(renderGraph, renderContext, cullResults, visibleLightEntityIndices, globalCB, hdCamera.frameSettings, "Render Cached Area Lights Shadow Maps"); BlitCachedShadows(renderGraph, ShadowMapType.AreaLightAtlas); - m_AreaLightShadowAtlas.RenderShadowMaps(renderGraph, renderContext, cullResults, globalCB, hdCamera.frameSettings, "Render Area Light Shadow Maps"); + m_AreaLightShadowAtlas.RenderShadowMaps(renderGraph, renderContext, cullResults, visibleLightEntityIndices, globalCB, hdCamera.frameSettings, "Render Area Light Shadow Maps"); result.areaShadowResult = m_AreaLightShadowAtlas.BlurShadows(renderGraph); result.cachedAreaShadowResult = cachedShadowManager.areaShadowAtlas.BlurShadows(renderGraph); } @@ -1401,11 +1407,11 @@ internal void RenderShadows(RenderGraph renderGraph, ScriptableRenderContext ren if (cachedShadowManager.directionalLightAtlas.HasShadowRequests()) { cachedShadowManager.UpdateDirectionalCacheTexture(renderGraph); - cachedShadowManager.directionalLightAtlas.RenderShadows(renderGraph, renderContext, cullResults, globalCB, hdCamera.frameSettings, "Render Cached Directional Lights Shadow Maps"); + cachedShadowManager.directionalLightAtlas.RenderShadows(renderGraph, renderContext, cullResults, visibleLightEntityIndices, globalCB, hdCamera.frameSettings, "Render Cached Directional Lights Shadow Maps"); } BlitCachedShadows(renderGraph, ShadowMapType.CascadedDirectional); } - result.directionalShadowResult = m_CascadeAtlas.RenderShadows(renderGraph, renderContext, cullResults, globalCB, hdCamera.frameSettings, "Render Directional Light Shadow Maps"); + result.directionalShadowResult = m_CascadeAtlas.RenderShadows(renderGraph, renderContext, cullResults, visibleLightEntityIndices, globalCB, hdCamera.frameSettings, "Render Directional Light Shadow Maps"); } // TODO RENDERGRAPH diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs index 05051fd4977..e2d1e2716d9 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs @@ -481,7 +481,7 @@ unsafe void PrepareBuildGPULightListPassData( passData.clearLightLists = true; tileAndClusterData.listsAreInitialized = true; } - + // Always build the light list in XR mode to avoid issues with multi-pass if (hdCamera.xr.enabled) { @@ -721,7 +721,7 @@ void PushGlobalCameraParams(RenderGraph renderGraph, HDCamera hdCamera) internal ShadowResult RenderShadows(RenderGraph renderGraph, ScriptableRenderContext renderContext, HDCamera hdCamera, CullingResults cullResults, ref ShadowResult result) { - m_ShadowManager.RenderShadows(m_RenderGraph, renderContext, m_ShaderVariablesGlobalCB, hdCamera, cullResults, ref result); + m_ShadowManager.RenderShadows(m_RenderGraph, renderContext, m_ShaderVariablesGlobalCB, hdCamera, cullResults, m_ProcessedLightsBuilder.visibleLightEntityDataIndices, ref result); // Need to restore global camera parameters. PushGlobalCameraParams(renderGraph, hdCamera); return result; From 4d59463fda03a8c470baa5e3f7f242e6605376ac Mon Sep 17 00:00:00 2001 From: Evergreen Date: Wed, 20 May 2026 04:43:48 +0000 Subject: [PATCH 03/38] [Port] [6000.4] [2d] Fix case where URP-2D shaders are used with Vfx Shadergraph. --- .../Shaders/2D/Include/Core2D.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl index 3b888875bd5..06b21292140 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl +++ b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl @@ -100,7 +100,7 @@ float3 UnitySkinSprite( in float3 inputData, in uint4 blendIndices, in float4 bl void SetUpSpriteInstanceProperties() { -#ifdef UNITY_INSTANCING_ENABLED +#if defined(UNITY_INSTANCING_ENABLED) && !defined(HAVE_VFX_MODIFICATION) unity_SpriteProps.xy = unity_SpriteFlip; #endif } From 115f806bea7f00a8b511b3e06fb75e8a3dfcb130 Mon Sep 17 00:00:00 2001 From: Sven Santema Date: Wed, 20 May 2026 04:43:50 +0000 Subject: [PATCH 04/38] [Port] [6000.4] Disable indirect draws for non-tessellated quad topology in GRD. --- .../Runtime/GPUDriven/InstanceCullingBatcherBurst.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcherBurst.cs b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcherBurst.cs index ae60d8d5546..9beffdccc7c 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcherBurst.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/GPUDriven/InstanceCullingBatcherBurst.cs @@ -177,6 +177,7 @@ private static void ProcessRenderer(int i, bool implicitInstanceIndices, in GPUD Span packedMaterialDatas = stackalloc GPUDrivenPackedMaterialData[materialsCount]; var supportsIndirect = true; + var isMetal = SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal; for (int matIndex = 0; matIndex < materialsCount; ++matIndex) { if (matIndex >= submeshCount) @@ -198,7 +199,14 @@ private static void ProcessRenderer(int i, bool implicitInstanceIndices, in GPUD bool isFound = packedMaterialDataHash.TryGetValue(materialID, out packedMaterialData); Assert.IsTrue(isFound); } - supportsIndirect &= packedMaterialData.isIndirectSupported; + + var submeshIndex = startSubMesh + matIndex; + var subMesh = rendererData.subMeshDesc[subMeshDescOffset + submeshIndex]; + + // The indirect path does not support topology adjustment; use the direct path when this is required. + // Concretely, for quads, only use the indirect path if we allow quads natively (e.g. tessellation shaders). + supportsIndirect &= subMesh.topology != MeshTopology.Quads || packedMaterialData.hasTessellation; + supportsIndirect &= !isMetal || !packedMaterialData.hasTessellation; packedMaterialDatas[matIndex] = packedMaterialData; } From db12441d04f01c6db868e5da15a2e1d3c0959969 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Thu, 21 May 2026 08:01:30 +0000 Subject: [PATCH 05/38] [Port] [6000.4] Lighting/uum 141983 apv clear on incompatible layout --- .../Editor/Lighting/ProbeVolume/ProbeGIBaking.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs index 3d3f66c16fd..bdf56fad216 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeGIBaking.cs @@ -1409,8 +1409,11 @@ Vector3Int GetCellPositionFromVoxel(Vector3Int voxelToLookup, int cellSizeInBric continue; // 3. - // Overwrite lighting data with trilinear sampled data from the brick with highest subdiv level - float brickSize = ProbeReferenceVolume.instance.BrickSize(largestBrick.subdivisionLevel - 1); + // Overwrite lighting data with trilinear sampled data from the brick with highest subdiv level. + // Use minBrickSize from m_ProfileInfo (live bake settings), not ProbeReferenceVolume.instance, + // because that runtime state is restored to the previous bake's snapshot at the end of + // ApplySubdivisionResults and would be stale here. UUM-141983. + float brickSize = ProbeVolumeUtil.BrickSize(minBrickSize, largestBrick.subdivisionLevel - 1); float3 uvw = math.clamp((pos - (Vector3)largestBrick.position * minBrickSize) / brickSize, 0, 3); var probe = Vector3Int.FloorToInt(uvw); From dcd21c85a8ef8b2ee2cf6546cd75c53eaac96eb9 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Thu, 21 May 2026 08:01:30 +0000 Subject: [PATCH 06/38] [Port] [6000.4] [UUM-142398] Fix preview generation for graphs using predefined keywords --- .../com.unity.shadergraph/Editor/Data/Graphs/ShaderKeyword.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/ShaderKeyword.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/ShaderKeyword.cs index 2bc1f332194..c67fe55c569 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/ShaderKeyword.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/ShaderKeyword.cs @@ -208,6 +208,9 @@ public void AppendKeywordDeclarationStrings(ShaderStringBuilder builder) public string GetKeywordPreviewDeclarationString() { + if (keywordDefinition == KeywordDefinition.Predefined) + return string.Empty; + if (this.IsDynamic) { switch(keywordType) From afc1e12c8e2d6af0c286e1e41da94fedd24413bf Mon Sep 17 00:00:00 2001 From: Robin Bradley Date: Thu, 21 May 2026 21:16:06 +0000 Subject: [PATCH 07/38] [content automatically redacted] touching PlatformDependent folder --- .../Targets/UniversalDecalSubTarget.cs | 1 + .../Targets/UniversalLitSubTarget.cs | 1 + .../ShaderGraph/Targets/UniversalTarget.cs | 6 +++++ .../Targets/UniversalTerrainLitSubTarget.cs | 1 + .../Targets/UniversalUnlitSubTarget.cs | 1 + .../Runtime/DeferredLights.cs | 1 + .../ShaderLibrary/GBufferOutputFormat.hlsl | 25 +++++++++++++++++++ .../GBufferOutputFormat.hlsl.meta | 7 ++++++ .../Shaders/ComplexLit.shader | 1 + .../Shaders/Lit.shader | 1 + .../Shaders/Nature/SpeedTree7.shader | 1 + .../Shaders/Nature/SpeedTree7Billboard.shader | 1 + .../Shaders/Nature/SpeedTree8.shader | 2 +- .../Shaders/Particles/ParticlesLit.shader | 1 + .../Particles/ParticlesSimpleLit.shader | 1 + .../Shaders/SimpleLit.shader | 1 + .../Shaders/Terrain/TerrainLit.shader | 1 + .../Shaders/Terrain/TerrainLitAdd.shader | 1 + .../Shaders/Terrain/TerrainLitBase.shader | 1 + .../Shaders/Terrain/WavingGrass.shader | 1 + .../Terrain/WavingGrassBillboard.shader | 1 + .../Shaders/Unlit.shader | 1 + 22 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl create mode 100644 Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl.meta 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 b73a8719002..4864d96e608 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 @@ -1121,6 +1121,7 @@ static class DecalIncludes // Post-graph { DecalPostgraph }, + { CoreIncludes.GBufferOutputFormat }, }; public static IncludeCollection ScenePicking = new IncludeCollection 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 63247006be5..47e9989e841 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 @@ -937,6 +937,7 @@ static class LitIncludes { CoreIncludes.CorePostgraph }, { kGBuffer, IncludeLocation.Postgraph }, { kPBRGBufferPass, IncludeLocation.Postgraph }, + { CoreIncludes.GBufferOutputFormat }, }; public static readonly IncludeCollection Meta = new IncludeCollection 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 2566168cdd1..bbf974fbda5 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 @@ -1773,6 +1773,7 @@ static class CoreIncludes const string kFog = "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Fog.hlsl"; const string kRenderingLayers = "Packages/com.unity.render-pipelines.universal/ShaderLibrary/RenderingLayers.hlsl"; const string kProbeVolumes = "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ProbeVolumeVariants.hlsl"; + const string kGbufferOutputFormat = "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl"; public static readonly IncludeCollection CorePregraph = new IncludeCollection { @@ -1913,6 +1914,11 @@ static class CoreIncludes { { kLODCrossFade, IncludeLocation.Pregraph } }; + + public static readonly IncludeCollection GBufferOutputFormat = new IncludeCollection + { + { kGbufferOutputFormat, IncludeLocation.Postgraph, true } + }; } #endregion diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTerrainLitSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTerrainLitSubTarget.cs index 81cb6c44c5a..1262a13f2f7 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTerrainLitSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTerrainLitSubTarget.cs @@ -1633,6 +1633,7 @@ static class TerrainCoreIncludes { TerrainCoreIncludes.CorePostgraph }, { TerrainCoreIncludes.kGBuffer, IncludeLocation.Postgraph }, { TerrainCoreIncludes.kPBRGBufferPass, IncludeLocation.Postgraph }, + { CoreIncludes.GBufferOutputFormat }, }; public static readonly IncludeCollection Meta = new IncludeCollection diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs index b5c6dfbe9d4..36971ba16d4 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalUnlitSubTarget.cs @@ -581,6 +581,7 @@ static class UnlitIncludes // Post-graph { CoreIncludes.CorePostgraph }, { kUnlitGBufferPass, IncludeLocation.Postgraph }, + { CoreIncludes.GBufferOutputFormat }, }; public static IncludeCollection LightingIncludes = new IncludeCollection diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs b/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs index 6a0f880c667..f906037b564 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs @@ -156,6 +156,7 @@ internal enum ClusterDeferredPasses internal int GBufferInputAttachmentCount { get { return 4 + (UseShadowMask ? 1 : 0); } } + // Keep these formats in sync with the formats in GBufferOutputFormat.hlsl internal GraphicsFormat GetGBufferFormat(int index) { if (index == GBufferAlbedoIndex) // sRGB albedo, materialFlags diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl new file mode 100644 index 00000000000..50a38ec224a --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl @@ -0,0 +1,25 @@ +// This file contains functionality for letting the Unity Shader Compiler know what render target formats could be used +// The functionality provided here is intended to be used during in the material GBuffer pass. +#ifndef UNIVERSAL_GBUFFEROUTPUTFORMAT_INCLUDED +#define UNIVERSAL_GBUFFEROUTPUTFORMAT_INCLUDED + +#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferCommon.hlsl" + +// Keep these formats in sync with the formats returned in DeferredLights.GetGBufferFormat +#pragma rendertarget_format_hint MRT0 R8G8B8A8_SRGB +#pragma rendertarget_format_hint MRT1 R8G8B8A8_SRGB +#pragma rendertarget_format_hint MRT2 R8G8B8A8_SRGB +#pragma rendertarget_format_hint MRT3 R8G8B8A8_SRGB,B10G11R11_UFloatPack32 +#pragma rendertarget_format_hint MRT4 R32_SFloat // Assume GBUFFER_FEATURE_DEPTH is always enabled at the moment. +#if defined(GBUFFER_FEATURE_RENDERING_LAYERS) +#pragma rendertarget_format_hint MRT5 R8_UInt, R16_UInt, R32_UInt +#if defined(GBUFFER_FEATURE_SHADOWMASK) +#pragma rendertarget_format_hint MRT6 B8G8R8A8_UNorm, R8G8B8A8_UNorm +#endif +#else // GBUFFER_FEATURE_RENDERING_LAYERS +#if defined(GBUFFER_FEATURE_SHADOWMASK) +#pragma rendertarget_format_hint MRT5 B8G8R8A8_UNorm, R8G8B8A8_UNorm +#endif +#endif + +#endif // UNIVERSAL_GBUFFEROUTPUTFORMAT_INCLUDED diff --git a/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl.meta b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl.meta new file mode 100644 index 00000000000..a7178b5a276 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 87322610c9b88a64e8bce40c056d8116 +ShaderIncludeImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/ComplexLit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/ComplexLit.shader index 4361ccfdd5e..967b54e3bfe 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/ComplexLit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/ComplexLit.shader @@ -316,6 +316,7 @@ Shader "Universal Render Pipeline/Complex Lit" // Includes #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader index 83bc8c01933..2166579f089 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Lit.shader @@ -314,6 +314,7 @@ Shader "Universal Render Pipeline/Lit" // Includes #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/LitGBufferPass.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7.shader index 22527c1a269..6e1fddc57e4 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7.shader @@ -173,6 +173,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree7" #include "SpeedTree7Input.hlsl" #include "SpeedTree7Passes.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader index bf07ebea661..f3b42d851f4 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree7Billboard.shader @@ -117,6 +117,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree7 Billboard" #include "SpeedTree7BillboardInput.hlsl" #include "SpeedTree7BillboardPasses.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8.shader index f728bc82a0e..c7c842bb8b3 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Nature/SpeedTree8.shader @@ -170,7 +170,7 @@ Shader "Universal Render Pipeline/Nature/SpeedTree8" #include "SpeedTree8Input.hlsl" #include "SpeedTree8Passes.hlsl" - + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader index 50f952ebdc6..f4e5db18fe7 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLit.shader @@ -234,6 +234,7 @@ Shader "Universal Render Pipeline/Particles/Lit" // Includes #include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesLitGbufferPass.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader index b0c05dd22e3..96f3e70a320 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLit.shader @@ -241,6 +241,7 @@ Shader "Universal Render Pipeline/Particles/Simple Lit" // Includes #include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitInput.hlsl" #include_with_pragmas "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesSimpleLitGBufferPass.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/SimpleLit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/SimpleLit.shader index 7b883dad1ff..7805c4a2c0b 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/SimpleLit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/SimpleLit.shader @@ -271,6 +271,7 @@ Shader "Universal Render Pipeline/Simple Lit" // Includes #include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/SimpleLitGBufferPass.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLit.shader index 95cb5fad49d..fbfae98c886 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLit.shader @@ -199,6 +199,7 @@ Shader "Universal Render Pipeline/Terrain/Lit" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitAdd.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitAdd.shader index 063504bd47b..ad293cd90d6 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitAdd.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitAdd.shader @@ -166,6 +166,7 @@ Shader "Hidden/Universal Render Pipeline/Terrain/Lit (Add Pass)" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitBase.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitBase.shader index c92bbb4ab92..4b8de69df4e 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitBase.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitBase.shader @@ -160,6 +160,7 @@ Shader "Hidden/Universal Render Pipeline/Terrain/Lit (Base Pass)" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/TerrainLitPasses.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrass.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrass.shader index 800b36c96fe..fbc031855cf 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrass.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrass.shader @@ -120,6 +120,7 @@ Shader "Hidden/TerrainEngine/Details/UniversalPipeline/WavingDoublePass" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassPasses.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader index 86f24509d19..0622e983e67 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassBillboard.shader @@ -104,6 +104,7 @@ Shader "Hidden/TerrainEngine/Details/UniversalPipeline/BillboardWavingDoublePass #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/Terrain/WavingGrassPasses.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/Unlit.shader b/Packages/com.unity.render-pipelines.universal/Shaders/Unlit.shader index 22bc54765fc..7eda6131479 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/Unlit.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/Unlit.shader @@ -139,6 +139,7 @@ Shader "Universal Render Pipeline/Unlit" // Includes #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitInput.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/UnlitGBufferPass.hlsl" + #include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/GBufferOutputFormat.hlsl" ENDHLSL } From 08b84d4fb804b06699c746fda26f1282fdd25bc2 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Fri, 22 May 2026 04:15:26 +0000 Subject: [PATCH 08/38] [Port] [6000.4] [VFX] Avoid access of SystemInfo during compilation --- .../Expressions/VFXExpressionDecodeDepth.cs | 26 +++++++++++++++++++ .../VFXExpressionDecodeDepth.cs.meta | 2 ++ .../Collision/CollisionDepth.cs | 11 +++----- .../Implementations/Position/PositionDepth.cs | 4 +-- .../Implementations/PositionDepth.cs | 6 +---- .../Shaders/VFXCommon.hlsl | 9 +++++++ 6 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs create mode 100644 Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs.meta diff --git a/Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs b/Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs new file mode 100644 index 00000000000..4b8a8191e5e --- /dev/null +++ b/Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs @@ -0,0 +1,26 @@ +using System; +using UnityEngine; +using UnityEngine.VFX; + +namespace UnityEditor.VFX +{ + class VFXExpressionDecodeDepth : VFXExpression + { + public VFXExpressionDecodeDepth() : this(VFXValue.Default) + { + } + + public VFXExpressionDecodeDepth(VFXExpression depth) + : base(Flags.InvalidOnCPU, new VFXExpression[] { depth }) + { + } + + public sealed override VFXExpressionOperation operation { get { return VFXExpressionOperation.None; } } + public sealed override VFXValueType valueType { get { return VFXValueType.Float; } } + + public sealed override string GetCodeString(string[] parents) + { + return string.Format("DecodeDepth({0})", parents[0]); + } + } +} diff --git a/Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs.meta b/Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs.meta new file mode 100644 index 00000000000..f5c43c83add --- /dev/null +++ b/Packages/com.unity.visualeffectgraph/Editor/Expressions/VFXExpressionDecodeDepth.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: 4a1a658b4b2aab742951cc9c4db81618 \ No newline at end of file diff --git a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Collision/CollisionDepth.cs b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Collision/CollisionDepth.cs index 43c04251366..3a60feae92b 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Collision/CollisionDepth.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Collision/CollisionDepth.cs @@ -116,9 +116,7 @@ protected sealed override string collisionDetection { float2 uv = projPos.xy * 0.5f + 0.5f; float depth = LOAD_TEXTURE2D_X(Camera_depthBuffer.t, uv*Camera_scaledPixelDimensions).r; - #if UNITY_REVERSED_Z - depth = 1.0f - depth; // reversed z - #endif + depth = DecodeDepth(depth); const float n = Camera_nearPlane; const float f = Camera_farPlane; @@ -154,11 +152,8 @@ protected sealed override string collisionDetection float depth10 = LOAD_TEXTURE2D_X(Camera_depthBuffer.t, depthPos10).r; float depth01 = LOAD_TEXTURE2D_X(Camera_depthBuffer.t, depthPos01).r; - - #if UNITY_REVERSED_Z - depth10 = 1.0f - depth10; - depth01 = 1.0f - depth01; - #endif + depth10 = DecodeDepth(depth10); + depth01 = DecodeDepth(depth01); float4 vPos10 = mul(ClipToView,float4(projPos10,depth10 * 2.0f - 1.0f,1.0f)); float4 vPos01 = mul(ClipToView,float4(projPos01,depth01 * 2.0f - 1.0f,1.0f)); diff --git a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Position/PositionDepth.cs b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Position/PositionDepth.cs index 288b93e59ea..d02b9d8643c 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Position/PositionDepth.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/Position/PositionDepth.cs @@ -186,9 +186,7 @@ public override string source source += @" float2 projpos = uvs * 2.0f - 1.0f; float depth = LOAD_TEXTURE2D_X(Camera_depthBuffer.t, uvs*Camera_scaledPixelDimensions).r; -#if UNITY_REVERSED_Z -depth = 1.0f - depth; // reversed z -#endif"; +depth = DecodeDepth(depth);"; if (cullMode == CullMode.FarPlane) source += @" diff --git a/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/PositionDepth.cs b/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/PositionDepth.cs index 4b574854397..cba040cc419 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/PositionDepth.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/PositionDepth.cs @@ -196,11 +196,7 @@ protected override VFXExpression[] BuildExpression(VFXExpression[] inputExpressi // Get depth VFXExpression depth = new VFXExpressionExtractComponent(new VFXExpressionLoadCameraBuffer(Camera_depthBuffer, uvs), 0); - - if (SystemInfo.usesReversedZBuffer) - { - depth = VFXOperatorUtility.OneExpression[depth.valueType] - depth; - } + depth = new VFXExpressionDecodeDepth(depth); VFXExpression isAlive = VFXValue.Constant(true); diff --git a/Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl b/Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl index 228be967851..f146cde7fc0 100644 --- a/Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl +++ b/Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl @@ -226,6 +226,15 @@ float4 LoadTexture(VFXSampler3D s, int4 pixelCoords) return s.t.Load(pixelCoords); } +float DecodeDepth(float depth) +{ +#if UNITY_REVERSED_Z + return 1.0f - depth; +#else + return depth; +#endif +} + float SampleSDF(VFXSampler3D s, float3 coords, float level = 0.0f) { return SampleTexture(s, coords, level).x; From 388b6200896f45819d8f185490bad0807e1973df Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 26 May 2026 09:23:06 +0000 Subject: [PATCH 09/38] [Port] [6000.4] Frame Debugger - Fix Preview icons broken & Memory consumption --- .../Runtime/RenderGraph/RenderGraph.cs | 36 ++- .../RenderGraph/RenderGraphResourcePool.cs | 71 ++++- .../RenderGraphResourceRegistry.cs | 15 +- .../RenderGraph/RenderGraphResources.cs | 12 +- .../Tests/Editor/RenderGraphTests.cs | 250 +++++++++++++++++- 5 files changed, 356 insertions(+), 28 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs index e2b014d2789..feba8336164 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraph.cs @@ -118,7 +118,6 @@ public class InternalRenderGraphContext internal RenderGraphPass executingPass; internal NativeRenderPassCompiler.CompilerContextData compilerContext; internal bool contextlessTesting; - internal bool forceResourceCreation; } // InternalRenderGraphContext is public (but all members are internal) @@ -1624,13 +1623,15 @@ public void BeginRecording(in RenderGraphParameters parameters) // With the actual implementation of the Frame Debugger, we cannot re-use resources during the same frame // or it breaks the rendering of the pass preview, since the FD copies the texture after the execution of the RG. - m_RenderGraphContext.forceResourceCreation = + // When disabled, this mode prevents resources released in the current frame from being reused until the next frame. #if UNITY_EDITOR || DEVELOPMENT_BUILD - FrameDebugger.enabled; + bool enableMemoryAliasing = !FrameDebugger.enabled; #else - false; + bool enableMemoryAliasing = true; #endif + m_Resources.EnableIntraFrameMemoryAliasing(enableMemoryAliasing); + if (m_DebugParameters.immediateMode) { UpdateCurrentCompiledGraph(graphHash: -1, forceNoCaching: true); @@ -3170,6 +3171,33 @@ internal void ClearGlobalBindings() m_RenderGraphContext.cmd.SetGlobalTexture(globalTex.Key, defaultResources.blackTexture); } } + + /// + /// Enables or disables intra-frame memory aliasing for render graph resources. + /// When enabled, resources released within the same execution can be immediately reused by subsequent passes. + /// When disabled, resources released in the current execution cannot be reused until the next execution. + /// Note: An execution corresponds to a single RenderGraph recording/execution cycle. Multiple executions can occur + /// within the same frame (e.g., Frame Debugger cascade-repaints, multiple cameras). + /// This is primarily used for testing purposes and for Frame Debugger compatibility. + /// + /// True to enable intra-frame memory aliasing, false to disable it. + internal void SetIntraFrameMemoryAliasing(bool enabled) + { + m_Resources.EnableIntraFrameMemoryAliasing(enabled); + } + +#if UNITY_EDITOR + [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)] + static void ResetStaticsOnLoad() + { + s_RegisteredExecutions.Clear(); + s_EnableCompilationCachingForTests = null; + onGraphRegistered = null; + onGraphUnregistered = null; + onExecutionRegistered = null; + s_DebugSessionWasActive = false; + } +#endif } /// diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourcePool.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourcePool.cs index 509a871c4ab..090ad9482fb 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourcePool.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourcePool.cs @@ -10,13 +10,35 @@ abstract class IRenderGraphResourcePool public abstract void Cleanup(); public abstract void CheckFrameAllocation(bool onException, int frameIndex); public abstract void LogResources(RenderGraphLogger logger); + + // When disabled, resources released in the current execution cannot be reused until the next execution. + // This is useful for Frame Debugger to ensure each pass uses unique resources within an execution. + public bool IntraFrameMemoryAliasing { get; set; } = true; + } + + /// + /// Encapsulates a pooled resource along with its frame and execution tracking metadata. + /// This allows the pool to track when resources were released for proper reuse and purging decisions. + /// + readonly struct PooledResourceEntry where Type : class + { + public readonly Type resource; + public readonly int frameIndex; + public readonly int executionCount; + + public PooledResourceEntry(Type resource, int frameIndex, int executionCount) + { + this.resource = resource; + this.frameIndex = frameIndex; + this.executionCount = executionCount; + } } abstract class RenderGraphResourcePool : IRenderGraphResourcePool where Type : class { // Dictionary tracks resources by hash and stores resources with same hash in a List (list instead of a stack because we need to be able to remove stale allocations, potentially in the middle of the stack). // The list needs to be sorted otherwise you could get inconsistent resource usage from one frame to another. - protected Dictionary> m_ResourcePool = new Dictionary>(); + protected Dictionary>> m_ResourcePool = new Dictionary>>(); // This list allows us to determine if all resources were correctly released in the frame when validity checks are enabled. // This is useful to warn in case of user error or avoid leaks when a render graph execution error occurs for example. @@ -30,25 +52,50 @@ abstract class RenderGraphResourcePool : IRenderGraphResourcePool where Ty protected abstract string GetResourceTypeName(); protected abstract ulong GetSortIndex(Type res); - public void ReleaseResource(int hash, Type resource, int currentFrameIndex) + public void ReleaseResource(int hash, Type resource, int currentFrameIndex, int currentExecutionCount) { if (!m_ResourcePool.TryGetValue(hash, out var list)) { - list = new SortedList(); + list = new SortedList>(); m_ResourcePool.Add(hash, list); } - list.Add(GetSortIndex(resource), (resource, currentFrameIndex)); + list.Add(GetSortIndex(resource), new PooledResourceEntry(resource, currentFrameIndex, currentExecutionCount)); } - public bool TryGetResource(int hashCode, out Type resource) + public bool TryGetResource(int hashCode, out Type resource, int currentFrameIndex, int currentExecutionCount) { - if (m_ResourcePool.TryGetValue(hashCode, out SortedList list) && list.Count > 0) + if (m_ResourcePool.TryGetValue(hashCode, out SortedList> list) && list.Count > 0) { - var index = list.Count - 1; - resource = list.Values[index].resource; - list.RemoveAt(index); // O(1) since it's the last element. - return true; + // When "intra frame memory aliasing" mode is disabled, skip resources that were released in the current execution. + // They will only be available for reuse in the next execution. + if (!IntraFrameMemoryAliasing) + { + // Iterate from the end to find a resource not from the current execution. + for (int i = list.Count - 1; i >= 0; i--) + { + var entry = list.Values[i]; + + // Allow reuse if the resource was released in a previous frame (normal case), + // or in a previous execution within the same frame (Frame Debugger cascade-repaints). + // This handles both standard frame-to-frame reuse and rapid repaints in Frame Debugger. + if (entry.frameIndex < currentFrameIndex || entry.executionCount < currentExecutionCount) + { + resource = entry.resource; + list.RemoveAt(i); + return true; + } + } + // All available resources are from the current execution, so we need to create a new one. + } + else + { + // Normal mode: take the most recent resource. + var index = list.Count - 1; + resource = list.Values[index].resource; + list.RemoveAt(index); // O(1) since it's the last element. + return true; + } } resource = null; @@ -104,7 +151,9 @@ public override void CheckFrameAllocation(bool onException, int frameIndex) { if (!onException) logMessage = $"{logMessage}\n\t{GetResourceName(value.Item2)}"; - ReleaseResource(value.Item1, value.Item2, frameIndex); + // When releasing on exception/error, use -1 as executionCount marker. + // This ensures the resource goes back to the pool but won't interfere with normal execution tracking. + ReleaseResource(value.Item1, value.Item2, frameIndex, -1); } if (!onException) // If onException is true, logMessage is "" diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs index 95d8f2a14b6..d5c21fff63d 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResourceRegistry.cs @@ -328,6 +328,17 @@ internal void EndExecute() current = null; } + internal void EnableIntraFrameMemoryAliasing(bool enabled) + { + for (int i = 0; i < (int)RenderGraphResourceType.Count; ++i) + { + if (m_RenderGraphResources[i].pool != null) + { + m_RenderGraphResources[i].pool.IntraFrameMemoryAliasing = enabled; + } + } + } + [Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")] [MethodImpl(MethodImplOptions.AggressiveInlining)] void CheckHandleValidity(in ResourceHandle res) @@ -1017,7 +1028,7 @@ internal bool CreatePooledResource(InternalRenderGraphContext rgContext, int typ var resource = m_RenderGraphResources[type].resourceArray[index]; if (!resource.imported) { - resource.CreatePooledGraphicsResource(rgContext.forceResourceCreation); + resource.CreatePooledGraphicsResource(m_CurrentFrameIndex, m_ExecutionCount); if (m_RenderGraphDebug.enableLogging) resource.LogCreation(m_FrameInformationLogger); @@ -1095,7 +1106,7 @@ internal void ReleasePooledResource(InternalRenderGraphContext rgContext, int ty resource.LogRelease(m_FrameInformationLogger); } - resource.ReleasePooledGraphicsResource(m_CurrentFrameIndex); + resource.ReleasePooledGraphicsResource(m_CurrentFrameIndex, m_ExecutionCount); } } diff --git a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs index 27b3a51cc65..86904ed5935 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/RenderGraphResources.cs @@ -198,10 +198,10 @@ public virtual bool NeedsFallBack() return requestFallBack && writeCount == 0; } - public virtual void CreatePooledGraphicsResource(bool forceResourceCreation) { } + public virtual void CreatePooledGraphicsResource(int frameIndex, int executionCount) { } public virtual void CreateGraphicsResource() { } public virtual void UpdateGraphicsResource() { } - public virtual void ReleasePooledGraphicsResource(int frameIndex) { } + public virtual void ReleasePooledGraphicsResource(int frameIndex, int executionCount) { } public virtual void ReleaseGraphicsResource() { } public virtual void LogCreation(RenderGraphLogger logger) { } public virtual void LogRelease(RenderGraphLogger logger) { } @@ -246,7 +246,7 @@ public override void ReleaseGraphicsResource() graphicsResource = null; } - public override void CreatePooledGraphicsResource(bool forceResourceCreation) + public override void CreatePooledGraphicsResource(int frameIndex, int executionCount) { Debug.Assert(m_Pool != null, "RenderGraphResource: CreatePooledGraphicsResource should only be called for regular pooled resources"); @@ -257,7 +257,7 @@ public override void CreatePooledGraphicsResource(bool forceResourceCreation) // If the pool doesn't have any available resource that we can use, we will create one // In any case, we will update the graphicsResource name based on the RenderGraph resource name - if (forceResourceCreation || !m_Pool.TryGetResource(hashCode, out graphicsResource)) + if (!m_Pool.TryGetResource(hashCode, out graphicsResource, frameIndex, executionCount)) { CreateGraphicsResource(); } @@ -270,7 +270,7 @@ public override void CreatePooledGraphicsResource(bool forceResourceCreation) m_Pool.RegisterFrameAllocation(cachedHash, graphicsResource); } - public override void ReleasePooledGraphicsResource(int frameIndex) + public override void ReleasePooledGraphicsResource(int frameIndex, int executionCount) { if (graphicsResource == null) throw new InvalidOperationException($"RenderGraphResource: Tried to release a resource ({GetName()}) that was never created. Check that there is at least one pass writing to it first."); @@ -278,7 +278,7 @@ public override void ReleasePooledGraphicsResource(int frameIndex) // Shared resources don't use the pool if (m_Pool != null) { - m_Pool.ReleaseResource(cachedHash, graphicsResource, frameIndex); + m_Pool.ReleaseResource(cachedHash, graphicsResource, frameIndex, executionCount); m_Pool.UnregisterFrameAllocation(cachedHash, graphicsResource); } diff --git a/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphTests.cs b/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphTests.cs index 3389eb7540f..fcb37de3f90 100644 --- a/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphTests.cs +++ b/Packages/com.unity.render-pipelines.core/Tests/Editor/RenderGraphTests.cs @@ -2372,8 +2372,8 @@ public void ResourcePool_Cleanup_ReleaseGfxResourceAndClearPool() useMipMap: false, autoGenerateMips: false, name: "DummyPoolTexture"); - // Release it into the pool - texturePool.ReleaseResource(0, resIn, 0); + // Release it into the pool (frameIndex=0, executionCount=0) + texturePool.ReleaseResource(0, resIn, 0, 0); Assert.IsTrue(texturePool.GetMemorySizeInMB() > 0); Assert.IsTrue(texturePool.GetNumResourcesAvailable() == 1); @@ -2400,12 +2400,13 @@ public void ResourcePool_TryGet() useMipMap: false, autoGenerateMips: false, name: "DummyPoolTexture"); - // Release it into the pool - texturePool.ReleaseResource(0, resIn, 0); + // Release it into the pool (frameIndex=0, executionCount=0) + texturePool.ReleaseResource(0, resIn, 0, 0); // Retrieve it from the pool and make sure this is the right one RTHandle resOut; - texturePool.TryGetResource(0, out resOut); + // Use frameIndex=1, executionCount=1 to ensure reuse (different frame and execution) + texturePool.TryGetResource(0, out resOut, 1, 1); Assert.IsTrue(resIn.GetUniqueID() == resOut.GetUniqueID()); texturePool.Cleanup(); @@ -2572,5 +2573,244 @@ public void TextureUVOrigin_CheckTextureReadBreaksBackbufferUVOriginInherited() m_RenderGraph.Cleanup(); } + + [Test] + public void IntraFrameMemoryAliasing_WhenEnabled_ResourcesCanBeReusedWithinSameFrame() + { + var format = GraphicsFormat.R8G8B8A8_UNorm; + if (!SystemInfo.IsFormatSupported(format, GraphicsFormatUsage.LoadStore)) + { + Assert.Ignore($"Platform does not support random writes (LoadStore) for {format}"); + } + + const int kWidth = 512; + const int kHeight = 512; + + EntityId pass1ResourceID = default; + EntityId pass2ResourceID = default; + + m_RenderGraphTestPipeline.recordRenderGraphBody = (context, camera, cmd) => + { + // Enable intra-frame memory aliasing + m_RenderGraph.SetIntraFrameMemoryAliasing(true); + + // TODO: Create texture 1 with enableRandomWrite to allow UAV access (compute/non-fragment usage). + // This prevents memoryless detection on Metal. When textures are used as fragment attachments + // (render targets), Metal's compiler marks them as memoryless even with disablePassMerging=true, + // which modifies TextureDesc.memoryless and breaks resource pooling hash matching. + // Using compute passes with UAV access avoids the fragment attachment path entirely. + var texture1 = m_RenderGraph.CreateTexture(new TextureDesc(kWidth, kHeight) { colorFormat = format, enableRandomWrite = true, name = "Texture1" }); + + using (var builder = m_RenderGraph.AddComputePass("Pass1_WriteTexture1", out var passData)) + { + passData.textures[0] = texture1; + builder.UseTexture(texture1, AccessFlags.Write); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, ComputeGraphContext ctx) => + { + RTHandle rtHandle = data.textures[0]; + if (rtHandle != null && rtHandle.rt != null) + pass1ResourceID = rtHandle.rt.GetEntityId(); + }); + } + + // Read texture1 to complete its lifetime (this will cause it to be released after this pass) + using (var builder = m_RenderGraph.AddComputePass("Pass1b_ReadTexture1", out var passData)) + { + builder.UseTexture(texture1, AccessFlags.Read); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, ComputeGraphContext ctx) => { }); + } + + // Create texture 2 with same spec (should reuse texture1's resource when intra-frame aliasing is enabled) + var texture2 = m_RenderGraph.CreateTexture(new TextureDesc(kWidth, kHeight) { colorFormat = format, enableRandomWrite = true, name = "Texture2" }); + + using (var builder = m_RenderGraph.AddComputePass("Pass2_WriteTexture2", out var passData)) + { + passData.textures[0] = texture2; + builder.UseTexture(texture2, AccessFlags.Write); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, ComputeGraphContext ctx) => + { + RTHandle rtHandle = data.textures[0]; + if (rtHandle != null && rtHandle.rt != null) + pass2ResourceID = rtHandle.rt.GetEntityId(); + }); + } + }; + + m_Camera.Render(); + + // When intra-frame memory aliasing is enabled (default), both textures should share the same underlying RenderTexture + Assert.AreNotEqual(default(EntityId), pass1ResourceID, "Pass 1 resource ID should not be default"); + Assert.AreNotEqual(default(EntityId), pass2ResourceID, "Pass 2 resource ID should not be default"); + Assert.AreEqual(pass1ResourceID, pass2ResourceID, "With intra-frame aliasing enabled, both textures should reuse the same underlying RenderTexture"); + } + + [Test] + public void IntraFrameMemoryAliasing_WhenDisabled_ResourcesCannotBeReusedWithinSameFrame() + { + const int kWidth = 256; + const int kHeight = 256; + + EntityId pass1ResourceID = default; + EntityId pass2ResourceID = default; + + m_RenderGraphTestPipeline.recordRenderGraphBody = (context, camera, cmd) => + { + // Disable intra-frame memory aliasing + m_RenderGraph.SetIntraFrameMemoryAliasing(false); + + // Create texture 1, write to it, then read from it so it has a complete lifetime + var texture1 = m_RenderGraph.CreateTexture(new TextureDesc(kWidth, kHeight) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, name = "Texture1" }); + + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass1_WriteTexture1", out var passData)) + { + passData.textures[0] = texture1; + builder.SetRenderAttachment(texture1, 0, AccessFlags.Write); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => + { + RTHandle rtHandle = data.textures[0]; + if (rtHandle != null && rtHandle.rt != null) + pass1ResourceID = rtHandle.rt.GetEntityId(); + }); + } + + // Read texture1 to complete its lifetime (this will cause it to be released after this pass) + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass1b_ReadTexture1", out var passData)) + { + builder.UseTexture(texture1, AccessFlags.Read); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => { }); + } + + // Create texture 2 with same spec (should NOT reuse texture1's resource when intra-frame aliasing is disabled) + var texture2 = m_RenderGraph.CreateTexture(new TextureDesc(kWidth, kHeight) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, name = "Texture2" }); + + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass2_WriteTexture2", out var passData)) + { + passData.textures[0] = texture2; + builder.SetRenderAttachment(texture2, 0, AccessFlags.Write); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => + { + RTHandle rtHandle = data.textures[0]; + if (rtHandle != null && rtHandle.rt != null) + pass2ResourceID = rtHandle.rt.GetEntityId(); + }); + } + }; + + m_Camera.Render(); + + // When intra-frame memory aliasing is disabled, both textures should use different underlying RenderTextures + Assert.AreNotEqual(default(EntityId), pass1ResourceID, "Pass 1 resource ID should not be default"); + Assert.AreNotEqual(default(EntityId), pass2ResourceID, "Pass 2 resource ID should not be default"); + Assert.AreNotEqual(pass1ResourceID, pass2ResourceID, "With intra-frame aliasing disabled, both textures should use different underlying RenderTextures"); + } + + [Test] + public void IntraFrameMemoryAliasing_RuntimeToggle_AffectsResourcePooling() + { + const int kWidth = 256; + const int kHeight = 256; + + int executionCount = 0; + EntityId[] capturedResourceIDs = new EntityId[6]; + + m_RenderGraphTestPipeline.recordRenderGraphBody = (context, camera, cmd) => + { + int currentExecution = executionCount; + + // Toggle intra-frame memory aliasing based on execution + if (currentExecution == 0) + { + // Start with enabled + m_RenderGraph.SetIntraFrameMemoryAliasing(true); + } + else if (currentExecution == 1) + { + // Switch to disabled for second execution + m_RenderGraph.SetIntraFrameMemoryAliasing(false); + } + else if (currentExecution == 2) + { + // Switch back to enabled for third execution + m_RenderGraph.SetIntraFrameMemoryAliasing(true); + } + + // Create and use two textures with same specs + var texture1 = m_RenderGraph.CreateTexture(new TextureDesc(kWidth, kHeight) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, name = "Texture1" }); + + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass1", out var passData)) + { + passData.textures[0] = texture1; + builder.SetRenderAttachment(texture1, 0, AccessFlags.Write); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => + { + RTHandle rtHandle = data.textures[0]; + if (rtHandle != null && rtHandle.rt != null) + capturedResourceIDs[currentExecution * 2] = rtHandle.rt.GetEntityId(); + }); + } + + // Read texture1 to complete its lifetime + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass1b_ReadTexture1", out var passData)) + { + builder.UseTexture(texture1, AccessFlags.Read); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => { }); + } + + var texture2 = m_RenderGraph.CreateTexture(new TextureDesc(kWidth, kHeight) { colorFormat = GraphicsFormat.R8G8B8A8_UNorm, name = "Texture2" }); + + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass2", out var passData)) + { + passData.textures[0] = texture2; + builder.SetRenderAttachment(texture2, 0, AccessFlags.Write); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => + { + RTHandle rtHandle = data.textures[0]; + if (rtHandle != null && rtHandle.rt != null) + capturedResourceIDs[currentExecution * 2 + 1] = rtHandle.rt.GetEntityId(); + }); + } + + // Read texture2 to ensure it's not culled + using (var builder = m_RenderGraph.AddRasterRenderPass("Pass3_Read", out var passData)) + { + builder.UseTexture(texture2, AccessFlags.Read); + builder.AllowPassCulling(false); + builder.SetRenderFunc((RenderGraphTestPassData data, RasterGraphContext ctx) => { }); + } + + executionCount++; + }; + + // Execute 3 times with different settings + m_Camera.Render(); // Execution 0: aliasing enabled + m_Camera.Render(); // Execution 1: aliasing disabled + m_Camera.Render(); // Execution 2: aliasing enabled again + + Assert.AreEqual(3, executionCount, "Should have executed 3 times"); + + // Execution 0: Aliasing enabled - resources should be same + Assert.AreNotEqual(default(EntityId), capturedResourceIDs[0], "Resource 0 ID should not be default"); + Assert.AreNotEqual(default(EntityId), capturedResourceIDs[1], "Resource 1 ID should not be default"); + Assert.AreEqual(capturedResourceIDs[0], capturedResourceIDs[1], "Execution 0: Resources should be aliased when enabled"); + + // Execution 1: Aliasing disabled - resources should be different + Assert.AreNotEqual(default(EntityId), capturedResourceIDs[2], "Resource 2 ID should not be default"); + Assert.AreNotEqual(default(EntityId), capturedResourceIDs[3], "Resource 3 ID should not be default"); + Assert.AreNotEqual(capturedResourceIDs[2], capturedResourceIDs[3], "Execution 1: Resources should NOT be aliased when disabled"); + + // Execution 2: Aliasing enabled again - resources should be same again + Assert.AreNotEqual(default(EntityId), capturedResourceIDs[4], "Resource 4 ID should not be default"); + Assert.AreNotEqual(default(EntityId), capturedResourceIDs[5], "Resource 5 ID should not be default"); + Assert.AreEqual(capturedResourceIDs[4], capturedResourceIDs[5], "Execution 2: Resources should be aliased again when re-enabled"); + } } } From 8bc93bf85c1cdf342076058670cdcf7b8028da6f Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 26 May 2026 09:23:06 +0000 Subject: [PATCH 10/38] [Port] [6000.4] Revert "Merge PR #55837 from graphics/hdrp/fix-uum-84980" --- .../Runtime/Material/Lit/Lit.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index fb73c092f7a..fa59460d947 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -1789,7 +1789,7 @@ IndirectLighting EvaluateBSDF_ScreenSpaceReflection(PositionInputs posInput, // // Note that the SSR with clear coat is a binary state, which means we should never enter the if condition if we don't have an active // clear coat (which is not guaranteed by the HasFlag condition in deferred mode in some cases). We then need to make sure that coatMask is actually non zero. - if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) && bsdfData.coatMask >= 0.0) + if (HasFlag(bsdfData.materialFeatures, MATERIALFEATUREFLAGS_LIT_CLEAR_COAT) && bsdfData.coatMask > 0.0) { // We use the coat-traced light according to how similar the base lobe roughness is to the coat roughness // (we can assume the coat is always smoother): From 80d88ca7e48a1c56a0805683ff79d255bc23e844 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 26 May 2026 09:23:07 +0000 Subject: [PATCH 11/38] [Port] [6000.4] Fix APV crash caused by stale cell indices in PruneCellIndexList --- .../Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.cs b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.cs index ff5e52958b4..b1241474be2 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Lighting/ProbeVolume/ProbeVolumeBakingSet.cs @@ -769,13 +769,13 @@ void ReleaseStreamableAssetData(NativeArray buffer) where T : struct m_ReadOperationScratchBuffers.Push(buffer.Reinterpret(UnsafeUtility.SizeOf())); } - void PruneCellIndexList(List cellIndices, List prunedIndexList) + internal void PruneCellIndexList(List cellIndices, List prunedIndexList) { prunedIndexList.Clear(); foreach (var cellIndex in cellIndices) { // When clearing data only partially (ie: not all scenes are loaded), there can be left over indices here but no cells in the set. - if (!cellDataMap.ContainsKey(cellIndex)) + if (!cellDataMap.ContainsKey(cellIndex) && cellDescs.ContainsKey(cellIndex)) { prunedIndexList.Add(cellIndex); } From d1d97b9760ae2f768f33cd999df0e691c1afc505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Myeongseon=20Kim=20=EF=BC=88=EA=B9=80=EB=AA=85=EC=84=A0?= =?UTF-8?q?=EF=BC=89?= Date: Wed, 27 May 2026 16:18:38 +0000 Subject: [PATCH 12/38] [Port] [6000.4] [UUM-137796] Fix offscreen UI rendering for HDR Output with stacked and multi-stack cameras --- .../2D/Rendergraph/Renderer2DRendergraph.cs | 9 +++++++- .../Runtime/UniversalRenderPipeline.cs | 22 ++++++++++++++----- .../Runtime/UniversalRendererRenderGraph.cs | 9 +++++++- 3 files changed, 32 insertions(+), 8 deletions(-) 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 d7456de6fda..aa63f99d295 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 @@ -682,10 +682,17 @@ void CreateCameraDepthCopyTexture(RenderGraph renderGraph, RenderTextureDescript void CreateOffscreenUITexture(RenderGraph renderGraph, in RenderTextureDescriptor descriptor) { UniversalResourceData resourceData = frameData.Get(); + UniversalCameraData cameraData = frameData.Get(); TextureDesc textureDesc = new TextureDesc(descriptor); DrawScreenSpaceUIPass.ConfigureOffscreenUITextureDesc(ref textureDesc); RenderingUtils.ReAllocateHandleIfNeeded(ref m_OffscreenUIColorHandle, textureDesc, name: "_OverlayUITexture"); - resourceData.overlayUITexture = renderGraph.ImportTexture(m_OffscreenUIColorHandle); + + // Clear the texture to avoid stale data from previous frames + ImportResourceParams importParams = new ImportResourceParams(); + importParams.clearOnFirstUse = cameraData.rendersOffscreenUI; + importParams.clearColor = Color.clear; + importParams.discardOnLastUse = false; + resourceData.overlayUITexture = renderGraph.ImportTexture(m_OffscreenUIColorHandle, importParams); } public override void OnBeginRenderGraphFrame() diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs index 118872dee1e..710bac00daf 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs @@ -1068,12 +1068,8 @@ static void RenderCameraStack(ScriptableRenderContext context, Camera baseCamera baseCameraData.stackAnyPostProcessingEnabled = stackAnyPostProcessingEnabled; baseCameraData.stackLastCameraOutputToHDR = finalOutputHDR; - // Render the offscreen overlay UI only in the first base camera. - var rendersOffscreenUI = baseCameraData.rendersOverlayUI && finalOutputHDR && !offscreenUIRenderedInCurrentFrame; - if (rendersOffscreenUI) - offscreenUIRenderedInCurrentFrame = true; - baseCameraData.rendersOffscreenUI = rendersOffscreenUI; - baseCameraData.blitsOffscreenUICover = rendersOffscreenUI && requireOffscreenUICoverPrepass; + // Render the HDR offscreen overlay UI only in the first base camera if it renders overlay UI. + UpdateOffscreenUIRendering(baseCameraData, finalOutputHDR); RenderSingleCamera(context, baseCameraData); } @@ -1125,6 +1121,10 @@ static void RenderCameraStack(ScriptableRenderContext context, Camera baseCamera overlayCameraData.stackAnyPostProcessingEnabled = stackAnyPostProcessingEnabled; overlayCameraData.stackLastCameraOutputToHDR = finalOutputHDR; + // Render the HDR offscreen overlay UI from the stack's last camera if earlier base camera did not render overlay UI. + if (isLastOverlayCamera) + UpdateOffscreenUIRendering(overlayCameraData, finalOutputHDR); + xrLayout.ReconfigurePass(overlayCameraData.xr, overlayCamera); RenderSingleCamera(context, overlayCameraData); @@ -1205,6 +1205,16 @@ static void UpdateCameraData(UniversalCameraData baseCameraData, in XRPass xr) #endif } + static void UpdateOffscreenUIRendering(UniversalCameraData cameraData, bool finalOutputHDR) + { + // The first eligible camera in the frame draws HDR offscreen overlay UI. + var rendersOffscreenUI = cameraData.rendersOverlayUI && finalOutputHDR && !offscreenUIRenderedInCurrentFrame; + if (rendersOffscreenUI) + offscreenUIRenderedInCurrentFrame = true; + cameraData.rendersOffscreenUI = rendersOffscreenUI; + cameraData.blitsOffscreenUICover = rendersOffscreenUI && requireOffscreenUICoverPrepass; + } + static void UpdateVolumeFramework(Camera camera, UniversalAdditionalCameraData additionalCameraData) { using var profScope = new ProfilingScope(ProfilingSampler.Get(URPProfileId.UpdateVolumeFramework)); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs index 557377db42c..b871cad48e3 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs @@ -1927,9 +1927,16 @@ void CreateRenderingLayersTexture(RenderGraph renderGraph, TextureDesc descripto void CreateOffscreenUITexture(RenderGraph renderGraph, TextureDesc descriptor) { UniversalResourceData resourceData = frameData.Get(); + UniversalCameraData cameraData = frameData.Get(); DrawScreenSpaceUIPass.ConfigureOffscreenUITextureDesc(ref descriptor); RenderingUtils.ReAllocateHandleIfNeeded(ref s_OffscreenUIColorHandle, descriptor, name: "_OverlayUITexture"); - resourceData.overlayUITexture = renderGraph.ImportTexture(s_OffscreenUIColorHandle); + + // Clear the texture to avoid stale data from previous frames + ImportResourceParams importParams = new ImportResourceParams(); + importParams.clearOnFirstUse = cameraData.rendersOffscreenUI; + importParams.clearColor = Color.clear; + importParams.discardOnLastUse = false; + resourceData.overlayUITexture = renderGraph.ImportTexture(s_OffscreenUIColorHandle, importParams); } void DepthNormalPrepassRender(RenderGraph renderGraph, RenderPassInputSummary renderPassInputs, in TextureHandle depthTarget, uint batchLayerMask, bool setGlobalDepth, bool setGlobalTextures, bool partialPass) From 4512650bdcd4f423e4f3ed04ee0a9ea531099e61 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Wed, 27 May 2026 16:18:39 +0000 Subject: [PATCH 13/38] [Port] [6000.4] [UUM-142661] Fix HDRP post-processing volume overrides not updating --- .../Runtime/Utilities/HashFNV1A32.cs | 35 +++++++++++++++++++ .../Runtime/Volume/VolumeComponent.cs | 20 +++++++++++ .../Runtime/Volume/VolumeProfile.cs | 30 ++++++++++++++++ .../HDRenderPipeline.PostProcess.cs | 33 +++++++++-------- 4 files changed, 103 insertions(+), 15 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Utilities/HashFNV1A32.cs b/Packages/com.unity.render-pipelines.core/Runtime/Utilities/HashFNV1A32.cs index ed76b8f56de..34cf6543054 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Utilities/HashFNV1A32.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Utilities/HashFNV1A32.cs @@ -5,6 +5,16 @@ namespace UnityEngine.Rendering { + /// + /// Incremental 32-bit FNV-1a hash builder. + /// Use this for change detection or other non-cryptographic hashing where + /// equally-shaped inputs should produce well-distributed hashes. + /// + /// + /// As a ref struct, instances cannot be stored in fields, boxed, or + /// captured by lambdas/async methods; create one, append inputs, then read + /// . + /// internal ref struct HashFNV1A32 { /// @@ -19,11 +29,17 @@ internal ref struct HashFNV1A32 uint m_Hash; + /// + /// Creates a new hash builder seeded with the FNV offset basis. + /// + /// An empty ready to receive calls. public static HashFNV1A32 Create() { return new HashFNV1A32 { m_Hash = k_OffsetBasis }; } + /// Mixes an into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in int input) { @@ -33,6 +49,8 @@ public void Append(in int input) } } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in uint input) { @@ -42,12 +60,16 @@ public void Append(in uint input) } } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in bool input) { m_Hash = (m_Hash ^ (input ? 1u : 0u)) * k_Prime; } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in float input) { @@ -57,6 +79,8 @@ public void Append(in float input) } } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in double input) { @@ -66,6 +90,8 @@ public void Append(in double input) } } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in Vector2 input) { @@ -75,6 +101,8 @@ public void Append(in Vector2 input) } } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in Vector3 input) { @@ -84,6 +112,8 @@ public void Append(in Vector3 input) } } + /// Mixes a into the running hash. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(in Vector4 input) { @@ -93,6 +123,9 @@ public void Append(in Vector4 input) } } + /// Mixes any value-type input into the running hash via its . + /// Any value type. + /// Value to fold in. [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Append(T input) where T : struct { @@ -102,8 +135,10 @@ public void Append(T input) where T : struct } } + /// The current hash value as a signed 32-bit integer. public int value => (int)m_Hash; + /// public override int GetHashCode() { return value; diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs index c125c1c7bf9..264b592be13 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeComponent.cs @@ -342,6 +342,26 @@ public bool AnyPropertiesIsOverridden() return false; } + /// + /// Computes a hash of the current state of every parameter on this component + /// (values and override flags). Intended for change detection — for example, + /// invalidating a cached render target when any parameter changes. + /// + /// + /// This value mutates as parameters change, so it must not be used as a key in + /// a , + /// , or any other structure + /// that assumes a stable hash. Use for that. + /// + /// A hash that changes whenever any parameter's value or override state changes. + public int GetStateHash() + { + var hash = HashFNV1A32.Create(); + for (int i = 0; i < parameterList.Length; i++) + hash.Append(parameterList[i].GetHashCode()); + return hash.value; + } + /// /// Unity calls this method before the object is destroyed. /// diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs index 38e3e6f29cf..7475939a712 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/Volume/VolumeProfile.cs @@ -334,6 +334,36 @@ internal int GetComponentListHashCode() } } + /// + /// Computes a hash of the current state of every component on this profile + /// (the values and override flags of all their parameters). + /// Intended for change detection — for example, detecting that a Volume Profile + /// asset has been edited and a dependent cached resource must be rebuilt. + /// + /// + /// This value mutates as parameters change, so it must not be used as a key in + /// a , + /// , or any other structure + /// that assumes a stable hash. Use for that. + /// + /// This hash covers parameter state only. To detect changes to the *set* of + /// components on the profile (additions/removals), use + /// . + /// + /// A hash that changes whenever any component's state changes. + public int GetStateHash() + { + var hash = HashFNV1A32.Create(); + for (int i = 0; i < components.Count; i++) + { + var comp = components[i]; + if (comp == null) + continue; + hash.Append(comp.GetStateHash()); + } + return hash.value; + } + /// /// Removes any components that were destroyed externally from the iternal list of components /// diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs index 93cf4ef4cc3..c8cd9eab3b6 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs @@ -425,23 +425,26 @@ void BeginPostProcessFrame(CommandBuffer cmd, HDCamera camera, HDRenderPipeline int ComputeLUTHash(HDCamera hdCamera) { - return m_Tonemapping.GetHashCode() * 23 + - m_WhiteBalance.GetHashCode() * 23 + - m_ColorAdjustments.GetHashCode() * 23 + - m_ChannelMixer.GetHashCode() * 23 + - m_SplitToning.GetHashCode() * 23 + - m_LiftGammaGain.GetHashCode() * 23 + - m_ShadowsMidtonesHighlights.GetHashCode() * 23 + - m_Curves.GetHashCode() * 23 + - m_TonemappingFS.GetHashCode() * 23 + - m_ColorGradingFS.GetHashCode() * 23 + - HDROutputActiveForCameraType(hdCamera).GetHashCode() + unchecked + { + int hash = 17; + hash = hash * 23 + m_Tonemapping.GetStateHash(); + hash = hash * 23 + m_WhiteBalance.GetStateHash(); + hash = hash * 23 + m_ColorAdjustments.GetStateHash(); + hash = hash * 23 + m_ChannelMixer.GetStateHash(); + hash = hash * 23 + m_SplitToning.GetStateHash(); + hash = hash * 23 + m_LiftGammaGain.GetStateHash(); + hash = hash * 23 + m_ShadowsMidtonesHighlights.GetStateHash(); + hash = hash * 23 + m_Curves.GetStateHash(); + hash = hash * 23 + m_TonemappingFS.GetHashCode(); + hash = hash * 23 + m_ColorGradingFS.GetHashCode(); + hash = hash * 23 + HDROutputActiveForCameraType(hdCamera).GetHashCode(); #if UNITY_EDITOR - * 23 - + m_ColorGradingSettings.space.GetHashCode() * 23 + - + UnityEditor.PlayerSettings.hdrBitDepth.GetHashCode() + hash = hash * 23 + m_ColorGradingSettings.space.GetHashCode(); + hash = hash * 23 + UnityEditor.PlayerSettings.hdrBitDepth.GetHashCode(); #endif - ; + return hash; + } } static void ValidateComputeBuffer(ref ComputeBuffer cb, int size, int stride, ComputeBufferType type = ComputeBufferType.Default) From 31c78903c024c96959407bfc7acadbc1719cf88d Mon Sep 17 00:00:00 2001 From: Evergreen Date: Thu, 28 May 2026 17:19:07 +0000 Subject: [PATCH 14/38] [Port] [6000.4] [UUM-141627][6000.6][URP 2D] Fix picking for sprites with -ve scale using shadergraph materials --- .../Editor/ShaderGraph/Targets/UniversalTarget.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 bbf974fbda5..688d584c119 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 @@ -1368,7 +1368,7 @@ public static PassDescriptor _2DScenePicking(UniversalTarget target) fieldDependencies = CoreFieldDependencies.Default, // Conditional State - renderStates = CoreRenderStates.ScenePicking(target), + renderStates = CoreRenderStates.ScenePicking2D, pragmas = CorePragmas._2DDefault, defines = new DefineCollection { CoreDefines.ScenePicking, { CoreKeywordDescriptors.AlphaClipThreshold, 0 } }, keywords = new KeywordCollection(), @@ -1678,6 +1678,12 @@ public static RenderStateCollection ScenePicking(UniversalTarget target) return result; } + + public static RenderStateCollection ScenePicking2D = new RenderStateCollection + { + { RenderState.Cull(Cull.Back), new FieldCondition(Fields.DoubleSided, false) }, + { RenderState.Cull(Cull.Off), new FieldCondition(Fields.DoubleSided, true) }, + }; } #endregion From 808697bc6b9d77db3a920245fd9003a66c8f2637 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Fri, 29 May 2026 01:35:27 +0000 Subject: [PATCH 15/38] [Port] [6000.4] [HDRP] Fix motion blur min-velocity sentinel leak (UUM-142360) --- .../PostProcessing/Shaders/MotionBlurMergeTilePass.compute | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/MotionBlurMergeTilePass.compute b/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/MotionBlurMergeTilePass.compute index bf92d87e716..5d0afff6e70 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/MotionBlurMergeTilePass.compute +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/MotionBlurMergeTilePass.compute @@ -25,7 +25,7 @@ void TileMerge(uint3 dispatchID : SV_DispatchThreadID) if (maxVelLen > TILE_SIZE*0.5f) { int tileCount = maxVelLen / TILE_SIZE; - if (tileCount > 4) tileCount = 4; + tileCount = clamp(tileCount, 1, 4); minVel = 999999.0f; // This is sub-optimal, but the texture is tiny and should be fairly cache efficient. From cb3fa050b81d1ae41d58c3e2f8f8370bb8eec5e8 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Fri, 29 May 2026 20:27:06 +0000 Subject: [PATCH 16/38] [Port] [6000.4] [UUM-141781][6000.6][URP 2D] Fix Lens Flare NaN error when used with 2D Renderer --- .../PostProcessing/LensFlareCommonSRP.cs | 14 +- .../2D/Rendergraph/Renderer2DRendergraph.cs | 2 +- .../Scenes/061_PostProcessing_LensFlare.unity | 460 ++++++++++++++++++ .../061_PostProcessing_LensFlare.unity.meta | 7 + 4 files changed, 476 insertions(+), 7 deletions(-) create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity create mode 100644 Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity.meta diff --git a/Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareCommonSRP.cs b/Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareCommonSRP.cs index 346b28985b8..6e19b8858d6 100644 --- a/Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareCommonSRP.cs +++ b/Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareCommonSRP.cs @@ -830,15 +830,15 @@ static Vector3 WorldToViewport(Camera camera, bool isLocalLight, bool isCameraRe { if (isLocalLight) { - return WorldToViewportLocal(isCameraRelative, viewProjMatrix, camera.transform.position, positionWS); + return WorldToViewportLocal(isCameraRelative, viewProjMatrix, camera.transform.position, positionWS, !camera.orthographic); } else { - return WorldToViewportDistance(camera, positionWS); + return WorldToViewportDistance(camera, positionWS, !camera.orthographic); } } - static Vector3 WorldToViewportLocal(bool isCameraRelative, Matrix4x4 viewProjMatrix, Vector3 cameraPosWS, Vector3 positionWS) + static Vector3 WorldToViewportLocal(bool isCameraRelative, Matrix4x4 viewProjMatrix, Vector3 cameraPosWS, Vector3 positionWS, bool isPerspective) { Vector3 localPositionWS = positionWS; if (isCameraRelative) @@ -847,7 +847,8 @@ static Vector3 WorldToViewportLocal(bool isCameraRelative, Matrix4x4 viewProjMat } Vector4 viewportPos4 = viewProjMatrix * localPositionWS; Vector3 viewportPos = new Vector3(viewportPos4.x, viewportPos4.y, 0f); - viewportPos /= viewportPos4.w; + if (isPerspective) + viewportPos /= viewportPos4.w; viewportPos.x = viewportPos.x * 0.5f + 0.5f; viewportPos.y = viewportPos.y * 0.5f + 0.5f; viewportPos.y = 1.0f - viewportPos.y; @@ -855,12 +856,13 @@ static Vector3 WorldToViewportLocal(bool isCameraRelative, Matrix4x4 viewProjMat return viewportPos; } - static Vector3 WorldToViewportDistance(Camera cam, Vector3 positionWS) + static Vector3 WorldToViewportDistance(Camera cam, Vector3 positionWS, bool isPerspective) { Vector4 camPos = cam.worldToCameraMatrix * positionWS; Vector4 viewportPos4 = cam.projectionMatrix * camPos; Vector3 viewportPos = new Vector3(viewportPos4.x, viewportPos4.y, 0f); - viewportPos /= viewportPos4.w; + if (isPerspective) + viewportPos /= viewportPos4.w; viewportPos.x = viewportPos.x * 0.5f + 0.5f; viewportPos.y = viewportPos.y * 0.5f + 0.5f; viewportPos.z = viewportPos4.w; 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 aa63f99d295..9701f184a02 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 @@ -661,7 +661,7 @@ bool RequiresDepthCopyPass() var renderPassInputs = GetRenderPassInputs(); bool requiresDepthTexture = cameraData.requiresDepthTexture || renderPassInputs.requiresDepthTexture; - bool cameraHasPostProcessingWithDepth = cameraData.postProcessEnabled && m_PostProcess != null && cameraData.postProcessingRequiresDepthTexture; + bool cameraHasPostProcessingWithDepth = cameraData.postProcessEnabled && m_PostProcess != null && (cameraData.postProcessingRequiresDepthTexture || !LensFlareCommonSRP.Instance.IsEmpty()); bool requiresDepthCopyPass = (cameraHasPostProcessingWithDepth || requiresDepthTexture) && m_CreateDepthTexture; return requiresDepthCopyPass; diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity new file mode 100644 index 00000000000..cce3c4d0e59 --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity @@ -0,0 +1,460 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 10 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_UseRadianceAmbientProbe: 0 +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 13 + m_BakeOnSceneLoad: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 0 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 12 + m_Resolution: 2 + m_BakeResolution: 40 + m_AtlasSize: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_ExtractAmbientOcclusion: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_ReflectionCompression: 2 + m_MixedBakeMode: 2 + m_BakeBackend: 2 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 512 + m_PVRBounces: 2 + m_PVREnvironmentSampleCount: 256 + m_PVREnvironmentReferencePointCount: 2048 + m_PVRFilteringMode: 1 + m_PVRDenoiserTypeDirect: 1 + m_PVRDenoiserTypeIndirect: 1 + m_PVRDenoiserTypeAO: 1 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVREnvironmentMIS: 1 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 1 + m_PVRFilteringGaussRadiusAO: 1 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ExportTrainingData: 0 + m_TrainingDataDestination: TrainingData + m_LightProbeSampleCountMultiplier: 4 + m_LightingDataAsset: {fileID: 20201, guid: 0000000000000000f000000000000000, type: 0} + m_LightingSettings: {fileID: 0} +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 3 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + manualTileSize: 0 + tileSize: 256 + buildHeightMesh: 0 + maxJobWorkers: 0 + preserveTilesOutsideBounds: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &261517873 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 261517878} + - component: {fileID: 261517877} + - component: {fileID: 261517876} + - component: {fileID: 261517875} + - component: {fileID: 261517874} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &261517874 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 261517873} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 73231aa468d81ea49bc3d914080de185, type: 3} + m_Name: + m_EditorClassIdentifier: UniversalGraphicsTests::UniversalGraphicsTestSettings + ImageComparisonSettings: + TargetWidth: 512 + TargetHeight: 512 + TargetMSAASamples: 1 + PerPixelCorrectnessThreshold: 0.001 + PerPixelGammaThreshold: 0.003921569 + PerPixelAlphaThreshold: 0.003921569 + RMSEThreshold: 0 + AverageCorrectnessThreshold: 0.005 + IncorrectPixelsThreshold: 0.0000038146973 + UseHDR: 1 + UseBackBuffer: 0 + ActiveImageTests: 1 + ActivePixelTests: 7 + WaitFrames: 0 + XRCompatible: 0 + gpuDrivenCompatible: 0 + CheckMemoryAllocation: 1 + renderBackendCompatibility: 2 + amdMinThreshold: 0.002 + SetBackBufferResolution: 0 +--- !u!114 &261517875 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 261517873} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a79441f348de89743a2939f4d699eac1, type: 3} + m_Name: + m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.UniversalAdditionalCameraData + m_RenderShadows: 1 + m_RequiresDepthTextureOption: 2 + m_RequiresOpaqueTextureOption: 2 + m_CameraType: 0 + m_Cameras: [] + m_RendererIndex: -1 + m_VolumeLayerMask: + serializedVersion: 2 + m_Bits: 1 + m_VolumeTrigger: {fileID: 0} + m_VolumeFrameworkUpdateModeOption: 2 + m_RenderPostProcessing: 1 + m_Antialiasing: 0 + m_AntialiasingQuality: 2 + m_StopNaN: 0 + m_Dithering: 0 + m_ClearDepth: 1 + m_AllowXRRendering: 1 + m_AllowHDROutput: 1 + m_UseScreenCoordOverride: 0 + m_ScreenSizeOverride: {x: 0, y: 0, z: 0, w: 0} + m_ScreenCoordScaleBias: {x: 0, y: 0, z: 0, w: 0} + m_RequiresDepthTexture: 0 + m_RequiresColorTexture: 0 + m_TaaSettings: + m_Quality: 3 + m_FrameInfluence: 0.1 + m_JitterScale: 1 + m_MipBias: 0 + m_VarianceClampScale: 0.9 + m_ContrastAdaptiveSharpening: 0 + m_Version: 2 +--- !u!81 &261517876 +AudioListener: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 261517873} + m_Enabled: 1 +--- !u!20 &261517877 +Camera: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 261517873} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 1} + m_projectionMatrixMode: 1 + m_GateFitMode: 2 + m_FOVAxisMode: 0 + m_Iso: 200 + m_ShutterSpeed: 0.005 + m_Aperture: 16 + m_FocusDistance: 10 + m_FocalLength: 50 + m_BladeCount: 5 + m_Curvature: {x: 2, y: 11} + m_BarrelClipping: 0.25 + m_Anamorphism: 0 + m_SensorSize: {x: 36, y: 24} + m_LensShift: {x: 0, y: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 1 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &261517878 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 261517873} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &518304874 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 518304876} + - component: {fileID: 518304875} + m_Layer: 0 + m_Name: LensFlare + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &518304875 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 518304874} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cc4d76f733087744991913c9d19d5274, type: 3} + m_Name: + m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.LensFlareComponentSRP + m_LensFlareData: {fileID: 11400000, guid: bd7eaf3bd49c39f4cb77bd809459aa72, type: 2} + version: 0 + intensity: 1 + maxAttenuationDistance: 100 + maxAttenuationScale: 100 + distanceAttenuationCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + scaleByDistanceCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + attenuationByLightShape: 1 + radialScreenAttenuationCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + useOcclusion: 0 + useBackgroundCloudOcclusion: 0 + environmentOcclusion: 0 + useWaterOcclusion: 0 + occlusionRadius: 0.1 + sampleCount: 32 + occlusionOffset: 0.05 + scale: 1 + allowOffScreen: 0 + volumetricCloudOcclusion: 0 + occlusionRemapCurve: + k__BackingField: 2 + m_Loop: 0 + m_ZeroValue: 1 + m_Range: 1 + m_Curve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 1 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 1 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + lightOverride: {fileID: 0} +--- !u!4 &518304876 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 518304874} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1.73, y: 1.53, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 261517878} + - {fileID: 518304876} diff --git a/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity.meta b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity.meta new file mode 100644 index 00000000000..ceb603d350d --- /dev/null +++ b/Tests/SRPTests/Projects/UniversalGraphicsTest_2D/Assets/Scenes/061_PostProcessing_LensFlare.unity.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 946db56769713744cbabb8b1d57aa16f +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: From 3e4818fe333115cbe3b089c344550eed28751f81 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Sat, 30 May 2026 03:39:59 +0000 Subject: [PATCH 17/38] [Port] [6000.4] [UUM-143038] Fix NRE in ReAllocateOffscreenUIColorBufferIfNeeded after build target switch --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 9d28ebc46d1..1e8e5340dfd 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -2187,12 +2187,12 @@ protected override void Render(ScriptableRenderContext renderContext, List Date: Sat, 30 May 2026 03:39:59 +0000 Subject: [PATCH 18/38] [Port] [6000.4] docg-8792: Restructure Block Node documentation into landing-page model --- .../Documentation~/Block-Node.md | 32 +++---------------- .../Documentation~/Master-Stack.md | 31 ++++++++++++++++++ .../Shader-Graph-Preferences.md | 2 +- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/Packages/com.unity.shadergraph/Documentation~/Block-Node.md b/Packages/com.unity.shadergraph/Documentation~/Block-Node.md index b98826160a4..6df0e78eadf 100644 --- a/Packages/com.unity.shadergraph/Documentation~/Block-Node.md +++ b/Packages/com.unity.shadergraph/Documentation~/Block-Node.md @@ -1,29 +1,7 @@ -# Block Node +# Block node reference -## Description +Block nodes are a specific type of node for the [Master Stack](Master-Stack.md). Each Block represents one piece of surface or vertex data that Shader Graph uses in the final shader output. -A Block is a specific type of node for the Master Stack. A Block represents a single piece of the surface (or vertex) description data that Shader Graph uses in the final shader output. [Built In Block nodes](Built-In-Blocks.md) are always available, but nodes that are specific to a certain render pipeline are only available for that pipeline. For example, Universal Block nodes are only available for the Universal Render Pipeline (URP), and High Definition Block nodes are only available for the High Definition Render Pipeline (HDRP). - -Some blocks are only compatible with specific [Graph Settings](Graph-Settings-Tab.md), and might become active or inactive based on the graph settings you select. You can't cut, copy, or paste Blocks. - -## Add and Remove Block Nodes - -To add a new Block node to a Context in the Master Stack, place the cursor over an empty area in the Context, then press the Spacebar or right-click and select **Create Node**. - -This brings up the Create Node menu, which displays only Block nodes that are valid for the Context. For example, Vertex Blocks don't appear in the Create Node menu of a Fragment Context. - -Select a Block node from the menu to add it to the Context. To remove a Block from the Context, select the Block node in the Context, then press the Delete key or right-click and select **Delete**. - -### Automatically Add or Remove Blocks - -You can also enable or disable an option in the Shader Graph Preferences to automatically add and remove Blocks from a Context. - -If you enable **Automatically Add or Remove Blocks**, Shader Graph automatically adds the required Block nodes for that particular asset's Target or material type. It automatically removes any incompatible Block nodes that have no connections and default values. - -If you disable **Automatically Add or Remove Blocks**, Shader Graph doesn't automatically add and remove Block nodes. You must manually add and remove all Block nodes. - -## Active and Inactive Blocks - -Active Block nodes are Blocks that contribute to the final shader. Inactive Block nodes are Blocks that are present in the Shader Graph, but don't contribute to the final shader. - -When you change the graph settings, certain Blocks might become active or inactive. Inactive Block nodes and any node streams that are connected only to Inactive Block nodes appear grayed out. +| Page | Description | +| :--- | :--- | +| [Built-In Blocks](Built-In-Blocks.md) | Block nodes that are always available, regardless of the active render pipeline. | diff --git a/Packages/com.unity.shadergraph/Documentation~/Master-Stack.md b/Packages/com.unity.shadergraph/Documentation~/Master-Stack.md index 442f31fa5e8..72aa58d053f 100644 --- a/Packages/com.unity.shadergraph/Documentation~/Master-Stack.md +++ b/Packages/com.unity.shadergraph/Documentation~/Master-Stack.md @@ -11,3 +11,34 @@ The content of the Master Stack might change depending on the [Graph Settings](G ## Contexts The Master Stack contains two Contexts: Vertex and Fragment. These represent the two stages of a shader. Nodes that you connect to Blocks in the Vertex Context become part of the final shader's vertex function. Nodes that you connect to Blocks in the Fragment Context become part of the final shader's fragment (or pixel) function. If you connect any nodes to both Contexts, they are executed twice, once in the vertex function and then again in the fragment function. You can't cut, copy, or paste Contexts. + +## Block Node + +A Block is a specific type of node for the Master Stack. A Block represents a single piece of the surface (or vertex) description data that Shader Graph uses in the final shader output. [Built In Block nodes](Built-In-Blocks.md) are always available, but nodes that are specific to a certain render pipeline are only available for that pipeline. + +Some blocks are only compatible with specific [Graph Settings](Graph-Settings-Tab.md), and might become active or inactive based on the graph settings you select. You can't cut, copy, or paste Blocks. + +### Add and Remove Block Nodes + +To add a new Block node to a Context in the Master Stack: + +1. Place the cursor over an empty area in the Context. +2. Press the Spacebar, or right-click and select **Create Node**. + + This brings up the Create Node menu, which displays only Block nodes that are valid for the Context. + +3. Select a Block node from the menu to add it to the Context. + +To remove a Block from the Context: + +1. Select the Block node in the Context. +2. Press the Delete key, or right-click and select **Delete**. + +> [!NOTE] +> You can configure Shader Graph to automatically add and remove Block nodes. For more information, refer to [Shader Graph preferences](Shader-Graph-Preferences.md). + +### Active and Inactive Blocks + +Active Block nodes are Blocks that contribute to the final shader. Inactive Block nodes are Blocks that are present in the Shader Graph, but don't contribute to the final shader. + +When you change the graph settings, certain Blocks might become active or inactive. Inactive Block nodes and any node streams that are connected only to Inactive Block nodes appear grayed out. diff --git a/Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Preferences.md b/Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Preferences.md index bb40ef0108b..abc5ae11c78 100644 --- a/Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Preferences.md +++ b/Packages/com.unity.shadergraph/Documentation~/Shader-Graph-Preferences.md @@ -7,7 +7,7 @@ To open the preferences, go to **Edit** > **Preferences** > **Shader Graph** (ma | Property | Description | | :--- | :--- | | **Preview Variant Limit** | Sets the maximum number of variants allowed in local projects. This is a local version of the **Shader Variant Limit** in the project settings. If your graph exceeds this maximum value, Unity returns the following error:
_Validation: Graph is generating too many variants. Either delete Keywords, reduce Keyword variants, or increase the **Shader Variant Limit** in Preferences > Shader Graph._
For more information about shader variants, refer to [Making multiple shader program variants](https://docs.unity3d.com/Manual/SL-MultipleProgramVariants.html). For more information about the Shader Variant Limit, refer to [Shader graph project settings](Shader-Graph-Project-Settings.md) | -| **Automatically Add and Remove Block Nodes** | Adds to the [Master Stack](Master-Stack.md) any needed [Block nodes](Block-Node.md) and removes from the Master Stack any Block nodes with no incoming connections. | +| **Automatically Add and Remove Block Nodes** | When enabled, Shader Graph automatically adds the required [Block nodes](Block-Node.md) for the asset's Target or material type to the [Master Stack](Master-Stack.md), and removes any incompatible Block nodes that have no connections and default values. When disabled, you must manually add and remove all Block nodes. | | **Enable Deprecated Nodes** | Disables warnings for deprecated nodes and properties. When enabled, Shader Graph doesn't display warnings if your graph contains deprecated nodes or properties. When disabled, Shader Graph displays warnings for deprecated nodes and properties, and the new nodes and properties you create use the latest version. | | **Zoom Step Size** | Adjusts how much the Shader Graph camera zooms with each mouse wheel movement. This helps balance zoom speed, since touchpads can zoom much faster than regular mouse wheels.
Only affects materials created automatically, such as when you make a new shader graph from a Decal Projector or Fullscreen Renderer Feature. | | **Graph Template Workflow** | Sets whether Unity creates new materials as [material variants](https://docs.unity3d.com/Manual/materialvariant-concept.html) from the child asset of the shader graph asset, or as standalone materials. The options are:
  • **Material Variant**: Unity creates material variants from the child asset of the shader graph asset.
  • **Material**: Unity creates standalone materials.
| From 8a21ec1742082f295c5530967e7e4307ecd0027b Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 2 Jun 2026 00:38:04 +0000 Subject: [PATCH 19/38] [Port] [6000.4] DOCG-8699 Fix color in subsurface scattering documentation --- .../skin-and-diffusive-surfaces-subsurface-scattering.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/skin-and-diffusive-surfaces-subsurface-scattering.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/skin-and-diffusive-surfaces-subsurface-scattering.md index b2680f20e4a..71ec8619b7c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/skin-and-diffusive-surfaces-subsurface-scattering.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/skin-and-diffusive-surfaces-subsurface-scattering.md @@ -49,11 +49,11 @@ To add subsurface scattering to a Material: 3. In the Surface Inputs section, select [Diffusion Profile](diffusion-profile-reference.md) and assign a diffusion profile. 4. If a warning box appears below the Diffusion Profile property, select **Fix**. -The following image displays grass in an environment scene. In the left image the grass renders correctly. The grass in the right image has the bright green tint that HDRP applies to a Material that doesn't have a valid diffusion profile: +The following image displays grass in an environment scene. In the left image the grass renders correctly. The grass in the right image has the bright magenta tint that HDRP applies to a Material that doesn't have a valid diffusion profile: ![Grass in an environment scene: In the left image the grass renders correctly. The grass in the right image has the bright green tint that HDRP applies to a Material that doesn't have a valid diffusion profile.](Images/missing_profile.png) -The Material appears bright green in the following cases: +The Material appears bright magenta in the following cases: - The Material doesn't have a diffusion profile assigned. From 8a41c6251a553b4348b92456cf068389b55a0461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Myeongseon=20Kim=20=EF=BC=88=EA=B9=80=EB=AA=85=EC=84=A0?= =?UTF-8?q?=EF=BC=89?= Date: Tue, 2 Jun 2026 00:38:04 +0000 Subject: [PATCH 20/38] [Port] [6000.4] [UUM-142884] Fix HDR UI overlay missing when path tracing is enabled --- .../HDRenderPipeline.RenderGraph.cs | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index 34adbd6ece4..b92b4471778 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -166,6 +166,8 @@ void RecordRenderGraph(RenderRequest renderRequest, Debug.LogWarning("Path Tracing is not supported with XR single-pass rendering."); } + uiBuffer = PrepareOffscreenUIBuffer(hdCamera, renderContext, colorBackBuffer); + #if ENABLE_VIRTUALTEXTURES resolveVirtualTextureFeedback = false; #endif @@ -258,23 +260,7 @@ void RecordRenderGraph(RenderRequest renderRequest, colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, renderContext, colorBuffer, prepassOutput.resolvedNormalBuffer, vtFeedbackBuffer, currentColorPyramid, volumetricLighting, rayCountTexture, opticalFogTransmittance, m_SkyManager.GetSkyReflection(hdCamera), gpuLightListOutput, transparentPrepass, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovCustomPassBuffers); - bool rendersOffscreenUI = !m_OffscreenUIRenderedInCurrentFrame && HDROutputActiveForCameraType(hdCamera) && SupportedRenderingFeatures.active.rendersUIOverlay && !NeedHDRDebugMode(m_CurrentDebugDisplaySettings); - if (rendersOffscreenUI) - { - uiBuffer = RenderHDROffscreenUI(m_RenderGraph, hdCamera, renderContext); - m_OffscreenUIRenderedInCurrentFrame = true; - } - else - { - // We do not render offscreen ui for the rest of cameras. - uiBuffer = m_OffscreenUIRenderedInCurrentFrame ? m_RenderGraph.ImportTexture(m_OffscreenUIColorBuffer.Value) : m_RenderGraph.defaultResources.blackTextureXR; - } - - bool blitsOffscreenUICover = rendersOffscreenUI && m_RequireOffscreenUICoverPrepass; - if (blitsOffscreenUICover) - { - BlitFullscreenUIToOffscreen(m_RenderGraph, colorBackBuffer, uiBuffer, hdCamera); - } + uiBuffer = PrepareOffscreenUIBuffer(hdCamera, renderContext, colorBackBuffer); if (NeedMotionVectorForTransparent(hdCamera.frameSettings)) { @@ -1063,6 +1049,30 @@ TextureHandle CreateOffscreenUIDepthBuffer(RenderGraph renderGraph, MSAASamples { format = CoreUtils.GetDefaultDepthStencilFormat(), clearBuffer = true, msaaSamples = msaaSamples, name = "UI Depth Buffer" }); } + TextureHandle PrepareOffscreenUIBuffer(HDCamera hdCamera, ScriptableRenderContext renderContext, TextureHandle colorBackBuffer) + { + TextureHandle uiBuffer; + bool rendersOffscreenUI = !m_OffscreenUIRenderedInCurrentFrame && HDROutputActiveForCameraType(hdCamera) && SupportedRenderingFeatures.active.rendersUIOverlay && !NeedHDRDebugMode(m_CurrentDebugDisplaySettings);; + if (rendersOffscreenUI) + { + uiBuffer = RenderHDROffscreenUI(m_RenderGraph, hdCamera, renderContext); + m_OffscreenUIRenderedInCurrentFrame = true; + } + else + { + // We do not render offscreen ui for the rest of cameras. + uiBuffer = m_OffscreenUIRenderedInCurrentFrame ? m_RenderGraph.ImportTexture(m_OffscreenUIColorBuffer.Value) : m_RenderGraph.defaultResources.blackTextureXR; + } + + bool blitsOffscreenUICover = rendersOffscreenUI && m_RequireOffscreenUICoverPrepass; + if (blitsOffscreenUICover) + { + BlitFullscreenUIToOffscreen(m_RenderGraph, colorBackBuffer, uiBuffer, hdCamera); + } + + return uiBuffer; + } + TextureHandle RenderHDROffscreenUI(RenderGraph renderGraph, HDCamera hdCamera, ScriptableRenderContext renderContext) { TextureHandle output; From b4a440ee3c819fac282bf8e7a8efd9251bb484ee Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 2 Jun 2026 00:38:05 +0000 Subject: [PATCH 21/38] [Port] [6000.4] DOCG-8860 Fixed a typo in HDRP docs --- .../physically-based-sky-volume-override-reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/physically-based-sky-volume-override-reference.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/physically-based-sky-volume-override-reference.md index 6d8937705a2..b5ccacca34e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/physically-based-sky-volume-override-reference.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/physically-based-sky-volume-override-reference.md @@ -18,7 +18,7 @@ The Physically Based Sky’s atmosphere has three types of particles: * Air particles with [Rayleigh scattering](). * Aerosol particles with anisotropic [Mie scattering](https://en.wikipedia.org/wiki/Mie_scattering). You can use aerosols to model pollution, height fog, or mist. -* Ozone particles, which do not contribute to scattering but absorp light. It contributes greatly to the blue color of the sky during twilight. +* Ozone particles, which do not contribute to scattering but absorb light. It contributes greatly to the blue color of the sky during twilight. You can use the Physically Based Sky to simulate the sky during both daytime and night-time. You can change the time of day at runtime without reducing performance. From cabb1581ea925f2f42a6cc32e738f43d8f090006 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Wed, 3 Jun 2026 23:34:05 +0000 Subject: [PATCH 22/38] [Port] [6000.4] Reference updates for Shader Graph side features due to bug fixes --- .../Documentation~/Keywords-reference.md | 6 ++++-- .../com.unity.shadergraph/Documentation~/Property-Types.md | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.shadergraph/Documentation~/Keywords-reference.md b/Packages/com.unity.shadergraph/Documentation~/Keywords-reference.md index 98576807ab3..abc1e7b669b 100644 --- a/Packages/com.unity.shadergraph/Documentation~/Keywords-reference.md +++ b/Packages/com.unity.shadergraph/Documentation~/Keywords-reference.md @@ -12,7 +12,8 @@ Parameters that all keyword types have in common. | **Reference** | The internal name for the keyword in the shader. Use this **Reference** name instead of the display **Name** when you reference the keyword in a script.

If you overwrite this parameter, be aware of the following:
  • A Keyword **Reference** has to be in full capitals. Unity converts any lowercase letters to uppercase.
  • If the string contains any characters that HLSL does not support, Unity replaces those characters with underscores.
  • You can revert to the default value: right-click on the **Reference** field label, and select **Reset Reference**.
| | **Promote to final Shader** | Makes the keyword available across the entire shader rather than only within the subgraph. | | **Definition** | Sets the keyword declaration type, which determines how Unity compiles the shader code. This allows you to [optimize the balance between build time, runtime, and file sizes](Keywords-concepts.md#keyword-impact-optimization).

The options are:
  • **Shader Feature**: Unity only compiles shader variants for keyword combinations used by materials in your build, and removes other shader variants.
  • **Multi Compile**: Unity compiles shader variants for all keyword combinations regardless of whether the build uses these variants.
  • **Predefined**: Specifies that the target/sub-target already defines the keyword and you just want to reuse it. Predefined Keywords can either use a [built-in macro](https://docs.unity3d.com/Manual/shader-branching-built-in-macros.html), which results in static branching at build time, or any of the keywords already defined by the Shader Graph Target (for example, [URP](https://docs.unity3d.com/Manual/urp/urp-shaders/shader-keywords-macros.html)), including [Built-In keyword sets](https://docs.unity3d.com/Manual/SL-MultipleProgramVariants-shortcuts.html), and where the branching depends on that definition.
  • **Dynamic Branch**: Unity keeps branching code in one compiled shader program.
| -| **Is Overridable** | Indicates whether the keyword's state can be overridden.
For more information, refer to [Toggle shader keywords in a script](https://docs.unity3d.com/Manual/shader-keywords-scripts.html). | +| **Allow Definition Override** | Makes the keyword's **Definition** overridable at compile time through the project's [Shader Build Settings](https://docs.unity3d.com/Manual/class-GraphicsSettings.html#shader-build-settings). When this option is enabled, Shader Graph uses dynamic branching (`if`) in generated code instead of preprocessor directives (`#if`). Enabling this option doesn't affect the shader's runtime performance unless the Shader Build Settings override the Definition to Dynamic Branch at compile time. | +| **Allow State Override** | Sets the keyword scope to Global, making the keyword state overridable at runtime. If this option is disabled, the keyword scope is set to Local and the keyword state is not overridable.
For more information, refer to [Toggle shader keywords in a script](https://docs.unity3d.com/Manual/shader-keywords-scripts.html). | | **Generate Material Property** | Generates a material property declaration to display the keyword as a property in the material inspector.
This adds a `[Toggle(_KEYWORD)]` attribute to the material property. For more information, refer to [`MaterialPropertyDrawer`](https://docs.unity3d.com/ScriptReference/MaterialPropertyDrawer.html). | | **Stages** | Set the stage the keyword applies to.

The following options are available:
  • **All** - Applies this keyword to all shader stages.
  • **Vertex** - Applies this keyword to the vertex stage.
  • **Fragment** - Applies this keyword to the fragment stage.
| @@ -34,7 +35,8 @@ Parameters specific to Enum keywords in addition to the [common parameters](#com | **Name** | **Description** | | :--- | :--- | -| **Default Value** | Select an entry from the drop-down menu to determine which value to use for the keyword when Shader Graph generates previews. This also defines the keyword's default value when you use this shader to create a new Material. When you edit the Entries list, Shader Graph automatically updates the options in this control. | +| **Include "none" entry** | Includes a special entry in addition to the **Entries** list to allow the enum to have a "no value selected" state.
For more details about the corresponding shader code behind this option, refer to [Branch when all keywords in a set are disabled](https://docs.unity3d.com/Manual/SL-MultipleProgramVariants-make-conditionals.html). | +| **Default Value** | Selects an entry from the drop-down menu to determine which value to use for the keyword when Shader Graph generates previews. This also defines the keyword's default value when you use this shader to create a new Material. When you edit the **Entries** list, Shader Graph automatically updates the options in this control. | | **Entries** | This list defines all the states for the keyword. Each state has a separate **Entry Name** and **Reference Suffix**.
  • **Entry Name**: The name displayed in drop-down menus for the keyword on the [Internal Inspector](Internal-Inspector.md) and the Material Inspector. Shader Graph also uses this name for port labels on nodes that reference the keyword.
  • **Reference Suffix**: This identifies the final keyword, presented in the format `Reference_ReferenceSuffix`.
| When you define an Enum keyword, Shader Graph displays labels for each state consisting of a version of the Enum's **Entry Name** appended to the main **Reference** name. diff --git a/Packages/com.unity.shadergraph/Documentation~/Property-Types.md b/Packages/com.unity.shadergraph/Documentation~/Property-Types.md index e432a1b79c7..d82f60c1457 100644 --- a/Packages/com.unity.shadergraph/Documentation~/Property-Types.md +++ b/Packages/com.unity.shadergraph/Documentation~/Property-Types.md @@ -122,6 +122,7 @@ Defines a [Texture 2D](https://docs.unity3d.com/Manual/class-TextureImporter.htm | **Mode** | Defines the fallback texture Unity uses when none is provided.

The options are:
  • **White**: Sets a solid white (1,1,1) texture to ensure full-intensity sampling.
  • **Black**: Sets a solid black (0,0,0) texture to yield zero contribution.
  • **Grey**: Sets a mid-grey in sRGB (~0.5) as a neutral fallback.
  • **Normal Map**: Sets a flat normal value to keep surfaces flat without a normal texture.
  • **Linear Grey**: Sets a mid-grey in linear color space.
  • **Red**: Sets a solid red (1,0,0) texture, useful for data expected in the red channel.
| | **Use Tiling and Offset** | Toggles the property `NoScaleOffset` to enable manipulating scale and offset separately from other texture properties; see [SplitTextureTransformNode](Split-Texture-Transform-Node.md).
A boolean value. | | **Use TexelSize** | Uses the size of texels expressed in UV space. | +| **Is HDR** | Allows any node that samples the texture to automatically decode the sampled value if the texture is stored in an encoded HDR format (for example, dLDR). | ## Texture 2D Array @@ -130,6 +131,7 @@ Defines a [Texture 2D Array](https://docs.unity3d.com/Manual/class-TextureImport | Parameter | Description | | :--- | :--- | | **Default Value** | Sets the initial value of the [Property](https://docs.unity3d.com/Manual/SL-Properties.html).
A texture asset reference. | +| **Is HDR** | Allows any node that samples the texture to automatically decode the sampled value if the texture is stored in an encoded HDR format (for example, dLDR). | ## Texture 3D @@ -138,6 +140,7 @@ Defines a [Texture 3D](https://docs.unity3d.com/Manual/class-TextureImporter.htm | Parameter | Description | | :--- | :--- | | **Default Value** | Sets the initial value of the [Property](https://docs.unity3d.com/Manual/SL-Properties.html).
A texture asset reference. | +| **Is HDR** | Allows any node that samples the texture to automatically decode the sampled value if the texture is stored in an encoded HDR format (for example, dLDR). | ## Cubemap @@ -146,6 +149,7 @@ Defines a [Cubemap](https://docs.unity3d.com/Manual/class-Cubemap.html) value. D | Parameter | Description | | :--- | :--- | | **Default Value** | Sets the initial value of the [Property](https://docs.unity3d.com/Manual/SL-Properties.html).
A cubemap asset reference. | +| **Is HDR** | Allows any node that samples the texture to automatically decode the sampled value if the texture is stored in an encoded HDR format (for example, dLDR). | ## Virtual Texture From d8c84301051a35c035f74e3f874a72a49551bcd4 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Wed, 3 Jun 2026 23:34:06 +0000 Subject: [PATCH 23/38] [Port] [6000.4] Fix UUM-137798: Update obsolete useRendererSilhouette property documentation --- .../Runtime/2D/Shadows/ShadowCaster2D.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 0d45a6e8ae6..3bb20354a79 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 @@ -195,9 +195,10 @@ public ShadowCastingOptions castingOption } /// - /// If selfShadows is true, useRendererSilhoutte specifies that the renderer's sihouette should be considered part of the shadow. If selfShadows is false, useRendererSilhoutte specifies that the renderer's sihouette should be excluded from the shadow + /// This property is obsolete and no longer has any effect. Its functionality has been removed because it is no longer required. + /// To achieve similar behavior, add a ShadowCaster2D component to an empty parent GameObject instead. /// - [Obsolete("useRendererSilhoutte is deprecated. Use selfShadows instead. #from(2023.1)")] + [Obsolete("useRendererSilhouette is obsolete and no longer has any effect. To achieve similar behavior, add a ShadowCaster2D component to an empty parent GameObject. #from(2023.1)")] public bool useRendererSilhouette { set { m_UseRendererSilhouette = value; } From 26d069ee48d87d20b4dd0e6f6575bb2b8a266bc5 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Mon, 8 Jun 2026 07:30:08 +0000 Subject: [PATCH 24/38] [Port] [6000.4] [HDRP][Docs] Fix missing Preset M and broken preset table for DLSS documentation --- .../Documentation~/deep-learning-super-sampling-in-hdrp.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/deep-learning-super-sampling-in-hdrp.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/deep-learning-super-sampling-in-hdrp.md index 15565a39b90..518e462415f 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/deep-learning-super-sampling-in-hdrp.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/deep-learning-super-sampling-in-hdrp.md @@ -84,9 +84,9 @@ Available presets are marked as '1' in the table below. |- |- |- |- |- |- |- |- | | Preset F | | | | 1 | 1 | Marked for deprecation in upcoming DLSS releases. Don't use for new projects. | CNN | | Preset J | 1 | 1 | 1| 1 | 1 | Slightly lowers ghosting but increases flickering.
NVIDIA recommends using **Preset K** instead of **Preset J**. | Transformer | -| Preset K | 1 | 1 | 1| 1 | 1 | Default preset for DLAA/Balanced/Quality modes. Requires fewer resources than Preset L. | Transformer | -| Preset L | | | | 1 | | Delivers a sharper, more stable image with less ghosting than Preset J, K, but lowers performance. Recommended for RTX 40 Series GPUs and above. | Transformer Gen 2 | -Provides about the same image quality as **Preset L**. This preset is slower than presets **J** and **K**, but faster than preset **L**. Recommended for RTX 40 Series GPUs and above. +| Preset K | 1 | 1 | 1| 1 | 1 | Default preset for DLAA/Balanced/Quality modes. Requires fewer resources than **Preset L**. | Transformer | +| Preset L | | | | 1 | | Delivers a sharper, more stable image with less ghosting than **Preset J** and **Preset K**, but lowers performance. Recommended for RTX 40 Series GPUs and above. | Transformer Gen 2 | +| Preset M | | | 1| | | Provides about the same image quality as **Preset L**. This preset is slower than **Preset J** and **Preset K**, but faster than **Preset L**. Recommended for RTX 40 Series GPUs and above. | Transformer Gen 2 | The defaults for each quality mode are: From 9bf3d77be0333b0ac0f3c190410c863c820e2a03 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 9 Jun 2026 04:42:49 +0000 Subject: [PATCH 25/38] [content automatically redacted] touching PlatformDependent folder --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index fcc798703c2..6561bd7e28d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -348,6 +348,9 @@ Editor/Resources/unity[[:space:]]editor[[:space:]]resources filter=lfs diff=lfs **/HDRP_RuntimeTests/Assets/Scenes/002-HDMaterials/cloud2.asset filter=lfs diff=lfs merge=lfs -text **/HDRP_RuntimeTests/Assets/Scenes/002-HDMaterials/perlin.asset filter=lfs diff=lfs merge=lfs -text +# Gfx ML acceleration test assets +**/MachineLearning/**/*.bytes filter=lfs diff=lfs merge=lfs -text + #GfxTests **/GfxTestProjectFolder/**/*.[hH][dD][rR] filter=lfs diff=lfs merge=lfs -text **/GfxTestProjectFolder/**/*.[tT][gG][aA] filter=lfs diff=lfs merge=lfs -text From f66af48d89fdb8fe859e83c194cd2377655a184e Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 9 Jun 2026 04:42:49 +0000 Subject: [PATCH 26/38] [Port] [6000.4] DOCR-6416 - updates to XR Plugin Architecture --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitattributes b/.gitattributes index 6561bd7e28d..efda4190108 100644 --- a/.gitattributes +++ b/.gitattributes @@ -385,3 +385,6 @@ Editor/Resources/unity[[:space:]]editor[[:space:]]resources filter=lfs diff=lfs # search test cases /Modules/QuickSearch/Tests/QuickSearch/Assets/Cases/UUM-113048/uum-113048.index filter=lfs diff=lfs merge=lfs -text +# documentation images +Documentation/ManualDocs/uploads/Main/unity-xr-tech-stack.png filter=lfs diff=lfs merge=lfs -text + From 792502d0a5f78be34521a35b5b621af446d8c09d Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 9 Jun 2026 04:42:50 +0000 Subject: [PATCH 27/38] [Port] [6000.4] [VFX] Custom HLSL did not support comments inside the function parameters --- .../Blocks/Implementations/HLSL/HLSLParser.cs | 16 +++- .../AllTests/Editor/Tests/HLSLParserTest.cs | 82 ++++++++++++++++++- .../AllTests/Editor/Tests/HelixFile.hlsl | 41 ++++++++++ .../AllTests/Editor/Tests/HelixFile.hlsl.meta | 7 ++ 4 files changed, 142 insertions(+), 4 deletions(-) create mode 100644 Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/HelixFile.hlsl create mode 100644 Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/AllTests/Editor/Tests/HelixFile.hlsl.meta diff --git a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs index b2b10bfb543..82b8c6170a2 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Models/Blocks/Implementations/HLSL/HLSLParser.cs @@ -147,7 +147,7 @@ public HLSLMissingIncludeFile(string filePath) class HLSLFunctionParameter { // Match inout/in/out accessor then any whitespace then the parameter type then optionally a template type any whitespace and then the parameter name - static readonly Regex s_ParametersParser = new Regex(@"(?(inout|in|out)\b)?\s*(?\w+)(?:[<](?