diff --git a/Packages/com.unity.render-pipelines.core/CHANGELOG.md b/Packages/com.unity.render-pipelines.core/CHANGELOG.md index c1cb0174fad..407e8971400 100644 --- a/Packages/com.unity.render-pipelines.core/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.core/CHANGELOG.md @@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [14.0.11] - 2025-02-13 + +This version is compatible with Unity 2022.3.59f1. + +### Fixed +- Fixed PackFloat2To8 in packing.hlsl. +- Rendering Debugger - Keep the correct selected panel when entering and exiting from playmode. +- Fixed _FOVEATED_RENDERING_NON_UNIFORM_RASTER shader compilation errors. +- Rendering Debugger - Silent crash when selecting a Volume component with public RTHandles. +- Fix truncated vector warning in DownSampleDepth shader + ## [14.0.10] - 2024-04-03 This version is compatible with Unity 2022.3.24f1. diff --git a/Packages/com.unity.render-pipelines.core/package.json b/Packages/com.unity.render-pipelines.core/package.json index a2c3af01d82..82867a8ff2b 100644 --- a/Packages/com.unity.render-pipelines.core/package.json +++ b/Packages/com.unity.render-pipelines.core/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.render-pipelines.core", "description": "SRP Core makes it easier to create or customize a Scriptable Render Pipeline (SRP). SRP Core contains reusable code, including boilerplate code for working with platform-specific graphics APIs, utility functions for common rendering operations, and shader libraries. The code in SRP Core is use by the High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP). If you are creating a custom SRP from scratch or customizing a prebuilt SRP, using SRP Core will save you time.", - "version": "14.0.11", + "version": "14.0.12", "unity": "2022.3", "displayName": "Core RP Library", "dependencies": { diff --git a/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md b/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md index c7c7d62a242..acce13b3ea3 100644 --- a/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.high-definition-config/CHANGELOG.md @@ -10,6 +10,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [14.0.11] - 2025-02-13 + +This version is compatible with Unity 2022.3.59f1. + +Version Updated +The version number for this package has increased due to a version update of a related graphics package. + ## [14.0.10] - 2024-04-03 This version is compatible with Unity 2022.3.24f1. diff --git a/Packages/com.unity.render-pipelines.high-definition-config/package.json b/Packages/com.unity.render-pipelines.high-definition-config/package.json index 193ff3d97c9..20b98942753 100644 --- a/Packages/com.unity.render-pipelines.high-definition-config/package.json +++ b/Packages/com.unity.render-pipelines.high-definition-config/package.json @@ -1,10 +1,10 @@ { "name": "com.unity.render-pipelines.high-definition-config", "description": "Configuration files for the High Definition Render Pipeline.", - "version": "14.0.11", + "version": "14.0.12", "unity": "2022.3", "displayName": "High Definition RP Config", "dependencies": { - "com.unity.render-pipelines.core": "14.0.11" + "com.unity.render-pipelines.core": "14.0.12" } } \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md b/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1af6ead3c86..5816eeb79cd 100644 --- a/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -10,6 +10,57 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [14.0.11] - 2025-02-13 + +This version is compatible with Unity 2022.3.59f1. + +### Changed +- Transparent materials now appear opaque when using Mipmap Streaming debug views for increased clarity. +- Create the Global Settings asset in to the current opened folder. +- Create the Global Settings asset in to the current opened folder. + +### Fixed +- Fixed an assert triggered when the decal count goes over the light count. +- Fixed scene modification when exiting play mode with the graphics compositor enabled. +- Added Graphics Compositor Limitation section for VR. +- Fixed underwater applied when water is disabled. +- Fixed cinematic eye shader lighting from directional lights. +- Fixed TAA post sharpen in XR. +- Banding in IES importer. +- Fixed realloc of history buffer when XR is enabled. +- Fixed invalid AABB errors in some other cases. +- Added framesettings to render volumetric clouds in half res to reduce jittering. +- Regenerate the hlsl include that where out of date. +- Cached shadow : Fix corruption when using a non square atlas and improve blit performance. +- Fixed an issue where the default terrain shader for HDRP was outputting incorrect albedo values to the lightmapper. +- Fixed a NullReferenceException when exiting Play Mode with HDRP + DLSS + XR. +- Fixed a motion blur blending issue. +- Fixed an issue where the Mipmap Streaming debug views would show up incorrectly when certain features were enabled (SRP Batcher, Volumetric Fog, Volumetric Clouds, and,...). +- Fixed an issue where certain Mipmap Streaming debug views (for example: "Mip Count") would not show up correctly on Metal. +- Fixed an issue where the Rendering Debugger "Terrain Texture" drop-down would appear only when enabling a Fullscreen Debug Mode, instead of appearing when enabling a Mipmap Streaming debug view as intended. +- Changed ProbeSettings.cubeResolution field from internal to public. +- Fixed shader warnings from TAA shader on Metal. +- Reduced some artifacts from High-Quality (PCSS) shadows for point and spot lights. +- Fixed issue with EndCameraRendering being called before renderContext submission. +- HDRP: SSGI, Ray traced GI, Path traced GI and No-GI now match when using an IBL. +- Reimporting ShaderGraph assets no longer triggers a UnityVCS/Perfoce local checkout. +- Fixed graphic corruption on some mobile platforms. +- Fixed sun flicker where the sun is close to cloud boundaries. +- Ignore material variants with log message. +- Fixed an issue where UI images using render textures would not render properly with HDR enabled. +- Added clamp to HairAngleWorld to prevent nan from FastASin. +- Fixed an issue where cascade shadows and distance shadowmask were not blended properly. +- Fixed invalid global state pushed when using override camera rendering in the CustomPassUtils functions. +- Fixed wrong SSR when using a shader graph with a clear coat value of 0. +- Fixed HDRP ambient scene lighting leaking into the material preview window. +- Fixed black line artifacts on top of the screen with DRS and downsampled SSAO. +- Fixed HDRP sky rendering when Camera Relative Rendering is disabled. +- Fixed artifacts when blending cascade shadows and distance shadowmask. +- Added a condition to the Receiver Motion Rejection function(feature) to check that the pixel has actually moved. +- Fixed an issue where the padding in the Lighting window was different between tabs. +- Fixed refraction sampling with DRS. +- Fixed color pyramid sampling when distortion is enabled after the distortion pass. + ## [14.0.10] - 2024-04-03 This version is compatible with Unity 2022.3.24f1. diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md index 932b75171e5..a2f7a204286 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Getting-Started.md @@ -283,6 +283,7 @@ HDRP ray tracing in Unity has the following limitations: - Ray tracing isn't supported when rendering [Reflection Probes](Reflection-Probe.md). - HDRP doesn't support [orthographic projection](HDRP-Camera.md). If you enable orthographic projection mode, you might experience rendering problems for Transparent Materials, volumetrics and planar reflections. - Ray Traced and Screen Space effects won't appear recursively in [Ray Traced Reflections](Ray-Traced-Reflections.md), [Ray Traced Global Illumination](Ray-Traced-Global-Illumination.md) or [Recursive Ray Tracing](Ray-Tracing-Recursive-Rendering.md). This means, for example, you won't be able to see [Screen Space Global Illumination](Override-Screen-Space-GI.md) in [ray-traced reflection](Ray-Traced-Reflections.md). +- Doesn't support water. ### Unsupported shader graph nodes for ray tracing diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md index 7d369ec1d46..f3eabc7c323 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md +++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Path-Tracing.md @@ -202,7 +202,8 @@ HDRP path tracing in Unity 2020.2 has the following limitations: - MSAA. - [Graphics.DrawMesh](https://docs.unity3d.com/ScriptReference/Graphics.DrawMesh.html) or [Graphics.RenderMesh](https://docs.unity3d.com/2022.1/Documentation/ScriptReference/Graphics.RenderMesh.html), because rasterization and ray tracing are different ways of generating an image. - [Streaming Virtual Texturing](https://docs.unity3d.com/Documentation/Manual/svt-streaming-virtual-texturing.html). - + - Vertex animation, for example wind deformation of vegetation. + ### Unsupported shader graph nodes for path tracing When building your custom shaders using shader graph, some nodes are incompatible with ray/path tracing. You need either to avoid using them or provide an alternative behavior using the [ray tracing shader node](SGNode-Raytracing-Quality). Here is the list of the incompatible nodes: diff --git a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs index 7bdc8a38f69..44b4057edfd 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Editor/Sky/HDLightingWindowEnvironmentSection.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; namespace UnityEditor.Rendering.HighDefinition { @@ -16,16 +17,7 @@ class HDLightingWindowEnvironmentSectionEditor : LightingWindowEnvironmentSectio { class Styles { - public static GUIStyle headerStyle; - static Styles() - { - headerStyle = new GUIStyle(EditorStyles.foldoutHeader); - headerStyle.fontStyle = FontStyle.Bold; - headerStyle.fontSize = 12; - headerStyle.margin = new RectOffset(17, 0, 0, 0); - headerStyle.padding = new RectOffset(16, 1, 0, 0); - headerStyle.fixedHeight = 21; - } + public static readonly GUIStyle inspectorTitle = "IN Title"; } class SerializedStaticLightingSky @@ -78,6 +70,8 @@ bool toggleValue } } + static MethodInfo k_FoldoutTitlebar; + public override void OnEnable() { m_SerializedActiveSceneLightingSky = new SerializedStaticLightingSky(GetStaticLightingSkyForScene(EditorSceneManager.GetActiveScene())); @@ -149,35 +143,20 @@ public override void OnInspectorGUI() void DrawGUI() { - Rect mainSeparator = EditorGUILayout.GetControlRect(GUILayout.Height(1)); - mainSeparator.xMin -= 3; - mainSeparator.xMax += 4; - EditorGUI.DrawRect(mainSeparator, EditorGUIUtility.isProSkin - ? new Color32(26, 26, 26, 255) - : new Color32(127, 127, 127, 255)); - - Rect line = EditorGUILayout.GetControlRect(); - line.xMin -= 3; - line.xMax += 4; - line.y -= 2; - line.yMax += 4; + if (k_FoldoutTitlebar == null) + { + var flags = BindingFlags.NonPublic | BindingFlags.Static; + Type[] args = new Type[] { typeof(Rect), typeof(GUIContent), typeof(bool), typeof(bool) }; + k_FoldoutTitlebar = typeof(EditorGUI).GetMethod("FoldoutTitlebar", flags, null, args, null); + } - toggleValue = EditorGUI.Foldout(line, toggleValue, EditorGUIUtility.TrTextContent("Environment (HDRP)", "Sky lighting environment for active Scene"), Styles.headerStyle); + var labelRect = GUILayoutUtility.GetRect(GUIContent.none, Styles.inspectorTitle, GUILayout.ExpandWidth(true)); + var label = EditorGUIUtility.TrTextContent("Environment (HDRP)", "Sky lighting environment for active Scene"); - EditorGUI.DrawRect(line, EditorGUIUtility.isProSkin - ? new Color(1f, 1f, 1f, 0.03f) - : new Color(1f, 1f, 1f, 0.2f)); + toggleValue = (bool)k_FoldoutTitlebar.Invoke(null, new object[] { labelRect, label, toggleValue, true }); if (m_ToggleValue) { - Rect separator = EditorGUILayout.GetControlRect(GUILayout.Height(1)); - separator.xMin -= 3; - separator.xMax += 4; - separator.y -= 1; - EditorGUI.DrawRect(separator, EditorGUIUtility.isProSkin - ? new Color32(48, 48, 48, 255) - : new Color32(186, 186, 186, 255)); - ++EditorGUI.indentLevel; //cannot use SerializeProperty due to logic in the property diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index b366fe5e4df..345b3701736 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -1948,9 +1948,9 @@ IndirectLighting EvaluateBSDF_ScreenspaceRefraction(LightLoopContext lightLoopCo float mipLevel = preLightData.transparentSSMipLevel; // Clamp to avoid potential leaks around the edges when the dynamic resolution is set to low and the smoothness too. - float2 diffLimit = _ColorPyramidUvScaleAndLimitPrevFrame.xy - _ColorPyramidUvScaleAndLimitPrevFrame.zw; + float2 diffLimit = _ColorPyramidUvScaleAndLimitCurrentFrame.xy - _ColorPyramidUvScaleAndLimitCurrentFrame.zw; float2 diffLimitMipAdjusted = diffLimit * pow(2.0,2.0 + ceil(abs(mipLevel))); - float2 limit = _ColorPyramidUvScaleAndLimitPrevFrame.xy - diffLimitMipAdjusted; + float2 limit = _ColorPyramidUvScaleAndLimitCurrentFrame.xy - diffLimitMipAdjusted; samplingUV.xy = min(samplingUV.xy, limit); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitBuiltinData.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitBuiltinData.hlsl index ead9f16f076..af49cce571b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitBuiltinData.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitBuiltinData.hlsl @@ -21,14 +21,14 @@ float3 GetEmissiveColor(SurfaceData surfaceData) return _EmissiveColor * lerp(float3(1.0, 1.0, 1.0), surfaceData.baseColor.rgb, _AlbedoAffectEmissive); } -#ifdef _EMISSIVE_COLOR_MAP float3 GetEmissiveColor(SurfaceData surfaceData, UVMapping emissiveMapMapping) { float3 emissiveColor = GetEmissiveColor(surfaceData); +#ifdef _EMISSIVE_COLOR_MAP emissiveColor *= SAMPLE_UVMAPPING_TEXTURE2D(_EmissiveColorMap, sampler_EmissiveColorMap, emissiveMapMapping).rgb; +#endif // _EMISSIVE_COLOR_MAP return emissiveColor; } -#endif // _EMISSIVE_COLOR_MAP void GetBuiltinData(FragInputs input, float3 V, inout PositionInputs posInput, SurfaceData surfaceData, float alpha, float3 bentNormalWS, float depthOffset, out BuiltinData builtinData) { diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index f61a0cb89b0..287bdcef05e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -262,6 +262,12 @@ void RecordRenderGraph(RenderRequest renderRequest, }); GenerateColorPyramid(m_RenderGraph, hdCamera, colorBuffer, distortionColorPyramid, FullScreenDebugMode.PreRefractionColorPyramid, distortionRendererList); currentColorPyramid = distortionColorPyramid; + + + // The color pyramid for distortion is not an history, so it need to be sampled appropriate RT handle scale. Thus we need to update it + var newScale = new Vector4(RTHandles.rtHandleProperties.rtHandleScale.x, RTHandles.rtHandleProperties.rtHandleScale.y, 0, 0); + m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = newScale; + PushGlobalCameraParams(m_RenderGraph, hdCamera); } using (new RenderGraphProfilingScope(m_RenderGraph, ProfilingSampler.Get(HDProfileId.Distortion))) @@ -941,9 +947,9 @@ class RenderOffscreenUIData public Rect viewport; } - TextureHandle CreateOffscreenUIBuffer(RenderGraph renderGraph, MSAASamples msaaSamples) + TextureHandle CreateOffscreenUIBuffer(RenderGraph renderGraph, MSAASamples msaaSamples, Rect viewport) { - return renderGraph.CreateTexture(new TextureDesc(Vector2.one, false, true) + return renderGraph.CreateTexture(new TextureDesc((int)viewport.width, (int)viewport.height, false, true) { colorFormat = GraphicsFormat.R8G8B8A8_SRGB, clearBuffer = false, msaaSamples = msaaSamples, name = "UI Buffer" }); } @@ -954,7 +960,8 @@ TextureHandle RenderTransparentUI(RenderGraph renderGraph, HDCamera hdCamera) { using (var builder = renderGraph.AddRenderPass("UI Rendering", out var passData, ProfilingSampler.Get(HDProfileId.OffscreenUIRendering))) { - output = builder.UseColorBuffer(CreateOffscreenUIBuffer(renderGraph, hdCamera.msaaSamples), 0); + // We cannot use rendererlist here because of the path tracing denoiser which will make it invalid due to multiple rendering per frame + output = builder.UseColorBuffer(CreateOffscreenUIBuffer(renderGraph, hdCamera.msaaSamples, hdCamera.finalViewport), 0); passData.camera = hdCamera.camera; passData.frameSettings = hdCamera.frameSettings; diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 6655623b629..eb9b24f555c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1134,6 +1134,8 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd) m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = 0; m_ShaderVariablesGlobalCB._SpecularOcclusionBlend = 1.0f; } + + m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitCurrentFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.currentViewportSize, hdCamera.historyRTHandleProperties.currentRenderTargetSize); m_ShaderVariablesGlobalCB._ColorPyramidUvScaleAndLimitPrevFrame = HDUtils.ComputeViewportScaleAndLimit(hdCamera.historyRTHandleProperties.previousViewportSize, hdCamera.historyRTHandleProperties.previousRenderTargetSize); ConstantBuffer.PushGlobal(cmd, m_ShaderVariablesGlobalCB, HDShaderIDs._ShaderVariablesGlobal); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index bd20de56c75..6b330bf5183 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -437,7 +437,6 @@ static class HDShaderIDs public static readonly int _LightLayersTexture = Shader.PropertyToID("_LightLayersTexture"); public static readonly int _DistortionTexture = Shader.PropertyToID("_DistortionTexture"); public static readonly int _ColorPyramidTexture = Shader.PropertyToID("_ColorPyramidTexture"); - public static readonly int _ColorPyramidUvScaleAndLimitPrevFrame = Shader.PropertyToID("_ColorPyramidUvScaleAndLimitPrevFrame"); public static readonly int _RoughDistortion = Shader.PropertyToID("_RoughDistortion"); public static readonly int _DebugColorPickerTexture = Shader.PropertyToID("_DebugColorPickerTexture"); diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute index c33a16e5461..b80bb53606c 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/TemporalFilter.compute @@ -138,7 +138,7 @@ void ValidateHistory(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 groupTh // Was the object of this pixel moving? uint stencilValue = GetStencilValue(LOAD_TEXTURE2D_X(_StencilTexture, centerCoord)); - if ((stencilValue & _ObjectMotionStencilBit) != 0) + if ((stencilValue & _ObjectMotionStencilBit) != 0 && any(abs(velocity) > 0)) historyRejectionResult = historyRejectionResult | HISTORYREJECTIONFLAGS_MOTION; // If none of the previous conditions have failed, the the history is valid diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/DownsampleDepth.shader b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/DownsampleDepth.shader index 157bfa0717d..9cf26939d35 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/DownsampleDepth.shader +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/DownsampleDepth.shader @@ -74,10 +74,10 @@ Shader "Hidden/HDRP/DownsampleDepth" #else uint2 fullResUpperCorner = uint2((((float2)input.positionCS.xy - 0.5f) * 2.0) + 0.5f); float4 depths; - depths.x = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner, 0); - depths.y = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner + uint2(0, 1), 0); - depths.z = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner + uint2(1, 0), 0); - depths.w = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner + uint2(1, 1), 0); + depths.x = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner, 0).r; + depths.y = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner + uint2(0, 1), 0).r; + depths.z = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner + uint2(1, 0), 0).r; + depths.w = LOAD_TEXTURE2D_X_LOD(_SourceDownsampleDepth, fullResUpperCorner + uint2(1, 1), 0).r; float minDepth = MinDepth(depths); #if MIN_DOWNSAMPLE diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl index 90d89962b0f..b653a13824e 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -264,7 +264,7 @@ float3 LoadCameraColor(uint2 pixelCoords, uint lod) float3 SampleCameraColor(float2 uv, float lod) { - return SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, uv * _RTHandleScaleHistory.xy, lod).rgb; + return SAMPLE_TEXTURE2D_X_LOD(_ColorPyramidTexture, s_trilinear_clamp_sampler, uv * _ColorPyramidUvScaleAndLimitCurrentFrame.xy, lod).rgb; } float3 LoadCameraColor(uint2 pixelCoords) diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs index dfe633a5a4f..8fc43a421c1 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs @@ -265,7 +265,7 @@ unsafe struct ShaderVariablesGlobal // See ScreenCoordOverride.hlsl for details. public Vector4 _ScreenSizeOverride; public Vector4 _ScreenCoordScaleBias; - + public Vector4 _ColorPyramidUvScaleAndLimitCurrentFrame; public Vector4 _ColorPyramidUvScaleAndLimitPrevFrame; } } diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl index 1cb63e17226..501cb83407b 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl @@ -154,6 +154,7 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0) float _DeExposureMultiplier; float4 _ScreenSizeOverride; float4 _ScreenCoordScaleBias; + float4 _ColorPyramidUvScaleAndLimitCurrentFrame; float4 _ColorPyramidUvScaleAndLimitPrevFrame; CBUFFER_END diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs index 9a022fa05ce..67302d1a491 100644 --- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs +++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Water/HDRenderPipeline.WaterSystem.cs @@ -132,9 +132,9 @@ void InitializeWaterSystem() void ReleaseWaterSystem() { - // Grab all the water surfaces in the scene - var waterSurfaces = WaterSurface.instancesAsArray; - int numWaterSurfaces = WaterSurface.instanceCount; + // Grab all the water surfaces in the scene. Including disabled ones (i.e. not in WaterSurface.instances). + var waterSurfaces = Object.FindObjectsByType(FindObjectsSortMode.None); + int numWaterSurfaces = waterSurfaces.Length; // Loop through them and display them for (int surfaceIdx = 0; surfaceIdx < numWaterSurfaces; ++surfaceIdx) @@ -324,7 +324,7 @@ void UpdateShaderVariablesWaterRendering(WaterSurface currentWater, HDCamera hdC } else { - cb._GridSize.Set(extent.x, extent.y); + cb._GridSize.Set(extent.x + 1, extent.y + 1); cb._WaterRotation.Set(Mathf.Cos(rotation), Mathf.Sin(rotation)); cb._PatchOffset = currentWater.transform.position; } diff --git a/Packages/com.unity.render-pipelines.high-definition/package.json b/Packages/com.unity.render-pipelines.high-definition/package.json index 68811f4cc95..02653c1a27d 100644 --- a/Packages/com.unity.render-pipelines.high-definition/package.json +++ b/Packages/com.unity.render-pipelines.high-definition/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.render-pipelines.high-definition", "description": "The High Definition Render Pipeline (HDRP) is a high-fidelity Scriptable Render Pipeline built by Unity to target modern (Compute Shader compatible) platforms. HDRP utilizes Physically-Based Lighting techniques, linear lighting, HDR lighting, and a configurable hybrid Tile/Cluster deferred/Forward lighting architecture and gives you the tools you need to create games, technical demos, animations, and more to a high graphical standard.", - "version": "14.0.11", + "version": "14.0.12", "unity": "2022.3", "displayName": "High Definition RP", "dependencies": { @@ -11,10 +11,10 @@ "com.unity.modules.animation": "1.0.0", "com.unity.modules.imageconversion": "1.0.0", "com.unity.modules.terrain": "1.0.0", - "com.unity.render-pipelines.core": "14.0.11", - "com.unity.shadergraph": "14.0.11", - "com.unity.visualeffectgraph": "14.0.11", - "com.unity.render-pipelines.high-definition-config": "14.0.11" + "com.unity.render-pipelines.core": "14.0.12", + "com.unity.shadergraph": "14.0.12", + "com.unity.visualeffectgraph": "14.0.12", + "com.unity.render-pipelines.high-definition-config": "14.0.12" }, "keywords": [ "graphics", diff --git a/Packages/com.unity.render-pipelines.universal/CHANGELOG.md b/Packages/com.unity.render-pipelines.universal/CHANGELOG.md index 74eeb5a1ef9..1eb4e2fc4c1 100644 --- a/Packages/com.unity.render-pipelines.universal/CHANGELOG.md +++ b/Packages/com.unity.render-pipelines.universal/CHANGELOG.md @@ -10,6 +10,49 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [14.0.11] - 2025-02-13 + +This version is compatible with Unity 2022.3.59f1. + +### Added +- RenderPipelineManager callbacks are raised from UniversalRenderPipeline.SingleCameraRequest. + +### Changed +- Updated URP documentation to explicitly mention that calling Submit() on a command buffer provided by URP from an user pass is not valid. +- Create the Global Settings asset in to the current opened folder. +- Create the Global Settings asset in to the current opened folder. + +### Fixed +- Fixed an issue where screen space decals wouldn't respect light cookies. +- Fixed an issue where using the "Accurate G-buffer Normals" feature for deferred rendering on mobile platforms would cause a large amount of artifacts. +- Pass name when the pass is "LightMode" = "Universal2D". +- Fixed an issue where the built in error shader didn't work correctly with depth priming. +- Scriptable TAA settings. +- Runtime intensity of non real-time reflection probes are now immediately reflected in scene view. +- Removed duplicated code in UniversalRenderer.cs. +- Fixed broken setting shadow rendering layer is not changing shadow when using shadowRenderingLayers in the script. +- Disabled faulty NRP for Editor-only FinalCopyDepth pass in URP 3D. +- Fixed incorrect scaling in copy depth pass when dynamic resolution is enabled. +- Fixed an issue with enabling instancing at runtime for a Decal material. +- Disabled fallback behavior on FSR EASU shader to prevent build errors on machines with old GPUs. +- Fixed an issue where glClientWaitSync: Expected application to have kicked everything until job: 96089 (possibly by calling glFlush)" are thrown in the Android Player on some devices with PowerVR Rogue GE8320 GPU. +- Fixed camera offset in the UI editor for the RenderObject RenderFeature. +- Fixed an issue where Shader Prefiltering data wasn't updated properly for Asset Bundles. +- Fixed shadow-map sampling artifacts present when using the Unlit DrawMode in the SceneView. +- Fixed scene-view wireframe rendering when using depth-priming. +- Fixed an issue where reflection probes would not render correctly on some platforms in some cases. +- Overlay Camera Clear Depth ignored on some Android devices when using Vulkan Graphics API. +- Stop spamming about c-buffer layout mispatch in GPU-instancing-enabled speed tree materials when enabling Rendering Layers. +- Fixed an issue where WorldToCamera matrix wasn't set before rendering shadows. +- Fixed a redundant empty line in a tooltip for Cast Shadows toggle in the URP Asset for Additional lights. +- Fixed an issue where Camera view is not rendered on PowerVR Rogue GE8320 GPU'S if Shadows are enabled in URP Asset and Camera stack contains Overlay Camera's. +- Fixed the CameraDepthAttachment turning black for DX11. +- Fixed sorting the Reflection Probe by resolution. +- Added SS Shadow coord transform to TransformWorldToShadowCoord. +- Fixed an issue where variants were being stripped out in Scriptable Stripping when "Strip Unused Variants" was disabled. +- Reduced banding on FSR upscaled render target by changing render target formats. +- Fixed light cookie texture memory leak when entering Playmode. + ## [14.0.10] - 2024-04-03 This version is compatible with Unity 2022.3.24f1. diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/Shadows-in-URP.md b/Packages/com.unity.render-pipelines.universal/Documentation~/Shadows-in-URP.md index 512748b60e4..e801cb129d3 100644 --- a/Packages/com.unity.render-pipelines.universal/Documentation~/Shadows-in-URP.md +++ b/Packages/com.unity.render-pipelines.universal/Documentation~/Shadows-in-URP.md @@ -20,7 +20,7 @@ Universal RP will try to use the best resolution according to the number of shad ## Shadow atlases -Universal RP renders all real-time shadows for a frame using one common shadow map atlas for all punctual light shadows (i.e shadows for Spot Lights and Point Lights), and an other shadow map atlas for Directional Light shadows. +Universal RP renders all real-time shadows for a frame using one common shadow map atlas for all punctual light shadows (i.e shadows for Spot Lights and Point Lights), and another shadow map atlas for Directional Light shadows. Set the size of these atlases in your Unity Project’s [Universal Render Pipeline Asset](universalrp-asset.md). The atlas size determines the maximum resolution of shadows in your Scene. diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/cameras/apply-different-post-proc-to-cameras.md b/Packages/com.unity.render-pipelines.universal/Documentation~/cameras/apply-different-post-proc-to-cameras.md index 73de81df8db..7831e223eb9 100644 --- a/Packages/com.unity.render-pipelines.universal/Documentation~/cameras/apply-different-post-proc-to-cameras.md +++ b/Packages/com.unity.render-pipelines.universal/Documentation~/cameras/apply-different-post-proc-to-cameras.md @@ -24,7 +24,7 @@ With the scene set up, the following steps show how to create and apply a post-p 3. Select the **Layer** dropdown and choose one of the layers created when you set up the scene. 4. Select the camera you want to apply this effect to. 5. In the Inspector window, go to **Environment** > **Volume Mask** and select the same layer that you chose for the GameObject. -6. Repeat stpes 1-5 for each GameObject and Camera pair that your scene requires. +6. Repeat steps 1-5 for each GameObject and Camera pair that your scene requires. > [!NOTE] > Some effects apply to all cameras in a scene by default. As a result of this, you might need to add the same effect to each volume. This overrides the effects from other volumes on individual cameras with the new values that you set. diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing-bloom.md b/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing-bloom.md index af3344c8141..4a4ab3283ef 100644 --- a/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing-bloom.md +++ b/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing-bloom.md @@ -31,10 +31,10 @@ To add **Bloom** to a Volume: | **Intensity** | Set the strength of the Bloom filter, in a range from 0 to 1. The default is 0, which means that the Bloom effect is disabled. | | **Scatter** | Set the radius of the bloom effect in a range from 0 to 1. Higher values give a larger radius. The default value is 0.7. | | **Tint** | Use the color picker to select a color for the Bloom effect to tint to. | -| **Clamp** | Set the maximum intensity that Unity uses to calculate Bloom. If pixels in your Scene are more intense than this, URP renders them at their current intensity, but uses this intensity value for the purposes of Bloom calculations. The default value is 65472. | -| **High Quality Filtering** | Enable this to use high quality sampling. This reduces flickering and improves the overall smoothness, but is more resource-intensive and can affect performance. | -| **Downscale** | Set the initial resolution scale for the effect. The lower this value is, the fewer system resources the initial blur effect consumes. -| **Max Iterations** | The size of the rendered image determines the number of iterations. Use this setting to define the maximum number of iterations. Decreasing this value reduces processing load and increases performance, especially on mobile devices with high DPI screens. The default value is 6. | +| **Clamp** | Set the maximum intensity that Unity uses to calculate Bloom. If pixels in your scene are more intense than this, URP renders them at their current intensity, but uses this intensity value for the purposes of Bloom calculations. The default value is 65472. | +| **High Quality Filtering** | Enable this to use high quality sampling and bilinear filtering instead of bicubic filtering. This reduces flickering and improves the overall smoothness but is more resource-intensive and can affect performance.

If you experience performance issues with Bloom, disable this property to greatly improve performance, especially on lower-end hardware and platforms. | +| **Downscale** | Set the initial resolution scale for the effect. The lower this value is, the fewer system resources the initial blur effect consumes.

For best performance, set this value to **Quarter** to significantly reducde the initial resource cost of Bloom.

This property is available only if you open the **More** (**⋮**) menu and select **Show Additional Properties**.| +| **Max Iterations** | The size of the rendered image determines the number of iterations. Use this setting to define the maximum number of iterations. Decreasing this value reduces processing load and increases performance, especially on mobile devices with high DPI screens. The default value is 6.

This property is available only if you open the **More** (**⋮**) menu and select **Show Additional Properties**. | ### Lens Dirt diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing/post-processing-custom-effect-low-code.md b/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing/post-processing-custom-effect-low-code.md index 7ac65468bd6..49bec023863 100644 --- a/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing/post-processing-custom-effect-low-code.md +++ b/Packages/com.unity.render-pipelines.universal/Documentation~/post-processing/post-processing-custom-effect-low-code.md @@ -59,3 +59,7 @@ Once you've created a compatible Shader Graph and Material, you can use the Mate You should now notice the effect in both Scene view and Game view. ![Example scene with a grayscale custom post-processing effect.](../Images/post-proc/custom-effect/grayscale-custom-effect.png) + +## Additional resources + +- [Custom rendering and post-processing in URP](../customizing-urp) diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/use-built-in-shader-methods-shadows.md b/Packages/com.unity.render-pipelines.universal/Documentation~/use-built-in-shader-methods-shadows.md index 6ca9fe08616..bfde92ab0e1 100644 --- a/Packages/com.unity.render-pipelines.universal/Documentation~/use-built-in-shader-methods-shadows.md +++ b/Packages/com.unity.render-pipelines.universal/Documentation~/use-built-in-shader-methods-shadows.md @@ -34,9 +34,9 @@ The following methods calculate shadows using shadow maps. To use these methods, ## Example -The following URP shader draws simple shadows onto a surface. +This code example is a simplified example of drawing shadows onto a surface. It might not work correctly with more than one [shadow cascade](../shadow-cascades). -To generate shadows, make sure there are objects in your scene that have a `ShadowCaster` shader pass, for example objects that use the `Universal Render Pipeline/Lit` shader. +To generate shadows, make sure there are objects in your scene that have a `ShadowCaster` shader pass, for example objects that use the `Universal Render Pipeline/Lit` shader. ```hlsl Shader "Custom/SimpleShadows" diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs index c0111c57645..67b44df185c 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/LightBatchingDebugger/LightBatchingDebugger.cs @@ -48,16 +48,20 @@ public static void ShowExample() private Vector3 cachedCamPos; ILight2DCullResult lightCullResult + { + get + { + return renderer2DData?.lightCullResult; + } + } + + Renderer2DData renderer2DData { get { // Game view main camera var renderer = Camera.main?.GetUniversalAdditionalCameraData().scriptableRenderer as Renderer2D; - var data = renderer?.GetRenderer2DData(); - if (data != null && data.lightCullResult.IsGameView()) - return data?.lightCullResult; - - return null; + return renderer?.GetRenderer2DData(); } } @@ -69,7 +73,7 @@ private bool PopulateData() batchList.Clear(); var layers = Light2DManager.GetCachedSortingLayer(); - var batches = LayerUtility.CalculateBatches(lightCullResult, out var batchCount); + var batches = LayerUtility.CalculateBatches(renderer2DData, out var batchCount); for (var i = 0; i < batchCount; i++) { diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DDataEditor.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DDataEditor.cs index 3808e25438c..e1aebb81aad 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DDataEditor.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/Renderer2DDataEditor.cs @@ -13,6 +13,9 @@ class Styles public static readonly GUIContent lightBlendStylesHeader = EditorGUIUtility.TrTextContent("Light Blend Styles", "A Light Blend Style is a collection of properties that describe a particular way of applying lighting."); public static readonly GUIContent postProcessHeader = EditorGUIUtility.TrTextContent("Post-processing"); + public static readonly GUIContent filteringSectionLabel = EditorGUIUtility.TrTextContent("Filtering", "Settings that controls and define which layers the renderer draws."); + public static readonly GUIContent layerMask = EditorGUIUtility.TrTextContent("Layer Mask", "Controls which transparent layers this renderer draws."); + public static readonly GUIContent transparencySortMode = EditorGUIUtility.TrTextContent("Transparency Sort Mode", "Default sorting mode used for transparent objects"); public static readonly GUIContent transparencySortAxis = EditorGUIUtility.TrTextContent("Transparency Sort Axis", "Axis used for custom axis sorting mode"); public static readonly GUIContent hdrEmulationScale = EditorGUIUtility.TrTextContent("HDR Emulation Scale", "Describes the scaling used by lighting to remap dynamic range between LDR and HDR"); @@ -43,6 +46,7 @@ struct LightBlendStyleProps public SerializedProperty blendFactorAdditive; } + SerializedProperty m_LayerMask; SerializedProperty m_TransparencySortMode; SerializedProperty m_TransparencySortAxis; SerializedProperty m_HDREmulationScale; @@ -60,6 +64,7 @@ struct LightBlendStyleProps SerializedProperty m_CameraSortingLayersTextureBound; SerializedProperty m_CameraSortingLayerDownsamplingMethod; + SavedBool m_FilteringFoldout; SavedBool m_GeneralFoldout; SavedBool m_LightRenderTexturesFoldout; SavedBool m_LightBlendStylesFoldout; @@ -88,6 +93,7 @@ void OnEnable() m_WasModified = false; m_Renderer2DData = (Renderer2DData)serializedObject.targetObject; + m_LayerMask = serializedObject.FindProperty("m_LayerMask"); m_TransparencySortMode = serializedObject.FindProperty("m_TransparencySortMode"); m_TransparencySortAxis = serializedObject.FindProperty("m_TransparencySortAxis"); m_HDREmulationScale = serializedObject.FindProperty("m_HDREmulationScale"); @@ -125,6 +131,7 @@ void OnEnable() m_DefaultMaterialType = serializedObject.FindProperty("m_DefaultMaterialType"); m_DefaultCustomMaterial = serializedObject.FindProperty("m_DefaultCustomMaterial"); + m_FilteringFoldout = new SavedBool($"{target.GetType()}.FilteringFoldout", true); m_GeneralFoldout = new SavedBool($"{target.GetType()}.GeneralFoldout", true); m_LightRenderTexturesFoldout = new SavedBool($"{target.GetType()}.LightRenderTexturesFoldout", true); m_LightBlendStylesFoldout = new SavedBool($"{target.GetType()}.LightBlendStylesFoldout", true); @@ -141,6 +148,7 @@ public override void OnInspectorGUI() { serializedObject.Update(); + DrawFiltering(); DrawGeneral(); DrawLightRenderTextures(); DrawLightBlendStyles(); @@ -188,6 +196,18 @@ public void DrawCameraSortingLayerTexture() EditorGUI.EndDisabledGroup(); } + private void DrawFiltering() + { + CoreEditorUtils.DrawSplitter(); + m_FilteringFoldout.value = CoreEditorUtils.DrawHeaderFoldout(Styles.filteringSectionLabel, m_FilteringFoldout.value); + if (!m_FilteringFoldout.value) + return; + + EditorGUILayout.PropertyField(m_LayerMask, Styles.layerMask); + + EditorGUILayout.Space(); + } + private void DrawGeneral() { CoreEditorUtils.DrawSplitter(); diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteLitPass.hlsl b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteLitPass.hlsl index 8640747f014..06971e0ee32 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteLitPass.hlsl +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteLitPass.hlsl @@ -1,4 +1,4 @@ - +#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl" @@ -25,8 +25,19 @@ half4 _RendererColor; PackedVaryings vert(Attributes input) { Varyings output = (Varyings)0; + UNITY_SETUP_INSTANCE_ID(input); + +#ifdef UNITY_INSTANCING_ENABLED + input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteFlip); +#endif + output = BuildVaryings(input); output.color *= _RendererColor; + +#ifdef UNITY_INSTANCING_ENABLED + output.color *= unity_SpriteColor; +#endif + PackedVaryings packedOutput = PackVaryings(output); return packedOutput; } diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteNormalPass.hlsl b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteNormalPass.hlsl index b0e141c0593..a8c7b930e21 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteNormalPass.hlsl +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteNormalPass.hlsl @@ -1,8 +1,19 @@ PackedVaryings vert(Attributes input) { Varyings output = (Varyings)0; + UNITY_SETUP_INSTANCE_ID(input); + +#ifdef UNITY_INSTANCING_ENABLED + input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteFlip); +#endif + output = BuildVaryings(input); output.normalWS = -GetViewForwardDir(); + +#ifdef UNITY_INSTANCING_ENABLED + output.color *= unity_SpriteColor; +#endif + PackedVaryings packedOutput = PackVaryings(output); return packedOutput; } diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteUnlitPass.hlsl b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteUnlitPass.hlsl index c21b796a91b..e9241faddaa 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteUnlitPass.hlsl +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Includes/SpriteUnlitPass.hlsl @@ -1,4 +1,4 @@ - +#include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl" #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Debug/Debugging2D.hlsl" @@ -7,8 +7,19 @@ half4 _RendererColor; PackedVaryings vert(Attributes input) { Varyings output = (Varyings)0; + UNITY_SETUP_INSTANCE_ID(input); + +#ifdef UNITY_INSTANCING_ENABLED + input.positionOS = UnityFlipSprite(input.positionOS, unity_SpriteFlip); +#endif + output = BuildVaryings(input); output.color *= _RendererColor; + +#ifdef UNITY_INSTANCING_ENABLED + output.color *= unity_SpriteColor; +#endif + PackedVaryings packedOutput = PackVaryings(output); return packedOutput; } diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/SpriteSubTargetUtility.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/SpriteSubTargetUtility.cs index e47b25a42da..0bc3f321c90 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/SpriteSubTargetUtility.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/SpriteSubTargetUtility.cs @@ -11,7 +11,7 @@ public static void AddDefaultFields(ref TargetFieldContext context, UniversalTar { // Only support SpriteColor legacy block if BaseColor/Alpha are not active var descs = context.blocks.Select(x => x.descriptor); - bool useLegacyBlocks = !descs.Contains(BlockFields.SurfaceDescription.BaseColor) && !descs.Contains(BlockFields.SurfaceDescription.Alpha); + bool useLegacyBlocks = descs.Contains(BlockFields.SurfaceDescriptionLegacy.SpriteColor); context.AddField(CoreFields.UseLegacySpriteBlocks, useLegacyBlocks); // Surface Type @@ -39,7 +39,7 @@ public static void AddDefaultFields(ref TargetFieldContext context, UniversalTar public static void GetDefaultActiveBlocks(ref TargetActiveBlockContext context, UniversalTarget target) { // Only support SpriteColor legacy block if BaseColor/Alpha are not active - bool useLegacyBlocks = !context.currentBlocks.Contains(BlockFields.SurfaceDescription.BaseColor) && !context.currentBlocks.Contains(BlockFields.SurfaceDescription.Alpha); + bool useLegacyBlocks = context.currentBlocks.Contains(BlockFields.SurfaceDescriptionLegacy.SpriteColor); context.AddBlock(BlockFields.SurfaceDescriptionLegacy.SpriteColor, useLegacyBlocks); context.AddBlock(BlockFields.SurfaceDescription.Alpha); diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteCustomLitSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteCustomLitSubTarget.cs index b1be0d8cbcc..d286891d075 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteCustomLitSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteCustomLitSubTarget.cs @@ -23,13 +23,14 @@ public override void Setup(ref TargetSetupContext context) { base.Setup(ref context); context.AddAssetDependency(kSourceCodeGuid, AssetCollection.Flags.SourceDependency); -#if HAS_VFX_GRAPH + var universalRPType = typeof(UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset); - if (TargetsVFX() && !context.HasCustomEditorForRenderPipeline(universalRPType)) - { - context.AddCustomEditorForRenderPipeline(typeof(VFXGenericShaderGraphMaterialGUI).FullName, universalRPType); - } + var gui = typeof(ShaderGraphSpriteGUI); +#if HAS_VFX_GRAPH + if (TargetsVFX()) + gui = typeof(VFXGenericShaderGraphMaterialGUI); #endif + context.AddCustomEditorForRenderPipeline(gui.FullName, universalRPType); context.AddSubShader(PostProcessSubShader(SubShaders.SpriteLit(target))); } @@ -110,7 +111,7 @@ public static PassDescriptor Lit(UniversalTarget target) // Conditional State renderStates = CoreRenderStates.Default, pragmas = CorePragmas._2DDefault, - defines = new DefineCollection(), + defines = new DefineCollection() { CoreDefines.UseFragmentFog }, keywords = SpriteLitKeywords.Lit, includes = SpriteLitIncludes.Lit, }; @@ -180,6 +181,7 @@ public static PassDescriptor Normal(UniversalTarget target) // Conditional State renderStates = CoreRenderStates.Default, pragmas = CorePragmas._2DDefault, + defines = new DefineCollection() { CoreDefines.UseFragmentFog }, includes = SpriteLitIncludes.Forward, // Custom Interpolator Support @@ -230,6 +232,7 @@ static class SpriteLitRequiredFields public static FieldCollection Normal = new FieldCollection() { + StructFields.Varyings.color, StructFields.Varyings.normalWS, StructFields.Varyings.tangentWS, }; diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteLitSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteLitSubTarget.cs index 0c122b6d52d..f2881dec68b 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteLitSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteLitSubTarget.cs @@ -25,13 +25,14 @@ public override void Setup(ref TargetSetupContext context) { base.Setup(ref context); context.AddAssetDependency(kSourceCodeGuid, AssetCollection.Flags.SourceDependency); -#if HAS_VFX_GRAPH + var universalRPType = typeof(UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset); - if (TargetsVFX() && !context.HasCustomEditorForRenderPipeline(universalRPType)) - { - context.AddCustomEditorForRenderPipeline(typeof(VFXGenericShaderGraphMaterialGUI).FullName, universalRPType); - } + var gui = typeof(ShaderGraphSpriteGUI); +#if HAS_VFX_GRAPH + if (TargetsVFX()) + gui = typeof(VFXGenericShaderGraphMaterialGUI); #endif + context.AddCustomEditorForRenderPipeline(gui.FullName, universalRPType); context.AddSubShader(PostProcessSubShader(SubShaders.SpriteLit(target))); } @@ -133,7 +134,7 @@ public static PassDescriptor Lit(UniversalTarget target) // Conditional State renderStates = CoreRenderStates.Default, pragmas = CorePragmas._2DDefault, - defines = new DefineCollection(), + defines = new DefineCollection() { CoreDefines.UseFragmentFog }, keywords = SpriteLitKeywords.Lit, includes = SpriteLitIncludes.Lit, @@ -209,6 +210,7 @@ public static PassDescriptor Normal(UniversalTarget target) // Conditional State renderStates = CoreRenderStates.Default, pragmas = CorePragmas._2DDefault, + defines = new DefineCollection() { CoreDefines.UseFragmentFog }, includes = SpriteLitIncludes.Forward, // Custom Interpolator Support @@ -253,6 +255,7 @@ static class SpriteLitRequiredFields public static FieldCollection Normal = new FieldCollection() { + StructFields.Varyings.color, StructFields.Varyings.normalWS, StructFields.Varyings.tangentWS, }; diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteUnlitSubTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteUnlitSubTarget.cs index 6a264a96a33..448f04dff32 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteUnlitSubTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShaderGraph/Targets/UniversalSpriteUnlitSubTarget.cs @@ -25,13 +25,14 @@ public override void Setup(ref TargetSetupContext context) { base.Setup(ref context); context.AddAssetDependency(kSourceCodeGuid, AssetCollection.Flags.SourceDependency); -#if HAS_VFX_GRAPH + var universalRPType = typeof(UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset); - if (TargetsVFX() && !context.HasCustomEditorForRenderPipeline(universalRPType)) - { - context.AddCustomEditorForRenderPipeline(typeof(VFXGenericShaderGraphMaterialGUI).FullName, universalRPType); - } + var gui = typeof(ShaderGraphSpriteGUI); +#if HAS_VFX_GRAPH + if (TargetsVFX()) + gui = typeof(VFXGenericShaderGraphMaterialGUI); #endif + context.AddCustomEditorForRenderPipeline(gui.FullName, universalRPType); context.AddSubShader(PostProcessSubShader(SubShaders.SpriteUnlit(target))); } @@ -128,7 +129,7 @@ public static PassDescriptor Unlit(UniversalTarget target) // Conditional State renderStates = CoreRenderStates.Default, pragmas = CorePragmas._2DDefault, - defines = new DefineCollection(), + defines = new DefineCollection() { CoreDefines.UseFragmentFog }, keywords = SpriteUnlitKeywords.Unlit, includes = SpriteUnlitIncludes.Unlit, @@ -165,6 +166,7 @@ public static PassDescriptor Unlit(UniversalTarget target) // Conditional State renderStates = CoreRenderStates.Default, pragmas = CorePragmas._2DDefault, + defines = new DefineCollection() { CoreDefines.UseFragmentFog }, keywords = SpriteUnlitKeywords.Unlit, includes = SpriteUnlitIncludes.Unlit, diff --git a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShapeEditor/EditorTool/PathEditorTool.cs b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShapeEditor/EditorTool/PathEditorTool.cs index d4e1a24d786..9ab3e1d260d 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/2D/ShapeEditor/EditorTool/PathEditorTool.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/2D/ShapeEditor/EditorTool/PathEditorTool.cs @@ -380,6 +380,8 @@ void IDuringSceneGuiTool.DuringSceneGui(SceneView sceneView) { if (m_GUIState.eventType == EventType.Layout) m_Controller.ClearClosestPath(); + else if (m_GUIState.eventType == EventType.ValidateCommand) + return; m_RectSelector.OnGUI(); diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs index 57d54a62259..5d75bcf04b8 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/BaseShaderGUI.cs @@ -840,8 +840,7 @@ public static void SetMaterialKeywords(Material material, Action shadi if (material.HasProperty(Property.EmissionColor)) MaterialEditor.FixupEmissiveFlag(material); - bool shouldEmissionBeEnabled = - (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; + bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.AnyEmissive) != 0; // Not sure what this is used for, I don't see this property declared by any Unity shader in our repo... // I'm guessing it is some kind of legacy material upgrade support thing? Or maybe just dead code now... diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/ShadergraphSpriteGUI.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/ShadergraphSpriteGUI.cs new file mode 100644 index 00000000000..0384ff111b0 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/ShadergraphSpriteGUI.cs @@ -0,0 +1,30 @@ +using UnityEngine; + +namespace UnityEditor +{ + // Used for ShaderGraph Sprite shaders + class ShaderGraphSpriteGUI : BaseShaderGUI + { + protected override uint materialFilter => uint.MaxValue & ~(uint)Expandable.SurfaceOptions; + + MaterialProperty[] properties; + + // collect properties from the material properties + public override void FindProperties(MaterialProperty[] properties) + { + // save off the list of all properties for shadergraph + this.properties = properties; + + var material = materialEditor?.target as Material; + if (material == null) + return; + + base.FindProperties(properties); + } + + public override void DrawSurfaceInputs(Material material) + { + DrawShaderGraphProperties(material, properties); + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/ShadergraphSpriteGUI.cs.meta b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/ShadergraphSpriteGUI.cs.meta new file mode 100644 index 00000000000..23195832dd5 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGUI/ShadergraphSpriteGUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 478c8ec8473e14f4597a729050dc56f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs index ea1b54d4069..2260c5bef23 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/ShaderGraph/Targets/UniversalTarget.cs @@ -634,7 +634,7 @@ void ClearUnusedData() var data = m_Datas[i]; if (data.value is null) continue; - + var type = data.value.GetType(); // Data requirement interfaces need generic type arguments @@ -654,10 +654,10 @@ public void SetDataOnSubTarget(SubTarget subTarget) where T : JsonObject T data = null; foreach (var x in m_Datas.SelectValue()) { - if (x is T y) + if (x.GetType().Equals(typeof(T))) { - data = y; - break; + data = x as T; + continue; } } @@ -1507,6 +1507,8 @@ static class CorePragmas { { Pragma.Target(ShaderModel.Target20) }, { Pragma.ExcludeRenderers(new[] { Platform.D3D9 }) }, + { Pragma.MultiCompileInstancing }, + { Pragma.MultiCompileFog }, { Pragma.Vertex("vert") }, { Pragma.Fragment("frag") }, }; diff --git a/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs b/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs index 15f93c2d219..287c1658e2e 100644 --- a/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs +++ b/Packages/com.unity.render-pipelines.universal/Editor/UniversalRenderPipelineMaterialUpgrader.cs @@ -598,7 +598,7 @@ internal static void UpdateMaterialKeywords(Material material) // or is enabled and may be modified at runtime. This state depends on the values of the current flag and emissive color. // The fixup routine makes sure that the material is in the correct state if/when changes are made to the mode or color. MaterialEditor.FixupEmissiveFlag(material); - bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.EmissiveIsBlack) == 0; + bool shouldEmissionBeEnabled = (material.globalIlluminationFlags & MaterialGlobalIlluminationFlags.AnyEmissive) != 0; CoreUtils.SetKeyword(material, "_EMISSION", shouldEmissionBeEnabled); UniversalRenderPipelineMaterialUpgrader.DisableKeywords(material); } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge.meta b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge.meta new file mode 100644 index 00000000000..843816c2664 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 609e524df3e15014fb5a6a6576d64b3a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/AssemblyInfo.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/AssemblyInfo.cs new file mode 100644 index 00000000000..db473281a83 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Unity.RenderPipelines.Universal.Runtime")] diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/AssemblyInfo.cs.meta b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/AssemblyInfo.cs.meta new file mode 100644 index 00000000000..4c548ec0201 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/AssemblyInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8cee5d271c90d444b9db4f9590a92c35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/InternalEngineBridge.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/InternalEngineBridge.cs new file mode 100644 index 00000000000..0283d7e2952 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/InternalEngineBridge.cs @@ -0,0 +1,17 @@ +using System; + +namespace UnityEngine.Rendering.Universal +{ + internal static class InternalEngineBridge + { + internal static void AddOnLayerchangedCallback(Action callback) + { + SortingLayer.onLayerChanged += callback; + } + + internal static void RemoveOnLayerchangedCallback(Action callback) + { + SortingLayer.onLayerChanged -= callback; + } + } +} diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/InternalEngineBridge.cs.meta b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/InternalEngineBridge.cs.meta new file mode 100644 index 00000000000..98a7e0cabde --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/InternalEngineBridge.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e04c99c6b908b49428428bfedd4110b6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/Unity.RenderPipelines.Universal.2D.Internal.asmdef b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/Unity.RenderPipelines.Universal.2D.Internal.asmdef new file mode 100644 index 00000000000..da00580a754 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/Unity.RenderPipelines.Universal.2D.Internal.asmdef @@ -0,0 +1,7 @@ +{ + "name": "Unity.RenderPipelines.Universal.2D.Internal", + "references": [], + "optionalUnityReferences": [], + "includePlatforms": [], + "excludePlatforms": [] +} diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/Unity.RenderPipelines.Universal.2D.Internal.asmdef.meta b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/Unity.RenderPipelines.Universal.2D.Internal.asmdef.meta new file mode 100644 index 00000000000..6567a0ff4a1 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/InternalBridge/Unity.RenderPipelines.Universal.2D.Internal.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e870d46803eab3349b48383a7e1b877d +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs index f1aa5950aa5..25cf40d5f21 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2D.cs @@ -400,11 +400,13 @@ internal bool IsLitLayer(int layer) private void Awake() { -#if UNITY_EDITOR // Default target sorting layers to "All" if (m_ApplyToSortingLayers == null) - m_ApplyToSortingLayers = SortingLayer.layers.Select(x => x.id).ToArray(); -#endif + { + m_ApplyToSortingLayers = new int[SortingLayer.layers.Length]; + for (int i = 0; i < m_ApplyToSortingLayers.Length; ++i) + m_ApplyToSortingLayers[i] = SortingLayer.layers[i].id; + } } void OnEnable() diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs index 87e525cea2a..bcc251c8386 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Light2DManager.cs @@ -1,5 +1,4 @@ using System.Collections.Generic; -using System.Linq; namespace UnityEngine.Rendering.Universal { @@ -9,6 +8,20 @@ internal static class Light2DManager public static List lights { get; } = new List(); + internal static void Initialize() + { +#if UNITY_EDITOR + InternalEngineBridge.AddOnLayerchangedCallback(OnSortingLayerChanged); +#endif + } + + internal static void Dispose() + { +#if UNITY_EDITOR + InternalEngineBridge.RemoveOnLayerchangedCallback(OnSortingLayerChanged); +#endif + } + // Called during OnEnable public static void RegisterLight(Light2D light) { @@ -108,5 +121,13 @@ public static SortingLayer[] GetCachedSortingLayer() return s_SortingLayers; } + +#if UNITY_EDITOR + internal static void OnSortingLayerChanged() + { + // Update sorting layers that were added or removed or changed order + s_SortingLayers = SortingLayer.layers; + } +#endif } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Render2DLightingPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Render2DLightingPass.cs index 0a00ee9e3e2..6805f56456d 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Render2DLightingPass.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Render2DLightingPass.cs @@ -43,7 +43,7 @@ public Render2DLightingPass(Renderer2DData rendererData, Material blitMaterial, m_BlitMaterial = blitMaterial; m_SamplingMaterial = samplingMaterial; - m_CameraSortingLayerBoundsIndex = GetCameraSortingLayerBoundsIndex(); + m_CameraSortingLayerBoundsIndex = GetCameraSortingLayerBoundsIndex(m_Renderer2DData); } internal void Setup(bool useDepth) @@ -99,12 +99,12 @@ private void CopyCameraSortingLayerRenderTexture(ScriptableRenderContext context cmd.Clear(); } - private short GetCameraSortingLayerBoundsIndex() + internal static short GetCameraSortingLayerBoundsIndex(Renderer2DData rendererData) { SortingLayer[] sortingLayers = Light2DManager.GetCachedSortingLayer(); for (short i = 0; i < sortingLayers.Length; i++) { - if (sortingLayers[i].id == m_Renderer2DData.cameraSortingLayerTextureBound) + if (sortingLayers[i].id == rendererData.cameraSortingLayerTextureBound) return (short)sortingLayers[i].value; } @@ -138,7 +138,7 @@ private void DetermineWhenToResolve(int startIndex, int batchesDrawn, int batchC if (m_Renderer2DData.useCameraSortingLayerTexture) { - var cameraSortingLayerBoundsIndex = GetCameraSortingLayerBoundsIndex(); + var cameraSortingLayerBoundsIndex = GetCameraSortingLayerBoundsIndex(m_Renderer2DData); var copyBatch = -1; for (int i = startIndex; i < startIndex + batchesDrawn; i++) { @@ -185,7 +185,6 @@ private int DrawLayerBatches( CommandBuffer cmd, ScriptableRenderContext context, ref RenderingData renderingData, - ref FilteringSettings filterSettings, ref DrawingSettings normalsDrawSettings, ref DrawingSettings drawSettings, ref RenderTextureDescriptor desc) @@ -222,7 +221,7 @@ private int DrawLayerBatches( if (layerBatch.useNormals) { - filterSettings.sortingLayerRange = layerBatch.layerRange; + LayerUtility.GetFilterSettings(m_Renderer2DData, ref layerBatch, out var filterSettings); var depthTarget = m_NeedsDepth ? depthAttachmentHandle.nameID : BuiltinRenderTextureType.None; this.RenderNormals(context, renderingData, normalsDrawSettings, filterSettings, depthTarget, normalsFirstClear); normalsFirstClear = false; @@ -293,30 +292,25 @@ private int DrawLayerBatches( context.ExecuteCommandBuffer(cmd); cmd.Clear(); - short cameraSortingLayerBoundsIndex = GetCameraSortingLayerBoundsIndex(); + short cameraSortingLayerBoundsIndex = GetCameraSortingLayerBoundsIndex(m_Renderer2DData); RenderBufferStoreAction copyStoreAction; if (msaaEnabled) copyStoreAction = resolveDuringBatch == i && resolveIsAfterCopy ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.StoreAndResolve; else copyStoreAction = RenderBufferStoreAction.Store; - // If our camera sorting layer texture bound is inside our batch we need to break up the DrawRenderers into two batches - if (cameraSortingLayerBoundsIndex >= layerBatch.layerRange.lowerBound && cameraSortingLayerBoundsIndex < layerBatch.layerRange.upperBound && m_Renderer2DData.useCameraSortingLayerTexture) - { - filterSettings.sortingLayerRange = new SortingLayerRange(layerBatch.layerRange.lowerBound, cameraSortingLayerBoundsIndex); - Render(context, cmd, ref renderingData, ref filterSettings, drawSettings); - CopyCameraSortingLayerRenderTexture(context, renderingData, copyStoreAction); - filterSettings.sortingLayerRange = new SortingLayerRange((short)(cameraSortingLayerBoundsIndex + 1), layerBatch.layerRange.upperBound); - Render(context, cmd, ref renderingData, ref filterSettings, drawSettings); - } - else - { - filterSettings.sortingLayerRange = new SortingLayerRange(layerBatch.layerRange.lowerBound, layerBatch.layerRange.upperBound); - Render(context, cmd, ref renderingData, ref filterSettings, drawSettings); - if (cameraSortingLayerBoundsIndex == layerBatch.layerRange.upperBound && m_Renderer2DData.useCameraSortingLayerTexture) + LayerUtility.GetFilterSettings(m_Renderer2DData, ref layerBatch, out var filterSettings); + + Render(context, cmd, ref renderingData, ref filterSettings, drawSettings); + + if (m_Renderer2DData.useCameraSortingLayerTexture) + { + if (cameraSortingLayerBoundsIndex >= layerBatch.layerRange.lowerBound && cameraSortingLayerBoundsIndex <= layerBatch.layerRange.upperBound) + { CopyCameraSortingLayerRenderTexture(context, renderingData, copyStoreAction); + } } // Draw light volumes @@ -398,11 +392,11 @@ public override void Execute(ScriptableRenderContext context, ref RenderingData var desc = this.GetBlendStyleRenderTextureDesc(renderingData); - var layerBatches = LayerUtility.CalculateBatches(m_Renderer2DData.lightCullResult, out var batchCount); + var layerBatches = LayerUtility.CalculateBatches(m_Renderer2DData, out var batchCount); var batchesDrawn = 0; for (var i = 0; i < batchCount; i += batchesDrawn) - batchesDrawn = DrawLayerBatches(layerBatches, batchCount, i, cmd, context, ref renderingData, ref filterSettings, ref normalsDrawSettings, ref combinedDrawSettings, ref desc); + batchesDrawn = DrawLayerBatches(layerBatches, batchCount, i, cmd, context, ref renderingData, ref normalsDrawSettings, ref combinedDrawSettings, ref desc); this.DisableAllKeywords(cmd); this.ReleaseRenderTextures(cmd); diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/LayerUtility.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/LayerUtility.cs index a6eedae58e4..32cf05fc7c0 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/LayerUtility.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/LayerUtility.cs @@ -92,13 +92,31 @@ private static bool CanBatchLightsInLayer(int layerIndex1, int layerIndex2, Sort return true; } - private static int FindUpperBoundInBatch(int startLayerIndex, SortingLayer[] sortingLayers, ILight2DCullResult lightCullResult) + private static bool CanBatchCameraSortingLayer(int startLayerIndex, SortingLayer[] sortingLayers, Renderer2DData rendererData) { + if (rendererData.useCameraSortingLayerTexture) + { + var cameraSortingLayerBoundsIndex = Render2DLightingPass.GetCameraSortingLayerBoundsIndex(rendererData); + return sortingLayers[startLayerIndex].value == cameraSortingLayerBoundsIndex; + } + + return false; + } + + private static int FindUpperBoundInBatch(int startLayerIndex, SortingLayer[] sortingLayers, Renderer2DData rendererData) + { + // break layer if camera sorting layer is active + if (CanBatchCameraSortingLayer(startLayerIndex, sortingLayers, rendererData)) + return startLayerIndex; + // start checking at the next layer for (var i = startLayerIndex + 1; i < sortingLayers.Length; i++) { - if (!CanBatchLightsInLayer(startLayerIndex, i, sortingLayers, lightCullResult)) + if (!CanBatchLightsInLayer(startLayerIndex, i, sortingLayers, rendererData.lightCullResult)) return i - 1; + + if (CanBatchCameraSortingLayer(i, sortingLayers, rendererData)) + return i; } return sortingLayers.Length - 1; } @@ -130,7 +148,7 @@ private static void InitializeBatchInfos(SortingLayer[] cachedSortingLayers) } } - public static LayerBatch[] CalculateBatches(ILight2DCullResult lightCullResult, out int batchCount) + public static LayerBatch[] CalculateBatches(Renderer2DData rendererData, out int batchCount) { var cachedSortingLayers = Light2DManager.GetCachedSortingLayer(); InitializeBatchInfos(cachedSortingLayers); @@ -140,11 +158,11 @@ public static LayerBatch[] CalculateBatches(ILight2DCullResult lightCullResult, for (var i = 0; i < cachedSortingLayers.Length;) { var layerToRender = cachedSortingLayers[i].id; - var lightStats = lightCullResult.GetLightStatsByLayer(layerToRender); + var lightStats = rendererData.lightCullResult.GetLightStatsByLayer(layerToRender); ref var layerBatch = ref s_LayerBatches[batchCount++]; - // Find the highest layer that share the same set of lights as this layer. - var upperLayerInBatch = FindUpperBoundInBatch(i, cachedSortingLayers, lightCullResult); + // Find the highest layer that share the same set of lights and shadows as this layer. + var upperLayerInBatch = FindUpperBoundInBatch(i, cachedSortingLayers, rendererData); // Some renderers override their sorting layer value with short.MinValue or short.MaxValue. // When drawing the first sorting layer, we should include the range from short.MinValue to layerValue. @@ -181,5 +199,14 @@ public static LayerBatch[] CalculateBatches(ILight2DCullResult lightCullResult, return s_LayerBatches; } + + public static void GetFilterSettings(Renderer2DData rendererData, ref LayerBatch layerBatch, out FilteringSettings filterSettings) + { + filterSettings = FilteringSettings.defaultValue; + filterSettings.renderQueueRange = RenderQueueRange.all; + filterSettings.layerMask = rendererData.layerMask; + filterSettings.renderingLayerMask = 0xFFFFFFFF; + filterSettings.sortingLayerRange = layerBatch.layerRange; + } } } diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2D.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2D.cs index 8cb1b34b966..141d48ba087 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2D.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2D.cs @@ -112,6 +112,8 @@ public Renderer2D(Renderer2DData data) : base(data) LensFlareCommonSRP.mergeNeeded = 0; LensFlareCommonSRP.maxLensFlareWithOcclusionTemporalSample = 1; LensFlareCommonSRP.Initialize(); + + Light2DManager.Initialize(); } protected override void Dispose(bool disposing) @@ -125,6 +127,7 @@ protected override void Dispose(bool disposing) m_FinalBlitPass?.Dispose(); m_DrawOffscreenUIPass?.Dispose(); m_DrawOverlayUIPass?.Dispose(); + Light2DManager.Dispose(); CoreUtils.Destroy(m_BlitMaterial); CoreUtils.Destroy(m_BlitHDRMaterial); @@ -386,7 +389,7 @@ public override void Setup(ScriptableRenderContext context, ref RenderingData re // Don't resolve during post processing if there are passes after or pixel perfect camera is used bool pixelPerfectCameraEnabled = ppc != null && ppc.enabled; bool hasCaptureActions = cameraData.captureActions != null && lastCameraInStack; - bool resolvePostProcessingToCameraTarget = !hasCaptureActions && !hasPassesAfterPostProcessing && !requireFinalPostProcessPass && !pixelPerfectCameraEnabled; + bool resolvePostProcessingToCameraTarget = lastCameraInStack && !hasCaptureActions && !hasPassesAfterPostProcessing && !requireFinalPostProcessPass && !pixelPerfectCameraEnabled; if (hasPostProcess) { diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2DData.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2DData.cs index 2761ae350f5..d0905518283 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2DData.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Renderer2DData.cs @@ -25,6 +25,9 @@ internal enum Renderer2DDefaultMaterialType Custom } + [SerializeField] + LayerMask m_LayerMask = -1; + [SerializeField] TransparencySortMode m_TransparencySortMode = TransparencySortMode.Default; @@ -138,6 +141,7 @@ internal enum Renderer2DDefaultMaterialType internal bool useCameraSortingLayerTexture => m_UseCameraSortingLayersTexture; internal int cameraSortingLayerTextureBound => m_CameraSortingLayersTextureBound; internal Downsampling cameraSortingLayerDownsamplingMethod => m_CameraSortingLayerDownsamplingMethod; + internal LayerMask layerMask => m_LayerMask; /// /// Creates the instance of the Renderer2D. diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs index 7ed5103ddd4..2d5aee7df2d 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineAsset.cs @@ -1472,7 +1472,7 @@ public bool useFastSRGBLinearConversion { get { return m_UseFastSRGBLinearConversion; } } - + /// /// Returns true if Data Driven Lens Flare are supported by this asset, false otherwise. /// @@ -1664,53 +1664,77 @@ public override Shader autodeskInteractiveMaskedShader } /// - /// Returns the terrain detail lit shader that this asset uses. + /// Returns the default SpeedTree7 shader that this asset uses. /// - /// Returns the terrain detail lit shader that this asset uses. - public override Shader terrainDetailLitShader + /// Returns the default SpeedTree7 shader that this asset uses. + public override Shader defaultSpeedTree7Shader { - get { return editorResources?.shaders.terrainDetailLitPS; } + get { return editorResources?.shaders.defaultSpeedTree7PS; } } /// - /// Returns the terrain detail grass shader that this asset uses. + /// Returns the default SpeedTree8 shader that this asset uses. /// - /// Returns the terrain detail grass shader that this asset uses. - public override Shader terrainDetailGrassShader + /// Returns the default SpeedTree8 shader that this asset uses. + public override Shader defaultSpeedTree8Shader { - get { return editorResources?.shaders.terrainDetailGrassPS; } + get { return editorResources?.shaders.defaultSpeedTree8PS; } } + /// + public override string renderPipelineShaderTag => UniversalRenderPipeline.k_ShaderTagName; +#endif + /// - /// Returns the terrain detail grass billboard shader that this asset uses. + /// Returns the terrain detail lit shader that this asset uses. /// - /// Returns the terrain detail grass billboard shader that this asset uses. - public override Shader terrainDetailGrassBillboardShader + public override Shader terrainDetailLitShader { - get { return editorResources?.shaders.terrainDetailGrassBillboardPS; } + get + { + foreach (var data in m_RendererDataList) + { + if (data is UniversalRendererData universalData) + return universalData.shaders.terrainDetailLitPS; + } + + return null; + } } /// - /// Returns the default SpeedTree7 shader that this asset uses. + /// Returns the terrain detail grass shader that this asset uses. /// - /// Returns the default SpeedTree7 shader that this asset uses. - public override Shader defaultSpeedTree7Shader + public override Shader terrainDetailGrassShader { - get { return editorResources?.shaders.defaultSpeedTree7PS; } + get + { + foreach (var data in m_RendererDataList) + { + if (data is UniversalRendererData universalData) + return universalData.shaders.terrainDetailGrassPS; + } + + return null; + } } /// - /// Returns the default SpeedTree8 shader that this asset uses. + /// Returns the terrain detail grass billboard shader that this asset uses. /// - /// Returns the default SpeedTree8 shader that this asset uses. - public override Shader defaultSpeedTree8Shader + public override Shader terrainDetailGrassBillboardShader { - get { return editorResources?.shaders.defaultSpeedTree8PS; } - } + get + { + foreach (var data in m_RendererDataList) + { + if (data is UniversalRendererData universalData) + return universalData.shaders.terrainDetailGrassBillboardPS; + } - /// - public override string renderPipelineShaderTag => UniversalRenderPipeline.k_ShaderTagName; -#endif + return null; + } + } /// Names used for display of rendering layer masks. public override string[] renderingLayerMaskNames => UniversalRenderPipelineGlobalSettings.instance.renderingLayerMaskNames; diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineEditorResources.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineEditorResources.cs index b076cce9237..2a2df3ab714 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineEditorResources.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Data/UniversalRenderPipelineEditorResources.cs @@ -33,24 +33,6 @@ public sealed class ShaderResources [Reload("Shaders/AutodeskInteractive/AutodeskInteractiveMasked.shadergraph")] public Shader autodeskInteractiveMaskedPS; - /// - /// Terrain Detail Lit shader. - /// - [Reload("Shaders/Terrain/TerrainDetailLit.shader")] - public Shader terrainDetailLitPS; - - /// - /// Terrain Detail Grass shader. - /// - [Reload("Shaders/Terrain/WavingGrass.shader")] - public Shader terrainDetailGrassPS; - - /// - /// Waving Grass Billboard shader. - /// - [Reload("Shaders/Terrain/WavingGrassBillboard.shader")] - public Shader terrainDetailGrassBillboardPS; - /// /// SpeedTree7 shader. /// diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Decal/DecalProjector.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Decal/DecalProjector.cs index 9c730542222..e74c895630e 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Decal/DecalProjector.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Decal/DecalProjector.cs @@ -246,6 +246,16 @@ public float fadeFactor } private Material m_OldMaterial = null; + private float m_OldDrawDistance = 1000.0f; + private float m_OldFadeScale = 0.9f; + private float m_OldStartAngleFade = 180.0f; + private float m_OldEndAngleFade = 180.0f; + private Vector2 m_OldUVScale = new Vector2(1, 1); + private Vector2 m_OldUVBias = new Vector2(0, 0); + private DecalScaleMode m_OldScaleMode = DecalScaleMode.ScaleInvariant; + private Vector3 m_OldOffset = new Vector3(0, 0, 0.5f); + private Vector3 m_OldSize = new Vector3(1, 1, 1); + private float m_OldFadeFactor = 1.0f; /// A scale that should be used for rendering and handles. internal Vector3 effectiveScale => m_ScaleMode == DecalScaleMode.InheritFromHierarchy ? transform.lossyScale : Vector3.one; @@ -318,6 +328,36 @@ internal void OnValidate() } else onDecalPropertyChange?.Invoke(this); + + m_OldDrawDistance = m_DrawDistance; + m_OldFadeScale = m_FadeScale; + m_OldStartAngleFade = m_StartAngleFade; + m_OldEndAngleFade = m_EndAngleFade; + m_OldUVScale = m_UVScale; + m_OldUVBias = m_UVBias; + m_OldScaleMode = m_ScaleMode; + m_OldOffset = m_Offset; + m_OldSize = m_Size; + m_OldFadeFactor = m_FadeFactor; + } + + void OnDidApplyAnimationProperties() + { + // Needed to be able to update state properly for animated serialized-properties. + if (m_OldMaterial != m_Material || + Mathf.Abs(m_OldDrawDistance - m_DrawDistance) > Mathf.Epsilon || + Mathf.Abs(m_OldFadeScale - m_FadeScale) > Mathf.Epsilon || + Mathf.Abs(m_OldStartAngleFade - m_StartAngleFade) > Mathf.Epsilon || + Mathf.Abs(m_OldEndAngleFade - m_EndAngleFade) > Mathf.Epsilon || + m_OldUVScale != m_UVScale || + m_OldUVBias != m_UVBias || + m_OldScaleMode != m_ScaleMode || + m_OldOffset != m_Offset || + m_OldSize != m_Size || + Mathf.Abs(m_OldFadeFactor - m_FadeFactor) > Mathf.Epsilon) + { + OnValidate(); + } } /// diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs b/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs index 3e06da0baed..364a4f9b977 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/DeferredLights.cs @@ -626,47 +626,51 @@ void SetupMainLightConstants(CommandBuffer cmd, ref LightData lightData) cmd.SetGlobalInt(ShaderConstants._MainLightLayerMask, (int)lightLayerMask); } - void SetupMatrixConstants(CommandBuffer cmd, ref RenderingData renderingData) + internal Matrix4x4[] GetScreenToWorldMatrix(CameraData cameraData) { - ref CameraData cameraData = ref renderingData.cameraData; - #if ENABLE_VR && ENABLE_XR_MODULE int eyeCount = cameraData.xr.enabled && cameraData.xr.singlePassEnabled ? 2 : 1; #else int eyeCount = 1; #endif + Matrix4x4[] screenToWorld = m_ScreenToWorld; // deferred shaders expects 2 elements - for (int eyeIndex = 0; eyeIndex < eyeCount; eyeIndex++) + // pixel coordinates to NDC coordinates. + Matrix4x4 screenToNDC = new Matrix4x4( + new Vector4(2.0f / (float)this.RenderWidth, 0.0f, 0.0f, 0.0f), + new Vector4(0.0f, 2.0f / (float)this.RenderHeight, 0.0f, 0.0f), + new Vector4(0.0f, 0.0f, 1.0f, 0.0f), + new Vector4(-1.0f, -1.0f, 0.0f, 1.0f) + ); + + if (DeferredConfig.IsOpenGL) { - Matrix4x4 proj = cameraData.GetProjectionMatrix(eyeIndex); - Matrix4x4 view = cameraData.GetViewMatrix(eyeIndex); - Matrix4x4 gpuProj = GL.GetGPUProjectionMatrix(proj, false); - - // xy coordinates in range [-1; 1] go to pixel coordinates. - Matrix4x4 toScreen = new Matrix4x4( - new Vector4(0.5f * this.RenderWidth, 0.0f, 0.0f, 0.0f), - new Vector4(0.0f, 0.5f * this.RenderHeight, 0.0f, 0.0f), - new Vector4(0.0f, 0.0f, 1.0f, 0.0f), - new Vector4(0.5f * this.RenderWidth, 0.5f * this.RenderHeight, 0.0f, 1.0f) + // We need to manunally adjust z in NDC space from [0; 1] (storage in depth texture) to [-1; 1]. + Matrix4x4 renormalizeZ = new Matrix4x4( + new Vector4(1.0f, 0.0f, 0.0f, 0.0f), + new Vector4(0.0f, 1.0f, 0.0f, 0.0f), + new Vector4(0.0f, 0.0f, 2.0f, 0.0f), + new Vector4(0.0f, 0.0f, -1.0f, 1.0f) ); - Matrix4x4 zScaleBias = Matrix4x4.identity; - if (DeferredConfig.IsOpenGL) - { - // We need to manunally adjust z in NDC space from [-1; 1] to [0; 1] (storage in depth texture). - zScaleBias = new Matrix4x4( - new Vector4(1.0f, 0.0f, 0.0f, 0.0f), - new Vector4(0.0f, 1.0f, 0.0f, 0.0f), - new Vector4(0.0f, 0.0f, 0.5f, 0.0f), - new Vector4(0.0f, 0.0f, 0.5f, 1.0f) - ); - } + screenToNDC = renormalizeZ * screenToNDC; + } + + for (int eyeIndex = 0; eyeIndex < eyeCount; eyeIndex++) + { + Matrix4x4 view = cameraData.GetViewMatrix(eyeIndex); + Matrix4x4 gpuProj = cameraData.GetGPUProjectionMatrix(false, eyeIndex); - screenToWorld[eyeIndex] = Matrix4x4.Inverse(toScreen * zScaleBias * gpuProj * view); + screenToWorld[eyeIndex] = Matrix4x4.Inverse(gpuProj * view) * screenToNDC; } - cmd.SetGlobalMatrixArray(ShaderConstants._ScreenToWorld, screenToWorld); + return screenToWorld; + } + + void SetupMatrixConstants(CommandBuffer cmd, ref RenderingData renderingData) + { + cmd.SetGlobalMatrixArray(ShaderConstants._ScreenToWorld, GetScreenToWorldMatrix(renderingData.cameraData)); } void PrecomputeLights( diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs b/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs index 21840f5443d..bbfccb0673b 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/ForwardLights.cs @@ -448,6 +448,8 @@ internal void Cleanup() m_TileMasksBuffer = null; m_ReflectionProbeManager.Dispose(); } + m_LightCookieManager?.Dispose(); + m_LightCookieManager = null; } void InitializeLightConstants(NativeArray lights, int lightIndex, out Vector4 lightPos, out Vector4 lightColor, out Vector4 lightAttenuation, out Vector4 lightSpotDir, out Vector4 lightOcclusionProbeChannel, out uint lightLayerMask, out bool isSubtractive) diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef b/Packages/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef index 02be9e8b79d..acbd3e9293f 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef +++ b/Packages/com.unity.render-pipelines.universal/Runtime/Unity.RenderPipelines.Universal.Runtime.asmdef @@ -7,7 +7,8 @@ "GUID:7dbf32976982c98448af054f2512cb79", "GUID:d8b63aba1907145bea998dd612889d6b", "GUID:2665a8d13d1b3f18800f46e256720795", - "GUID:86bc95e6fdb13ff43aa04316542905ae" + "GUID:86bc95e6fdb13ff43aa04316542905ae", + "GUID:e870d46803eab3349b48383a7e1b877d" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs index 386672756ef..d92492da6fa 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs @@ -236,9 +236,33 @@ internal void PushBuiltinShaderConstantsXR(CommandBuffer cmd, bool renderIntoTex } else { + + Matrix4x4 viewMatrix = GetViewMatrix(); // Update multipass worldSpace camera pos Vector3 worldSpaceCameraPos = Matrix4x4.Inverse(GetViewMatrix(0)).GetColumn(3); cmd.SetGlobalVector(ShaderPropertyId.worldSpaceCameraPos, worldSpaceCameraPos); + + //Multipass uses the same value as a normal render, and doesn't use the value set for stereo, + //which is why you need to set a value like unity_MatrixInvV. + //The values below should be the same as set in the SetCameraMatrices function in ScriptableRenderer.cs. + Matrix4x4 gpuProjectionMatrix = GetGPUProjectionMatrix(renderIntoTexture); + Matrix4x4 viewAndProjectionMatrix = gpuProjectionMatrix * viewMatrix; + Matrix4x4 inverseViewMatrix = Matrix4x4.Inverse(viewMatrix); + Matrix4x4 inverseProjectionMatrix = Matrix4x4.Inverse(gpuProjectionMatrix); + Matrix4x4 inverseViewProjection = inverseViewMatrix * inverseProjectionMatrix; + + // There's an inconsistency in handedness between unity_matrixV and unity_WorldToCamera + // Unity changes the handedness of unity_WorldToCamera (see Camera::CalculateMatrixShaderProps) + // we will also change it here to avoid breaking existing shaders. (case 1257518) + Matrix4x4 worldToCameraMatrix = Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)) * viewMatrix; + Matrix4x4 cameraToWorldMatrix = worldToCameraMatrix.inverse; + cmd.SetGlobalMatrix(ShaderPropertyId.worldToCameraMatrix, worldToCameraMatrix); + cmd.SetGlobalMatrix(ShaderPropertyId.cameraToWorldMatrix, cameraToWorldMatrix); + + cmd.SetGlobalMatrix(ShaderPropertyId.inverseViewMatrix, inverseViewMatrix); + cmd.SetGlobalMatrix(ShaderPropertyId.inverseProjectionMatrix, inverseProjectionMatrix); + cmd.SetGlobalMatrix(ShaderPropertyId.inverseViewAndProjectionMatrix, inverseViewProjection); + } } #endif diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererData.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererData.cs index 2ca0a3abb84..e67d81acc14 100644 --- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererData.cs +++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererData.cs @@ -127,12 +127,30 @@ public sealed class ShaderResources /// [Reload("Shaders/ObjectMotionVectors.shader")] public Shader objectMotionVector; - + /// /// Data Driven Lens Flare shader. /// [Reload("Shaders/PostProcessing/LensFlareDataDriven.shader")] public Shader dataDrivenLensFlare; + + /// + /// Terrain Detail Lit shader. + /// + [Reload("Shaders/Terrain/TerrainDetailLit.shader")] + public Shader terrainDetailLitPS; + + /// + /// Terrain Detail Grass shader. + /// + [Reload("Shaders/Terrain/WavingGrass.shader")] + public Shader terrainDetailGrassPS; + + /// + /// Waving Grass Billboard shader. + /// + [Reload("Shaders/Terrain/WavingGrassBillboard.shader")] + public Shader terrainDetailGrassBillboardPS; } /// diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl new file mode 100644 index 00000000000..8e74198f155 --- /dev/null +++ b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl @@ -0,0 +1,21 @@ +#ifndef INPUT_CORE_2D_INCLUDED +#define INPUT_CORE_2D_INCLUDED + +float3 UnityFlipSprite( in float3 pos, in float2 flip ) +{ + return float3(pos.xy * flip, pos.z); +} + +#ifdef UNITY_INSTANCING_ENABLED + UNITY_INSTANCING_BUFFER_START(PerDrawSprite) + // SpriteRenderer.Color while Non-Batched/Instanced. + UNITY_DEFINE_INSTANCED_PROP(float4, unity_SpriteRendererColorArray) + // this could be smaller but that's how bit each entry is regardless of type + UNITY_DEFINE_INSTANCED_PROP(float2, unity_SpriteFlipArray) + UNITY_INSTANCING_BUFFER_END(PerDrawSprite) + + #define unity_SpriteColor UNITY_ACCESS_INSTANCED_PROP(PerDrawSprite, unity_SpriteRendererColorArray) + #define unity_SpriteFlip UNITY_ACCESS_INSTANCED_PROP(PerDrawSprite, unity_SpriteFlipArray) +#endif // instancing + +#endif diff --git a/Tests/SRPTests/Packages/local.code.coverage.references/package.json.meta b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl.meta similarity index 60% rename from Tests/SRPTests/Packages/local.code.coverage.references/package.json.meta rename to Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl.meta index 8dedda951b4..c76a36e0dfc 100644 --- a/Tests/SRPTests/Packages/local.code.coverage.references/package.json.meta +++ b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 66e0272e0e254d74590f6cea02eecd53 -PackageManifestImporter: +guid: b1ab2a3655b2e554794f4f6338212e57 +ShaderIncludeImporter: externalObjects: {} userData: assetBundleName: diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Lit-Default.shader b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Lit-Default.shader index 66d9ba81523..505d7376d3a 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Lit-Default.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Lit-Default.shader @@ -28,10 +28,13 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" HLSLPROGRAM #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #pragma vertex CombinedShapeLightVertex #pragma fragment CombinedShapeLightFragment + // GPU Instancing + #pragma multi_compile_instancing #pragma multi_compile USE_SHAPE_LIGHT_TYPE_0 __ #pragma multi_compile USE_SHAPE_LIGHT_TYPE_1 __ #pragma multi_compile USE_SHAPE_LIGHT_TYPE_2 __ @@ -90,6 +93,9 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" UNITY_SETUP_INSTANCE_ID(v); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); +#ifdef UNITY_INSTANCING_ENABLED + v.positionOS = UnityFlipSprite(v.positionOS, unity_SpriteFlip); +#endif o.positionCS = TransformObjectToHClip(v.positionOS); #if defined(DEBUG_DISPLAY) o.positionWS = TransformObjectToWorld(v.positionOS); @@ -98,6 +104,9 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" o.lightingUV = half2(ComputeScreenPos(o.positionCS / o.positionCS.w).xy); o.color = v.color * _Color * _RendererColor; +#ifdef UNITY_INSTANCING_ENABLED + o.color *= unity_SpriteColor; +#endif return o; } @@ -124,10 +133,14 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" HLSLPROGRAM #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #pragma vertex NormalsRenderingVertex #pragma fragment NormalsRenderingFragment + // GPU Instancing + #pragma multi_compile_instancing + struct Attributes { float3 positionOS : POSITION; @@ -160,12 +173,18 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" UNITY_SETUP_INSTANCE_ID(attributes); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); +#ifdef UNITY_INSTANCING_ENABLED + attributes.positionOS = UnityFlipSprite(attributes.positionOS, unity_SpriteFlip); +#endif o.positionCS = TransformObjectToHClip(attributes.positionOS); o.uv = TRANSFORM_TEX(attributes.uv, _NormalMap); o.color = attributes.color; o.normalWS = -GetViewForwardDir(); o.tangentWS = TransformObjectToWorldDir(attributes.tangent.xyz); o.bitangentWS = cross(o.normalWS, o.tangentWS) * attributes.tangent.w; +#ifdef UNITY_INSTANCING_ENABLED + o.color *= unity_SpriteColor; +#endif return o; } @@ -187,10 +206,14 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" HLSLPROGRAM #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #pragma vertex UnlitVertex #pragma fragment UnlitFragment + // GPU Instancing + #pragma multi_compile_instancing + struct Attributes { float3 positionOS : POSITION; @@ -222,12 +245,18 @@ Shader "Universal Render Pipeline/2D/Sprite-Lit-Default" UNITY_SETUP_INSTANCE_ID(attributes); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); +#ifdef UNITY_INSTANCING_ENABLED + attributes.positionOS = UnityFlipSprite(attributes.positionOS, unity_SpriteFlip); +#endif o.positionCS = TransformObjectToHClip(attributes.positionOS); #if defined(DEBUG_DISPLAY) o.positionWS = TransformObjectToWorld(v.positionOS); #endif o.uv = TRANSFORM_TEX(attributes.uv, _MainTex); o.color = attributes.color * _Color * _RendererColor; +#ifdef UNITY_INSTANCING_ENABLED + o.color *= unity_SpriteColor; +#endif return o; } diff --git a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Unlit-Default.shader b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Unlit-Default.shader index 72514a9ad3b..36671121765 100644 --- a/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Unlit-Default.shader +++ b/Packages/com.unity.render-pipelines.universal/Shaders/2D/Sprite-Unlit-Default.shader @@ -17,7 +17,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" { Tags {"Queue" = "Transparent" "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" } - Blend SrcAlpha OneMinusSrcAlpha + Blend SrcAlpha OneMinusSrcAlpha, One OneMinusSrcAlpha Cull Off ZWrite Off @@ -27,6 +27,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" HLSLPROGRAM #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #if defined(DEBUG_DISPLAY) #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl" @@ -36,6 +37,8 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" #pragma vertex UnlitVertex #pragma fragment UnlitFragment + // GPU Instancing + #pragma multi_compile_instancing #pragma multi_compile _ DEBUG_DISPLAY struct Attributes @@ -69,12 +72,18 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" UNITY_SETUP_INSTANCE_ID(v); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); +#ifdef UNITY_INSTANCING_ENABLED + v.positionOS = UnityFlipSprite(v.positionOS, unity_SpriteFlip); +#endif o.positionCS = TransformObjectToHClip(v.positionOS); #if defined(DEBUG_DISPLAY) o.positionWS = TransformObjectToWorld(v.positionOS); #endif o.uv = TRANSFORM_TEX(v.uv, _MainTex); o.color = v.color * _Color * _RendererColor; +#ifdef UNITY_INSTANCING_ENABLED + o.color *= unity_SpriteColor; +#endif return o; } @@ -108,6 +117,7 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" HLSLPROGRAM #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl" + #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/Core2D.hlsl" #if defined(DEBUG_DISPLAY) #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/InputData2D.hlsl" #include "Packages/com.unity.render-pipelines.universal/Shaders/2D/Include/SurfaceData2D.hlsl" @@ -117,6 +127,8 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" #pragma vertex UnlitVertex #pragma fragment UnlitFragment + // GPU Instancing + #pragma multi_compile_instancing #pragma multi_compile_fragment _ DEBUG_DISPLAY struct Attributes @@ -150,12 +162,18 @@ Shader "Universal Render Pipeline/2D/Sprite-Unlit-Default" UNITY_SETUP_INSTANCE_ID(attributes); UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); +#ifdef UNITY_INSTANCING_ENABLED + attributes.positionOS = UnityFlipSprite(attributes.positionOS, unity_SpriteFlip); +#endif o.positionCS = TransformObjectToHClip(attributes.positionOS); #if defined(DEBUG_DISPLAY) o.positionWS = TransformObjectToWorld(attributes.positionOS); #endif o.uv = TRANSFORM_TEX(attributes.uv, _MainTex); o.color = attributes.color * _Color * _RendererColor; +#ifdef UNITY_INSTANCING_ENABLED + o.color *= unity_SpriteColor; +#endif return o; } diff --git a/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json b/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json index cf2e8ce0b01..3f0caa5a844 100644 --- a/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json +++ b/Packages/com.unity.render-pipelines.universal/ValidationExceptions.json @@ -2,12 +2,12 @@ "Exceptions": [ { "ValidationTest": "Package Lifecycle Validation", - "ExceptionError": "Package com.unity.render-pipelines.universal@14.0.11 depends on package com.unity.burst@1.5.0 which is in an invalid track for release purposes. Release versions can only depend on Release versions.", - "PackageVersion": "14.0.11" + "ExceptionError": "Package com.unity.render-pipelines.universal@14.0.12 depends on package com.unity.burst@1.5.0 which is in an invalid track for release purposes. Release versions can only depend on Release versions.", + "PackageVersion": "14.0.12" }, { "ValidationTest": "API Updater Configuration Validation", - "PackageVersion": "14.0.11" + "PackageVersion": "14.0.12" } ] } \ No newline at end of file diff --git a/Packages/com.unity.render-pipelines.universal/package.json b/Packages/com.unity.render-pipelines.universal/package.json index f16fdb12935..755fba711dd 100644 --- a/Packages/com.unity.render-pipelines.universal/package.json +++ b/Packages/com.unity.render-pipelines.universal/package.json @@ -1,14 +1,14 @@ { "name": "com.unity.render-pipelines.universal", "description": "The Universal Render Pipeline (URP) is a prebuilt Scriptable Render Pipeline, made by Unity. URP provides artist-friendly workflows that let you quickly and easily create optimized graphics across a range of platforms, from mobile to high-end consoles and PCs.", - "version": "14.0.11", + "version": "14.0.12", "unity": "2022.3", "displayName": "Universal RP", "dependencies": { "com.unity.mathematics": "1.2.1", "com.unity.burst": "1.8.9", - "com.unity.render-pipelines.core": "14.0.11", - "com.unity.shadergraph": "14.0.11", + "com.unity.render-pipelines.core": "14.0.12", + "com.unity.shadergraph": "14.0.12", "com.unity.render-pipelines.universal-config": "14.0.9" }, "keywords": [ diff --git a/Packages/com.unity.shadergraph/CHANGELOG.md b/Packages/com.unity.shadergraph/CHANGELOG.md index 54c4491d46d..7299c568820 100644 --- a/Packages/com.unity.shadergraph/CHANGELOG.md +++ b/Packages/com.unity.shadergraph/CHANGELOG.md @@ -10,6 +10,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. Version Updated The version number for this package has increased due to a version update of a related graphics package. +## [14.0.11] - 2025-02-13 + +This version is compatible with Unity 2022.3.59f1. + +### Fixed +- Added issues where shaders generated for iOS or Android may not compile correctly due to precision. +- Fixed an issue where the Baked GI Node was not displaying correctly after initially adding it to a graph. +- Added support for perceptual color mode for gradients in shader graph. +- Fixed issues with the Feature Examples sample and Production Ready Shaders sample. +- Fixed an issue where cross pipeline shader graphs would run into NRE. +- Disallowed shader variant related settings to be set to negative values. +- Added a null reference exception when shader variant project settings were changed under certain circumstances. +- Users can no longer select 'Delete' for context blocks. +- Fixed a bug where the Custom Function node's "Body" field would expand off-screen instead of scrolling. +- Fixed an issue in ShaderGraph where undoing changes to a property after modifying its value in the Graph Inspector would cause the property to become deselected. +- Fixed 'Objects are trying to be loaded during a domain backup' errors due to invalid serialization of some shader graphs. +- Fixed a bug that Normal From Height node in a shader graph might return an invalid value when using 16-bit half precision. +- The name displayed in the Graph inspector when a BlockNode is selected has changed. +- Added issue where precision mismatch could result in an asset failing to import. +- Fixed a bug that a shader graph is reverted to its last saved state when entering Play Mode without saving changes. +- Fixed an issue where the Main Light Direction node always returned 0 on the built-in render pipeline. +- Fixed Shader Graph undeclared identifier error around foveated rendering area. +- Fixed so that pasting an empty group positions it based on the cursor's location. +- Fixed Shader warnings in URP ShaderGraph when using the Normal From Texture node. +- Fixed/improved identifier collision detection on properties. +- Fix NullReferenceException thrown when updating a legacy node for second time through undo. + ## [14.0.10] - 2024-04-03 This version is compatible with Unity 2022.3.24f1. diff --git a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/BakedGINode.cs b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/BakedGINode.cs index 3c2e861c097..0cde32f1a8e 100644 --- a/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/BakedGINode.cs +++ b/Packages/com.unity.shadergraph/Editor/Data/Nodes/Input/Lighting/BakedGINode.cs @@ -76,7 +76,7 @@ public sealed override void UpdateNodeAfterDeserialization() public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMode) { - if (generationMode == GenerationMode.ForReals) + if (generationMode == GenerationMode.ForReals || generationMode == GenerationMode.VFX) { sb.AppendLine("$precision3 {6} = SHADERGRAPH_BAKED_GI({0}, {1}, IN.{2}.xy, {3}, {4}, {5});", GetSlotValue(kPositionWSInputSlotId, generationMode), diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/Blackboard/SGBlackboardField.cs b/Packages/com.unity.shadergraph/Editor/Drawing/Blackboard/SGBlackboardField.cs index ec7e87d8cb9..f45a63d7c83 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/Blackboard/SGBlackboardField.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/Blackboard/SGBlackboardField.cs @@ -99,7 +99,7 @@ internal SGBlackboardField(ShaderInputViewModel viewModel) property.onAfterVersionChange += () => { this.typeText = property.GetPropertyTypeString(); - this.m_InspectorUpdateDelegate(); + this.m_InspectorUpdateDelegate?.Invoke(); }; } diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs b/Packages/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs index 37be3b316fb..a4c30239d36 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs @@ -192,6 +192,33 @@ public void Update() m_NodeSettingsContainer.MarkDirtyRepaint(); } + public void RefreshInspectables() + { + // Set callbacks to newly created Inspectables + VisualElement temp = new VisualElement(); + var inspectables = new List(); + FindChildrenRecursive(ParentView, inspectables); + foreach (IInspectable inspectable in inspectables) + { + DrawInspectable(temp, inspectable, null); + } + + // And redraw the inspector + doesInspectorNeedUpdate = true; + Update(); + } + + private static void FindChildrenRecursive(VisualElement element, List results) + { + foreach (var child in element.Children()) + { + if (child is T tChild) + results.Add(tChild); + + FindChildrenRecursive(child, results); + } + } + void DrawInspectable( VisualElement outputVisualElement, IInspectable inspectable, diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs b/Packages/com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs index b1274e22ac5..2aa8aad3588 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/MaterialGraphEditWindow.cs @@ -373,6 +373,11 @@ void Update() graphEditorView.HandleGraphChanges(wasUndoRedoPerformed); graphObject.graph.ClearChanges(); + if (wasUndoRedoPerformed) + { + graphEditorView.inspectorView.RefreshInspectables(); + } + if (updateTitle) UpdateTitle(); } diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs b/Packages/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs index 0f4a7589b47..eaad09f4cf8 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/Views/GraphEditorView.cs @@ -97,6 +97,11 @@ public MaterialGraphView graphView get { return m_GraphView; } } + public InspectorView inspectorView + { + get { return m_InspectorView; } + } + internal PreviewManager previewManager { get { return m_PreviewManager; } diff --git a/Packages/com.unity.shadergraph/Editor/Drawing/Views/PropertyNodeView.cs b/Packages/com.unity.shadergraph/Editor/Drawing/Views/PropertyNodeView.cs index f160f9d003b..ed1d3c2df2d 100644 --- a/Packages/com.unity.shadergraph/Editor/Drawing/Views/PropertyNodeView.cs +++ b/Packages/com.unity.shadergraph/Editor/Drawing/Views/PropertyNodeView.cs @@ -56,6 +56,14 @@ public PropertyNodeView(PropertyNode node, EdgeConnectorListener edgeConnectorLi // add the right click context menu IManipulator contextMenuManipulator = new ContextualMenuManipulator(AddContextMenuOptions); this.AddManipulator(contextMenuManipulator); + + if (property != null) + { + property.onAfterVersionChange += () => + { + m_TriggerInspectorUpdate?.Invoke(); + }; + } } // Updating the text label of the output slot diff --git a/Packages/com.unity.shadergraph/Editor/Generation/ShaderGraphVfxAsset.cs b/Packages/com.unity.shadergraph/Editor/Generation/ShaderGraphVfxAsset.cs index 6ec7a588904..9a6f1839740 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/ShaderGraphVfxAsset.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/ShaderGraphVfxAsset.cs @@ -133,6 +133,11 @@ public string outputStructName internal set { m_OutputStructName = value; } } + internal void SetGUID(string guid) + { + m_Data.OverrideObjectId(guid, "SerializedVfxAssetData"); + } + public List properties { get diff --git a/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Targets/BuiltInLitSubTarget.cs b/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Targets/BuiltInLitSubTarget.cs index 0d220023de4..58a26978735 100644 --- a/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Targets/BuiltInLitSubTarget.cs +++ b/Packages/com.unity.shadergraph/Editor/Generation/Targets/BuiltIn/Editor/ShaderGraph/Targets/BuiltInLitSubTarget.cs @@ -572,8 +572,6 @@ static class LitKeywords public static readonly KeywordCollection Deferred = new KeywordCollection { - { CoreKeywordDescriptors.Lightmap }, - { CoreKeywordDescriptors.DirectionalLightmapCombined }, { CoreKeywordDescriptors.MainLightShadows }, { CoreKeywordDescriptors.ShadowsSoft }, { CoreKeywordDescriptors.LightmapShadowMixing }, diff --git a/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs b/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs index 9b018519bc2..bd366d6d19a 100644 --- a/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs +++ b/Packages/com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs @@ -976,6 +976,7 @@ void AddCoordinateSpaceSnippets(InterpolatorType interpolatorType, Func