From aaecbcd2896d290e0d9401aeee69f40a09c20374 Mon Sep 17 00:00:00 2001 From: Sebastien Phaneuf Date: Tue, 28 Apr 2026 13:48:13 +0000 Subject: [PATCH 01/27] Use IMGUI drawer to bypass ui issue with Light Rendering Layer --- .../Editor/Lighting/HDLightingSearchColumnProviders.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightingSearchColumnProviders.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightingSearchColumnProviders.cs index 1d8fe4e7b39..0d74ae14cd2 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightingSearchColumnProviders.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Lighting/HDLightingSearchColumnProviders.cs @@ -14,6 +14,7 @@ static class HDLightingSearchColumnProviders internal const string k_LightShapePath = k_LightPath + "ShapeHDRP"; internal const string k_LightIntensityPath = k_LightPath + "Intensity"; internal const string k_LightIntensityUnitPath = k_LightPath + "IntensityUnit"; + internal const string k_LightLayerPath = k_LightPath + "LightLayer"; internal const string k_LightModePath = k_LightPath + "ModeHDRP"; internal const string k_ContactShadowsPath = k_LightPath + "ContactShadows"; internal const string k_ShadowResolutionPath = k_LightPath + "ShadowResolution"; @@ -231,6 +232,7 @@ public static void RayTracingModeSearchColumnProvider(SearchColumn column) }; } + [SearchColumnProvider(k_ReflectionProbeResolutionPath)] public static void ReflectionProbeResolutionSearchColumnProvider(SearchColumn column) { From 56ccff1aadc3a5f686dbd06977d5f82b226890cb Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 28 Apr 2026 13:48:13 +0000 Subject: [PATCH 02/27] [Port] [6000.5] [UUM-134522][UUM-136056][URP 2D][6000.6] Fix 2d shadow volumetric bugs --- .../Runtime/2D/Lights/Light2DCullResult.cs | 2 +- .../Runtime/2D/Passes/Utility/RendererLighting.cs | 5 +++++ .../Runtime/2D/Rendergraph/DrawLight2DPass.cs | 3 ++- .../Runtime/2D/Rendergraph/DrawShadow2DPass.cs | 5 +++++ .../Runtime/2D/Rendergraph/Renderer2DRendergraph.cs | 10 +++++++++- .../Shaders/2D/Include/LightingUtility.hlsl | 4 ++-- 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Lights/Light2DCullResult.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Lights/Light2DCullResult.cs index 7ced864a6bf..c5cb4033581 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Lights/Light2DCullResult.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Lights/Light2DCullResult.cs @@ -74,7 +74,7 @@ public LightStats GetLightStatsByLayer(int layerID, ref LayerBatch layer) returnStats.totalNormalMapUsage++; if (light.volumeIntensity > 0 && light.volumetricEnabled) returnStats.totalVolumetricUsage++; - if (light.volumeIntensity > 0 && light.volumetricEnabled && RendererLighting.CanCastShadows(light, layerID)) + if (RendererLighting.CanCastVolumetricShadows(light, layer.endLayerValue)) returnStats.totalVolumetricShadowUsage++; returnStats.blendStylesUsed |= (uint)(1 << light.blendStyleIndex); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs index 321f03a60ff..3bb30327df0 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs @@ -142,6 +142,11 @@ internal static bool CanCastShadows(Light2D light, int layerToRender) return light.shadowsEnabled && light.shadowIntensity > 0 && light.IsLitLayer(layerToRender); } + internal static bool CanCastVolumetricShadows(Light2D light, int endLayerValue) + { + return light.volumeIntensity > 0 && light.volumetricEnabled && light.renderVolumetricShadows && light.GetTopMostLitLayer() == endLayerValue; + } + internal static void SetLightShaderGlobals(IRasterCommandBuffer cmd, Light2DBlendStyle[] lightBlendStyles, int[] blendStyleIndices) { for (var i = 0; i < blendStyleIndices.Length; i++) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs index 8a2b1de03f6..01ce1a8b979 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs @@ -78,7 +78,8 @@ private static void Execute(RasterCommandBuffer cmd, PassData passData, LayerBat layerBatch.endLayerValue != light.GetTopMostLitLayer())) continue; - var useShadows = passData.layerBatch.lightStats.useShadows && layerBatch.shadowIndices.Contains(j); + var useShadows = (!passData.isVolumetric && passData.layerBatch.lightStats.useShadows) || (passData.isVolumetric && passData.layerBatch.lightStats.useVolumetricShadowLights); + useShadows &= layerBatch.shadowIndices.Contains(j); var lightMaterial = passData.rendererData.GetLightMaterial(light, passData.isVolumetric, useShadows); var lightMesh = light.lightMesh; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawShadow2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawShadow2DPass.cs index 6fc8ded1de0..1a8b0f66e7c 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawShadow2DPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawShadow2DPass.cs @@ -33,6 +33,7 @@ internal class PassData internal Renderer2DData rendererData; internal TextureHandle[] shadowTextures; internal TextureHandle shadowDepth; + internal bool isVolumetric; } public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex, bool isVolumetric = false) @@ -52,6 +53,7 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex using (var builder = graph.AddUnsafePass(passName, out var passData, LayerDebug.GetProfilingSampler(passName, profilingSampler))) { + passData.isVolumetric = isVolumetric; passData.layerBatch = layerBatch; passData.rendererData = rendererData; passData.shadowTextures = universal2DResourceData.shadowTextures[batchIndex]; @@ -72,6 +74,9 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex var index = data.layerBatch.shadowIndices[i]; var light = data.layerBatch.lights[index]; + if (data.isVolumetric && !RendererLighting.CanCastVolumetricShadows(light, data.layerBatch.endLayerValue)) + continue; + // Shadow Pass ExecuteShadowPass(cmd, data, light, i); } 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 ee9bbd216a3..2824eb8808f 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 @@ -189,6 +189,13 @@ private RenderPassInputSummary GetRenderPassInputs() inputSummary.requiresColorTexture |= needsColor; } + // Volumetric shadow pass requires intermediate texture + bool hasVolumetricShadowPass = false; + var layerBatches = frameData.Get().layerBatches; + var batchCount = frameData.Get().batchCount; + for (int i = 0; i < batchCount; ++i) + hasVolumetricShadowPass |= layerBatches[i].lightStats.useVolumetricShadowLights; + inputSummary.requiresColorTexture |= cameraData.postProcessEnabled || cameraData.isHdrEnabled || cameraData.isSceneViewCamera @@ -199,7 +206,8 @@ private RenderPassInputSummary GetRenderPassInputs() || m_Renderer2DData.useCameraSortingLayerTexture || !Mathf.Approximately(cameraData.renderScale, 1.0f) || (DebugHandler != null && DebugHandler.WriteToDebugScreenTexture(cameraData.resolveFinalTarget)) - || cameraData.captureActions != null; + || cameraData.captureActions != null + || hasVolumetricShadowPass; return inputSummary; } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl index 458024f290f..ddf6f32cbf2 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl +++ b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/LightingUtility.hlsl @@ -59,8 +59,8 @@ if(intensity < 1)\ {\ half4 shadowTex = SAMPLE_TEXTURE2D(_ShadowTex, sampler_ShadowTex, input.shadowUV); \ - half4 shadowIntensity = 1-max(shadowTex.r, shadowTex.g * 1-shadowTex.b);\ - color.rgb = (color.rgb * shadowIntensity.rgb) + (color.rgb * intensity*(1 - shadowIntensity.rgb));\ + half shadowIntensity = 1 - max(shadowTex.r, shadowTex.g * (1 - shadowTex.b));\ + color.rgb = (color.rgb * shadowIntensity) + (color.rgb * intensity * (1 - shadowIntensity));\ } #define TRANSFER_SHADOWS(output)\ From e9fd41ce3a5f481ac2ba03a30bfff42c0b69192e Mon Sep 17 00:00:00 2001 From: Cal Chiu Date: Tue, 28 Apr 2026 13:48:13 +0000 Subject: [PATCH 03/27] [Port] [6000.5] [UUM-138256] Added shader variant stripping for point sampling upsampling --- .../Editor/ShaderBuildPreprocessor.cs | 9 ++++++++- .../Editor/ShaderScriptableStripper.cs | 14 ++++++++++++++ .../UniversalRenderPipelineAssetPrefiltering.cs | 8 ++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs index 294b8f8a9c7..53ae5fe1d4e 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderBuildPreprocessor.cs @@ -73,8 +73,9 @@ enum ShaderFeatures : long StencilLODCrossFade = (1L << 50), DeferredPlus = (1L << 51), ReflectionProbeAtlas = (1L << 52), + PointSamplingUpsampling = (1L << 54), #if SURFACE_CACHE - SurfaceCache = (1L << 53), + SurfaceCache = (1L << 55), #endif All = ~0 } @@ -589,6 +590,9 @@ internal static ShaderFeatures GetSupportedShaderFeaturesFromAsset( if(urpAsset.allowPostProcessAlphaOutput) urpAssetShaderFeatures |= ShaderFeatures.AlphaOutput; + if (urpAsset.upscalingFilter == UpscalingFilterSelection.Point) + urpAssetShaderFeatures |= ShaderFeatures.PointSamplingUpsampling; + // Check each renderer & renderer feature urpAssetShaderFeatures = GetSupportedShaderFeaturesFromRenderers( ref urpAsset, @@ -1139,6 +1143,9 @@ ref List ssaoRendererFeatures spd.stripSSAOSampleCountHigh &= ssaoSettings.Samples != ScreenSpaceAmbientOcclusionSettings.AOSampleOption.High; } + // Upscaling + spd.stripPointSamplingUpsampling = !IsFeatureEnabled(shaderFeatures, ShaderFeatures.PointSamplingUpsampling); + return spd; } diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs index 0e5cd32bcda..b1df72bf110 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderScriptableStripper.cs @@ -116,6 +116,7 @@ public bool PassHasKeyword(LocalKeyword keyword) Shader m_StencilDeferred = Shader.Find("Hidden/Universal Render Pipeline/StencilDeferred"); Shader m_ClusterDeferred = Shader.Find("Hidden/Universal Render Pipeline/ClusterDeferred"); Shader m_UberPostShader = Shader.Find("Hidden/Universal Render Pipeline/UberPost"); + Shader m_FinalPostShader = Shader.Find("Hidden/Universal Render Pipeline/FinalPost"); Shader m_HDROutputBlitShader = Shader.Find("Hidden/Universal/BlitHDROverlay"); Shader m_DataDrivenLensFlareShader = Shader.Find("Hidden/Universal Render Pipeline/LensFlareDataDriven"); Shader m_ScreenSpaceLensFlareShader = Shader.Find("Hidden/Universal Render Pipeline/LensFlareScreenSpace"); @@ -197,6 +198,7 @@ public bool PassHasKeyword(LocalKeyword keyword) LocalKeyword m_Instancing; LocalKeyword m_DotsInstancing; LocalKeyword m_ProceduralInstancing; + LocalKeyword m_PointSampling; private LocalKeyword TryGetLocalKeyword(Shader shader, string name) { @@ -268,6 +270,7 @@ private void InitializeLocalShaderKeywords([DisallowNull] Shader shader) m_FilmGrain = TryGetLocalKeyword(shader, ShaderKeywordStrings.FilmGrain); m_SHPerVertex = TryGetLocalKeyword(shader, ShaderKeywordStrings.EVALUATE_SH_VERTEX); m_SHMixed = TryGetLocalKeyword(shader, ShaderKeywordStrings.EVALUATE_SH_MIXED); + m_PointSampling = TryGetLocalKeyword(shader, ShaderKeywordStrings.PointSampling); m_Instancing = TryGetLocalKeyword(shader, "INSTANCING_ON"); m_DotsInstancing = TryGetLocalKeyword(shader, "DOTS_INSTANCING_ON"); @@ -819,6 +822,14 @@ internal bool StripUnusedFeatures_CrossFadeLod(ref IShaderScriptableStrippingDat return !strippingData.IsShaderFeatureEnabled(ShaderFeatures.LODCrossFade); } + internal bool StripUnusedFeatures_PointSamplingUpsampling(ref IShaderScriptableStrippingData strippingData, ref ShaderStripTool stripTool) + { + if (strippingData.shader != m_UberPostShader && strippingData.shader != m_FinalPostShader) + return false; + + return stripTool.StripMultiCompile(m_PointSampling, ShaderFeatures.PointSamplingUpsampling); + } + internal bool StripUnusedFeatures(ref IShaderScriptableStrippingData strippingData) { if (StripUnusedFeatures_DebugDisplay(ref strippingData)) @@ -929,6 +940,9 @@ internal bool StripUnusedFeatures(ref IShaderScriptableStrippingData strippingDa if (StripUnusedFeatures_XRMotionVector(ref strippingData)) return true; + if (StripUnusedFeatures_PointSamplingUpsampling(ref strippingData, ref stripTool)) + return true; + return false; } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAssetPrefiltering.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAssetPrefiltering.cs index 814e25d750b..9c631839939 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAssetPrefiltering.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAssetPrefiltering.cs @@ -209,6 +209,10 @@ internal enum PrefilteringModeAdditionalLights [ShaderKeywordFilter.RemoveIf(true, keywordNames: ShaderKeywordStrings.ReflectionProbeAtlas)] [SerializeField] private bool m_PrefilterReflectionProbeAtlas = false; + // Point Sampling Upscaling (_POINT_SAMPLING) + [ShaderKeywordFilter.RemoveIf(true, keywordNames: ShaderKeywordStrings.PointSampling)] + [SerializeField] private bool m_PrefilterPointSamplingUpsampling = false; + /// /// Data used for Shader Prefiltering. Gathered after going through the URP Assets, /// Renderers and Renderer Features in OnPreprocessBuild() inside ShaderPreprocessor.cs. @@ -253,6 +257,8 @@ internal struct ShaderPrefilteringData public bool stripReflectionProbeBoxProjection; public bool stripReflectionProbeAtlas; + public bool stripPointSamplingUpsampling; + public bool stripScreenSpaceIrradiance; public static ShaderPrefilteringData GetDefault() @@ -315,6 +321,8 @@ internal void UpdateShaderKeywordPrefiltering(ref ShaderPrefilteringData prefilt m_PrefilterReflectionProbeBoxProjection = prefilteringData.stripReflectionProbeBoxProjection; m_PrefilterReflectionProbeAtlas = prefilteringData.stripReflectionProbeAtlas; + m_PrefilterPointSamplingUpsampling = prefilteringData.stripPointSamplingUpsampling; + m_PrefilterScreenSpaceIrradiance = prefilteringData.stripScreenSpaceIrradiance; } } From 5c01380df9ea897b5ed08bea38f3498b6fb3aed4 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Wed, 29 Apr 2026 10:14:31 +0000 Subject: [PATCH 04/27] [Port] [6000.5] [UUM-140770][URP 2D][6000.6] Fix Inspector Preview window showing black sprites --- .../2D/FrameData/Universal2DRenderingData.cs | 3 +++ .../Runtime/2D/Rendergraph/DrawLight2DPass.cs | 12 +++------ .../2D/Rendergraph/DrawRenderer2DPass.cs | 15 ++++------- .../2D/Rendergraph/Renderer2DRendergraph.cs | 26 ++++++++++++++++--- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/FrameData/Universal2DRenderingData.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/FrameData/Universal2DRenderingData.cs index 750c516d466..01799d2af06 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/FrameData/Universal2DRenderingData.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/FrameData/Universal2DRenderingData.cs @@ -8,11 +8,14 @@ internal class Universal2DRenderingData : ContextItem internal int batchCount; + internal bool isLightingActive; + public override void Reset() { renderingData = null; layerBatches = null; batchCount = 0; + isLightingActive = true; } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs index 01ce1a8b979..2e133a4748d 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawLight2DPass.cs @@ -175,15 +175,11 @@ internal void Render(RenderGraph graph, ContextContainer frameData, int batchInd { Universal2DResourceData universal2DResourceData = frameData.Get(); UniversalCameraData cameraData = frameData.Get(); - var layerBatch = frameData.Get().layerBatches[batchIndex]; - - DebugHandler debugHandler = GetActiveDebugHandler(cameraData); - var isLightingActive = debugHandler?.IsLightingActive ?? true; + Universal2DRenderingData rendering2DData = frameData.Get(); + var layerBatch = rendering2DData.layerBatches[batchIndex]; -#if UNITY_EDITOR - if (cameraData.isSceneViewCamera && UnityEditor.SceneView.currentDrawingSceneView != null) - isLightingActive &= UnityEditor.SceneView.currentDrawingSceneView.sceneLighting; -#endif + // Check for lighting in scene/prefab/preview camera + var isLightingActive = rendering2DData.isLightingActive; if (!layerBatch.lightStats.useLights || isVolumetric && !layerBatch.lightStats.useVolumetricLights || diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs index ccd9def2553..4439f3d4559 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Rendergraph/DrawRenderer2DPass.cs @@ -90,17 +90,12 @@ public void Render(RenderGraph graph, ContextContainer frameData, int batchIndex UniversalLightData lightData = frameData.Get(); Universal2DResourceData universal2DResourceData = frameData.Get(); CommonResourceData commonResourceData = frameData.Get(); - Renderer2DData rendererData = frameData.Get().renderingData; - var layerBatch = frameData.Get().layerBatches[batchIndex]; - - DebugHandler debugHandler = GetActiveDebugHandler(cameraData); - var isLightingActive = debugHandler?.IsLightingActive ?? true; + Universal2DRenderingData rendering2DData = frameData.Get(); + Renderer2DData rendererData = rendering2DData.renderingData; + var layerBatch = rendering2DData.layerBatches[batchIndex]; -#if UNITY_EDITOR - // Early out for prefabs - if (cameraData.isSceneViewCamera && UnityEditor.SceneView.currentDrawingSceneView != null) - isLightingActive = UnityEditor.SceneView.currentDrawingSceneView.sceneLighting; -#endif + // Check for lighting in scene/prefab/preview camera + var isLightingActive = rendering2DData.isLightingActive; // Preset global light textures for first batch if (batchIndex == 0) 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 2824eb8808f..7871d8367ab 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 @@ -345,11 +345,13 @@ public override void SetupCullingParameters(ref ScriptableCullingParameters cull void InitializeLayerBatches() { Universal2DResourceData resourceData = frameData.Get(); - var renderingData = frameData.Get().renderingData; - ref var layerBatches = ref frameData.Get().layerBatches; + UniversalCameraData cameraData = frameData.Get(); + Universal2DRenderingData renderData = frameData.Get(); + ref var layerBatches = ref renderData.layerBatches; - layerBatches = LayerUtility.CalculateBatches(renderingData, out var batchCount); - frameData.Get().batchCount = batchCount; + layerBatches = LayerUtility.CalculateBatches(renderData.renderingData, out var batchCount); + renderData.batchCount = batchCount; + renderData.isLightingActive = IsSceneViewOrPreviewLightingActive(cameraData); // Initialize textures dependent on batch size if (resourceData.normalsTexture.Length != batchCount) @@ -1091,5 +1093,21 @@ internal static bool supportsMRT { get => !IsGLESDevice(); } + + static internal bool IsSceneViewOrPreviewLightingActive(UniversalCameraData cameraData) + { + DebugHandler debugHandler = ScriptableRenderPass.GetActiveDebugHandler(cameraData); + var isLightingActive = debugHandler?.IsLightingActive ?? true; + +#if UNITY_EDITOR + if (cameraData.isSceneViewCamera && UnityEditor.SceneView.currentDrawingSceneView != null) + isLightingActive &= UnityEditor.SceneView.currentDrawingSceneView.sceneLighting; + + if (cameraData.isPreviewCamera && cameraData.camera.name == "Preview Scene Camera") + isLightingActive = false; +#endif + + return isLightingActive; + } } } From 594fb8b7d871292d4667f2e70dd5f3efe51a0949 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Thu, 30 Apr 2026 01:22:36 +0000 Subject: [PATCH 05/27] [Port] [6000.5] docg-8419: Fix Flipbook Player property visibility descriptions --- .../Documentation~/Block-FlipbookPlayer.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Packages/com.unity.visualeffectgraph/Documentation~/Block-FlipbookPlayer.md b/Packages/com.unity.visualeffectgraph/Documentation~/Block-FlipbookPlayer.md index 2e008daa58d..9ad1e8663b3 100644 --- a/Packages/com.unity.visualeffectgraph/Documentation~/Block-FlipbookPlayer.md +++ b/Packages/com.unity.visualeffectgraph/Documentation~/Block-FlipbookPlayer.md @@ -62,10 +62,10 @@ This Block is compatible with the following Contexts: | **Frame Rate Mode** | Enum | Selects between different modes to control the frame rate when **FrameRate** mode is selected. Refer to [Frame Rate mode](#frame-rate-mode). | | **Cycles Mode** | Enum | Selects between different modes to specify the number of cycles when **Cycles** mode is selected. Refer to [Cycles mode](#cycles-mode). | | **Animation Range** | Enum | Different modes to control which frames are displayed. Refer to [Animation Range](#animation-range). | -| **Use Custom Range** | Boolean | In **FrameRate** mode, allows to customize the animation range. | +| **Use Custom Range** | Boolean | In **Frame Rate** mode, allows you to customize the animation range. | | **Reverse** | Boolean | Plays the animation from end to start. | | **Clamp Blending** | Boolean | Only visible if flipbook blending is enabled. Clamps the blending between the last and first frames. | -| **Custom Curve** | Boolean | Allows using a curve to control animation speed over one cycle. By default, speed is linear: each frame is displayed for the same amount of time. | +| **Custom Curve** | Boolean | Allows using a curve to control animation speed over one cycle. By default, speed is linear: each frame is displayed for the same amount of time. In **Frame Rate** mode, this property only appears if you enable **Over Lifetime**, **By Speed**, or **Custom**. In **Cycles** mode, this property only appears if you enable **Custom Curve**. | ## Block properties From 8c400086c6858849cb84f19eb3c19ff50bcff8b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kay=20Leng=20Chang=20=EF=BC=88=E3=83=81=E3=83=A3=E3=83=B3?= =?UTF-8?q?=20=E3=82=B1=E3=82=A4=E3=83=AC=E3=83=B3=20-=20=E3=83=81?= =?UTF-8?q?=E3=83=A3=E3=83=B3=20=E3=82=B1=E3=82=A4=E3=83=AC=E3=83=B3?= =?UTF-8?q?=EF=BC=89?= Date: Thu, 30 Apr 2026 15:14:17 +0000 Subject: [PATCH 06/27] [UUM-138337][Switch2] Clear UI overlay texture on base camera if created but not rendered into --- .../Runtime/UniversalRendererRenderGraph.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs index a5814d5e642..fd5a6ef064c 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs @@ -1906,7 +1906,12 @@ void CreateOffscreenUITexture(RenderGraph renderGraph, TextureDesc descriptor) UniversalResourceData resourceData = 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 = true; + importParams.clearColor = Color.clear; + importParams.discardOnLastUse = true; + 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 a86f1738861fb4d211e27eddc2d17000d827a3e8 Mon Sep 17 00:00:00 2001 From: Adrian Smith Date: Thu, 30 Apr 2026 20:15:30 +0000 Subject: [PATCH 07/27] [6000.5] VFX out of bounds shader access fix --- .../Operators/Implementations/SampleMesh.cs | 6 +++- .../Shaders/SDFBaker/GenSdfRayMap.compute | 33 +++++++++++++------ .../HDRP_VisualEffectsGraph_GraphicsTests.cs | 1 - 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/SampleMesh.cs b/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/SampleMesh.cs index 921f478b3e9..a8ba59a4a73 100644 --- a/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/SampleMesh.cs +++ b/Packages/com.unity.visualeffectgraph/Editor/Models/Operators/Implementations/SampleMesh.cs @@ -445,7 +445,11 @@ private static VFXExpression SampleVertexAttribute(VFXExpression source, VFXExpr var outputType = GetSampledType(vertexAttribute); VFXExpression sampled = null; - vertexIndex = new VFXExpressionMin(vertexIndex, new VFXExpressionMeshVertexCount(mesh)); + var count = new VFXExpressionMeshVertexCount(mesh); + var safeCount = new VFXExpressionMax(count, VFXOperatorUtility.OneExpression[VFXValueType.Uint32]); + var countMinusOne = safeCount - VFXOperatorUtility.OneExpression[VFXValueType.Uint32]; + + vertexIndex = new VFXExpressionMin(vertexIndex, countMinusOne); var meshChannelFormatAndDimension = new VFXExpressionMeshChannelInfos(mesh, channelIndex); var vertexOffset = vertexIndex * meshVertexStride + meshChannelOffset; diff --git a/Packages/com.unity.visualeffectgraph/Shaders/SDFBaker/GenSdfRayMap.compute b/Packages/com.unity.visualeffectgraph/Shaders/SDFBaker/GenSdfRayMap.compute index 36ca56d6788..c73b8c4d6a5 100644 --- a/Packages/com.unity.visualeffectgraph/Shaders/SDFBaker/GenSdfRayMap.compute +++ b/Packages/com.unity.visualeffectgraph/Shaders/SDFBaker/GenSdfRayMap.compute @@ -74,7 +74,14 @@ uint LoadIndex32(uint idx) float3 GetVertexObj(uint idThread, uint idVertex) { uint idIndex = (3 * idThread + idVertex); - uint index = indexStride == 2 ? LoadIndex16(idIndex) : LoadIndex32(idIndex); + + uint index; + UNITY_BRANCH + if (indexStride == 2) + index = LoadIndex16(idIndex); + else + index = LoadIndex32(idIndex); + uint vertIdx = vertexPositionOffset + index * vertexStride; uint3 vRaw = vertices.Load3(vertIdx); return asfloat(vRaw); @@ -205,7 +212,7 @@ RWStructuredBuffer Result ; #define groupthreads 512 groupshared uint2 bucket[groupthreads]; -void PrefixSum(uint id, uint gid, uint x) +void PrefixSum(uint id, uint gid, uint x, bool valid) { uint thid = id; //load input into shared memory @@ -269,7 +276,9 @@ void PrefixSum(uint id, uint gid, uint x) } n = !n; } - Result[thid] = bucket[gid].y; //Careful, works for groupthreads = 512 (2^(2n+1)) + + if (valid) + Result[thid] = bucket[gid].y; //Careful, works for groupthreads = 512 (2^(2n+1)) } uint numElem; uint dispatchWidth; @@ -279,30 +288,34 @@ void InBucketSum(uint3 GTid: SV_GroupThreadID, uint GI: SV_GroupIndex, uint3 gro uint x; const uint id = GTid.x + groupId.x * groupthreads + groupId.y * dispatchWidth * groupthreads; - if(id >= numElem) + bool valid = id < numElem; + UNITY_BRANCH + if(!valid) { x = 0u; } else{ x = Input[id]; } - PrefixSum(id, GI, x); + PrefixSum(id, GI, x, valid); } [numthreads(groupthreads, 1, 1)] void BlockSums(uint3 DTid: SV_DispatchThreadID, uint GI: SV_GroupIndex) { - uint x ; - if((DTid.x + 1) * groupthreads -1 >= numElem ) + uint x; + uint idx = (DTid.x + 1) * groupthreads - 1; + bool validWrite = DTid.x * groupthreads < numElem; + UNITY_BRANCH + if (idx >= numElem) { x = 0u; } else { - uint id = (DTid.x + 1) * groupthreads - 1; - x = Input[id] + inputCounter[id]; // Change the type of x here if scan other types + x = Input[idx] + inputCounter[idx]; // Change the type of x here if scan other types } - PrefixSum(DTid.x, GI, x); + PrefixSum(DTid.x, GI, x, validWrite); } bool exclusive; diff --git a/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/Tests/HDRP_VisualEffectsGraph_GraphicsTests.cs b/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/Tests/HDRP_VisualEffectsGraph_GraphicsTests.cs index 7ac63ee7142..48b10ebc1cd 100644 --- a/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/Tests/HDRP_VisualEffectsGraph_GraphicsTests.cs +++ b/Tests/SRPTests/Projects/VisualEffectGraph_HDRP/Assets/Tests/HDRP_VisualEffectsGraph_GraphicsTests.cs @@ -32,7 +32,6 @@ public class VFXGraphicsTests [IgnoreGraphicsTest("102_ShadergraphShadow", "See UUM-96202", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.Switch })] [IgnoreGraphicsTest("015_FixedTime", "See UUM-109089", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.Switch })] [IgnoreGraphicsTest("DebugAlbedo", "Onscreen assert", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.Switch2 })] - [IgnoreGraphicsTest("36_SkinnedSDF", "Onscreen assert", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.Switch2 })] [IgnoreGraphicsTest("015_FixedTime", "Onscreen assert", runtimePlatforms: new RuntimePlatform[] { RuntimePlatform.Switch2 })] [IgnoreGraphicsTest("Repro_SampleGradient_Branch_Instancing", "Compute shader ([Repro_SampleGradient_Branch_Instancing] [Minimal] Update Particles): Property (Repro_SampleGradient_Branch_Instancing_Buffer) at kernel index (0) is not set")] [IgnoreGraphicsTest("Empty", "No reference images provided")] From cee93b4c6d0fc38fe28e533cf94396cd9d377aba Mon Sep 17 00:00:00 2001 From: Evergreen Date: Mon, 4 May 2026 16:24:52 +0000 Subject: [PATCH 08/27] [Port] [6000.5] Fix GPU crash with shadergraph AdditionalLightsBasic node in some cases --- .../AdditionalLights/AdditionalLightsBasic.shadersubgraph | 2 +- .../AdditionalLights/AdditionalLightsColorize.shadersubgraph | 2 +- .../AdditionalLights/AdditionalLightsHalfLambert.shadersubgraph | 2 +- .../AdditionalLights/AdditionalLightsSimple.shadersubgraph | 2 +- .../AdditionalLights/AdditionalLightsURP.shadersubgraph | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsBasic.shadersubgraph b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsBasic.shadersubgraph index f39f62cf8ee..d0ff9eea2f6 100644 --- a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsBasic.shadersubgraph +++ b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsBasic.shadersubgraph @@ -849,7 +849,7 @@ "m_FunctionName": "AddAdditionalLightsBasic", "m_FunctionSource": "3beadf505dbc54f4cae878435013d751", "m_FunctionSourceUsePragmas": true, - "m_FunctionBody": "Diffuse = MainDiffuse;\r\nColor = MainColor * MainDiffuse;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float thisDiffuse = light.distanceAttenuation * NdotL;\r\n Diffuse += thisDiffuse;\r\n Color += light.color * thisDiffuse;\r\n LIGHT_LOOP_END\r\n float total = Diffuse;\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif" + "m_FunctionBody": "Diffuse = MainDiffuse;\r\nColor = MainColor * MainDiffuse;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n#if defined(_ADDITIONAL_LIGHTS) || defined(_CLUSTER_LIGHT_LOOP)\r\n\r\n #if defined(_ADDITIONAL_LIGHTS)\r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n #endif\r\n\r\n #if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n #endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n // Convert the pixel light index to the light data index\r\n #if !USE_CLUSTER_LIGHT_LOOP\r\n lightIndex = GetPerObjectLightIndex(lightIndex);\r\n #endif\r\n Light light = GetAdditionalPerObjectLight(lightIndex, WorldPosition);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float thisDiffuse = light.distanceAttenuation * NdotL;\r\n Diffuse += thisDiffuse;\r\n Color += light.color * thisDiffuse;\r\n LIGHT_LOOP_END\r\n float total = Diffuse;\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif // _ADDITIONAL_LIGHTS || _CLUSTER_LIGHT_LOOP\r\n\r\n#endif // SHADERGRAPH_PREVIEW" } { diff --git a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsColorize.shadersubgraph b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsColorize.shadersubgraph index 87086bfd402..fba7d686953 100644 --- a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsColorize.shadersubgraph +++ b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsColorize.shadersubgraph @@ -1269,7 +1269,7 @@ "m_FunctionName": "AddAdditionalLightsColorize", "m_FunctionSource": "3beadf505dbc54f4cae878435013d751", "m_FunctionSourceUsePragmas": true, - "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\nAtten = 0;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n\t\tAtten += atten;\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif" + "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\nAtten = 0;\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n#if defined(_ADDITIONAL_LIGHTS) || defined(_CLUSTER_LIGHT_LOOP)\r\n\r\n #if defined(_ADDITIONAL_LIGHTS)\r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n #endif\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n\t\tAtten += atten;\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif // _ADDITIONAL_LIGHTS || _CLUSTER_LIGHT_LOOP\r\n\r\n#endif // SHADERGRAPH_PREVIEW" } { diff --git a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsHalfLambert.shadersubgraph b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsHalfLambert.shadersubgraph index 2f5c6f4fc13..cdef9743b5d 100644 --- a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsHalfLambert.shadersubgraph +++ b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsHalfLambert.shadersubgraph @@ -1140,7 +1140,7 @@ "m_FunctionName": "AddAdditionalLightsHalfLambert", "m_FunctionSource": "3beadf505dbc54f4cae878435013d751", "m_FunctionSourceUsePragmas": true, - "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = dot(WorldNormal, light.direction);\r\n float halfLambert = NdotL * 0.5 + 0.5;\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * halfLambert;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif" + "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n#if defined(_ADDITIONAL_LIGHTS) || defined(_CLUSTER_LIGHT_LOOP)\r\n\r\n #if defined(_ADDITIONAL_LIGHTS)\r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n #endif\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = dot(WorldNormal, light.direction);\r\n float halfLambert = NdotL * 0.5 + 0.5;\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * halfLambert;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif // _ADDITIONAL_LIGHTS || _CLUSTER_LIGHT_LOOP\r\n\r\n#endif // SHADERGRAPH_PREVIEW" } { diff --git a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsSimple.shadersubgraph b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsSimple.shadersubgraph index 56e5d24268b..804367d2915 100644 --- a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsSimple.shadersubgraph +++ b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsSimple.shadersubgraph @@ -1152,7 +1152,7 @@ "m_FunctionName": "AddAdditionalLightsSimple", "m_FunctionSource": "3beadf505dbc54f4cae878435013d751", "m_FunctionSourceUsePragmas": true, - "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif" + "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n#if defined(_ADDITIONAL_LIGHTS) || defined(_CLUSTER_LIGHT_LOOP)\r\n\r\n #if defined(_ADDITIONAL_LIGHTS)\r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n #endif\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = atten * NdotL;\r\n float3 halfAngle = normalize(light.direction + WorldView);\r\n float spec = pow(saturate(dot(halfAngle, WorldNormal)), SpecPower);\r\n float3 thisSpecular = spec * Reflectance * atten;\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif // _ADDITIONAL_LIGHTS || _CLUSTER_LIGHT_LOOP\r\n\r\n#endif // SHADERGRAPH_PREVIEW" } { diff --git a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsURP.shadersubgraph b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsURP.shadersubgraph index f96145ec574..68fd8464ef7 100644 --- a/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsURP.shadersubgraph +++ b/Packages/com.unity.shadergraph/Samples~/CustomLighting/Components/AdditionalLights/AdditionalLightsURP.shadersubgraph @@ -1148,7 +1148,7 @@ "m_FunctionName": "AddAdditionalLights", "m_FunctionSource": "3beadf505dbc54f4cae878435013d751", "m_FunctionSourceUsePragmas": true, - "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n half Roughness = pow(1 - Smoothness, 2);\r\n half Roughness2 = Roughness * Roughness;\r\n\thalf Roughness2Minus1 = Roughness2 - 1;\r\n\thalf normalizationTerm = (Roughness * half(4.0) + half(2.0));\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = NdotL * atten;\r\n //DirectBRDFSpecular\r\n\r\n float3 lightDirectionWSFloat3 = float3(light.direction);\r\n float3 halfDir = SafeNormalize(lightDirectionWSFloat3 + float3(WorldView));\r\n float NoH = saturate(dot(float3(WorldNormal), halfDir));\r\n half LoH = half(saturate(dot(lightDirectionWSFloat3, halfDir)));\r\n float d = NoH * NoH * Roughness2Minus1 + 1.00001f;\r\n half LoH2 = LoH * LoH;\r\n half spec = Roughness2 / ((d * d) * max(0.1h, LoH2) * normalizationTerm);\r\n #if REAL_IS_HALF\r\n spec = spec - HALF_MIN;\r\n spec = clamp(spec, 0.0, 1000.0);\r\n #endif\t\t\r\n float3 thisSpecular = spec * Reflectance * NdotL * atten;\r\n\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif" + "m_FunctionBody": "Diffuse = MainDiffuse;\r\nSpecular = MainSpecular;\r\nColor = MainColor * (MainDiffuse + MainSpecular);\r\n\r\n#ifndef SHADERGRAPH_PREVIEW\r\n \r\n#if defined(_ADDITIONAL_LIGHTS) || defined(_CLUSTER_LIGHT_LOOP)\r\n\r\n #if defined(_ADDITIONAL_LIGHTS)\r\n uint pixelLightCount = GetAdditionalLightsCount();\r\n #endif\r\n half Roughness = pow(1 - Smoothness, 2);\r\n half Roughness2 = Roughness * Roughness;\r\n\thalf Roughness2Minus1 = Roughness2 - 1;\r\n\thalf normalizationTerm = (Roughness * half(4.0) + half(2.0));\r\n\r\n#if USE_CLUSTER_LIGHT_LOOP\r\n // for Foward+ LIGHT_LOOP_BEGIN macro uses inputData.normalizedScreenSpaceUV and inputData.positionWS\r\n InputData inputData = (InputData)0;\r\n\r\n inputData.normalizedScreenSpaceUV = ScreenPosition;\r\n inputData.positionWS = WorldPosition;\r\n#endif\r\n\r\n LIGHT_LOOP_BEGIN(pixelLightCount)\r\n\t\t// Call the URP additional light algorithm. This will not calculate shadows, since we don't pass a shadow mask value\r\n\t\tLight light = GetAdditionalLight(lightIndex, WorldPosition);\r\n\t\t// Manually set the shadow attenuation by calculating realtime shadows\r\n\t\tlight.shadowAttenuation = AdditionalLightRealtimeShadow(lightIndex, WorldPosition, light.direction);\r\n #if defined(_LIGHT_COOKIES)\r\n float3 cookieColor = SampleAdditionalLightCookie(lightIndex, WorldPosition);\r\n light.color *= cookieColor;\r\n #endif\r\n float NdotL = saturate(dot(WorldNormal, light.direction));\r\n float atten = light.distanceAttenuation * light.shadowAttenuation;\r\n float thisDiffuse = NdotL * atten;\r\n //DirectBRDFSpecular\r\n\r\n float3 lightDirectionWSFloat3 = float3(light.direction);\r\n float3 halfDir = SafeNormalize(lightDirectionWSFloat3 + float3(WorldView));\r\n float NoH = saturate(dot(float3(WorldNormal), halfDir));\r\n half LoH = half(saturate(dot(lightDirectionWSFloat3, halfDir)));\r\n float d = NoH * NoH * Roughness2Minus1 + 1.00001f;\r\n half LoH2 = LoH * LoH;\r\n half spec = Roughness2 / ((d * d) * max(0.1h, LoH2) * normalizationTerm);\r\n #if REAL_IS_HALF\r\n spec = spec - HALF_MIN;\r\n spec = clamp(spec, 0.0, 1000.0);\r\n #endif\t\t\r\n float3 thisSpecular = spec * Reflectance * NdotL * atten;\r\n\r\n Diffuse += thisDiffuse;\r\n Specular += thisSpecular;\r\n\r\n Color += light.color * (thisDiffuse + thisSpecular);\r\n LIGHT_LOOP_END\r\n float total = Diffuse + dot(Specular, float3(0.333, 0.333, 0.333));\r\n Color = total <= 0 ? MainColor : Color / total;\r\n#endif // _ADDITIONAL_LIGHTS || _CLUSTER_LIGHT_LOOP\r\n\r\n#endif // SHADERGRAPH_PREVIEW" } { From 1f3d060e1b3c7b125afd002c41d46735610b1469 Mon Sep 17 00:00:00 2001 From: Beini Gu Date: Mon, 4 May 2026 16:24:53 +0000 Subject: [PATCH 09/27] [6000.5 Backport] [HDRP][XR] Update ClearBuffer2D to support XR views --- .../Runtime/Core/CoreResources/ClearBuffer2D.compute | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Core/CoreResources/ClearBuffer2D.compute b/Packages/com.unity.render-pipelines.high-definition/Runtime/Core/CoreResources/ClearBuffer2D.compute index b52cd1f64fe..d4754113ccb 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Core/CoreResources/ClearBuffer2D.compute +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Core/CoreResources/ClearBuffer2D.compute @@ -12,6 +12,8 @@ RW_TEXTURE2D_X(float4, _Buffer2D); [numthreads(8, 8, 1)] void ClearBuffer2DMain(uint3 dispatchThreadID : SV_DispatchThreadID) { + UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadID.z); + if (any(dispatchThreadID.xy >= (uint2)_BufferSize.xy)) return; From 79255cbfd4efd48d0e936eb074d1750bcf411960 Mon Sep 17 00:00:00 2001 From: Evergreen Date: Mon, 4 May 2026 16:24:53 +0000 Subject: [PATCH 10/27] [Port] [6000.5] [ShaderGraph] Address issue where linkage hints for reflected functions are not useful. --- .../Editor/Data/Graphs/MaterialSlot.cs | 51 +- .../Editor/Drawing/SearchWindowProvider.cs | 6 +- .../Model/Header/HeaderUtils.cs | 4 + .../Model/Header/ParameterHeader.cs | 8 + .../Model/Header/ParameterHints.cs | 31 + .../Utility/ReflectedFunction.shadergraph | 706 ++++++++++-------- .../ShaderFunctionReflectionReference.hlsl | 21 +- .../Graphs/ProviderSystem/AllHints.hlsl | 19 + .../ShouldCompileProperlyOnImport.shadergraph | 1 - 9 files changed, 526 insertions(+), 321 deletions(-) diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs index 5de12e31da4..432baf4e055 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/MaterialSlot.cs @@ -36,8 +36,36 @@ abstract class MaterialSlot : JsonObject, IDisposable [SerializeField] ShaderStageCapability m_StageCapability; + [SerializeField] + string m_CustomBinding; + bool m_HasError; + internal string CustomBinding + { + get + { + if (!string.IsNullOrWhiteSpace(m_CustomBinding)) + return m_CustomBinding; + + else if (owner is SubGraphNode sgNode) + { + var property = sgNode.GetShaderProperty(id); + return property?.customSlotLabel; + } + + else if (owner is PropertyNode propertyNode) + { + return propertyNode.property?.customSlotLabel; + } + + return null; + } + set { m_CustomBinding = value; } + } + + internal bool HasCustomBinding => !string.IsNullOrWhiteSpace(CustomBinding); + protected MaterialSlot() { } protected MaterialSlot(int slotId, string displayName, string shaderOutputName, SlotType slotType, ShaderStageCapability stageCapability = ShaderStageCapability.All, bool hidden = false) @@ -56,30 +84,13 @@ internal void SetInternalData(SlotType slotType, string shaderOutputName) this.shaderOutputName = shaderOutputName; } - public bool IsConnectionTestable() - { - if (owner is SubGraphNode sgNode) - { - var property = sgNode.GetShaderProperty(id); - if (property != null) - { - return property.isConnectionTestable; - } - } - else if (owner is PropertyNode propertyNode) - { - return propertyNode.property.isConnectionTestable; - } - return false; - } + public bool IsConnectionTestable() => HasCustomBinding; public VisualElement InstantiateCustomControl() { - if (!isConnected && IsConnectionTestable()) + if (!isConnected && HasCustomBinding) { - var sgNode = owner as SubGraphNode; - var property = sgNode.GetShaderProperty(id); - return new LabelSlotControlView(property.customSlotLabel); + return new LabelSlotControlView(CustomBinding); } return null; } diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/SearchWindowProvider.cs b/Packages/com.unity.shadergraph/Editor/Drawing/SearchWindowProvider.cs index e0f07a5adf3..fcd3a08a4aa 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/SearchWindowProvider.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/SearchWindowProvider.cs @@ -11,6 +11,7 @@ using UnityEngine.Pool; using Object = UnityEngine.Object; using UnityEditor.ShaderGraph.ProviderSystem; +using UnityEditor.ShaderGraph.ProviderSystem.Hints; namespace UnityEditor.ShaderGraph.Drawing { @@ -47,7 +48,7 @@ public void Initialize(EditorWindow editorWindow, GraphData graph, GraphView gra // Transparent icon to trick search window into indenting items m_Icon = new Texture2D(1, 1); - m_Icon.SetPixel(0, 0, new Color(0, 0, 0, 0)); + m_Icon.SetPixel(0, 0, new UnityEngine.Color(0, 0, 0, 0)); m_Icon.Apply(); } @@ -208,6 +209,9 @@ public void GenerateNodeEntries() HashSet providerCollisions = new(); foreach (var provider in ProviderLibrary.Instance.AllProvidersByType()) { + if (!provider.IsValid || !provider.Definition.Hints.ContainsKey(Func.kProviderKey)) + continue; + if (!ProviderTypeCache.TryCreateModel(provider.ProviderKey, out var model) || model is not ProviderNode node) node = new ProviderNode(); diff --git a/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/HeaderUtils.cs b/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/HeaderUtils.cs index d979523cd44..06e57e3a15d 100644 --- a/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/HeaderUtils.cs +++ b/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/HeaderUtils.cs @@ -280,6 +280,10 @@ internal static MaterialSlot MakeSlotFromParameter(ParameterHeader header, int s slot.hideConnector = header.isStatic && dir == SlotType.Input; slot.hidden = header.isLocal; slot.bareResource = header.isBareResource; + + if (header.hasCustomBinding) + slot.CustomBinding = header.customBinding; + return slot; } diff --git a/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHeader.cs b/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHeader.cs index 7728955f292..b7e59b03519 100644 --- a/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHeader.cs +++ b/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHeader.cs @@ -43,6 +43,9 @@ internal class ParameterHeader : StrongHeader internal bool isLinkage { get; private set; } internal string linkTarget { get; private set; } + internal bool hasCustomBinding { get; private set; } + internal string customBinding { get; private set; } + private static HintRegistry s_HintRegistry; protected override HintRegistry GetHintRegistry() { @@ -64,6 +67,7 @@ protected override HintRegistry GetHintRegistry() s_HintRegistry.RegisterStrongHint(new Hints.Referable()); s_HintRegistry.RegisterStrongHint(new Hints.Dynamic()); s_HintRegistry.RegisterStrongHint(new Hints.Linkage()); + s_HintRegistry.RegisterStrongHint(new Hints.CustomBinding()); } return s_HintRegistry; } @@ -127,6 +131,10 @@ protected override void OnProcess(IShaderField param, IProvider provider) isLocal = true; } + if (hasCustomBinding = Has(Hints.Param.kCustomBinding)) + { + customBinding = Get(Hints.Param.kCustomBinding); + } } internal ParameterHeader(IShaderField param, IProvider provider) diff --git a/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHints.cs b/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHints.cs index 2ffb77fb2db..a9834e63330 100644 --- a/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHints.cs +++ b/Packages/com.unity.shadergraph/Editor/ProviderSystem/Model/Header/ParameterHints.cs @@ -22,6 +22,8 @@ internal static class Param internal const string kDynamic = "sg:DynamicVector"; internal const string kReferable = "sg:Referable"; + internal const string kCustomBinding = "sg:CustomBinding"; + internal static class Ref { internal const string kUV = "UV"; @@ -436,4 +438,33 @@ public bool Process(bool found, string rawValue, IShaderField obj, IProvider pro return true; } } + + internal class CustomBinding : IStrongHint + { + public string Key => Param.kCustomBinding; + public IReadOnlyCollection Conflicts { get; } = new string[] { Param.kCustomEditor }; + + public bool Process(bool found, string rawValue, IShaderField obj, IProvider provider, out object value, out string msg, string actualHintKey) + { + value = rawValue; + msg = null; + if (!found) + return false; + + if (!obj.IsInput) + { + msg = $"Expected input parameter."; + return false; + } + + if (string.IsNullOrEmpty(rawValue)) + { + msg = "Invalid value."; + return false; + } + + return true; + } + } + } diff --git a/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ReflectedFunction.shadergraph b/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ReflectedFunction.shadergraph index 405d3ed71d9..eed0a7c6f18 100644 --- a/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ReflectedFunction.shadergraph +++ b/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ReflectedFunction.shadergraph @@ -104,9 +104,6 @@ { "m_Id": "3a4010eed5544bde9b3d9d4e824c5415" }, - { - "m_Id": "30812e910c88404f867da8d64db34643" - }, { "m_Id": "b9450bb77d1a4e1f9db31b3c546072ed" }, @@ -121,6 +118,9 @@ }, { "m_Id": "3f5900b6dbad4f10a972758d7676197f" + }, + { + "m_Id": "e34776ba035e444581dda83ed9f6150a" } ], "m_GroupDatas": [ @@ -580,10 +580,11 @@ "m_HideConnector": false, "m_ShaderOutputName": "color", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.5471698045730591, - "y": 0.29165181517601013, - "z": 0.29165181517601013, + "y": 0.29165181517601015, + "z": 0.29165181517601015, "w": 1.0 }, "m_DefaultValue": { @@ -643,6 +644,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "A", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "e00": 0.0, "e01": 0.0, @@ -681,21 +683,6 @@ } } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", - "m_ObjectId": "04585ab4c4bd47c1813dc6214b6860f3", - "m_Id": 2, - "m_DisplayName": "overrideSkyColor", - "m_SlotType": 0, - "m_Hidden": true, - "m_HideConnector": false, - "m_ShaderOutputName": "overrideSkyColor", - "m_StageCapability": 3, - "m_Value": false, - "m_DefaultValue": false -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot", @@ -707,6 +694,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -744,6 +732,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Cosine Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -761,6 +750,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "uv", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -783,6 +773,7 @@ "m_HideConnector": true, "m_ShaderOutputName": "animated", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": false, "m_DefaultValue": false } @@ -793,8 +784,8 @@ "m_ObjectId": "0917fa34a2534125a5502fdaf5d26666", "m_Title": "Dynamic Vectors", "m_Position": { - "x": -4079.0, - "y": 91.0 + "x": -4078.999755859375, + "y": 91.00003814697266 } } @@ -843,6 +834,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vertex", "m_StageCapability": 3, + "m_CustomBinding": "", "m_typeName": "ShaderFunctionReflectionStructExample::VertexData", "m_rawDefaultValueString": "0" } @@ -858,8 +850,9 @@ "m_HideConnector": false, "m_ShaderOutputName": "color", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { - "x": 0.30588236451148987, + "x": 0.30588236451148989, "y": 0.7176470756530762, "z": 1.0 }, @@ -889,6 +882,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "BaseColor", "m_StageCapability": 2, + "m_CustomBinding": "", "m_Value": { "x": 0.5, "y": 0.5, @@ -920,6 +914,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Z Buffer Sign", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -943,6 +938,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "X", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -960,12 +956,39 @@ "m_HideConnector": false, "m_ShaderOutputName": "Sine Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], "m_LiteralMode": false } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "18af09b3dea1467d8b10346ba93c9303", + "m_Id": 1, + "m_DisplayName": "position", + "m_SlotType": 0, + "m_Hidden": false, + "m_HideConnector": false, + "m_ShaderOutputName": "position", + "m_StageCapability": 3, + "m_CustomBinding": "", + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -977,6 +1000,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Near Plane", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -986,7 +1010,7 @@ { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.TangentMaterialSlot", - "m_ObjectId": "1994ae4644e24962b70c99779a6ff389", + "m_ObjectId": "19b921f435d840c784dc85dc0403bb16", "m_Id": 3, "m_DisplayName": "tangent", "m_SlotType": 0, @@ -994,6 +1018,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "tangent", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -1055,6 +1080,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -1079,6 +1105,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Smooth Delta", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -1096,6 +1123,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "center", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.5, "y": 0.5 @@ -1118,6 +1146,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Smooth Delta", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -1155,6 +1184,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Position", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -1179,6 +1209,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vertex", "m_StageCapability": 3, + "m_CustomBinding": "", "m_typeName": "ShaderFunctionReflectionStructExample::VertexData", "m_rawDefaultValueString": "0" } @@ -1214,6 +1245,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "uv", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -1225,6 +1257,22 @@ "m_Labels": [] } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", + "m_ObjectId": "2ca7b70f63264419b565bb60f1d1e62d", + "m_Id": 4, + "m_DisplayName": "overrideGroundColor", + "m_SlotType": 0, + "m_Hidden": true, + "m_HideConnector": false, + "m_ShaderOutputName": "overrideGroundColor", + "m_StageCapability": 3, + "m_CustomBinding": "", + "m_Value": false, + "m_DefaultValue": false +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -1236,6 +1284,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "thickness", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.009999999776482582, "m_DefaultValue": 0.009999999776482582, "m_Labels": [], @@ -1253,6 +1302,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "UV", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -1265,80 +1315,6 @@ "m_Channel": 0 } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.ProviderSystem.ProviderNode", - "m_ObjectId": "30812e910c88404f867da8d64db34643", - "m_Group": { - "m_Id": "72636737d68045df848d96f5349455ec" - }, - "m_Name": "Linkage Example", - "m_DrawState": { - "m_Expanded": true, - "m_Position": { - "serializedVersion": "2", - "x": -2543.0, - "y": 150.0, - "width": 225.0, - "height": 335.0 - } - }, - "m_Slots": [ - { - "m_Id": "765c03230145400889a3e1fa426dd81a" - }, - { - "m_Id": "d05a945dd8ac46948092b564201d7546" - }, - { - "m_Id": "b09062b1082c4c689d82b4564f5b87c4" - }, - { - "m_Id": "04585ab4c4bd47c1813dc6214b6860f3" - }, - { - "m_Id": "df3caaef43f44d5cb5012e67911e5952" - }, - { - "m_Id": "b6a07950c02c4a67a88ee4700e3e8cba" - }, - { - "m_Id": "c3cbda0d119b42a88d793c492b05cc18" - } - ], - "synonyms": [ - "Reference", - "Hint" - ], - "m_Precision": 0, - "m_PreviewExpanded": true, - "m_DismissedVersion": 0, - "m_PreviewMode": 2, - "m_CustomColors": { - "m_SerializableColors": [] - }, - "m_provider": { - "rid": 1000 - }, - "references": { - "version": 2, - "RefIds": [ - { - "rid": 1000, - "type": { - "class": "ReflectedFunctionProvider", - "ns": "UnityEditor.ShaderGraph.ProviderSystem", - "asm": "Unity.ShaderGraph.Editor" - }, - "data": { - "m_providerKey": "SG.NodeReference.Linkage.Example", - "m_sourceAssetId": "a9e2b4c78c7e11c4a98ae1e60be55112" - } - } - ] - } -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -1350,6 +1326,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -1363,7 +1340,7 @@ "m_Title": "Function Examples", "m_Position": { "x": -3114.0, - "y": 1428.0 + "y": 1427.9998779296875 } } @@ -1378,6 +1355,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Delta Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -1395,6 +1373,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "color", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 1.0, "y": 1.0, @@ -1426,6 +1405,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vc", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -1447,8 +1427,8 @@ "m_ObjectId": "395e687c1c3844b5928a6c0f9b0db35d", "m_Title": "Dual Precision", "m_Position": { - "x": -3544.0, - "y": 91.0 + "x": -3543.999755859375, + "y": 91.00003814697266 } } @@ -1525,6 +1505,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Alpha", "m_StageCapability": 2, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -1604,6 +1585,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "color", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.5, "y": 0.5, @@ -1665,15 +1647,15 @@ "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", "m_ObjectId": "401ff46c9a1641aea7a99cbd40d6e205", "m_Title": "", - "m_Content": "For missing Varying Reference Types, the hint allows querying the input connection state.\n\nThis is similar to using BranchOnInputConnection in a Subgraph.\n\nFor instance, this allows to default to built-in variables such as unity_AmbientSky or UNITY_MATRIX_V[2]. ", + "m_Content": "For missing Varying Reference Types, the hint allows querying the input connection state.\n\nThis is similar to using BranchOnInputConnection in a Subgraph.\n\nFor instance, this allows to default to built-in variables such as unity_AmbientSky or UNITY_MATRIX_V[2].\n\nThe hint allows for labeling inputs ports of linked parameters.", "m_TextSize": 0, "m_Theme": 0, "m_Position": { "serializedVersion": "2", "x": -2906.0, "y": 346.0, - "width": 321.0, - "height": 148.1634521484375 + "width": 348.0, + "height": 169.47763061523438 }, "m_Group": { "m_Id": "72636737d68045df848d96f5349455ec" @@ -1770,6 +1752,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -1787,6 +1770,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Normal", "m_StageCapability": 1, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -1815,8 +1799,8 @@ "m_ObjectId": "45d837fe36d5481d96d2af7ed2d45e80", "m_Title": "Texture", "m_Position": { - "x": -1821.00048828125, - "y": 90.99998474121094 + "x": -1820.9998779296875, + "y": 91.00003814697266 } } @@ -1926,31 +1910,6 @@ "m_SerializedDescriptor": "VertexDescription.Normal" } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", - "m_ObjectId": "4759905ff9d5423888b9d529002d90fe", - "m_Id": 1, - "m_DisplayName": "position", - "m_SlotType": 0, - "m_Hidden": false, - "m_HideConnector": false, - "m_ShaderOutputName": "position", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_Labels": [], - "m_Space": 0 -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.ColorRGBMaterialSlot", @@ -1962,6 +1921,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Color/Sky", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -1993,6 +1953,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "b", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -2010,6 +1971,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "cutoff", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.5, "m_DefaultValue": 0.5, "m_Labels": [], @@ -2035,6 +1997,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Y", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [ @@ -2054,6 +2017,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -2092,7 +2056,7 @@ "m_Id": "e00af0a8a01b40cfb942717a7c580563" }, { - "m_Id": "ed843934fe1f4fc29e6833a9925ea644" + "m_Id": "630c342f6b7f4934ba043990a4099af4" }, { "m_Id": "dc1dbefb11aa469c820ad6f9d29bafc0" @@ -2182,7 +2146,7 @@ "m_Title": "Static", "m_Position": { "x": -4445.0, - "y": 91.0 + "y": 91.00003814697266 } } @@ -2197,6 +2161,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "position", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -2221,6 +2186,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Z", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [ @@ -2240,6 +2206,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -2257,6 +2224,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Width", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -2274,6 +2242,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "color", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 1.0, "y": 1.0, @@ -2294,6 +2263,32 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", + "m_ObjectId": "630c342f6b7f4934ba043990a4099af4", + "m_Id": 5, + "m_DisplayName": "position", + "m_SlotType": 0, + "m_Hidden": false, + "m_HideConnector": false, + "m_ShaderOutputName": "position", + "m_StageCapability": 3, + "m_CustomBinding": "", + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.TimeNode", @@ -2350,6 +2345,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "uv", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -2373,6 +2369,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Far Plane", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -2390,6 +2387,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Scale", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 3.0, "m_DefaultValue": 10.0, "m_Labels": [], @@ -2407,6 +2405,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -2424,38 +2423,13 @@ "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.GroupData", "m_ObjectId": "72636737d68045df848d96f5349455ec", - "m_Title": "Linkage", + "m_Title": "Linkage & CustomBinding", "m_Position": { - "x": -2941.999755859375, - "y": 90.99999237060547 + "x": -2942.0, + "y": 91.00003814697266 } } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", - "m_ObjectId": "72776a17d5bd475e85ae05594c4c9320", - "m_Id": 2, - "m_DisplayName": "normal", - "m_SlotType": 0, - "m_Hidden": false, - "m_HideConnector": false, - "m_ShaderOutputName": "normal", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_Labels": [], - "m_Space": 0 -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.UVMaterialSlot", @@ -2467,6 +2441,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "uv", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -2490,6 +2465,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "mask", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -2519,14 +2495,15 @@ { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", - "m_ObjectId": "765c03230145400889a3e1fa426dd81a", - "m_Id": 0, - "m_DisplayName": "Out", - "m_SlotType": 1, + "m_ObjectId": "767fff9e6fca49c5847036238a037fc1", + "m_Id": 2, + "m_DisplayName": "groundColor", + "m_SlotType": 0, "m_Hidden": false, "m_HideConnector": false, - "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", + "m_ShaderOutputName": "groundColor", "m_StageCapability": 3, + "m_CustomBinding": "Ambient Ground Color", "m_Value": { "x": 0.0, "y": 0.0, @@ -2551,6 +2528,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "uv", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -2578,7 +2556,7 @@ "x": -1796.000244140625, "y": 150.0, "width": 208.0, - "height": 335.00006103515625 + "height": 335.00006103515627 } }, "m_Slots": [ @@ -2639,6 +2617,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "A", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "e00": 0.0, "e01": 0.0, @@ -2688,6 +2667,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Ground", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -2723,7 +2703,7 @@ "x": -2903.999755859375, "y": 811.9999389648438, "width": 232.0, - "height": 146.00006103515625 + "height": 146.00006103515626 } }, "m_Slots": [ @@ -2740,7 +2720,7 @@ "m_SerializableColors": [] }, "m_Value": { - "x": 0.36000001430511475, + "x": 0.36000001430511477, "y": -1.0, "z": 1.0 } @@ -2791,6 +2771,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Orthographic", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -2808,6 +2789,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "A", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -2834,6 +2816,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "e00": 0.0, "e01": 0.0, @@ -2883,6 +2866,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "normal", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -3023,7 +3007,8 @@ "m_HideConnector": true, "m_ShaderOutputName": "multiplier", "m_StageCapability": 3, - "m_Value": 0.23999999463558197, + "m_CustomBinding": "", + "m_Value": 0.23999999463558198, "m_DefaultValue": 1.0, "m_Labels": [], "m_LiteralMode": false, @@ -3066,6 +3051,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "e00": 0.0, "e01": 0.0, @@ -3115,6 +3101,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "uv", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -3127,6 +3114,31 @@ "m_Channel": 0 } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "85b3f2b315994cb29450cf3354062a11", + "m_Id": 5, + "m_DisplayName": "cameraDirectionWS", + "m_SlotType": 0, + "m_Hidden": false, + "m_HideConnector": false, + "m_ShaderOutputName": "cameraDirectionWS", + "m_StageCapability": 3, + "m_CustomBinding": "Camera Direction WS", + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.AddNode", @@ -3181,6 +3193,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -3200,9 +3213,9 @@ "m_Position": { "serializedVersion": "2", "x": -4054.0, - "y": 375.99993896484375, + "y": 375.99993896484377, "width": 131.0, - "height": 149.00006103515625 + "height": 149.00006103515626 } }, "m_Slots": [ @@ -3254,6 +3267,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "B", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "e00": 2.0, "e01": 2.0, @@ -3303,6 +3317,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -3338,13 +3353,13 @@ }, "m_Slots": [ { - "m_Id": "4759905ff9d5423888b9d529002d90fe" + "m_Id": "18af09b3dea1467d8b10346ba93c9303" }, { - "m_Id": "72776a17d5bd475e85ae05594c4c9320" + "m_Id": "a2d4de43f8984ed086ee63192008d4ae" }, { - "m_Id": "1994ae4644e24962b70c99779a6ff389" + "m_Id": "19b921f435d840c784dc85dc0403bb16" }, { "m_Id": "ed4a9431a40c41538ee717bd94313762" @@ -3451,6 +3466,22 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", + "m_ObjectId": "90f8b9848b074f44b436879c4a1ac2d7", + "m_Id": 6, + "m_DisplayName": "overrideCameraDirectionWS", + "m_SlotType": 0, + "m_Hidden": true, + "m_HideConnector": false, + "m_ShaderOutputName": "overrideCameraDirectionWS", + "m_StageCapability": 3, + "m_CustomBinding": "", + "m_Value": false, + "m_DefaultValue": false +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -3462,6 +3493,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Sine Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -3479,6 +3511,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "b", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.5, "y": 0.5, @@ -3505,6 +3538,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -3623,7 +3657,7 @@ "m_SerializableColors": [] }, "m_Value": { - "x": 0.30000001192092896, + "x": 0.30000001192092898, "y": 0.0, "z": 2.0 } @@ -3640,6 +3674,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Tex", "m_StageCapability": 3, + "m_CustomBinding": "", "m_BareResource": false, "m_Texture": { "m_SerializedTexture": "{\"texture\":{\"fileID\":10309,\"guid\":\"0000000000000000f000000000000000\",\"type\":0}}", @@ -3659,6 +3694,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0 @@ -3681,6 +3717,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -3698,6 +3735,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -3724,6 +3762,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -3748,6 +3787,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "a", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 1.0, "y": 1.0, @@ -3832,6 +3872,32 @@ "inspectorFoldoutMask": 0 } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.NormalMaterialSlot", + "m_ObjectId": "a2d4de43f8984ed086ee63192008d4ae", + "m_Id": 2, + "m_DisplayName": "normal", + "m_SlotType": 0, + "m_Hidden": false, + "m_HideConnector": false, + "m_ShaderOutputName": "normal", + "m_StageCapability": 3, + "m_CustomBinding": "", + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [], + "m_Space": 0 +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.Rendering.HighDefinition.ShaderGraph.BuiltinData", @@ -3858,8 +3924,8 @@ "m_ObjectId": "a336489e22914f4a9470f05854e32387", "m_Title": "Local", "m_Position": { - "x": -2223.00048828125, - "y": 90.99998474121094 + "x": -2223.0, + "y": 91.00003814697266 } } @@ -3874,6 +3940,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "amount", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -3891,6 +3958,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -3964,6 +4032,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Y", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [ @@ -4003,6 +4072,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4029,6 +4099,7 @@ "m_HideConnector": true, "m_ShaderOutputName": "antialiased", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": false, "m_DefaultValue": false } @@ -4044,6 +4115,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4070,6 +4142,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -4087,6 +4160,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Delta Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -4096,16 +4170,17 @@ { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", - "m_ObjectId": "b09062b1082c4c689d82b4564f5b87c4", - "m_Id": 5, - "m_DisplayName": "groundColor", - "m_SlotType": 0, + "m_ObjectId": "aff3fbb927c74cd89639a598b83d2390", + "m_Id": 0, + "m_DisplayName": "Out", + "m_SlotType": 1, "m_Hidden": false, "m_HideConnector": false, - "m_ShaderOutputName": "groundColor", + "m_ShaderOutputName": "__UNITY_SHADERGRAPH_UNUSED", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { - "x": 1.0, + "x": 0.0, "y": 0.0, "z": 0.0 }, @@ -4128,6 +4203,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4154,6 +4230,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Equator", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4185,6 +4262,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "W", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [ @@ -4193,30 +4271,6 @@ "m_LiteralMode": false } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", - "m_ObjectId": "b6a07950c02c4a67a88ee4700e3e8cba", - "m_Id": 3, - "m_DisplayName": "cameraDirectionWS", - "m_SlotType": 0, - "m_Hidden": false, - "m_HideConnector": false, - "m_ShaderOutputName": "cameraDirectionWS", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 1.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_Labels": [] -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -4228,6 +4282,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "a", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -4245,6 +4300,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -4303,6 +4359,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "tangent", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4327,6 +4384,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "B", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4427,21 +4485,6 @@ "m_SupportLineRendering": false } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", - "m_ObjectId": "c3cbda0d119b42a88d793c492b05cc18", - "m_Id": 4, - "m_DisplayName": "overrideCameraDirectionWS", - "m_SlotType": 0, - "m_Hidden": true, - "m_HideConnector": false, - "m_ShaderOutputName": "overrideCameraDirectionWS", - "m_StageCapability": 3, - "m_Value": false, - "m_DefaultValue": false -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector2MaterialSlot", @@ -4453,6 +4496,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "spacing", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 5.0, "y": 5.0 @@ -4475,6 +4519,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Position", "m_StageCapability": 1, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4504,7 +4549,7 @@ "x": -2198.000244140625, "y": 150.0, "width": 207.9998779296875, - "height": 287.00006103515625 + "height": 287.00006103515627 } }, "m_Slots": [ @@ -4639,6 +4684,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "sum", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4654,30 +4700,6 @@ "m_LiteralMode": false } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", - "m_ObjectId": "d05a945dd8ac46948092b564201d7546", - "m_Id": 1, - "m_DisplayName": "skyColor", - "m_SlotType": 0, - "m_Hidden": false, - "m_HideConnector": false, - "m_ShaderOutputName": "skyColor", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 1.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_Labels": [] -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.DynamicValueMaterialSlot", @@ -4689,6 +4711,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "B", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "e00": 2.0, "e01": 2.0, @@ -4738,6 +4761,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Out", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -4830,6 +4854,22 @@ } } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", + "m_ObjectId": "da8a89c6421e4f65aa16ff0572fca368", + "m_Id": 3, + "m_DisplayName": "overrideSkyColor", + "m_SlotType": 0, + "m_Hidden": true, + "m_HideConnector": false, + "m_ShaderOutputName": "overrideSkyColor", + "m_StageCapability": 3, + "m_CustomBinding": "", + "m_Value": false, + "m_DefaultValue": false +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", @@ -4841,6 +4881,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "position", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -4933,41 +4974,27 @@ "m_HideConnector": false, "m_ShaderOutputName": "lineColor", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { - "x": 0.20000000298023224, + "x": 0.20000000298023225, "y": 0.699999988079071, "z": 0.800000011920929 }, "m_DefaultValue": { - "x": 0.20000000298023224, + "x": 0.20000000298023225, "y": 0.699999988079071, "z": 0.800000011920929 }, "m_Labels": [], "m_ColorMode": 0, "m_DefaultColor": { - "r": 0.20000000298023224, + "r": 0.20000000298023225, "g": 0.699999988079071, "b": 0.800000011920929, "a": 1.0 } } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.BooleanMaterialSlot", - "m_ObjectId": "df3caaef43f44d5cb5012e67911e5952", - "m_Id": 6, - "m_DisplayName": "overrideGroundColor", - "m_SlotType": 0, - "m_Hidden": true, - "m_HideConnector": false, - "m_ShaderOutputName": "overrideGroundColor", - "m_StageCapability": 3, - "m_Value": false, - "m_DefaultValue": false -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.StickyNoteData", @@ -4999,6 +5026,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vc", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5025,6 +5053,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Direction", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5049,12 +5078,87 @@ "m_HideConnector": false, "m_ShaderOutputName": "strength", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 4.03000020980835, "m_DefaultValue": 0.0, "m_Labels": [], "m_LiteralMode": false } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.ProviderSystem.ProviderNode", + "m_ObjectId": "e34776ba035e444581dda83ed9f6150a", + "m_Group": { + "m_Id": "72636737d68045df848d96f5349455ec" + }, + "m_Name": "Linkage Example", + "m_DrawState": { + "m_Expanded": true, + "m_Position": { + "serializedVersion": "2", + "x": -2542.999755859375, + "y": 149.99998474121095, + "width": 225.0, + "height": 150.99998474121095 + } + }, + "m_Slots": [ + { + "m_Id": "aff3fbb927c74cd89639a598b83d2390" + }, + { + "m_Id": "e3b3802ff06a4267a06c6638a4829f49" + }, + { + "m_Id": "767fff9e6fca49c5847036238a037fc1" + }, + { + "m_Id": "da8a89c6421e4f65aa16ff0572fca368" + }, + { + "m_Id": "2ca7b70f63264419b565bb60f1d1e62d" + }, + { + "m_Id": "85b3f2b315994cb29450cf3354062a11" + }, + { + "m_Id": "90f8b9848b074f44b436879c4a1ac2d7" + } + ], + "synonyms": [ + "Reference", + "Hint" + ], + "m_Precision": 0, + "m_PreviewExpanded": true, + "m_DismissedVersion": 0, + "m_PreviewMode": 0, + "m_CustomColors": { + "m_SerializableColors": [] + }, + "m_provider": { + "rid": 1000 + }, + "references": { + "version": 2, + "RefIds": [ + { + "rid": 1000, + "type": { + "class": "ReflectedFunctionProvider", + "ns": "UnityEditor.ShaderGraph.ProviderSystem", + "asm": "Unity.ShaderGraph.Editor" + }, + "data": { + "m_providerKey": "SG.NodeReference.Linkage.Example", + "m_sourceAssetId": "a9e2b4c78c7e11c4a98ae1e60be55112" + } + } + ] + } +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -5066,12 +5170,38 @@ "m_HideConnector": false, "m_ShaderOutputName": "X", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], "m_LiteralMode": false } +{ + "m_SGVersion": 0, + "m_Type": "UnityEditor.ShaderGraph.Vector3MaterialSlot", + "m_ObjectId": "e3b3802ff06a4267a06c6638a4829f49", + "m_Id": 1, + "m_DisplayName": "skyColor", + "m_SlotType": 0, + "m_Hidden": false, + "m_HideConnector": false, + "m_ShaderOutputName": "skyColor", + "m_StageCapability": 3, + "m_CustomBinding": "Ambient Sky Color", + "m_Value": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_DefaultValue": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "m_Labels": [] +} + { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.ProviderSystem.ProviderNode", @@ -5144,6 +5274,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5170,6 +5301,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vc", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5196,6 +5328,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "X", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -5213,6 +5346,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Z", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [ @@ -5232,6 +5366,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vertex", "m_StageCapability": 3, + "m_CustomBinding": "", "m_typeName": "ShaderFunctionReflectionStructExample::VertexData", "m_rawDefaultValueString": "0" } @@ -5247,6 +5382,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5262,31 +5398,6 @@ "m_LiteralMode": true } -{ - "m_SGVersion": 0, - "m_Type": "UnityEditor.ShaderGraph.PositionMaterialSlot", - "m_ObjectId": "ed843934fe1f4fc29e6833a9925ea644", - "m_Id": 5, - "m_DisplayName": "position", - "m_SlotType": 0, - "m_Hidden": false, - "m_HideConnector": false, - "m_ShaderOutputName": "position", - "m_StageCapability": 3, - "m_Value": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_DefaultValue": { - "x": 0.0, - "y": 0.0, - "z": 0.0 - }, - "m_Labels": [], - "m_Space": 0 -} - { "m_SGVersion": 0, "m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot", @@ -5298,6 +5409,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Y", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [ @@ -5337,6 +5449,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "vertex", "m_StageCapability": 3, + "m_CustomBinding": "", "m_typeName": "ShaderFunctionReflectionStructExample::VertexData", "m_rawDefaultValueString": "0" } @@ -5352,6 +5465,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Height", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 1.0, "m_DefaultValue": 1.0, "m_Labels": [], @@ -5434,6 +5548,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5460,6 +5575,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "gradient", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -5497,6 +5613,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, @@ -5523,6 +5640,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Cosine Time", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": 0.0, "m_DefaultValue": 0.0, "m_Labels": [], @@ -5540,6 +5658,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "a", "m_StageCapability": 3, + "m_CustomBinding": "", "m_Value": { "x": 0.5, "y": 0.5, @@ -5561,8 +5680,8 @@ "m_ObjectId": "fb7001c484e442778b74cc94d1d09c4e", "m_Title": "Reference Types", "m_Position": { - "x": -3208.0, - "y": 91.0 + "x": -3207.999755859375, + "y": 91.00003814697266 } } @@ -5577,6 +5696,7 @@ "m_HideConnector": false, "m_ShaderOutputName": "Tangent", "m_StageCapability": 1, + "m_CustomBinding": "", "m_Value": { "x": 0.0, "y": 0.0, diff --git a/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ShaderFunctionReflectionReference.hlsl b/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ShaderFunctionReflectionReference.hlsl index 939c43b96c4..b001d16c1fa 100644 --- a/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ShaderFunctionReflectionReference.hlsl +++ b/Packages/com.unity.shadergraph/Samples~/NodeReference/Utility/ShaderFunctionReflectionReference.hlsl @@ -101,15 +101,24 @@ namespace ShaderFunctionReflectionReference { /// Linkage Example /// Reference, Hint /// - /// + /// + /// Ambient Sky Color + /// + /// + /// Ambient Ground Color + /// + /// + /// Camera Direction WS + /// + /// /// skyColor - /// - /// + /// + /// /// groundColor - /// - /// + /// + /// /// cameraDirectionWS - /// + /// UNITY_EXPORT_REFLECTION float3 LinkageExample( float3 skyColor, diff --git a/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/AllHints.hlsl b/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/AllHints.hlsl index 0ed7ee70a5e..ba0f7f816af 100644 --- a/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/AllHints.hlsl +++ b/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/AllHints.hlsl @@ -216,3 +216,22 @@ UNITY_EXPORT_REFLECTION float3 LinkageExample(bool test, float other) else return float3(0, other, 0); } + +/// +/// LinkageExampleWithBinding +/// +/// + /// My Special Label +/// +/// + /// other +/// +UNITY_EXPORT_REFLECTION +float3 LinkageExampleWithBinding(bool test, float other) +{ + if (!test) + return float3(1, 0, 0); + else + return float3(0, other, 0); +} + diff --git a/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/ShouldCompileProperlyOnImport.shadergraph b/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/ShouldCompileProperlyOnImport.shadergraph index eb337ee7936..6fa003618ce 100644 --- a/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/ShouldCompileProperlyOnImport.shadergraph +++ b/Tests/SRPTests/Projects/ShaderGraph/Assets/Testing/IntegrationTests/Graphs/ProviderSystem/ShouldCompileProperlyOnImport.shadergraph @@ -2457,4 +2457,3 @@ }, "m_Labels": [] } - From a88508d49741525f2deea6f7b7d5a3dd37388d00 Mon Sep 17 00:00:00 2001 From: Alexandre Thibodeau Date: Tue, 5 May 2026 14:43:22 +0000 Subject: [PATCH 11/27] [Port] [6000.5] Fixed Main Preview not being updated properly in UITK shaders (Other Option) --- .../Editor/Data/Graphs/GradientInputMaterialSlot.cs | 2 +- .../Editor/Data/Graphs/GraphData.cs | 2 +- .../Editor/Data/Interfaces/GenerationMode.cs | 3 ++- .../Editor/Data/Nodes/Input/PropertyNode.cs | 6 +++--- .../Editor/Data/Nodes/Utility/CustomFunctionNode.cs | 2 +- .../Editor/Data/Nodes/Utility/DropdownNode.cs | 4 ++-- .../Nodes/Utility/Logic/BranchOnInputConnection.cs | 2 +- .../Editor/Data/Util/KeywordCollector.cs | 2 +- .../Editor/Drawing/PreviewManager.cs | 3 ++- .../Editor/Drawing/Views/MaterialNodeView.cs | 2 +- .../Editor/Generation/Processors/GenerationUtils.cs | 6 +++--- .../Editor/Generation/Processors/Generator.cs | 12 ++++++------ .../Generation/Processors/PropertyCollector.cs | 2 +- .../Targets/CustomRenderTexture/CustomTextureSelf.cs | 2 +- .../Targets/CustomRenderTexture/CustomTextureSize.cs | 2 +- .../CustomRenderTexture/CustomTextureSlice.cs | 2 +- .../Targets/Fullscreen/FullscreenSubTarget.cs | 2 +- 17 files changed, 29 insertions(+), 27 deletions(-) diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/GradientInputMaterialSlot.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/GradientInputMaterialSlot.cs index 6ecdf7c58c3..837ffd2af80 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/GradientInputMaterialSlot.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/GradientInputMaterialSlot.cs @@ -70,7 +70,7 @@ public override void AddDefaultProperty(PropertyCollector properties, Generation if (matOwner == null) throw new Exception(string.Format("Slot {0} either has no owner, or the owner is not a {1}", this, typeof(AbstractMaterialNode))); - if (generationMode != GenerationMode.Preview) + if (!generationMode.IsPreview()) return; GradientUtil.GetGradientPropertiesForPreview(properties, matOwner.GetVariableNameForSlot(id), value); diff --git a/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs b/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs index f6d2a171c63..ca10c003fc4 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs @@ -1376,7 +1376,7 @@ public void CollectShaderProperties(PropertyCollector collector, GenerationMode } // ugh, this needs to be moved to the gradient property implementation - if (prop is GradientShaderProperty gradientProp && generationMode == GenerationMode.Preview) + if (prop is GradientShaderProperty gradientProp && generationMode.IsPreview()) { GradientUtil.GetGradientPropertiesForPreview(collector, gradientProp.referenceName, gradientProp.value); continue; diff --git a/Packages/com.unity.shadergraph/Editor/Data/Interfaces/GenerationMode.cs b/Packages/com.unity.shadergraph/Editor/Data/Interfaces/GenerationMode.cs index d484c1d7c25..fd53eeaf2ab 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Interfaces/GenerationMode.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Interfaces/GenerationMode.cs @@ -4,10 +4,11 @@ enum GenerationMode { Preview, ForReals, + PreviewForReals, // Combines ForReals features (UITK macros) with Preview behavior (uniforms for slots) VFX } static class GenerationModeExtensions { - public static bool IsPreview(this GenerationMode mode) { return mode == GenerationMode.Preview; } + public static bool IsPreview(this GenerationMode mode) { return mode == GenerationMode.Preview || mode == GenerationMode.PreviewForReals; } } } diff --git a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/PropertyNode.cs b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/PropertyNode.cs index c8bc4bc4588..b675889a32f 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/PropertyNode.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/PropertyNode.cs @@ -154,7 +154,7 @@ void AddOutputSlot() public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode mode) { // preview is always generating a full shader, even when previewing within a subgraph - bool isGeneratingSubgraph = owner.isSubGraph && (mode != GenerationMode.Preview); + bool isGeneratingSubgraph = owner.isSubGraph && !mode.IsPreview(); switch (property.propertyType) { @@ -222,7 +222,7 @@ public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode mode) sb.AppendLine($"UnitySamplerState {GetVariableNameForSlot(OutputSlotId)} = {property.GetHLSLVariableName(isGeneratingSubgraph, mode)};"); break; case PropertyType.Gradient: - if (mode == GenerationMode.Preview) + if (mode.IsPreview()) sb.AppendLine($"Gradient {GetVariableNameForSlot(OutputSlotId)} = {GradientUtil.GetGradientForPreview(property.GetHLSLVariableName(isGeneratingSubgraph, mode))};"); else sb.AppendLine($"Gradient {GetVariableNameForSlot(OutputSlotId)} = {property.GetHLSLVariableName(isGeneratingSubgraph, mode)};"); @@ -234,7 +234,7 @@ public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode mode) // If in a subgraph, the value will be read from a function parameter. // If generating preview mode code, we always inline the value, according to code gen requirements. // The parent graph always sets the explicit value to be passed to a subgraph function. - sb.AppendLine("bool {0} = {1};", GetConnectionStateVariableNameForSlot(OutputSlotId), (mode == GenerationMode.Preview || !isGeneratingSubgraph) ? (IsSlotConnected(OutputSlotId) ? "true" : "false") : property.GetConnectionStateHLSLVariableName()); + sb.AppendLine("bool {0} = {1};", GetConnectionStateVariableNameForSlot(OutputSlotId), (mode.IsPreview() || !isGeneratingSubgraph) ? (IsSlotConnected(OutputSlotId) ? "true" : "false") : property.GetConnectionStateHLSLVariableName()); } } diff --git a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/CustomFunctionNode.cs b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/CustomFunctionNode.cs index 77236515a48..7f2186371c2 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/CustomFunctionNode.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/CustomFunctionNode.cs @@ -159,7 +159,7 @@ public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMo if (!IsValidFunction()) { // invalid functions generate special preview code.. (why?) - if (generationMode == GenerationMode.Preview && outputSlots.Count != 0) + if (generationMode.IsPreview() && outputSlots.Count != 0) { outputSlots.OrderBy(s => s.id); var hlslVariableType = outputSlots[0].concreteValueType.ToShaderString(); diff --git a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/DropdownNode.cs b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/DropdownNode.cs index 861f02c6b16..036e70db629 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/DropdownNode.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/DropdownNode.cs @@ -121,8 +121,8 @@ public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMo { var outputSlot = FindOutputSlot(OutputSlotId); - bool isGeneratingSubgraph = owner.isSubGraph && (generationMode != GenerationMode.Preview); - if (generationMode == GenerationMode.Preview || !isGeneratingSubgraph) + bool isGeneratingSubgraph = owner.isSubGraph && !generationMode.IsPreview(); + if (generationMode.IsPreview() || !isGeneratingSubgraph) { sb.AppendLine(string.Format($"{outputSlot.concreteValueType.ToShaderString()} {GetVariableNameForSlot(OutputSlotId)};")); var value = GetSlotValue(GetSlotIdForActiveSelection(), generationMode); diff --git a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/BranchOnInputConnection.cs b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/BranchOnInputConnection.cs index ea15708d450..546df3eb521 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/BranchOnInputConnection.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/Logic/BranchOnInputConnection.cs @@ -50,7 +50,7 @@ public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMo var notconnected = GetSlotValue(NotConnectedSlotId, generationMode); var output = GetVariableNameForSlot(OutSlotId); - if (generationMode == GenerationMode.Preview) + if (generationMode.IsPreview()) sb.AppendLine($"{dynamicType} {output} = {notconnected};"); else sb.AppendLine($"{dynamicType} {output} = {input} ? {connected} : {notconnected};"); diff --git a/Packages/com.unity.shadergraph/Editor/Data/Util/KeywordCollector.cs b/Packages/com.unity.shadergraph/Editor/Data/Util/KeywordCollector.cs index 7e0cd195ba9..8ea0eb51755 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Util/KeywordCollector.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Util/KeywordCollector.cs @@ -38,7 +38,7 @@ public void GetKeywordsDeclaration(ShaderStringBuilder builder, GenerationMode m foreach (var keyword in keywords) { // Hardcode active keywords in preview to reduce compiled variants - if (mode == GenerationMode.Preview) + if (mode.IsPreview()) { string declaration = keyword.GetKeywordPreviewDeclarationString(); if (!string.IsNullOrEmpty(declaration)) diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs b/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs index 1350999e7fc..7ca3e14f839 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/PreviewManager.cs @@ -1403,7 +1403,8 @@ void CompileMasterNodeShader() if (!m_Graph.isOnlyVFXTarget) { // UITK shaders need ForReals mode to have access to UITK macros for proper rendering - var mode = prefersUITKPreview ? GenerationMode.ForReals : GenerationMode.Preview; + // Use PreviewForReals to get both ForReals features and Preview slot behavior (uniforms instead of inlined constants) + var mode = prefersUITKPreview ? GenerationMode.PreviewForReals : GenerationMode.Preview; var generator = new Generator(m_Graph, m_Graph.outputNode, mode, "Master"); shaderData.shaderString = generator.generatedShader; diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs b/Packages/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs index fa97974a540..116553994f2 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/Views/MaterialNodeView.cs @@ -426,7 +426,7 @@ public void ShowGeneratedCode(DropdownMenuAction action) var mode = (GenerationMode)action.userData; string path = String.Format("Temp/GeneratedFromGraph-{0}-{1}-{2}{3}.shader", SanitizeName(name), - SanitizeName(node.name), node.objectId, mode == GenerationMode.Preview ? "-Preview" : ""); + SanitizeName(node.name), node.objectId, mode.IsPreview() ? "-Preview" : ""); if (GraphUtil.WriteToFile(path, ConvertToShader(mode))) GraphUtil.OpenFile(path); } diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs b/Packages/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs index e64e1b0f20e..3106f987eed 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Processors/GenerationUtils.cs @@ -876,7 +876,7 @@ internal static void GeneratePropertiesBlock(ShaderStringBuilder sb, PropertyCol // Keywords use hardcoded state in preview // Do not add them to the Property Block - if (mode == GenerationMode.Preview) + if (mode.IsPreview()) return; foreach (var key in keywordCollector.keywords.Where(x => x.generatePropertyBlock)) @@ -890,7 +890,7 @@ internal static void GeneratePropertiesBlock(ShaderStringBuilder sb, PropertyCol var keywordInputs = keywordCollector.keywords.Where(x => x.generatePropertyBlock).ToList(); foreach (var input in graphInputs) { - if (input.isKeyword && mode != GenerationMode.Preview) + if (input.isKeyword && !mode.IsPreview()) { var keyword = keywordInputs.FirstOrDefault(x => x.referenceName.CompareTo(input.referenceName) == 0); if (keyword != null) @@ -915,7 +915,7 @@ internal static void GeneratePropertiesBlock(ShaderStringBuilder sb, PropertyCol property.AppendPropertyBlockStrings(sb); } - if (mode != GenerationMode.Preview) + if (!mode.IsPreview()) { foreach (var keyword in keywordInputs) { diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs b/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs index 63335045ebc..734e31cd414 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Processors/Generator.cs @@ -258,7 +258,7 @@ GeneratedShader BuildShader(string additionalShaderID, List outTempor string shaderName = isPrimaryShader ? m_PrimaryShaderFullName : ProcessShaderName(additionalShaderID); var activeNodeList = Pool.HashSetPool.Get(); - bool ignoreActiveState = (m_Mode == GenerationMode.Preview); // for previews, we ignore node active state + bool ignoreActiveState = m_Mode.IsPreview(); // for previews, we ignore node active state if (m_OutputNode == null) { foreach (var block in m_ActiveBlocks) @@ -294,7 +294,7 @@ GeneratedShader BuildShader(string additionalShaderID, List outTempor } } - var variantLimit = this.m_Mode == GenerationMode.Preview + var variantLimit = m_Mode.IsPreview() ? Mathf.Min(ShaderGraphPreferences.previewVariantLimit, ShaderGraphProjectSettings.instance.shaderVariantLimit) : ShaderGraphProjectSettings.instance.shaderVariantLimit; if (!ShaderGraphProjectSettings.instance.overrideShaderVariantLimit) @@ -417,7 +417,7 @@ void GenerateSubShader(int targetIndex, SubShaderDescriptor descriptor, Property return; // Early out of preview generation if no passes are used in preview - if (m_Mode == GenerationMode.Preview && descriptor.generatesPreview == false) + if (m_Mode.IsPreview() && descriptor.generatesPreview == false) return; m_Builder.AppendLine("SubShader"); @@ -435,7 +435,7 @@ void GenerateSubShader(int targetIndex, SubShaderDescriptor descriptor, Property var activeFields = GatherActiveFieldsFromNode(m_OutputNode, pass.descriptor, activeBlockDescriptors, connectedBlockDescriptors, m_Targets[targetIndex]); // TODO: cleanup this preview check, needed for HD decal preview pass - if (m_Mode == GenerationMode.Preview) + if (m_Mode.IsPreview()) activeFields.baseInstance.Add(Fields.IsPreview); // Check masternode fields for valid passes @@ -574,7 +574,7 @@ void GenerateKernel(int targetIndex, KernelDescriptor kernel) void GenerateShaderPass(int targetIndex, PassDescriptor pass, ActiveFields activeFields, List currentBlockDescriptors, PropertyCollector subShaderProperties) { // Early exit if pass is not used in preview - if (m_Mode == GenerationMode.Preview && !pass.useInPreview) + if (m_Mode.IsPreview() && !pass.useInPreview) return; // using (s_profileGenerateShaderPass.Auto()) @@ -1095,7 +1095,7 @@ void ProcessStackForPass(ContextData contextData, BlockFieldDescriptor[] passBlo { graphDefines.AppendLine("#define SHADERPASS {0}", pass.referenceName); - if (m_OutputNode == null && m_Mode == GenerationMode.Preview) + if (m_OutputNode == null && m_Mode.IsPreview()) graphDefines.AppendLine("#define SHADERGRAPH_PREVIEW_MAIN"); if (pass.defines != null) diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Processors/PropertyCollector.cs b/Packages/com.unity.shadergraph/Editor/Generation/Processors/PropertyCollector.cs index d0a96c4089e..480e7430e7d 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Processors/PropertyCollector.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Processors/PropertyCollector.cs @@ -155,7 +155,7 @@ public void GetPropertiesDeclaration(ShaderStringBuilder builder, GenerationMode // build a list of all HLSL properties var hlslProps = BuildHLSLPropertyList(); - if (mode == GenerationMode.Preview) + if (mode.IsPreview()) { builder.AppendLine("CBUFFER_START(UnityPerMaterial)"); diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSelf.cs b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSelf.cs index 57f8bb83160..b55170aa149 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSelf.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSelf.cs @@ -49,7 +49,7 @@ public override string GetVariableNameForSlot(int slotId) public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) { // For preview only we declare CRT defines - if (generationMode == GenerationMode.Preview) + if (generationMode.IsPreview()) { registry.builder.AppendLine("#if !defined(UNITY_CRT_PREVIEW_TEXTURE) && !defined(UNITY_CUSTOM_TEXTURE_INCLUDED)"); registry.builder.AppendLine("#define UNITY_CRT_PREVIEW_TEXTURE"); diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSize.cs b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSize.cs index 9c6f9a2c08d..023abc3f45f 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSize.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSize.cs @@ -49,7 +49,7 @@ public override string GetVariableNameForSlot(int slotId) public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) { // For preview only we declare CRT defines - if (generationMode == GenerationMode.Preview) + if (generationMode.IsPreview()) { registry.builder.AppendLine("#ifndef _CustomRenderTextureHeight"); registry.builder.AppendLine("#define _CustomRenderTextureHeight 1.0"); diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSlice.cs b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSlice.cs index 89036ca4f70..79e60323e24 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSlice.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/CustomRenderTexture/CustomTextureSlice.cs @@ -47,7 +47,7 @@ public override string GetVariableNameForSlot(int slotId) public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode) { // For preview only we declare CRT defines - if (generationMode == GenerationMode.Preview) + if (generationMode.IsPreview()) { registry.builder.AppendLine("#define _CustomRenderTextureCubeFace 0.0"); registry.builder.AppendLine("#define _CustomRenderTexture3DSlice 0.0"); diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/Fullscreen/FullscreenSubTarget.cs b/Packages/com.unity.shadergraph/Editor/Generation/Targets/Fullscreen/FullscreenSubTarget.cs index fdf58da2805..fb35410a28f 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/Fullscreen/FullscreenSubTarget.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/Fullscreen/FullscreenSubTarget.cs @@ -543,7 +543,7 @@ public override void CollectShaderProperties(PropertyCollector collector, Genera public void CollectRenderStateShaderProperties(PropertyCollector collector, GenerationMode generationMode) { - if (generationMode != GenerationMode.Preview && fullscreenData.allowMaterialOverride) + if (!generationMode.IsPreview() && fullscreenData.allowMaterialOverride) { // When blend mode is disabled, we can't override if (fullscreenData.blendMode != FullscreenBlendMode.Disabled) From 5776c8ed0e82c16caf524f02b9d62d539fa732fe Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 5 May 2026 20:30:24 +0000 Subject: [PATCH 12/27] [Port] [6000.5] URP Renderer - When adding/removing scriptable render features refresh the project browser to reflect the changes. --- .../Editor/ScriptableRendererDataEditor.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ScriptableRendererDataEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/ScriptableRendererDataEditor.cs index 8d86be0f8fb..4261385ed00 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ScriptableRendererDataEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ScriptableRendererDataEditor.cs @@ -365,6 +365,8 @@ private void ClearEditorsList() private void ForceSave() { EditorUtility.SetDirty(target); + AssetDatabase.SaveAssetIfDirty(target); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); } } From 334ca942bd3c13a4909b21adab2d0efceea1246b Mon Sep 17 00:00:00 2001 From: Evergreen Date: Tue, 5 May 2026 20:30:24 +0000 Subject: [PATCH 13/27] [Port] [6000.5] Fixed Cancel behavior for ObjectSelector With Confirmation --- .../Editor/InternalBridge/AssemblyInfo.cs | 1 + .../Editor/InternalBridge/ObjectSelector.cs | 7 + ...aultVolumeProfileSettingsPropertyDrawer.cs | 142 ++++++++++++++++++ .../Editor/Volume/VolumeProfileUtils.cs | 3 +- ...aultVolumeProfileSettingsPropertyDrawer.cs | 73 +-------- .../HDRPDefaultVolumeProfileSetting.cs | 8 +- ...aultVolumeProfileSettingsPropertyDrawer.cs | 77 +--------- ...ty.RenderPipelines.Universal.Editor.asmdef | 3 +- 8 files changed, 165 insertions(+), 149 deletions(-) diff --git a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs index 8ea160f1dec..0a04494f984 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/AssemblyInfo.cs @@ -2,3 +2,4 @@ [assembly: InternalsVisibleTo("Unity.RenderPipelines.Core.Editor")] [assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Editor")] +[assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Editor")] diff --git a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs index 8c398439214..ea3b96a5f2b 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/InternalBridge/ObjectSelector.cs @@ -10,5 +10,12 @@ public static void Show(UnityEngine.Object obj, Type requiredType, UnityEngine.O { UnityEditor.ObjectSelector.get.Show(obj, requiredType, objectBeingEdited, allowSceneObjects, allowedEntityIds, onObjectSelectorClosed, onObjectSelectedUpdated, showNoneItem); } + + public static void SetVisualSelection(EntityId entityId) + { + UnityEditor.ObjectSelector.get.SetVisualSelection(entityId); + } + + public static bool isVisible => UnityEditor.ObjectSelector.isVisible; } } diff --git a/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs b/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs index 3e1a845611b..4704543a9ac 100644 --- a/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs +++ b/Packages/com.unity.render-pipelines.core/Editor/Settings/PropertyDrawers/DefaultVolumeProfileSettingsPropertyDrawer.cs @@ -1,7 +1,9 @@ using System; +using UnityEditor.UIElements; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UIElements; +using Object = UnityEngine.Object; namespace UnityEditor.Rendering { @@ -17,6 +19,7 @@ public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer : Prope static DefaultVolumeProfileEditor s_DefaultVolumeProfileEditor; VisualElement m_Root; + ObjectField m_ObjectField; /// SerializedObject representing the settings object protected SerializedObject m_SettingsSerializedObject; @@ -31,6 +34,9 @@ public abstract partial class DefaultVolumeProfileSettingsPropertyDrawer : Prope /// Info box message protected abstract GUIContent volumeInfoBoxLabel { get; } + /// Label and tooltip used for the Default Volume Profile asset field. + protected abstract GUIContent defaultVolumeProfileAssetLabel { get; } + /// /// CreatePropertyGUI implementation. /// @@ -107,6 +113,142 @@ protected void DestroyDefaultVolumeProfileEditor() s_DefaultVolumeProfileSerializedProperty = null; } + /// + /// Show modal dialog to confirm update of selected volume if needed and apply new volume profile. + /// + /// Object Field used to display Default Volume profile + /// New Volume profile + /// Previous volume profile + /// Optionally provided default volume profile to extract default values + /// Render Pipeline type + void ShowGlobalDefaultVolumeDialog(ObjectField field, Object newValue, + Object previousValue, IDefaultVolumeProfileSettings defaultVolumeProfileSettings = null) + where TRenderPipeline : RenderPipeline + { + bool confirmed = VolumeProfileUtils.UpdateGlobalDefaultVolumeProfileWithConfirmation(newValue as VolumeProfile, defaultVolumeProfileSettings?.volumeProfile); + if (confirmed) + { + UpdateDefaultVolumeSerializedPropertyAndRecreate(field, newValue); + } + else + { + m_VolumeProfileSerializedProperty.objectReferenceValue = previousValue; + m_VolumeProfileSerializedProperty.serializedObject.ApplyModifiedProperties(); + field.SetValueWithoutNotify(previousValue); + // Update the ObjectSelector's visual selection if it's still open + if (previousValue != null && ObjectSelector.isVisible) + ObjectSelector.SetVisualSelection(previousValue.GetEntityId()); + } + } + + /// + /// Update serialized property for Default Volume profile and recreate related Editors + /// + /// Object Field used to display Default Volume profile + /// New Volume profile + void UpdateDefaultVolumeSerializedPropertyAndRecreate(ObjectField field, Object newValue) + { + m_VolumeProfileSerializedProperty.objectReferenceValue = newValue; + m_VolumeProfileSerializedProperty.serializedObject.ApplyModifiedProperties(); + field.SetValueWithoutNotify(newValue); + DestroyDefaultVolumeProfileEditor(); + CreateDefaultVolumeProfileEditor(); + } + + /// + /// Draw ObjectField for Default Volume. + /// + /// Default value source if available + /// Render Pipeline type for Default Volume + /// Default Volume settings container type + /// New Object Field + protected VisualElement DrawDefaultVolumeObjectField(TDefaultVolumeSettings defaultVolumeProfileSettings = null) + where TRenderPipeline: RenderPipeline + where TDefaultVolumeSettings : class, IDefaultVolumeProfileSettings + { + VisualElement profileLine = new(); + var toggle = new Toggle(); + toggle.AddToClassList(Foldout.toggleUssClassName); + var checkmark = toggle.Q(className: Toggle.checkmarkUssClassName); + checkmark.AddToClassList(Foldout.checkmarkUssClassName); + m_ObjectField = new ObjectField(defaultVolumeProfileAssetLabel.text) + { + tooltip = defaultVolumeProfileAssetLabel.tooltip, + objectType = typeof(VolumeProfile), + value = m_VolumeProfileSerializedProperty.objectReferenceValue as VolumeProfile, + style = + { + flexShrink = 1, + } + }; + m_ObjectField.AddToClassList("unity-base-field__aligned"); //Align with other BaseField + m_ObjectField.Q