Browse Source

Updated packages to those from Unity 6000.3.2f1

master
Nico de Poel 1 month ago
parent
commit
651040e488
  1. 1
      Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs
  2. 2
      Packages/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs
  3. 1
      Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareComponentSRP.cs
  4. 14
      Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs
  5. 16
      Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs
  6. 5
      Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/RayTracingResources.cs
  7. 31
      Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs
  8. 173
      Packages/com.unity.render-pipelines.core/Runtime/Utilities/SweepLineRectUtils.cs
  9. 2
      Packages/com.unity.render-pipelines.core/Runtime/Utilities/SweepLineRectUtils.cs.meta
  10. 4
      Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs
  11. 184
      Packages/com.unity.render-pipelines.core/Tests/Editor/SweepLineRectUtilsTests.cs
  12. 2
      Packages/com.unity.render-pipelines.core/Tests/Editor/SweepLineRectUtilsTests.cs.meta
  13. 2
      Packages/com.unity.render-pipelines.core/package.json
  14. 7
      Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs
  15. 8
      Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/ShaderStrippers/HDRPComputeShaderVariantStripper.cs
  16. 2
      Packages/com.unity.render-pipelines.high-definition/Editor/Material/BaseShaderPreprocessor.cs
  17. 53
      Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/LookDevVolumeProfileSettingsPropertyDrawer.cs
  18. 60
      Packages/com.unity.render-pipelines.high-definition/Editor/SceneTemplates/Indoors/IndoorsScene.unity
  19. 27
      Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs
  20. 3
      Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.cs
  21. 3
      Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/NVIDIADebugView.cs
  22. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs
  23. 36
      Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute
  24. 35
      Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild.compute
  25. 6
      Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDRenderPipeline.ScreenSpaceShadows.cs
  26. 5
      Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs
  27. 1
      Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader
  28. 1
      Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader
  29. 1
      Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader
  30. 1
      Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader
  31. 6
      Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/CompositeWithUIAndOETF.shader
  32. 4
      Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader
  33. 4
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs
  34. 8
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LookDev.cs
  35. 10
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs
  36. 117
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs
  37. 49
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs
  38. 8
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineGlobalSettings.cs
  39. 1
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs
  40. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs
  41. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/LookDevVolumeProfileSettings.cs
  42. 2
      Packages/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl
  43. 2
      Packages/com.unity.render-pipelines.high-definition/package.json
  44. 10
      Packages/com.unity.shadergraph/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs
  45. 2
      Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs
  46. 13
      Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector1MaterialSlot.cs
  47. 10
      Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector2MaterialSlot.cs
  48. 10
      Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector3MaterialSlot.cs
  49. 10
      Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector4MaterialSlot.cs
  50. 63
      Packages/com.unity.shadergraph/Editor/Data/Nodes/Channel/SwizzleNode.cs
  51. 10
      Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/SubGraphNode.cs
  52. 2
      Packages/com.unity.shadergraph/Editor/Data/SubGraph/SubGraphAsset.cs
  53. 8
      Packages/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs
  54. 16
      Packages/com.unity.shadergraph/Editor/ShaderGraphPreferences.cs
  55. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8Billboard.shadersubgraph.meta
  56. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8CameraFacingLeafEffect.shadersubgraph.meta
  57. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8ColorAlpha.shadersubgraph.meta
  58. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8InterpolatedNormals.shadersubgraph.meta
  59. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8LODTransition.shadersubgraph.meta
  60. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8Wind.shadersubgraph.meta
  61. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree9CameraFacingLeafEffect.shadersubgraph.meta
  62. 1
      Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree9Wind.shadersubgraph.meta
  63. 2
      Packages/com.unity.shadergraph/package.json
  64. 6
      Packages/com.unity.ugui/Runtime/TMP/TMP_InputField.cs
  65. 69
      Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs
  66. 6
      Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Image.cs
  67. 5
      Packages/com.unity.ugui/Runtime/UGUI/UnityEngine.UI.asmdef
  68. 114
      Packages/com.unity.ugui/Tests/Runtime/UGUI/EventSystem/GraphicRaycasterButtonTests.cs
  69. 2
      Packages/com.unity.ugui/Tests/Runtime/UGUI/EventSystem/GraphicRaycasterButtonTests.cs.meta
  70. 137
      Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs
  71. 2
      Packages/com.unity.ugui/package.json
  72. 1
      Packages/com.unity.visualeffectgraph/Editor/SamplesLinkPackageManagerExtension.cs
  73. 12
      Packages/com.unity.visualeffectgraph/Editor/ShaderGraph/Templates/VFXConfig.template.hlsl
  74. 2
      Packages/com.unity.visualeffectgraph/Editor/Utilities/pCache/BakeTool/PointCacheBakeTool.cs
  75. 6
      Packages/com.unity.visualeffectgraph/Shaders/ParticleLines/PassForwardCommon.template
  76. 6
      Packages/com.unity.visualeffectgraph/Shaders/ParticleLinesSW/PassForwardCommon.template
  77. 7
      Packages/com.unity.visualeffectgraph/Shaders/ParticleMeshes/PassForwardCommon.template
  78. 6
      Packages/com.unity.visualeffectgraph/Shaders/ParticlePlanarPrimitives/PassForwardCommon.template
  79. 6
      Packages/com.unity.visualeffectgraph/Shaders/ParticlePoints/PassForwardCommon.template
  80. 6
      Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl
  81. 8
      Packages/com.unity.visualeffectgraph/Shaders/VFXPassDepthCommonFragmentUnlit.template
  82. 2
      Packages/com.unity.visualeffectgraph/package.json

1
Packages/com.unity.render-pipelines.core/Editor/Lighting/ProbeVolume/ProbeVolumeLightingTab.cs

@ -361,6 +361,7 @@ namespace UnityEngine.Rendering
activeSet = newSet; activeSet = newSet;
ProbeReferenceVolume.instance.Clear(); ProbeReferenceVolume.instance.Clear();
ProbeReferenceVolume.instance.SetActiveBakingSet(newSet);
} }
if (activeSet != null) if (activeSet != null)

2
Packages/com.unity.render-pipelines.core/Editor/LookDev/DisplayWindow.EnvironmentLibrarySidePanel.cs

@ -451,7 +451,7 @@ namespace UnityEditor.Rendering.LookDev
void OnFocus() void OnFocus()
{ {
//OnFocus is called before OnEnable that open backend if not already opened, so only sync if backend is open //OnFocus is called before OnEnable that open backend if not already opened, so only sync if backend is open
if (LookDev.open)
if (LookDev.open && LookDev.currentContext != null)
{ {
//If EnvironmentLibrary asset as been edited by the user (deletion), //If EnvironmentLibrary asset as been edited by the user (deletion),
//update all view to use null environment if it was not temporary ones //update all view to use null environment if it was not temporary ones

1
Packages/com.unity.render-pipelines.core/Runtime/PostProcessing/LensFlareComponentSRP.cs

@ -13,6 +13,7 @@ namespace UnityEngine.Rendering
/// </summary> /// </summary>
[ExecuteAlways] [ExecuteAlways]
[AddComponentMenu("Rendering/Lens Flare (SRP)")] [AddComponentMenu("Rendering/Lens Flare (SRP)")]
[CurrentPipelineHelpURL("shared/lens-flare/lens-flare-component")]
public sealed class LensFlareComponentSRP : MonoBehaviour public sealed class LensFlareComponentSRP : MonoBehaviour
{ {
[SerializeField] [SerializeField]

14
Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/NativePassCompiler.cs

@ -1076,7 +1076,7 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
foreach (ref readonly var nativePass in contextData.NativePasses) foreach (ref readonly var nativePass in contextData.NativePasses)
{ {
// Loop over all created resources by this nrp // Loop over all created resources by this nrp
var graphPasses = nativePass.GraphPasses(contextData);
var graphPasses = nativePass.GraphPasses(contextData, out var actualPasses);
foreach (ref readonly var subPass in graphPasses) foreach (ref readonly var subPass in graphPasses)
{ {
foreach (ref readonly var createdRes in subPass.FirstUsedResources(contextData)) foreach (ref readonly var createdRes in subPass.FirstUsedResources(contextData))
@ -1118,6 +1118,8 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
} }
} }
} }
if (actualPasses.IsCreated)
actualPasses.Dispose();
} }
} }
} }
@ -1168,7 +1170,8 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
if (pass.mergeState == PassMergeState.Begin || pass.mergeState == PassMergeState.None) if (pass.mergeState == PassMergeState.Begin || pass.mergeState == PassMergeState.None)
{ {
ref var nativePass = ref contextData.nativePassData.ElementAt(pass.nativePassIndex); ref var nativePass = ref contextData.nativePassData.ElementAt(pass.nativePassIndex);
foreach (ref readonly var subPass in nativePass.GraphPasses(contextData))
var graphPasses = nativePass.GraphPasses(contextData, out var actualPasses);
foreach (ref readonly var subPass in graphPasses)
{ {
foreach (ref readonly var res in subPass.FirstUsedResources(contextData)) foreach (ref readonly var res in subPass.FirstUsedResources(contextData))
{ {
@ -1204,6 +1207,8 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
} }
} }
} }
if (actualPasses.IsCreated)
actualPasses.Dispose();
} }
} }
// Other passes just create them at the beginning of the individual pass // Other passes just create them at the beginning of the individual pass
@ -1826,7 +1831,8 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
if (pass.mergeState == PassMergeState.End || pass.mergeState == PassMergeState.None) if (pass.mergeState == PassMergeState.End || pass.mergeState == PassMergeState.None)
{ {
ref var nativePass = ref contextData.nativePassData.ElementAt(pass.nativePassIndex); ref var nativePass = ref contextData.nativePassData.ElementAt(pass.nativePassIndex);
foreach (ref readonly var subPass in nativePass.GraphPasses(contextData))
var graphPasses = nativePass.GraphPasses(contextData, out var actualPasses);
foreach (ref readonly var subPass in graphPasses)
{ {
foreach (ref readonly var res in subPass.LastUsedResources(contextData)) foreach (ref readonly var res in subPass.LastUsedResources(contextData))
{ {
@ -1837,6 +1843,8 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
} }
} }
} }
if (actualPasses.IsCreated)
actualPasses.Dispose();
} }
} }
else else

16
Packages/com.unity.render-pipelines.core/Runtime/RenderGraph/Compiler/PassesData.cs

@ -781,15 +781,16 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly ReadOnlySpan<PassData> GraphPasses(CompilerContextData ctx)
public readonly ReadOnlySpan<PassData> GraphPasses(CompilerContextData ctx, out NativeArray<PassData> actualPasses)
{ {
// When there's no pass being culled, we can directly return a Span of the Native List // When there's no pass being culled, we can directly return a Span of the Native List
if (lastGraphPass - firstGraphPass + 1 == numGraphPasses) if (lastGraphPass - firstGraphPass + 1 == numGraphPasses)
{ {
actualPasses = default;
return ctx.passData.MakeReadOnlySpan(firstGraphPass, numGraphPasses); return ctx.passData.MakeReadOnlySpan(firstGraphPass, numGraphPasses);
} }
var actualPasses =
actualPasses =
new NativeArray<PassData>(numGraphPasses, Allocator.Temp, new NativeArray<PassData>(numGraphPasses, Allocator.Temp,
NativeArrayOptions.UninitializedMemory); NativeArrayOptions.UninitializedMemory);
@ -808,10 +809,14 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly void GetGraphPassNames(CompilerContextData ctx, DynamicArray<Name> dest) public readonly void GetGraphPassNames(CompilerContextData ctx, DynamicArray<Name> dest)
{ {
foreach (ref readonly var pass in GraphPasses(ctx))
var span = GraphPasses(ctx, out var actualPasses);
foreach (ref readonly var pass in span)
{ {
dest.Add(pass.GetName(ctx)); dest.Add(pass.GetName(ctx));
} }
if (actualPasses.IsCreated)
actualPasses.Dispose();
} }
static bool CanMergeMSAASamples(ref NativePassData nativePass, ref PassData passToMerge) static bool CanMergeMSAASamples(ref NativePassData nativePass, ref PassData passToMerge)
@ -953,7 +958,7 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
// Temporary cache of sampled textures in current Native Render Pass for conflict detection against fragments // Temporary cache of sampled textures in current Native Render Pass for conflict detection against fragments
using (HashSetPool<int>.Get(out var tempSampledTextures)) using (HashSetPool<int>.Get(out var tempSampledTextures))
{ {
var graphPasses = nativePass.GraphPasses(contextData);
var graphPasses = nativePass.GraphPasses(contextData, out var actualPasses);
foreach (ref readonly var graphPass in graphPasses) foreach (ref readonly var graphPass in graphPasses)
{ {
if (graphPass.numSampledOnlyRaster > 0) // Skip passes with no sampled textures if (graphPass.numSampledOnlyRaster > 0) // Skip passes with no sampled textures
@ -965,6 +970,9 @@ namespace UnityEngine.Rendering.RenderGraphModule.NativeRenderPassCompiler
} }
} }
if (actualPasses.IsCreated)
actualPasses.Dispose();
foreach (ref readonly var fragment in passToMerge.Fragments(contextData)) foreach (ref readonly var fragment in passToMerge.Fragments(contextData))
{ {
bool alreadyAttached = false; bool alreadyAttached = false;

5
Packages/com.unity.render-pipelines.core/Runtime/UnifiedRayTracing/RayTracingResources.cs

@ -5,6 +5,11 @@ using UnityEditor;
namespace UnityEngine.Rendering.UnifiedRayTracing namespace UnityEngine.Rendering.UnifiedRayTracing
{ {
[Scripting.APIUpdating.MovedFrom(
autoUpdateAPI: true,
sourceNamespace: "UnityEngine.Rendering.UnifiedRayTracing",
sourceAssembly: "Unity.Rendering.LightTransport.Runtime"
)]
[Serializable] [Serializable]
[SupportedOnRenderPipeline()] [SupportedOnRenderPipeline()]
[Categorization.CategoryInfo(Name = "R: Unified Ray Tracing", Order = 1000), HideInInspector] [Categorization.CategoryInfo(Name = "R: Unified Ray Tracing", Order = 1000), HideInInspector]

31
Packages/com.unity.render-pipelines.core/Runtime/Utilities/CoreUtils.cs

@ -1951,6 +1951,37 @@ namespace UnityEngine.Rendering
#endif #endif
} }
/// <summary>
/// Indicates whether the combined camera viewports fully cover the screen area.
/// </summary>
/// <param name="cameras">List of cameras to render.</param>
/// <returns>True if the combined camera viewports fully cover the screen area.</returns>
public static bool IsScreenFullyCoveredByCameras(List<Camera> cameras)
{
if (cameras == null || cameras.Count == 0)
return false;
bool isScreenFullyCovered = false;
using (ListPool<Rect>.Get(out var cameraRects))
{
// We don't need to exclude stacked cameras for the input camera list because the overlay camera have the same viewport with its base camera.
foreach (var camera in cameras)
{
if (camera.targetTexture != null || camera.cameraType != CameraType.Game)
continue;
// Skip test if any viewport is full-screen
if (Mathf.Approximately(camera.rect.xMin, 0f) && Mathf.Approximately(camera.rect.yMin, 0f) && camera.rect.width >= Screen.width && camera.rect.height >= Screen.height)
return true;
cameraRects.Add(camera.rect);
}
isScreenFullyCovered = Mathf.Approximately(SweepLineRectUtils.CalculateRectUnionArea(cameraRects), 1f);
}
return isScreenFullyCovered;
}
#if UNITY_EDITOR #if UNITY_EDITOR
/// <summary> /// <summary>
/// Populates null fields or collection elements in a target object from a source object of the same type. /// Populates null fields or collection elements in a target object from a source object of the same type.

173
Packages/com.unity.render-pipelines.core/Runtime/Utilities/SweepLineRectUtils.cs

@ -0,0 +1,173 @@
using System.Buffers;
using System.Collections.Generic;
using Unity.Collections;
namespace UnityEngine.Rendering
{
/// <summary>
/// Utility class that computes the total rect area via a sweep-line.
/// </summary>
public static class SweepLineRectUtils
{
struct EventComparer : IComparer<Vector4>
{
public int Compare(Vector4 a, Vector4 b)
{
int cx = a.x.CompareTo(b.x);
if (cx != 0) return cx;
// tie on x: larger y first (+1 before -1)
return b.y.CompareTo(a.y);
}
}
struct ActiveComparer : IComparer<Vector2>
{
public int Compare(Vector2 a, Vector2 b)
{
return a.x.CompareTo(b.x);
}
}
/// <summary>
/// Computes the total covered area (union) of a set of axis-aligned rectangles, counting overlaps only once.
/// </summary>
/// <param name="rects">List of rects to compute.</param>
/// <returns>The normalized union area in [0,1], with overlaps counted once.</returns>
public static float CalculateRectUnionArea(List<Rect> rects)
{
int rectsCount = rects.Count;
var eventsBuffer = ArrayPool<Vector4>.Shared.Rent(rectsCount * 2);
var activeBuffer = ArrayPool<Vector2>.Shared.Rent(rectsCount);
int eventCount = 0;
foreach (var rect in rects)
InsertEvents(rect, eventsBuffer, ref eventCount);
float area = CalculateRectUnionArea(eventsBuffer, activeBuffer, eventCount);
ArrayPool<Vector4>.Shared.Return(eventsBuffer);
ArrayPool<Vector2>.Shared.Return(activeBuffer);
return area;
}
// Merge overlapping intervals and return total covered Y length
static float MergeLengthY(Vector2[] activeBuffer, int count)
{
if (count <= 0)
return 0f;
// ActiveBuffer stores (yMin, yMax)
float total = 0f;
float cy0 = activeBuffer[0].x;
float cy1 = activeBuffer[0].y;
for (int i = 1; i < count; i++)
{
float y0 = activeBuffer[i].x;
float y1 = activeBuffer[i].y;
if (y0 <= cy1)
{
if (y1 > cy1) cy1 = y1;
}
else
{
total += (cy1 - cy0);
cy0 = y0; cy1 = y1;
}
}
total += (cy1 - cy0);
return Mathf.Clamp01(total);
}
/// <summary>
/// Computes the total covered area (union) of a set of axis-aligned rectangles using a sweep-line.
/// </summary>
static unsafe float CalculateRectUnionArea(Vector4[] eventsBuffer, Vector2[] activeBuffer, int eventCount)
{
if (eventCount == 0)
return 0f;
// Sort events by (x asc, enter first)
fixed (Vector4* ptr = eventsBuffer)
{
NativeSortExtension.Sort(ptr, eventCount, new EventComparer());
}
int activeCount = 0;
float area = 0f;
float lastX = eventsBuffer[0].x;
bool needLastXUpdate = false;
int i = 0;
while (i < eventCount)
{
float x = eventsBuffer[i].x;
if (needLastXUpdate)
{
lastX = x;
needLastXUpdate = false;
}
// Accumulate area over [lastX, x)
float dx = x - lastX;
if (dx > 0f && activeCount > 0)
{
fixed (Vector2* ptr = activeBuffer)
{
NativeSortExtension.Sort(ptr, activeCount, new ActiveComparer());
}
area += MergeLengthY(activeBuffer, activeCount) * dx;
lastX = x;
}
// Consume all events at this x (group approx-equal x's)
do
{
Vector4 ev = eventsBuffer[i];
float y0 = ev.z;
float y1 = ev.w;
if (ev.y > 0f) // Enter
{
activeBuffer[activeCount++] = new Vector2(y0, y1);
}
else // Leave
{
// Remove once (swap with last)
for (int k = 0; k < activeCount; k++)
{
Vector2 v = activeBuffer[k];
if (Mathf.Approximately(v.x, y0) && Mathf.Approximately(v.y, y1))
{
int last = activeCount - 1;
activeBuffer[k] = activeBuffer[last];
activeCount = last;
break;
}
}
if (activeCount == 0)
needLastXUpdate = true;
}
i++;
}
while (i < eventCount && Mathf.Approximately(eventsBuffer[i].x, x));
}
return area;
}
// Insert events with clamped rects
static void InsertEvents(in Rect rect, Vector4[] eventsBuffer, ref int eventCount)
{
if (rect.width > 0f && rect.height > 0f)
{
var y0 = Mathf.Clamp01(rect.yMin);
var y1 = Mathf.Clamp01(rect.yMax);
eventsBuffer[eventCount++] = new Vector4(Mathf.Clamp01(rect.xMin), +1f, y0, y1); // enter
eventsBuffer[eventCount++] = new Vector4(Mathf.Clamp01(rect.xMax), -1f, y0, y1); // leave
}
}
}
}

2
Packages/com.unity.render-pipelines.core/Runtime/Utilities/SweepLineRectUtils.cs.meta

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ff1aad7bfc102a847b1979aebf787494

4
Packages/com.unity.render-pipelines.core/Tests/Editor/NativePassCompilerRenderGraphTests.cs

@ -1569,7 +1569,9 @@ namespace UnityEngine.Rendering.Tests
ValidateNoGCAllocs(() => ValidateNoGCAllocs(() =>
{ {
passes[0].GraphPasses(result.contextData);
var graphPasses = passes[0].GraphPasses(result.contextData, out var actualPasses);
if (actualPasses.IsCreated)
actualPasses.Dispose();
}); });
// From RenderPassCullingTests.cs // From RenderPassCullingTests.cs

184
Packages/com.unity.render-pipelines.core/Tests/Editor/SweepLineRectUtilsTests.cs

@ -0,0 +1,184 @@
using NUnit.Framework;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
namespace UnityEditor.Rendering.Tests
{
class SweepLineRectUtilsTests
{
const float Epsilon = 1e-5f;
static object[][] s_Empty = new object[][]
{
new object[] { new List<Rect>() }
};
[Test]
[TestCaseSource("s_Empty")]
public void TestEmpty(List<Rect> rects)
{
var area = SweepLineRectUtils.CalculateRectUnionArea(rects);
Assert.That(area, Is.EqualTo(0f).Within(Epsilon));
}
static object[][] s_SingleRect = new object[][]
{
new object[] { new Rect(0.1f, 0.2f, 0.3f, 0.4f), 0.12f },
new object[] { new Rect(0f, 0f, 1f, 1f), 1f },
};
[Test]
[TestCaseSource("s_SingleRect")]
public void SingleRect(Rect r, float expected)
{
var area = SweepLineRectUtils.CalculateRectUnionArea(new List<Rect> { r });
Assert.That(area, Is.EqualTo(expected).Within(Epsilon));
}
static object[][] s_NonOverlapping = new object[][]
{
new object[]
{
new List<Rect> { new Rect(0f, 0f, 0.5f, 0.5f), new Rect(0.5f, 0.5f, 0.5f, 0.5f) }, 0.5f
},
new object[]
{
new List<Rect>
{
new Rect(0f, 0f, 0.2f, 0.2f), // 0.04
new Rect(0.2f, 0f, 0.3f, 0.2f), // 0.06
new Rect(0.5f, 0.5f, 0.25f, 0.25f) // 0.0625
},
0.1625f
},
new object[]
{
new List<Rect> { new Rect(0f, 0f, 0.5f, 1f), new Rect(0.5f, 0f, 0.5f, 1f) }, 1f
},
new object[]
{
new List<Rect> { new Rect(0.2f, 0.2f, 0f, 0.5f), new Rect(0.2f, 0.2f, 0.5f, 0f) }, 0f
},
new object[]
{
new List<Rect> { new Rect(0f, 0f, 0f, 0f), new Rect(0.1f, 0.1f, 0.2f, 0.3f) }, 0.06f
},
new object[]
{
new List<Rect>
{
new Rect(0f, 0.3f, 0.3f, 0.3f),
new Rect(0.6f, 0.3f, 0.3f, 0.3f),
new Rect(0.3f, 0.3f, 0.3f, 0.3f),
new Rect(0f, 0.6f, 0.3f, 0.3f),
new Rect(0.7f, 0.7f, 0.3f, 0.3f),
},
0.45f
}
};
[Test]
[TestCaseSource("s_NonOverlapping")]
public void NonOverlappingRects(List<Rect> rects, float expected)
{
var area = SweepLineRectUtils.CalculateRectUnionArea(rects);
Assert.That(area, Is.EqualTo(expected).Within(Epsilon));
}
static object[][] s_Overlapping = new object[][]
{
new object[]
{
new List<Rect>
{
new Rect(0.2f, 0.2f, 0.4f, 0.3f),
new Rect(0.2f, 0.2f, 0.4f, 0.3f)
},
0.4f * 0.3f
},
new object[]
{
new List<Rect>
{
new Rect(0f, 0f, 0.6f, 0.5f),
new Rect(0.3f, 0f, 0.6f, 0.5f)
},
0.9f * 0.5f
},
new object[]
{
new List<Rect>
{
new Rect(0f, 0.3f, 0.4f, 0.4f),
new Rect(0.6f, 0.3f, 0.4f, 0.4f),
new Rect(0.3f, 0f, 0.4f, 0.4f),
new Rect(0.3f, 0.6f, 0.4f, 0.4f)
},
0.64f - 0.04f
}
};
[Test]
[TestCaseSource("s_Overlapping")]
public void OverlappingRects(List<Rect> rects, float expected)
{
var area = SweepLineRectUtils.CalculateRectUnionArea(rects);
Assert.That(area, Is.EqualTo(expected).Within(Epsilon));
}
static object[][] s_ClampingOutside = new object[][]
{
new object[]
{
new List<Rect>
{
new Rect(-0.2f, -0.2f, 0.3f, 0.3f), // clamps to [0,0,0.1,0.1] area 0.01
new Rect(0.9f, 0.9f, 0.5f, 0.5f), // clamps to [0.9,0.9,0.1,0.1] area 0.01
},
0.02f
},
new object[] { new List<Rect> { new Rect(-10f, -10f, 20f, 20f) }, 1f }
};
[Test]
[TestCaseSource("s_ClampingOutside")]
public void ClampingOutside(List<Rect> rects, float expected)
{
var area = SweepLineRectUtils.CalculateRectUnionArea(rects);
Assert.That(area, Is.EqualTo(expected).Within(Epsilon));
}
static object[][] s_IntervalsSorting = new object[][]
{
new object[]
{
new List<Rect>
{
new Rect(0.0f, 0.2f, 0.2f, 0.2f),
new Rect(0.0f, 0.0f, 0.2f, 0.1f),
new Rect(0.0f, 0.3f, 0.2f, 0.2f),
},
0.2f * 0.4f
},
new object[]
{
new List<Rect>
{
new Rect(0.0f, 0.0f, 0.2f, 0.1f),
new Rect(0.3f, 0.0f, 0.3f, 0.1f),
new Rect(0.5f, 0.0f, 0.2f, 0.1f),
},
0.6f * 0.1f
}
};
[Test]
[TestCaseSource("s_IntervalsSorting")]
public void IntervalsSorting(List<Rect> rects, float expected)
{
var area = SweepLineRectUtils.CalculateRectUnionArea(rects);
Assert.That(area, Is.EqualTo(expected).Within(Epsilon));
}
}
}

2
Packages/com.unity.render-pipelines.core/Tests/Editor/SweepLineRectUtilsTests.cs.meta

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bfba7561301ac2a44b010c12825cd189

2
Packages/com.unity.render-pipelines.core/package.json

@ -13,5 +13,5 @@
"com.unity.modules.terrain": "1.0.0", "com.unity.modules.terrain": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0" "com.unity.modules.jsonserialize": "1.0.0"
}, },
"_fingerprint": "33b0f6d355dd85889fe12b1205b211093eedf629"
"_fingerprint": "ce86d16dfe9d627973eff1e9329caf16c648363c"
} }

7
Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs

@ -214,10 +214,9 @@ namespace UnityEditor.Rendering.HighDefinition
} }
else else
{ {
// Strip all the area light shadow filtering variants when they are disabled in the shader config.
foreach (var areaShadowVariant in m_ShadowKeywords.AreaShadowVariants)
if (inputData.shaderKeywordSet.IsEnabled(areaShadowVariant.Value))
return true;
// Strip only AREA_SHADOW_HIGH variant, because HDRP enables AREA_SHADOW_MEDIUM if area light is disabled in ShaderConfig
if (inputData.shaderKeywordSet.IsEnabled(m_AreaShadowHigh))
return true;
} }
if (!shadowInitParams.supportScreenSpaceShadows && shader == m_ShaderResources.screenSpaceShadowPS) if (!shadowInitParams.supportScreenSpaceShadows && shader == m_ShaderResources.screenSpaceShadowPS)

8
Packages/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/ShaderStrippers/HDRPComputeShaderVariantStripper.cs

@ -15,6 +15,7 @@ namespace UnityEditor.Rendering.HighDefinition
protected ShaderKeyword m_ProbeVolumesL1 = new ShaderKeyword("PROBE_VOLUMES_L1"); protected ShaderKeyword m_ProbeVolumesL1 = new ShaderKeyword("PROBE_VOLUMES_L1");
protected ShaderKeyword m_ProbeVolumesL2 = new ShaderKeyword("PROBE_VOLUMES_L2"); protected ShaderKeyword m_ProbeVolumesL2 = new ShaderKeyword("PROBE_VOLUMES_L2");
protected ShaderKeyword m_WaterAbsorption = new ShaderKeyword("SUPPORT_WATER_ABSORPTION"); protected ShaderKeyword m_WaterAbsorption = new ShaderKeyword("SUPPORT_WATER_ABSORPTION");
protected ShaderKeyword m_AreaShadowHigh = new ShaderKeyword("AREA_SHADOW_HIGH");
protected HDRenderPipelineRuntimeShaders m_Shaders; protected HDRenderPipelineRuntimeShaders m_Shaders;
@ -123,10 +124,9 @@ namespace UnityEditor.Rendering.HighDefinition
} }
else else
{ {
// Strip all the area light shadow filtering variants when they are disabled in the shader config.
foreach (var areaShadowVariant in m_ShadowKeywords.AreaShadowVariants)
if (inputData.shaderKeywordSet.IsEnabled(areaShadowVariant.Value))
return true;
// Strip only AREA_SHADOW_HIGH variant, because HDRP enables AREA_SHADOW_MEDIUM if area light is disabled in ShaderConfig
if (inputData.shaderKeywordSet.IsEnabled(m_AreaShadowHigh))
return true;
} }
// Screen space shadow variant is exclusive, either we have a variant with dynamic if that support screen space shadow or not // Screen space shadow variant is exclusive, either we have a variant with dynamic if that support screen space shadow or not

2
Packages/com.unity.render-pipelines.high-definition/Editor/Material/BaseShaderPreprocessor.cs

@ -64,6 +64,7 @@ namespace UnityEditor.Rendering.HighDefinition
// Common keyword list // Common keyword list
protected ShaderKeyword m_Transparent; protected ShaderKeyword m_Transparent;
protected ShaderKeyword m_AlphaTestOn; protected ShaderKeyword m_AlphaTestOn;
protected ShaderKeyword m_AreaShadowHigh;
protected ShaderKeyword m_DebugDisplay; protected ShaderKeyword m_DebugDisplay;
protected ShaderKeyword m_TileLighting; protected ShaderKeyword m_TileLighting;
protected ShaderKeyword m_ClusterLighting; protected ShaderKeyword m_ClusterLighting;
@ -115,6 +116,7 @@ namespace UnityEditor.Rendering.HighDefinition
// INSTANCING_ON // INSTANCING_ON
m_Transparent = new ShaderKeyword("_SURFACE_TYPE_TRANSPARENT"); m_Transparent = new ShaderKeyword("_SURFACE_TYPE_TRANSPARENT");
m_AlphaTestOn = new ShaderKeyword("_ALPHATEST_ON"); m_AlphaTestOn = new ShaderKeyword("_ALPHATEST_ON");
m_AreaShadowHigh = new ShaderKeyword("AREA_SHADOW_HIGH");
m_DebugDisplay = new ShaderKeyword("DEBUG_DISPLAY"); m_DebugDisplay = new ShaderKeyword("DEBUG_DISPLAY");
m_TileLighting = new ShaderKeyword("USE_FPTL_LIGHTLIST"); m_TileLighting = new ShaderKeyword("USE_FPTL_LIGHTLIST");
m_ClusterLighting = new ShaderKeyword("USE_CLUSTERED_LIGHTLIST"); m_ClusterLighting = new ShaderKeyword("USE_CLUSTERED_LIGHTLIST");

53
Packages/com.unity.render-pipelines.high-definition/Editor/PropertyDrawers/LookDevVolumeProfileSettingsPropertyDrawer.cs

@ -13,6 +13,7 @@ namespace UnityEditor.Rendering.HighDefinition
{ {
VisualElement m_Root; VisualElement m_Root;
Editor m_LookDevVolumeProfileEditor; Editor m_LookDevVolumeProfileEditor;
int m_LookDevVolumeProfileHash = -1;
SerializedObject m_SettingsSerializedObject; SerializedObject m_SettingsSerializedObject;
SerializedProperty m_VolumeProfileSerializedProperty; SerializedProperty m_VolumeProfileSerializedProperty;
EditorPrefBool m_DefaultVolumeProfileFoldoutExpanded; EditorPrefBool m_DefaultVolumeProfileFoldoutExpanded;
@ -51,6 +52,14 @@ namespace UnityEditor.Rendering.HighDefinition
Editor GetLookDevDefaultVolumeProfileEditor(VolumeProfile lookDevAsset) Editor GetLookDevDefaultVolumeProfileEditor(VolumeProfile lookDevAsset)
{ {
int currentHash = (lookDevAsset != null) ? lookDevAsset.GetHashCode() : -1;
if (currentHash != m_LookDevVolumeProfileHash)
{
Editor.DestroyImmediate(m_LookDevVolumeProfileEditor);
m_LookDevVolumeProfileEditor = null;
m_LookDevVolumeProfileHash = currentHash;
}
Editor.CreateCachedEditor(lookDevAsset, typeof(VolumeProfileEditor), ref m_LookDevVolumeProfileEditor); Editor.CreateCachedEditor(lookDevAsset, typeof(VolumeProfileEditor), ref m_LookDevVolumeProfileEditor);
return m_LookDevVolumeProfileEditor; return m_LookDevVolumeProfileEditor;
} }
@ -68,8 +77,12 @@ namespace UnityEditor.Rendering.HighDefinition
{ {
tooltip = k_LookDevVolumeProfileAssetLabel.tooltip, tooltip = k_LookDevVolumeProfileAssetLabel.tooltip,
objectType = typeof(VolumeProfile), objectType = typeof(VolumeProfile),
value = m_VolumeProfileSerializedProperty.objectReferenceValue as VolumeProfile,
style =
{
flexShrink = 1,
}
}; };
field.BindProperty(m_VolumeProfileSerializedProperty);
field.AddToClassList("unity-base-field__aligned"); //Align with other BaseField<T> field.AddToClassList("unity-base-field__aligned"); //Align with other BaseField<T>
field.Q<Label>().RegisterCallback<ClickEvent>(evt => toggle.value ^= true); field.Q<Label>().RegisterCallback<ClickEvent>(evt => toggle.value ^= true);
@ -91,37 +104,15 @@ namespace UnityEditor.Rendering.HighDefinition
if (evt.newValue == evt.previousValue) if (evt.newValue == evt.previousValue)
return; return;
if (evt.newValue == null)
if (GraphicsSettings.TryGetRenderPipelineSettings<LookDevVolumeProfileSettings>(out var lookDevVolumeProfileSettings))
{ {
if (evt.previousValue != null)
{
field.SetValueWithoutNotify(evt.previousValue);
Debug.Log("This Volume Profile Asset cannot be null. Rolling back to previous value.");
return;
}
else
{
if (RenderPipelineManager.currentPipeline is not HDRenderPipeline)
{
m_VolumeProfileSerializedProperty.objectReferenceValue = null;
}
else
{
var lookDevVolumeProfileSettings = GraphicsSettings.GetRenderPipelineSettings<LookDevVolumeProfileSettings>();
if (lookDevVolumeProfileSettings.volumeProfile == null)
{
lookDevVolumeProfileSettings.volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(
GraphicsSettings.GetRenderPipelineSettings<HDRenderPipelineEditorAssets>().lookDevVolumeProfile);
}
m_VolumeProfileSerializedProperty.objectReferenceValue = lookDevVolumeProfileSettings.volumeProfile;
}
}
lookDevVolumeProfileSettings.volumeProfile = evt.newValue as VolumeProfile;
m_VolumeProfileSerializedProperty.objectReferenceValue = lookDevVolumeProfileSettings.volumeProfile;
m_VolumeProfileSerializedProperty.serializedObject.ApplyModifiedProperties();
m_SettingsSerializedObject.Update();
} }
else
m_VolumeProfileSerializedProperty.objectReferenceValue = evt.newValue;
m_VolumeProfileSerializedProperty.serializedObject.ApplyModifiedProperties();
m_LookDevVolumeProfileHash = -1; // Invalidate the hash, to allow the IMGUI container recreate the editor
}); });
return profileLine; return profileLine;
@ -154,6 +145,10 @@ namespace UnityEditor.Rendering.HighDefinition
if (lookDevAsset.Has<HDRISky>()) if (lookDevAsset.Has<HDRISky>())
EditorGUILayout.HelpBox("HDRISky is not modifiable and will be overridden by the LookDev", MessageType.Warning); EditorGUILayout.HelpBox("HDRISky is not modifiable and will be overridden by the LookDev", MessageType.Warning);
} }
else
{
EditorGUILayout.HelpBox("No Look Dev Volume Profile assigned. A default profile will be created automatically when you open the Look Dev tool (Window > Rendering > Look Dev).", MessageType.Info);
}
}); });
} }
} }

60
Packages/com.unity.render-pipelines.high-definition/Editor/SceneTemplates/Indoors/IndoorsScene.unity

@ -531,50 +531,6 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 59383918} m_Father: {fileID: 59383918}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1045504573
GameObject:
m_ObjectHideFlags: 19
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1045504575}
- component: {fileID: 1045504574}
m_Layer: 0
m_Name: SceneIDMap
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1045504574
MonoBehaviour:
m_ObjectHideFlags: 19
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1045504573}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1642155417}
m_Name:
m_EditorClassIdentifier:
--- !u!4 &1045504575
Transform:
m_ObjectHideFlags: 19
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1045504573}
serializedVersion: 2
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1191974066 --- !u!1 &1191974066
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -708,21 +664,6 @@ Transform:
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!115 &1642155417
MonoScript:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name:
serializedVersion: 7
m_DefaultReferences: {}
m_Icon: {fileID: 0}
m_Type: 0
m_ExecutionOrder: 0
m_ClassName: SceneObjectIDMapSceneAsset
m_Namespace: UnityEngine.Rendering.HighDefinition
m_AssemblyName: Unity.RenderPipelines.HighDefinition.Runtime
--- !u!1 &119734848978804391 --- !u!1 &119734848978804391
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -5175,7 +5116,6 @@ SceneRoots:
- {fileID: 450753641} - {fileID: 450753641}
- {fileID: 7057516004932664435} - {fileID: 7057516004932664435}
- {fileID: 59383918} - {fileID: 59383918}
- {fileID: 1045504575}
- {fileID: 1191974067} - {fileID: 1191974067}
- {fileID: 1522427161} - {fileID: 1522427161}
- {fileID: 1276148452} - {fileID: 1276148452}

27
Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.Configuration.cs

@ -187,7 +187,6 @@ namespace UnityEditor.Rendering.HighDefinition
(fromAsync) => HDRenderPipelineGlobalSettings.Ensure(true), indent: 1), (fromAsync) => HDRenderPipelineGlobalSettings.Ensure(true), indent: 1),
new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpVolumeProfile, IsDefaultVolumeProfileCorrect, FixDefaultVolumeProfile, indent: 1), new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpVolumeProfile, IsDefaultVolumeProfileCorrect, FixDefaultVolumeProfile, indent: 1),
new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpDiffusionProfile, IsDiffusionProfileCorrect, FixDiffusionProfile, indent: 1), new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpDiffusionProfile, IsDiffusionProfileCorrect, FixDiffusionProfile, indent: 1),
new Entry(QualityScope.Global, InclusiveMode.HDRP, Style.hdrpLookDevVolumeProfile, IsDefaultLookDevVolumeProfileCorrect, FixDefaultLookDevVolumeProfile, indent: 1),
}); });
entryList.AddRange(new Entry[] entryList.AddRange(new Entry[]
@ -583,32 +582,6 @@ namespace UnityEditor.Rendering.HighDefinition
VolumeManager.instance.SetGlobalDefaultProfile(volumeProfileCopy); VolumeManager.instance.SetGlobalDefaultProfile(volumeProfileCopy);
} }
bool IsDefaultLookDevVolumeProfileCorrect()
{
if (!IsHdrpGlobalSettingsUsedCorrect())
return false;
if (!GraphicsSettings.TryGetRenderPipelineSettings<LookDevVolumeProfileSettings>(out var settings) ||
settings.volumeProfile == null)
return false;
if (!GraphicsSettings.TryGetRenderPipelineSettings<HDRenderPipelineEditorAssets>(out var editorAssets))
return false;
var defaultValuesAsset = editorAssets.lookDevVolumeProfile;
return !VolumeUtils.IsDefaultVolumeProfile(settings.volumeProfile, defaultValuesAsset);
}
void FixDefaultLookDevVolumeProfile(bool fromAsyncUnused)
{
if (!IsHdrpGlobalSettingsUsedCorrect())
FixHdrpGlobalSettingsUsed(fromAsync: false);
var settings = GraphicsSettings.GetRenderPipelineSettings<LookDevVolumeProfileSettings>();
var defaultValuesAsset = GraphicsSettings.GetRenderPipelineSettings<HDRenderPipelineEditorAssets>().lookDevVolumeProfile;
settings.volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(defaultValuesAsset);
}
IEnumerable<IMigratableAsset> migratableAssets IEnumerable<IMigratableAsset> migratableAssets
{ {
get get

3
Packages/com.unity.render-pipelines.high-definition/Editor/Wizard/HDWizard.cs

@ -101,9 +101,6 @@ namespace UnityEditor.Rendering.HighDefinition
public static readonly ConfigStyle hdrpVolumeProfile = new ConfigStyle( public static readonly ConfigStyle hdrpVolumeProfile = new ConfigStyle(
label: L10n.Tr("Default volume profile"), label: L10n.Tr("Default volume profile"),
error: L10n.Tr("Default volume profile must be assigned in the Project Settings > Graphics > HDRP! Also, for it to be editable, it should be outside of package.")); error: L10n.Tr("Default volume profile must be assigned in the Project Settings > Graphics > HDRP! Also, for it to be editable, it should be outside of package."));
public static readonly ConfigStyle hdrpLookDevVolumeProfile = new ConfigStyle(
label: L10n.Tr("Default Look Dev volume profile"),
error: L10n.Tr("Default Look Dev volume profile must be assigned in the Project Settings > Graphics > HDRP! Also, for it to be editable, it should be outside of package."));
public static readonly ConfigStyle hdrpMigratableAssets = new ConfigStyle( public static readonly ConfigStyle hdrpMigratableAssets = new ConfigStyle(
label: L10n.Tr("Assets Migration"), label: L10n.Tr("Assets Migration"),

3
Packages/com.unity.render-pipelines.high-definition/Runtime/Debug/NVIDIADebugView.cs

@ -249,6 +249,9 @@ namespace UnityEngine.NVIDIA
private void UpdateDebugUITable() private void UpdateDebugUITable()
{ {
if (m_DlssViewStateTableRows == null)
return;
for (int r = 0; r < m_DlssViewStateTableRows.Length; ++r) for (int r = 0; r < m_DlssViewStateTableRows.Length; ++r)
{ {
var d = m_Data.dlssFeatureInfos[r]; var d = m_Data.dlssFeatureInfos[r];

2
Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs

@ -860,7 +860,7 @@ namespace UnityEngine.Rendering.HighDefinition
static int NumLightIndicesPerClusteredTile() static int NumLightIndicesPerClusteredTile()
{ {
return ShaderConfig.FPTLMaxLightCount * (1 << k_Log2NumClusters); // total footprint for all layers of the tile (measured in light index entries)
return (ShaderConfig.FPTLMaxLightCount + 1) * (1 << (k_Log2NumClusters + 1)); // total footprint for all layers of the tile (measured in light index entries)
} }
void LightLoopAllocResolutionDependentBuffers(HDCamera hdCamera, int width, int height) void LightLoopAllocResolutionDependentBuffers(HDCamera hdCamera, int width, int height)

36
Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild-clustered.compute

@ -61,7 +61,9 @@ RWStructuredBuffer<float> g_logBaseBuffer : register( u3 ); // don't
#define MAX_NR_COARSE_ENTRIES LIGHT_CLUSTER_MAX_COARSE_ENTRIES #define MAX_NR_COARSE_ENTRIES LIGHT_CLUSTER_MAX_COARSE_ENTRIES
#define MAX_NR_VISIBLE_LIGHTS 826 // correspond to m_MaxLightsOnScreen in LightLoop.cs
groupshared unsigned int ldsTilePassList[MAX_NR_VISIBLE_LIGHTS];
groupshared unsigned int coarseList[MAX_NR_COARSE_ENTRIES]; groupshared unsigned int coarseList[MAX_NR_COARSE_ENTRIES];
groupshared unsigned int clusterIdxs[MAX_NR_COARSE_ENTRIES/2]; groupshared unsigned int clusterIdxs[MAX_NR_COARSE_ENTRIES/2];
groupshared float4 lightPlanes[4*6]; // Each plane is defined by a float4. 6 planes per light, 4 lights (24 planes) groupshared float4 lightPlanes[4*6]; // Each plane is defined by a float4. 6 planes per light, 4 lights (24 planes)
@ -241,6 +243,16 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
uint2 tileIDX = u3GroupID.xy; uint2 tileIDX = u3GroupID.xy;
uint t=threadID; uint t=threadID;
int i;
const bool lightSortRequired = g_iNrVisibLights > MAX_NR_COARSE_ENTRIES; // Uniform runtime branch
if (lightSortRequired)
{
UNITY_LOOP
for(i=t; i<MAX_NR_VISIBLE_LIGHTS; i+=NR_THREADS)
if(i<MAX_NR_VISIBLE_LIGHTS)
ldsTilePassList[i]=0;
}
const uint log2TileSize = firstbithigh(TILE_SIZE_CLUSTERED); const uint log2TileSize = firstbithigh(TILE_SIZE_CLUSTERED);
uint nrTilesX = ((uint)g_screenSize.x +(TILE_SIZE_CLUSTERED-1))>>log2TileSize; uint nrTilesX = ((uint)g_screenSize.x +(TILE_SIZE_CLUSTERED-1))>>log2TileSize;
@ -340,7 +352,27 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
unsigned int uInc = 1; unsigned int uInc = 1;
unsigned int uIndex; unsigned int uIndex;
InterlockedAdd(lightOffs, uInc, uIndex); InterlockedAdd(lightOffs, uInc, uIndex);
if(uIndex<MAX_NR_COARSE_ENTRIES) coarseList[uIndex] = l; // add to light list
if (lightSortRequired)
ldsTilePassList[l] = 1;
else
if(uIndex<MAX_NR_COARSE_ENTRIES) coarseList[uIndex] = l; // add to light list
}
}
if (lightSortRequired)
{
#if NR_THREADS > PLATFORM_LANE_COUNT
GroupMemoryBarrierWithGroupSync();
#endif
// Ascending sort to prevent unpredictable light list when the number of visible lights is greater than the coarse entries.
if(t==0)
{
int c=0;
for(int ii=0; ii<g_iNrVisibLights && c < MAX_NR_COARSE_ENTRIES; ii++)
{
if(ldsTilePassList[ii] == 1)
coarseList[c++] = ii;
}
} }
} }
@ -399,7 +431,7 @@ void LIGHTLISTGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID)
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
uint start = 0; uint start = 0;
int i=(int) t;
i=(int) t;
int iSpaceAvail = 0; int iSpaceAvail = 0;
int iSum = 0; int iSum = 0;
if(i<nrClusters) if(i<nrClusters)

35
Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/lightlistbuild.compute

@ -49,7 +49,9 @@ StructuredBuffer<uint> g_vBigTileLightList : register( t4 ); // don't sup
RWStructuredBuffer<uint> g_vLightList : register( u0 ); // don't support RWBuffer yet in unity RWStructuredBuffer<uint> g_vLightList : register( u0 ); // don't support RWBuffer yet in unity
#define CATEGORY_LIST_SIZE LIGHTCATEGORY_COUNT #define CATEGORY_LIST_SIZE LIGHTCATEGORY_COUNT
#define MAX_NR_VISIBLE_LIGHTS 826 // correspond to m_MaxLightsOnScreen in LightLoop.cs
groupshared unsigned int ldsTilePassList[MAX_NR_VISIBLE_LIGHTS];
groupshared unsigned int coarseList[LIGHT_LIST_MAX_COARSE_ENTRIES]; groupshared unsigned int coarseList[LIGHT_LIST_MAX_COARSE_ENTRIES];
groupshared unsigned int prunedList[LIGHT_LIST_MAX_COARSE_ENTRIES]; // temporarily support room for all 64 while in LDS groupshared unsigned int prunedList[LIGHT_LIST_MAX_COARSE_ENTRIES]; // temporarily support room for all 64 while in LDS
@ -155,6 +157,15 @@ void TileLightListGen(uint3 dispatchThreadId : SV_DispatchThreadID, uint threadI
if(i<LIGHT_LIST_MAX_COARSE_ENTRIES) if(i<LIGHT_LIST_MAX_COARSE_ENTRIES)
prunedList[i]=0; prunedList[i]=0;
const bool lightSortRequired = g_iNrVisibLights > LIGHT_LIST_MAX_COARSE_ENTRIES; // Uniform runtime branch
if (lightSortRequired)
{
UNITY_LOOP
for(i=t; i<MAX_NR_VISIBLE_LIGHTS; i+=NR_THREADS)
if(i<MAX_NR_VISIBLE_LIGHTS)
ldsTilePassList[i]=0;
}
uint iWidth = g_viDimensions.x; uint iWidth = g_viDimensions.x;
uint iHeight = g_viDimensions.y; uint iHeight = g_viDimensions.y;
uint nrTilesX = (iWidth+15)/16; uint nrTilesX = (iWidth+15)/16;
@ -244,7 +255,10 @@ void TileLightListGen(uint3 dispatchThreadId : SV_DispatchThreadID, uint threadI
unsigned int uInc = 1; unsigned int uInc = 1;
unsigned int uIndex; unsigned int uIndex;
InterlockedAdd(lightOffs, uInc, uIndex); InterlockedAdd(lightOffs, uInc, uIndex);
if(uIndex<LIGHT_LIST_MAX_COARSE_ENTRIES) coarseList[uIndex] = l; // add to light list
if (lightSortRequired)
ldsTilePassList[l] = 1;
else
if(uIndex<LIGHT_LIST_MAX_COARSE_ENTRIES) coarseList[uIndex] = l; // add to light list
} }
} }
@ -252,6 +266,23 @@ void TileLightListGen(uint3 dispatchThreadId : SV_DispatchThreadID, uint threadI
if(t<LIGHT_FPTL_VISIBILITY_DWORD_COUNTS) ldsDoesLightIntersect[t] = 0; if(t<LIGHT_FPTL_VISIBILITY_DWORD_COUNTS) ldsDoesLightIntersect[t] = 0;
#endif #endif
if (lightSortRequired)
{
#if NR_THREADS > PLATFORM_LANE_COUNT
GroupMemoryBarrierWithGroupSync();
#endif
// Ascending sort to prevent unpredictable light list when the number of visible lights is greater than the coarse entries.
if(t==0)
{
int c=0;
for(int ii=0; ii<g_iNrVisibLights && c < LIGHT_LIST_MAX_COARSE_ENTRIES; ii++)
{
if(ldsTilePassList[ii] == 1)
coarseList[c++] = ii;
}
}
}
#if NR_THREADS > PLATFORM_LANE_COUNT #if NR_THREADS > PLATFORM_LANE_COUNT
GroupMemoryBarrierWithGroupSync(); GroupMemoryBarrierWithGroupSync();
#endif #endif
@ -626,7 +657,7 @@ void FinePruneLights(uint threadID, int iNrCoarseLights, uint2 viTilLL, float vL
if (uIndex < LIGHT_LIST_MAX_COARSE_ENTRIES) if (uIndex < LIGHT_LIST_MAX_COARSE_ENTRIES)
{ {
// InterlockedAdd ensures atomic and ordered writing to prunedList, preventing threads from overwriting each other's values. // InterlockedAdd ensures atomic and ordered writing to prunedList, preventing threads from overwriting each other's values.
// Increment ldsNrLightsFinal (represents the total number of lights for the tile).
// Increment ldsNrLightsFinal (represents the total number of lights for the tile).
unsigned int uInc = 1; unsigned int uInc = 1;
unsigned int finalPrunedLightIndex; unsigned int finalPrunedLightIndex;
InterlockedAdd(ldsNrLightsFinal, uInc, finalPrunedLightIndex); InterlockedAdd(ldsNrLightsFinal, uInc, finalPrunedLightIndex);

6
Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDRenderPipeline.ScreenSpaceShadows.cs

@ -239,7 +239,7 @@ namespace UnityEngine.Rendering.HighDefinition
break; break;
} }
switch (m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.directionalShadowFilteringQuality)
switch (m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.directionalShadowFilteringQuality)
{ {
case HDShadowFilteringQuality.Low: case HDShadowFilteringQuality.Low:
s_ScreenSpaceShadowsMat.EnableKeyword("DIRECTIONAL_SHADOW_LOW"); s_ScreenSpaceShadowsMat.EnableKeyword("DIRECTIONAL_SHADOW_LOW");
@ -255,7 +255,9 @@ namespace UnityEngine.Rendering.HighDefinition
break; break;
} }
switch (m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality)
var areaShadowFilteringQuality = (ShaderConfig.s_AreaLights == 0) ? HDAreaShadowFilteringQuality.Medium
: m_Asset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality;
switch (areaShadowFilteringQuality)
{ {
case HDAreaShadowFilteringQuality.Medium: case HDAreaShadowFilteringQuality.Medium:
s_ScreenSpaceShadowsMat.EnableKeyword("AREA_SHADOW_MEDIUM"); s_ScreenSpaceShadowsMat.EnableKeyword("AREA_SHADOW_MEDIUM");

5
Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/HDShadowManager.cs

@ -870,7 +870,7 @@ namespace UnityEngine.Rendering.HighDefinition
public static HDShadowAtlas.BlurAlgorithm GetAreaLightShadowBlurAlgorithm() public static HDShadowAtlas.BlurAlgorithm GetAreaLightShadowBlurAlgorithm()
{ {
return HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality == HDAreaShadowFilteringQuality.High ?
return (ShaderConfig.s_AreaLights == 1 && HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality == HDAreaShadowFilteringQuality.High) ?
HDShadowAtlas.BlurAlgorithm.None : HDShadowAtlas.BlurAlgorithm.EVSM; HDShadowAtlas.BlurAlgorithm.None : HDShadowAtlas.BlurAlgorithm.EVSM;
} }
@ -1238,7 +1238,8 @@ namespace UnityEngine.Rendering.HighDefinition
{ {
shadowManagerData.shadowRequests = m_ShadowRequests; shadowManagerData.shadowRequests = m_ShadowRequests;
shadowManagerData.shadowResolutionRequestStorage = m_ShadowResolutionRequestStorage; shadowManagerData.shadowResolutionRequestStorage = m_ShadowResolutionRequestStorage;
shadowManagerData.areaShadowFilteringQuality = HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality;
shadowManagerData.areaShadowFilteringQuality = (ShaderConfig.s_AreaLights == 0) ? HDAreaShadowFilteringQuality.Medium
: HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality;
m_Atlas.GetUnmanageDataForShadowRequestJobs(ref shadowManagerData.atlas); m_Atlas.GetUnmanageDataForShadowRequestJobs(ref shadowManagerData.atlas);
m_CascadeAtlas.GetUnmanageDataForShadowRequestJobs(ref shadowManagerData.cascadeShadowAtlas); m_CascadeAtlas.GetUnmanageDataForShadowRequestJobs(ref shadowManagerData.cascadeShadowAtlas);
if (ShaderConfig.s_AreaLights == 1) if (ShaderConfig.s_AreaLights == 1)

1
Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader

@ -1187,6 +1187,7 @@ Shader "HDRP/LayeredLit"
HLSLPROGRAM HLSLPROGRAM
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2
#pragma multi_compile _ DOTS_INSTANCING_ON
#define SHADERPASS SHADERPASS_CONSTANT #define SHADERPASS SHADERPASS_CONSTANT
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"

1
Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader

@ -1243,6 +1243,7 @@ Shader "HDRP/LayeredLitTessellation"
HLSLPROGRAM HLSLPROGRAM
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2
#pragma multi_compile _ DOTS_INSTANCING_ON
#define SHADERPASS SHADERPASS_CONSTANT #define SHADERPASS SHADERPASS_CONSTANT
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"

1
Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader

@ -1137,6 +1137,7 @@ Shader "HDRP/Lit"
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2
// enable dithering LOD crossfade // enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE #pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile _ DOTS_INSTANCING_ON
#define SHADERPASS SHADERPASS_CONSTANT #define SHADERPASS SHADERPASS_CONSTANT
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"

1
Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader

@ -1164,6 +1164,7 @@ Shader "HDRP/LitTessellation"
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2 #pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch switch2
// enable dithering LOD crossfade // enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE #pragma multi_compile _ LOD_FADE_CROSSFADE
#pragma multi_compile _ DOTS_INSTANCING_ON
#define SHADERPASS SHADERPASS_CONSTANT #define SHADERPASS SHADERPASS_CONSTANT
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"

6
Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/CompositeWithUIAndOETF.shader

@ -21,6 +21,7 @@ Shader "Hidden/HDRP/CompositeUI"
CBUFFER_START(cb) CBUFFER_START(cb)
float4 _HDROutputParams; float4 _HDROutputParams;
float4 _OffscreenUIViewportParams;
float4 _SrcOffset; float4 _SrcOffset;
int _NeedsFlip; int _NeedsFlip;
int _BlitTexArraySlice; int _BlitTexArraySlice;
@ -88,10 +89,11 @@ Shader "Hidden/HDRP/CompositeUI"
outColor.xyz = afterPostColor.a * outColor.xyz + afterPostColor.xyz; outColor.xyz = afterPostColor.a * outColor.xyz + afterPostColor.xyz;
#endif #endif
float2 uiCoord = (samplePos * _ScreenSize.zw) * _OffscreenUIViewportParams.zw + _OffscreenUIViewportParams.xy;
#if defined(USE_TEXTURE2D_X_AS_ARRAY) && defined(BLIT_SINGLE_SLICE) #if defined(USE_TEXTURE2D_X_AS_ARRAY) && defined(BLIT_SINGLE_SLICE)
float4 uiValue = LOAD_TEXTURE2D_ARRAY(_UITexture, samplePos.xy, _BlitTexArraySlice);
float4 uiValue = SAMPLE_TEXTURE2D_ARRAY_LOD(_UITexture, s_point_clamp_sampler, uiCoord, _BlitTexArraySlice, 0);
#else #else
float4 uiValue = LOAD_TEXTURE2D_X(_UITexture, samplePos.xy);
float4 uiValue = SAMPLE_TEXTURE2D_X_LOD(_UITexture, s_point_clamp_sampler, uiCoord, 0);
#endif #endif

4
Packages/com.unity.render-pipelines.high-definition/Runtime/PostProcessing/Shaders/FinalPass.shader

@ -63,6 +63,7 @@ Shader "Hidden/HDRP/FinalPass"
float4 _HDROutputParams; float4 _HDROutputParams;
float4 _HDROutputParams2; float4 _HDROutputParams2;
float4 _OffscreenUIViewportParams;
#define _MinNits _HDROutputParams.x #define _MinNits _HDROutputParams.x
#define _MaxNits _HDROutputParams.y #define _MaxNits _HDROutputParams.y
#define _PaperWhite _HDROutputParams.z #define _PaperWhite _HDROutputParams.z
@ -208,7 +209,8 @@ Shader "Hidden/HDRP/FinalPass"
#ifdef HDR_ENCODING #ifdef HDR_ENCODING
// Screen space overlay blending. // Screen space overlay blending.
{ {
float4 uiValue = SAMPLE_TEXTURE2D_X_LOD(_UITexture, s_point_clamp_sampler, positionNDC.xy * _RTHandleScale.xy, 0);
float2 uiCoord = positionNDC.xy * _OffscreenUIViewportParams.zw + _OffscreenUIViewportParams.xy;
float4 uiValue = SAMPLE_TEXTURE2D_X_LOD(_UITexture, s_point_clamp_sampler, uiCoord, 0);
outColor.rgb = SceneUIComposition(uiValue, outColor.rgb, _PaperWhite, _MaxNits); outColor.rgb = SceneUIComposition(uiValue, outColor.rgb, _PaperWhite, _MaxNits);
outColor.rgb = OETF(outColor.rgb, _MaxNits); outColor.rgb = OETF(outColor.rgb, _MaxNits);

4
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LightLoop.cs

@ -818,7 +818,9 @@ namespace UnityEngine.Rendering.HighDefinition
break; break;
} }
switch (HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality)
var areaShadowFilteringQuality = (ShaderConfig.s_AreaLights == 0) ? HDAreaShadowFilteringQuality.Medium
: HDRenderPipeline.currentAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams.areaShadowFilteringQuality;
switch (areaShadowFilteringQuality)
{ {
case HDAreaShadowFilteringQuality.Medium: case HDAreaShadowFilteringQuality.Medium:
data.deferredComputeShader.EnableKeyword("AREA_SHADOW_MEDIUM"); data.deferredComputeShader.EnableKeyword("AREA_SHADOW_MEDIUM");

8
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.LookDev.cs

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor;
using UnityEngine.Rendering.LookDev; using UnityEngine.Rendering.LookDev;
namespace UnityEngine.Rendering.HighDefinition namespace UnityEngine.Rendering.HighDefinition
@ -25,10 +26,15 @@ namespace UnityEngine.Rendering.HighDefinition
{ {
lookDevVolumeSettings.volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(GraphicsSettings lookDevVolumeSettings.volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(GraphicsSettings
.GetRenderPipelineSettings<HDRenderPipelineEditorAssets>().lookDevVolumeProfile); .GetRenderPipelineSettings<HDRenderPipelineEditorAssets>().lookDevVolumeProfile);
// Invalidate the volume profile hash
volumeProfileHash = -1;
Debug.Log($"[Look Dev] Created default Volume Profile at: {AssetDatabase.GetAssetPath(lookDevVolumeSettings.volumeProfile)}");
} }
var lookDevVolumeProfile = lookDevVolumeSettings.volumeProfile; var lookDevVolumeProfile = lookDevVolumeSettings.volumeProfile;
int newHashCode = lookDevVolumeProfile.GetHashCode();
int newHashCode = lookDevVolumeProfile != null ? lookDevVolumeProfile.GetHashCode() : -1;
if (newHashCode != volumeProfileHash) if (newHashCode != volumeProfileHash)
{ {
VolumeProfile oldProfile = volume.sharedProfile; VolumeProfile oldProfile = volume.sharedProfile;

10
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.PostProcess.cs

@ -5139,6 +5139,12 @@ namespace UnityEngine.Rendering.HighDefinition
hdrOutputParameters2 = new Vector4(eetfMode, hueShift, paperWhite, (int)ColorGamutUtility.GetColorPrimaries(gamut)); hdrOutputParameters2 = new Vector4(eetfMode, hueShift, paperWhite, (int)ColorGamutUtility.GetColorPrimaries(gamut));
} }
static void GetOffscreenUIViewportParams(HDCamera hdCamera, out Vector4 offscreenUIViewportParams)
{
var rcpScreenSize = new Vector2(1f / Mathf.Max(Screen.width, 1f), 1f / Mathf.Max(Screen.height, 1f));
offscreenUIViewportParams = new Vector4(hdCamera.finalViewport.x * rcpScreenSize.x, hdCamera.finalViewport.y * rcpScreenSize.y, hdCamera.finalViewport.width * rcpScreenSize.x, hdCamera.finalViewport.height * rcpScreenSize.y);
}
void ComputeShadowsMidtonesHighlights(out Vector4 shadows, out Vector4 midtones, out Vector4 highlights, out Vector4 limits) void ComputeShadowsMidtonesHighlights(out Vector4 shadows, out Vector4 midtones, out Vector4 highlights, out Vector4 limits)
{ {
float weight; float weight;
@ -5961,6 +5967,7 @@ namespace UnityEngine.Rendering.HighDefinition
public Vector4 hdroutParameters; public Vector4 hdroutParameters;
public Vector4 hdroutParameters2; public Vector4 hdroutParameters2;
public Vector4 offscreenUIViewportParams;
public TextureHandle inputTest; public TextureHandle inputTest;
@ -6023,6 +6030,7 @@ namespace UnityEngine.Rendering.HighDefinition
if (passData.hdrOutputIsActive) if (passData.hdrOutputIsActive)
{ {
GetHDROutputParameters(HDRDisplayInformationForCamera(hdCamera), HDRDisplayColorGamutForCamera(hdCamera), m_Tonemapping, out passData.hdroutParameters, out passData.hdroutParameters2); GetHDROutputParameters(HDRDisplayInformationForCamera(hdCamera), HDRDisplayColorGamutForCamera(hdCamera), m_Tonemapping, out passData.hdroutParameters, out passData.hdroutParameters2);
GetOffscreenUIViewportParams(hdCamera, out passData.offscreenUIViewportParams);
} }
builder.SetRenderFunc( builder.SetRenderFunc(
@ -6144,12 +6152,14 @@ namespace UnityEngine.Rendering.HighDefinition
finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams, data.hdroutParameters); finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams, data.hdroutParameters);
finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams2, data.hdroutParameters2); finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams2, data.hdroutParameters2);
finalPassMaterial.SetVector(HDShaderIDs._OffscreenUIViewportParams, data.offscreenUIViewportParams);
} }
else if (hdrOutputActive) else if (hdrOutputActive)
{ {
data.finalPassMaterial.EnableKeyword("HDR_INPUT"); data.finalPassMaterial.EnableKeyword("HDR_INPUT");
finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams, data.hdroutParameters); finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams, data.hdroutParameters);
finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams2, data.hdroutParameters2); finalPassMaterial.SetVector(HDShaderIDs._HDROutputParams2, data.hdroutParameters2);
finalPassMaterial.SetVector(HDShaderIDs._OffscreenUIViewportParams, data.offscreenUIViewportParams);
} }
finalPassMaterial.SetTexture(HDShaderIDs._UITexture, data.uiBuffer); finalPassMaterial.SetTexture(HDShaderIDs._UITexture, data.uiBuffer);

117
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs

@ -258,7 +258,23 @@ namespace UnityEngine.Rendering.HighDefinition
colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, renderContext, colorBuffer, prepassOutput.resolvedNormalBuffer, vtFeedbackBuffer, currentColorPyramid, volumetricLighting, rayCountTexture, opticalFogTransmittance, colorBuffer = RenderTransparency(m_RenderGraph, hdCamera, renderContext, colorBuffer, prepassOutput.resolvedNormalBuffer, vtFeedbackBuffer, currentColorPyramid, volumetricLighting, rayCountTexture, opticalFogTransmittance,
m_SkyManager.GetSkyReflection(hdCamera), gpuLightListOutput, transparentPrepass, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovCustomPassBuffers); m_SkyManager.GetSkyReflection(hdCamera), gpuLightListOutput, transparentPrepass, ref prepassOutput, shadowResult, cullingResults, customPassCullingResults, aovRequest, aovCustomPassBuffers);
uiBuffer = RenderTransparentUI(m_RenderGraph, hdCamera, renderContext);
bool rendersOffscreenUI = !m_OffscreenUIRenderedInCurrentFrame && HDROutputActiveForCameraType(hdCamera) && SupportedRenderingFeatures.active.rendersUIOverlay && !NeedHDRDebugMode(m_CurrentDebugDisplaySettings);
if (rendersOffscreenUI)
{
uiBuffer = RenderHDROffscreenUI(m_RenderGraph, hdCamera, renderContext);
m_OffscreenUIRenderedInCurrentFrame = true;
}
else
{
// We do not render offscreen ui for the rest of cameras.
uiBuffer = m_OffscreenUIRenderedInCurrentFrame ? m_RenderGraph.ImportTexture(m_OffscreenUIColorBuffer.Value) : m_RenderGraph.defaultResources.blackTextureXR;
}
bool blitsOffscreenUICover = rendersOffscreenUI && m_RequireOffscreenUICoverPrepass;
if (blitsOffscreenUICover)
{
BlitFullscreenUIToOffscreen(m_RenderGraph, colorBackBuffer, uiBuffer, hdCamera);
}
if (NeedMotionVectorForTransparent(hdCamera.frameSettings)) if (NeedMotionVectorForTransparent(hdCamera.frameSettings))
{ {
@ -440,7 +456,9 @@ namespace UnityEngine.Rendering.HighDefinition
StopXRSinglePass(m_RenderGraph, hdCamera); StopXRSinglePass(m_RenderGraph, hdCamera);
if (renderRequest.isLast) if (renderRequest.isLast)
{
RenderScreenSpaceOverlayUI(m_RenderGraph, hdCamera, colorBackBuffer); RenderScreenSpaceOverlayUI(m_RenderGraph, hdCamera, colorBackBuffer);
}
} }
} }
@ -495,6 +513,7 @@ namespace UnityEngine.Rendering.HighDefinition
public Rect viewport; public Rect viewport;
public Material blitMaterial; public Material blitMaterial;
public Vector4 hdrOutputParmeters; public Vector4 hdrOutputParmeters;
public Vector4 offscreenUIViewportParams;
public bool applyAfterPP; public bool applyAfterPP;
public CubemapFace cubemapFace; public CubemapFace cubemapFace;
@ -538,6 +557,7 @@ namespace UnityEngine.Rendering.HighDefinition
// Pick the right material based off XR rendering using texture arrays and if we are dealing with a single slice at the moment or processing all slices automatically. // Pick the right material based off XR rendering using texture arrays and if we are dealing with a single slice at the moment or processing all slices automatically.
passData.blitMaterial = (TextureXR.useTexArray && passData.srcTexArraySlice >= 0) ? m_FinalBlitWithOETFTexArraySingleSlice : m_FinalBlitWithOETF; passData.blitMaterial = (TextureXR.useTexArray && passData.srcTexArraySlice >= 0) ? m_FinalBlitWithOETFTexArraySingleSlice : m_FinalBlitWithOETF;
GetHDROutputParameters(HDRDisplayInformationForCamera(hdCamera), HDRDisplayColorGamutForCamera(hdCamera), m_Tonemapping, out passData.hdrOutputParmeters, out var unused); GetHDROutputParameters(HDRDisplayInformationForCamera(hdCamera), HDRDisplayColorGamutForCamera(hdCamera), m_Tonemapping, out passData.hdrOutputParmeters, out var unused);
GetOffscreenUIViewportParams(hdCamera, out passData.offscreenUIViewportParams);
passData.uiTexture = uiTexture; passData.uiTexture = uiTexture;
builder.UseTexture(passData.uiTexture, AccessFlags.Read); builder.UseTexture(passData.uiTexture, AccessFlags.Read);
passData.applyAfterPP = hdCamera.frameSettings.IsEnabled(FrameSettingsField.AfterPostprocess) && !NeedHDRDebugMode(m_CurrentDebugDisplaySettings); passData.applyAfterPP = hdCamera.frameSettings.IsEnabled(FrameSettingsField.AfterPostprocess) && !NeedHDRDebugMode(m_CurrentDebugDisplaySettings);
@ -562,6 +582,7 @@ namespace UnityEngine.Rendering.HighDefinition
propertyBlock.SetTexture(HDShaderIDs._InputTexture, sourceTexture); propertyBlock.SetTexture(HDShaderIDs._InputTexture, sourceTexture);
propertyBlock.SetVector(HDShaderIDs._HDROutputParams, data.hdrOutputParmeters); propertyBlock.SetVector(HDShaderIDs._HDROutputParams, data.hdrOutputParmeters);
propertyBlock.SetVector(HDShaderIDs._OffscreenUIViewportParams, data.offscreenUIViewportParams);
propertyBlock.SetInt(HDShaderIDs._BlitTexArraySlice, data.srcTexArraySlice); propertyBlock.SetInt(HDShaderIDs._BlitTexArraySlice, data.srcTexArraySlice);
HDROutputUtils.ConfigureHDROutput(data.blitMaterial, data.colorGamut, HDROutputUtils.Operation.ColorEncoding); HDROutputUtils.ConfigureHDROutput(data.blitMaterial, data.colorGamut, HDROutputUtils.Operation.ColorEncoding);
@ -1035,46 +1056,86 @@ namespace UnityEngine.Rendering.HighDefinition
public Rect viewport; public Rect viewport;
} }
TextureHandle CreateOffscreenUIBuffer(RenderGraph renderGraph, MSAASamples msaaSamples, Rect viewport)
TextureHandle CreateOffscreenUIDepthBuffer(RenderGraph renderGraph, MSAASamples msaaSamples)
{ {
return renderGraph.CreateTexture(new TextureDesc((int)viewport.width, (int)viewport.height, false, true)
{ format = GraphicsFormat.R8G8B8A8_SRGB, clearBuffer = false, msaaSamples = msaaSamples, name = "UI Color Buffer" });
return renderGraph.CreateTexture(new TextureDesc(Screen.width, Screen.height, false, true)
{ format = CoreUtils.GetDefaultDepthStencilFormat(), clearBuffer = true, msaaSamples = msaaSamples, name = "UI Depth Buffer" });
} }
TextureHandle CreateOffscreenUIDepthBuffer(RenderGraph renderGraph, MSAASamples msaaSamples, Rect viewport)
TextureHandle RenderHDROffscreenUI(RenderGraph renderGraph, HDCamera hdCamera, ScriptableRenderContext renderContext)
{ {
return renderGraph.CreateTexture(new TextureDesc((int)viewport.width, (int)viewport.height, false, true)
{ format = CoreUtils.GetDefaultDepthStencilFormat(), clearBuffer = true, msaaSamples = msaaSamples, name = "UI Depth Buffer" });
TextureHandle output;
using (var builder = renderGraph.AddUnsafePass<RenderOffscreenUIData>("UI Rendering", out var passData, ProfilingSampler.Get(HDProfileId.OffscreenUIRendering)))
{
output = renderGraph.ImportTexture(m_OffscreenUIColorBuffer.Value);
builder.SetRenderAttachment(output, 0);
var depthBuffer = CreateOffscreenUIDepthBuffer(renderGraph, hdCamera.msaaSamples);
builder.SetRenderAttachmentDepth(depthBuffer);
passData.camera = hdCamera.camera;
passData.rendererList = renderGraph.CreateUIOverlayRendererList(hdCamera.camera);
builder.UseRendererList(passData.rendererList);
passData.viewport = new Rect(0.0f, 0.0f, Screen.width, Screen.height);
builder.SetRenderFunc(static (RenderOffscreenUIData data, UnsafeGraphContext ctx) =>
{
ctx.cmd.SetViewport(data.viewport);
ctx.cmd.ClearRenderTarget(false, true, Color.clear);
if (data.camera.targetTexture == null)
ctx.cmd.DrawRendererList(data.rendererList);
});
}
return output;
} }
TextureHandle RenderTransparentUI(RenderGraph renderGraph, HDCamera hdCamera, ScriptableRenderContext renderContext)
void BlitFullscreenUIToOffscreen(RenderGraph renderGraph, TextureHandle backBuffer, TextureHandle uiTexture, HDCamera hdCamera)
{ {
var output = renderGraph.defaultResources.blackTextureXR;
if (HDROutputActiveForCameraType(hdCamera) && SupportedRenderingFeatures.active.rendersUIOverlay && !NeedHDRDebugMode(m_CurrentDebugDisplaySettings))
using (var builder = renderGraph.AddUnsafePass<FinalBlitPassData>("Offscreen UI Blit", out var passData, ProfilingSampler.Get(HDProfileId.OffscreenUIRendering)))
{ {
using (var builder = renderGraph.AddUnsafePass<RenderOffscreenUIData>("UI Rendering", out var passData, ProfilingSampler.Get(HDProfileId.OffscreenUIRendering)))
{
output = CreateOffscreenUIBuffer(renderGraph, hdCamera.msaaSamples, hdCamera.finalViewport);
builder.SetRenderAttachment(output, 0);
var depthBuffer = CreateOffscreenUIDepthBuffer(renderGraph, hdCamera.msaaSamples, hdCamera.finalViewport);
builder.SetRenderAttachmentDepth(depthBuffer);
passData.viewport = new Rect(0.0f, 0.0f, Screen.width, Screen.height);
passData.srcTexArraySlice = -1;
passData.dstTexArraySlice = -1;
passData.flip = hdCamera.flipYMode == HDAdditionalCameraData.FlipYMode.ForceFlipY || hdCamera.isMainGameView;
passData.blitMaterial = HDUtils.GetBlitMaterial(TextureDimension.Tex2D);
passData.destination = backBuffer;
builder.UseTexture(passData.destination, AccessFlags.Write);
passData.colorGamut = HDRDisplayColorGamutForCamera(hdCamera);
passData.camera = hdCamera.camera;
passData.rendererList = renderGraph.CreateUIOverlayRendererList(hdCamera.camera);
builder.UseRendererList(passData.rendererList);
passData.viewport = new Rect(0.0f, 0.0f, hdCamera.finalViewport.width, hdCamera.finalViewport.height);
passData.blitMaterial = m_BlitOffscreenUICover;
GetHDROutputParameters(HDRDisplayInformationForCamera(hdCamera), HDRDisplayColorGamutForCamera(hdCamera), m_Tonemapping, out passData.hdrOutputParmeters, out var unused);
passData.offscreenUIViewportParams = new Vector4(0f, 0f, hdCamera.finalViewport.width * (1f / Screen.width), hdCamera.finalViewport.height * (1f / Screen.height));
passData.uiTexture = uiTexture;
builder.UseTexture(passData.uiTexture, AccessFlags.Read);
passData.applyAfterPP = false;
passData.cubemapFace = CubemapFace.Unknown;
builder.SetRenderFunc((RenderOffscreenUIData data, UnsafeGraphContext ctx) =>
builder.SetRenderFunc(
static (FinalBlitPassData data, UnsafeGraphContext ctx) =>
{ {
ctx.cmd.SetViewport(data.viewport);
ctx.cmd.ClearRenderTarget(false, true, Color.clear);
if (data.camera.targetTexture == null)
ctx.cmd.DrawRendererList(passData.rendererList);
var propertyBlock = ctx.renderGraphPool.GetTempMaterialPropertyBlock();
RTHandle sourceTexture = TextureXR.GetBlackTexture();
// We are in HDR mode so the final blit is different
if (data.hdrOutputParmeters.x >= 0)
{
data.blitMaterial.SetInt(HDShaderIDs._NeedsFlip, data.flip ? 1 : 0);
propertyBlock.SetVector(HDShaderIDs._SrcOffset, new Vector4(data.viewport.x, data.viewport.y, Screen.width, Screen.height));
propertyBlock.SetTexture(HDShaderIDs._UITexture, data.uiTexture);
propertyBlock.SetTexture(HDShaderIDs._InputTexture, sourceTexture);
propertyBlock.SetVector(HDShaderIDs._HDROutputParams, data.hdrOutputParmeters);
propertyBlock.SetVector(HDShaderIDs._OffscreenUIViewportParams, data.offscreenUIViewportParams);
propertyBlock.SetInt(HDShaderIDs._BlitTexArraySlice, data.srcTexArraySlice);
HDROutputUtils.ConfigureHDROutput(data.blitMaterial, data.colorGamut, HDROutputUtils.Operation.ColorEncoding);
data.blitMaterial.DisableKeyword("APPLY_AFTER_POST");
data.blitMaterial.SetTexture(HDShaderIDs._AfterPostProcessTexture, TextureXR.GetBlackTexture());
}
HDUtils.DrawFullScreen(CommandBufferHelpers.GetNativeCommandBuffer(ctx.cmd), data.viewport, data.blitMaterial, data.destination, data.cubemapFace, propertyBlock, 0, data.dstTexArraySlice);
}); });
}
} }
return output;
} }
class AfterPostProcessPassData class AfterPostProcessPassData

49
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs

@ -149,6 +149,7 @@ namespace UnityEngine.Rendering.HighDefinition
Material m_ApplyDistortionMaterial; Material m_ApplyDistortionMaterial;
Material m_FinalBlitWithOETF; Material m_FinalBlitWithOETF;
Material m_BlitOffscreenUICover;
Material m_FinalBlitWithOETFTexArraySingleSlice; Material m_FinalBlitWithOETFTexArraySingleSlice;
Material m_ClearStencilBufferMaterial; Material m_ClearStencilBufferMaterial;
@ -157,6 +158,12 @@ namespace UnityEngine.Rendering.HighDefinition
Lazy<RTHandle> m_CustomPassColorBuffer; Lazy<RTHandle> m_CustomPassColorBuffer;
Lazy<RTHandle> m_CustomPassDepthBuffer; Lazy<RTHandle> m_CustomPassDepthBuffer;
Lazy<RTHandle> m_OffscreenUIColorBuffer;
// Use to check if offscreen UI cover prepass should be executed for the current frame.
bool m_RequireOffscreenUICoverPrepass = false;
// Keep track of whether the shared offscreen UI texture has been already rendered in the current frame or not.
bool m_OffscreenUIRenderedInCurrentFrame = false;
RTHandle m_CurrentColorBackBuffer; RTHandle m_CurrentColorBackBuffer;
RTHandle m_CurrentDepthBackBuffer; RTHandle m_CurrentDepthBackBuffer;
@ -628,6 +635,7 @@ namespace UnityEngine.Rendering.HighDefinition
m_ApplyDistortionMaterial = CoreUtils.CreateEngineMaterial(runtimeShaders.applyDistortionPS); m_ApplyDistortionMaterial = CoreUtils.CreateEngineMaterial(runtimeShaders.applyDistortionPS);
m_FinalBlitWithOETF = CoreUtils.CreateEngineMaterial(runtimeShaders.compositeUIAndOETFApplyPS); m_FinalBlitWithOETF = CoreUtils.CreateEngineMaterial(runtimeShaders.compositeUIAndOETFApplyPS);
m_BlitOffscreenUICover = CoreUtils.CreateEngineMaterial(runtimeShaders.compositeUIAndOETFApplyPS);
if (TextureXR.useTexArray) if (TextureXR.useTexArray)
{ {
@ -706,8 +714,8 @@ namespace UnityEngine.Rendering.HighDefinition
m_DepthPyramidMipLevelOffsetsBuffer = new ComputeBuffer(15, sizeof(int) * 2); m_DepthPyramidMipLevelOffsetsBuffer = new ComputeBuffer(15, sizeof(int) * 2);
m_CustomPassColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
m_CustomPassDepthBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.None, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: CoreUtils.GetDefaultDepthBufferBits()));
AllocateCustomPassBuffers();
m_OffscreenUIColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Screen.width, Screen.height, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R8G8B8A8_SRGB, useDynamicScale: false, wrapMode: TextureWrapMode.Clamp, autoGenerateMips: false, name: "UI Color Buffer"));
// For debugging // For debugging
MousePositionDebug.instance.Build(); MousePositionDebug.instance.Build();
@ -1026,6 +1034,7 @@ namespace UnityEngine.Rendering.HighDefinition
CoreUtils.Destroy(m_ApplyDistortionMaterial); CoreUtils.Destroy(m_ApplyDistortionMaterial);
CoreUtils.Destroy(m_ClearStencilBufferMaterial); CoreUtils.Destroy(m_ClearStencilBufferMaterial);
CoreUtils.Destroy(m_FinalBlitWithOETF); CoreUtils.Destroy(m_FinalBlitWithOETF);
CoreUtils.Destroy(m_BlitOffscreenUICover);
CoreUtils.Destroy(m_FinalBlitWithOETFTexArraySingleSlice); CoreUtils.Destroy(m_FinalBlitWithOETFTexArraySingleSlice);
XRSystem.Dispose(); XRSystem.Dispose();
@ -1051,6 +1060,8 @@ namespace UnityEngine.Rendering.HighDefinition
RTHandles.Release(m_CustomPassColorBuffer.Value); RTHandles.Release(m_CustomPassColorBuffer.Value);
if (m_CustomPassDepthBuffer.IsValueCreated) if (m_CustomPassDepthBuffer.IsValueCreated)
RTHandles.Release(m_CustomPassDepthBuffer.Value); RTHandles.Release(m_CustomPassDepthBuffer.Value);
if (m_OffscreenUIColorBuffer.IsValueCreated)
RTHandles.Release(m_OffscreenUIColorBuffer.Value);
RTHandles.Release(m_CurrentColorBackBuffer); RTHandles.Release(m_CurrentColorBackBuffer);
RTHandles.Release(m_CurrentDepthBackBuffer); RTHandles.Release(m_CurrentDepthBackBuffer);
@ -2166,6 +2177,14 @@ namespace UnityEngine.Rendering.HighDefinition
// For XR, HDR and no camera cases, UI Overlay ownership must be enforced // For XR, HDR and no camera cases, UI Overlay ownership must be enforced
AdjustUIOverlayOwnership(cameraCount); AdjustUIOverlayOwnership(cameraCount);
// When HDR output is enabled, SRP renders the overlay UI per camera viewport, so any screen area not covered by viewports won’t display the UI.
// The offscreen UI cover prepass ensures the overlay UI covers the entire display by blitting UI to the screen first, even when the combined camera viewports do not fill the screen.
m_RequireOffscreenUICoverPrepass = HDROutputForMainDisplayIsActive() && SupportedRenderingFeatures.active.rendersUIOverlay && !CoreUtils.IsScreenFullyCoveredByCameras(cameras);
m_OffscreenUIRenderedInCurrentFrame = false;
// Reallocate the offscreen UI buffer when the resolution changes.
ReAllocateOffscreenUIColorBufferIfNeeded();
if (!m_ValidAPI || cameraCount == 0) if (!m_ValidAPI || cameraCount == 0)
return; return;
@ -2265,6 +2284,14 @@ namespace UnityEngine.Rendering.HighDefinition
// so will present rendering at native resolution. This will only pay a small cost of memory on the texture aliasing that the runtime has to keep track of. // so will present rendering at native resolution. This will only pay a small cost of memory on the texture aliasing that the runtime has to keep track of.
RTHandles.SetHardwareDynamicResolutionState(m_Asset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.dynResType == DynamicResolutionType.Hardware); RTHandles.SetHardwareDynamicResolutionState(m_Asset.currentPlatformRenderPipelineSettings.dynamicResolutionSettings.dynResType == DynamicResolutionType.Hardware);
// This is to ensure that custom pass buffers have the adequate depth/number of slices when switching from XR enabled/disabled
if (m_CustomPassColorBuffer.Value.rt.volumeDepth != TextureXR.slices)
{
RTHandles.Release(m_CustomPassColorBuffer.Value);
RTHandles.Release(m_CustomPassDepthBuffer.Value);
AllocateCustomPassBuffers();
}
// Culling loop // Culling loop
foreach ((Camera camera, XRPass xrPass) in xrLayout.GetActivePasses()) foreach ((Camera camera, XRPass xrPass) in xrLayout.GetActivePasses())
{ {
@ -3441,5 +3468,23 @@ namespace UnityEngine.Rendering.HighDefinition
SupportedRenderingFeatures.active.rendersUIOverlay = true; SupportedRenderingFeatures.active.rendersUIOverlay = true;
} }
} }
void ReAllocateOffscreenUIColorBufferIfNeeded()
{
if (m_OffscreenUIColorBuffer.IsValueCreated)
{
if (Screen.width != m_OffscreenUIColorBuffer.Value.rt.width || Screen.height != m_OffscreenUIColorBuffer.Value.rt.height)
{
RTHandles.Release(m_OffscreenUIColorBuffer.Value);
m_OffscreenUIColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Screen.width, Screen.height, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.R8G8B8A8_SRGB, useDynamicScale: false, wrapMode: TextureWrapMode.Clamp, autoGenerateMips: false, name: "UI Color Buffer"));
}
}
}
void AllocateCustomPassBuffers()
{
m_CustomPassColorBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GetCustomBufferFormat(), enableRandomWrite: true, useDynamicScale: true, name: "CustomPassColorBuffer"));
m_CustomPassDepthBuffer = new Lazy<RTHandle>(() => RTHandles.Alloc(Vector2.one, TextureXR.slices, dimension: TextureXR.dimension, colorFormat: GraphicsFormat.None, useDynamicScale: true, name: "CustomPassDepthBuffer", depthBufferBits: CoreUtils.GetDefaultDepthBufferBits()));
}
} }
} }

8
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineGlobalSettings.cs

@ -109,14 +109,6 @@ namespace UnityEngine.Rendering.HighDefinition
EditorUtility.SetDirty(diffusionProfileList); EditorUtility.SetDirty(diffusionProfileList);
} }
} }
if (TryGet(typeof(LookDevVolumeProfileSettings), out var lookDevSettings) &&
lookDevSettings is LookDevVolumeProfileSettings lookDevVolumeProfileSettings &&
lookDevVolumeProfileSettings.volumeProfile == null &&
assets != null)
{
lookDevVolumeProfileSettings.volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(assets.lookDevVolumeProfile);
}
} }
void SetUpRPAssetIncluded() void SetUpRPAssetIncluded()

1
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs

@ -1128,6 +1128,7 @@ namespace UnityEngine.Rendering.HighDefinition
public static readonly int _UITexture = Shader.PropertyToID("_UITexture"); public static readonly int _UITexture = Shader.PropertyToID("_UITexture");
public static readonly int _HDROutputParams = Shader.PropertyToID("_HDROutputParams"); public static readonly int _HDROutputParams = Shader.PropertyToID("_HDROutputParams");
public static readonly int _HDROutputParams2 = Shader.PropertyToID("_HDROutputParams2"); public static readonly int _HDROutputParams2 = Shader.PropertyToID("_HDROutputParams2");
public static readonly int _OffscreenUIViewportParams = Shader.PropertyToID("_OffscreenUIViewportParams");
public static readonly int _NeedsFlip = Shader.PropertyToID("_NeedsFlip"); public static readonly int _NeedsFlip = Shader.PropertyToID("_NeedsFlip");
public static readonly int _MotionVecAndDepth = Shader.PropertyToID("_MotionVecAndDepth"); public static readonly int _MotionVecAndDepth = Shader.PropertyToID("_MotionVecAndDepth");

2
Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/FSR2Pass.cs

@ -403,7 +403,7 @@ namespace UnityEngine.Rendering.HighDefinition
float percentage = 100.0f; float percentage = 100.0f;
if (enableAutomaticSettings) if (enableAutomaticSettings)
{ {
var qualityMode = (AMD.FSR2Quality)(hdCam.fidelityFX2SuperResolutionUseCustomAttributes ? hdCam.fidelityFX2SuperResolutionQuality : dynamicResolutionSettings.FSR2QualitySetting);
var qualityMode = (AMD.FSR2Quality)(hdCam.fidelityFX2SuperResolutionUseCustomQualitySettings ? hdCam.fidelityFX2SuperResolutionQuality : dynamicResolutionSettings.FSR2QualitySetting);
percentage = (1.0f / m_Device.GetUpscaleRatioFromQualityMode(qualityMode)) * 100.0f; percentage = (1.0f / m_Device.GetUpscaleRatioFromQualityMode(qualityMode)) * 100.0f;
DynamicResolutionHandler.SetSystemDynamicResScaler(fsr2Camera.ScaleDelegate, DynamicResScalePolicyType.ReturnsPercentage); DynamicResolutionHandler.SetSystemDynamicResScaler(fsr2Camera.ScaleDelegate, DynamicResScalePolicyType.ReturnsPercentage);
DynamicResolutionHandler.SetActiveDynamicScalerSlot(DynamicResScalerSlot.System); DynamicResolutionHandler.SetActiveDynamicScalerSlot(DynamicResScalerSlot.System);

2
Packages/com.unity.render-pipelines.high-definition/Runtime/Settings/LookDevVolumeProfileSettings.cs

@ -50,7 +50,7 @@ namespace UnityEngine.Rendering.HighDefinition
[SerializeField][HideInInspector] [SerializeField][HideInInspector]
Version m_Version; Version m_Version;
/// <summary>Current version of these settings container. Used only for upgrading a project.</summary>
/// <summary>Current version of these settings container. Used only for upgrading a project.</summary>
public int version => (int)m_Version; public int version => (int)m_Version;
#endregion #endregion

2
Packages/com.unity.render-pipelines.high-definition/Runtime/VFXGraph/Shaders/VFXDefines.hlsl

@ -3,6 +3,8 @@
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/TextureXR.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialBlendModeEnum.cs.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialBlendModeEnum.cs.hlsl"
#define VFX_WRITE_RENDERING_LAYERS 0
#if VFX_BLENDMODE_ALPHA #if VFX_BLENDMODE_ALPHA
#define _BlendMode BLENDINGMODE_ALPHA #define _BlendMode BLENDINGMODE_ALPHA
#elif VFX_BLENDMODE_ADD #elif VFX_BLENDMODE_ADD

2
Packages/com.unity.render-pipelines.high-definition/package.json

@ -109,5 +109,5 @@
] ]
} }
], ],
"_fingerprint": "c910145d3955132d5f5cc4bad378101002152b8b"
"_fingerprint": "4f6eeca1f47a39897566f81c29d146e894b57ea6"
} }

10
Packages/com.unity.shadergraph/Editor/Data/Graphs/DynamicVectorMaterialSlot.cs

@ -139,9 +139,13 @@ namespace UnityEditor.ShaderGraph
public override void CopyValuesFrom(MaterialSlot foundSlot) public override void CopyValuesFrom(MaterialSlot foundSlot)
{ {
var slot = foundSlot as DynamicVectorMaterialSlot;
if (slot != null)
value = slot.value;
switch (foundSlot)
{
case IMaterialSlotHasValue<float> slot1: value = new Vector4(slot1.value, slot1.value, slot1.value, slot1.value); break;
case IMaterialSlotHasValue<Vector2> slot2: value = new Vector4(slot2.value.x, slot2.value.y); break;
case IMaterialSlotHasValue<Vector3> slot3: value = new Vector4(slot3.value.x, slot3.value.y, slot3.value.z); break;
case IMaterialSlotHasValue<Vector4> slot4: value = slot4.value; break;
}
} }
public override void CopyDefaultValue(MaterialSlot other) public override void CopyDefaultValue(MaterialSlot other)

2
Packages/com.unity.shadergraph/Editor/Data/Graphs/GraphData.cs

@ -708,6 +708,8 @@ namespace UnityEditor.ShaderGraph
return; return;
} }
materialNode.previewExpanded = ShaderGraphPreferences.newNodesPreview;
AddNodeNoValidate(materialNode); AddNodeNoValidate(materialNode);
// If adding a Sub Graph node whose asset contains Keywords // If adding a Sub Graph node whose asset contains Keywords

13
Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector1MaterialSlot.cs

@ -4,7 +4,6 @@ using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Slots; using UnityEditor.ShaderGraph.Drawing.Slots;
using UnityEditor.ShaderGraph.Internal; using UnityEditor.ShaderGraph.Internal;
using UnityEngine; using UnityEngine;
using UnityEngine.Serialization;
using UnityEngine.UIElements; using UnityEngine.UIElements;
namespace UnityEditor.ShaderGraph namespace UnityEditor.ShaderGraph
@ -117,11 +116,15 @@ namespace UnityEditor.ShaderGraph
public override void CopyValuesFrom(MaterialSlot foundSlot) public override void CopyValuesFrom(MaterialSlot foundSlot)
{ {
var slot = foundSlot as Vector1MaterialSlot;
if (slot != null)
if (foundSlot is IMaterialSlotSupportsLiteralMode literal)
LiteralMode = literal.LiteralMode;
switch(foundSlot)
{ {
value = slot.value;
LiteralMode = slot.LiteralMode;
case IMaterialSlotHasValue<float> slot1: value = slot1.value; break;
case IMaterialSlotHasValue<Vector2> slot2: value = slot2.value.x; break;
case IMaterialSlotHasValue<Vector3> slot3: value = slot3.value.x; break;
case IMaterialSlotHasValue<Vector4> slot4: value = slot4.value.x; break;
} }
} }

10
Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector2MaterialSlot.cs

@ -125,9 +125,13 @@ namespace UnityEditor.ShaderGraph
public override void CopyValuesFrom(MaterialSlot foundSlot) public override void CopyValuesFrom(MaterialSlot foundSlot)
{ {
var slot = foundSlot as Vector2MaterialSlot;
if (slot != null)
value = slot.value;
switch (foundSlot)
{
case IMaterialSlotHasValue<float> slot1: value = new Vector2(slot1.value, slot1.value); break;
case IMaterialSlotHasValue<Vector2> slot2: value = slot2.value; break;
case IMaterialSlotHasValue<Vector3> slot3: value = new Vector2(slot3.value.x, slot3.value.y); break;
case IMaterialSlotHasValue<Vector4> slot4: value = new Vector2(slot4.value.x, slot4.value.y); break;
}
} }
public override void CopyDefaultValue(MaterialSlot other) public override void CopyDefaultValue(MaterialSlot other)

10
Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector3MaterialSlot.cs

@ -117,9 +117,13 @@ namespace UnityEditor.ShaderGraph
public override void CopyValuesFrom(MaterialSlot foundSlot) public override void CopyValuesFrom(MaterialSlot foundSlot)
{ {
var slot = foundSlot as Vector3MaterialSlot;
if (slot != null)
value = slot.value;
switch (foundSlot)
{
case IMaterialSlotHasValue<float> slot1: value = new Vector3(slot1.value, slot1.value, slot1.value); break;
case IMaterialSlotHasValue<Vector2> slot2: value = new Vector3(slot2.value.x, slot2.value.y); break;
case IMaterialSlotHasValue<Vector3> slot3: value = slot3.value; break;
case IMaterialSlotHasValue<Vector4> slot4: value = new Vector3(slot4.value.x, slot4.value.y, slot4.value.z); break;
}
} }
public override void CopyDefaultValue(MaterialSlot other) public override void CopyDefaultValue(MaterialSlot other)

10
Packages/com.unity.shadergraph/Editor/Data/Graphs/Vector4MaterialSlot.cs

@ -120,9 +120,13 @@ namespace UnityEditor.ShaderGraph
public override void CopyValuesFrom(MaterialSlot foundSlot) public override void CopyValuesFrom(MaterialSlot foundSlot)
{ {
var slot = foundSlot as Vector4MaterialSlot;
if (slot != null)
value = slot.value;
switch (foundSlot)
{
case IMaterialSlotHasValue<float> slot1: value = new Vector4(slot1.value, slot1.value, slot1.value, slot1.value); break;
case IMaterialSlotHasValue<Vector2> slot2: value = new Vector4(slot2.value.x, slot2.value.y); break;
case IMaterialSlotHasValue<Vector3> slot3: value = new Vector4(slot3.value.x, slot3.value.y, slot3.value.z); break;
case IMaterialSlotHasValue<Vector4> slot4: value = slot4.value; break;
}
} }
public override void CopyDefaultValue(MaterialSlot other) public override void CopyDefaultValue(MaterialSlot other)

63
Packages/com.unity.shadergraph/Editor/Data/Nodes/Channel/SwizzleNode.cs

@ -100,8 +100,36 @@ namespace UnityEditor.ShaderGraph
if (_maskInput == null) if (_maskInput == null)
_maskInput = "xxxx"; _maskInput = "xxxx";
AddSlot(new DynamicVectorMaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector4.zero));
switch (_maskInput.Length)
int outputLength = _maskInput.Length;
int inputLength = 1;
foreach(var c in _maskInput)
{
switch (c)
{
case 'g': case 'y': inputLength = Mathf.Max(2, inputLength); break;
case 'b': case 'z': inputLength = Mathf.Max(3, inputLength); break;
case 'a': case 'w': inputLength = Mathf.Max(4, inputLength); break;
default: break;
}
}
switch (inputLength)
{
case 1:
AddSlot(new Vector1MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, 0));
break;
case 2:
AddSlot(new Vector2MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector2.zero));
break;
case 3:
AddSlot(new Vector3MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector3.zero));
break;
default:
AddSlot(new Vector4MaterialSlot(InputSlotId, kInputSlotName, kInputSlotName, SlotType.Input, Vector4.zero));
break;
}
switch (outputLength)
{ {
case 1: case 1:
AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0)); AddSlot(new Vector1MaterialSlot(OutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, 0));
@ -131,12 +159,6 @@ namespace UnityEditor.ShaderGraph
{ {
sb.AppendLine(string.Format("{0} {1} = 0;", outputSlotType, outputName)); sb.AppendLine(string.Format("{0} {1} = 0;", outputSlotType, outputName));
} }
else if(!FindInputSlot<MaterialSlot>(InputSlotId).isConnected)
{
// cannot swizzle off of a float literal, so if there is no upstream connection, it means we have defaulted to a float,
// and the node's initial base case will generate invalid code.
sb.AppendLine("{0} {1} = $precision({2}).{3};", outputSlotType, outputName, inputValue, convertedMask);
}
else else
{ {
sb.AppendLine("{0} {1} = {2}.{3};", outputSlotType, outputName, inputValue, convertedMask); sb.AppendLine("{0} {1} = {2}.{3};", outputSlotType, outputName, inputValue, convertedMask);
@ -146,12 +168,17 @@ namespace UnityEditor.ShaderGraph
public override void ValidateNode() public override void ValidateNode()
{ {
base.ValidateNode(); base.ValidateNode();
var inputSlot = FindInputSlot<MaterialSlot>(InputSlotId);
int InputValueSize = GetInputLength(inputSlot);
int ExpectedInputSize = SlotValueHelper.GetChannelCount(inputSlot.concreteValueType);
var inputValueType = FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType;
var InputValueSize = SlotValueHelper.GetChannelCount(inputValueType);
if (!ValidateMaskInput(InputValueSize)) if (!ValidateMaskInput(InputValueSize))
{ {
owner.AddValidationError(objectId, "Invalid mask for a Vector" + InputValueSize + " input.", ShaderCompilerMessageSeverity.Error);
owner.AddValidationError(objectId, "Invalid mask for a 'Vector" + InputValueSize + "' input.", ShaderCompilerMessageSeverity.Error);
}
else if ( InputValueSize < ExpectedInputSize)
{
owner.AddValidationError(objectId, $"Connected input 'Vector{InputValueSize}' is smaller than expected input 'Vector{ExpectedInputSize}'.", ShaderCompilerMessageSeverity.Warning);
} }
} }
@ -199,5 +226,19 @@ namespace UnityEditor.ShaderGraph
node._maskInput = s_ComponentList[legacySwizzleChannelData.m_RedChannel] + s_ComponentList[legacySwizzleChannelData.m_GreenChannel] + s_ComponentList[legacySwizzleChannelData.m_BlueChannel] + s_ComponentList[legacySwizzleChannelData.m_AlphaChannel]; node._maskInput = s_ComponentList[legacySwizzleChannelData.m_RedChannel] + s_ComponentList[legacySwizzleChannelData.m_GreenChannel] + s_ComponentList[legacySwizzleChannelData.m_BlueChannel] + s_ComponentList[legacySwizzleChannelData.m_AlphaChannel];
} }
} }
private static int GetInputLength(MaterialSlot slot)
{
if (!slot.isConnected)
return SlotValueHelper.GetChannelCount(slot.concreteValueType);
var graph = slot.owner.owner; //slot.isConnected null checks this already;
var edges = graph.GetEdges(slot.slotReference);
foreach(var edge in edges)
return SlotValueHelper.GetChannelCount(edge.outputSlot.slot.concreteValueType);
// this shouldn't be reached, but we fall back to the slot's original concrete length.
return SlotValueHelper.GetChannelCount(slot.concreteValueType);
}
} }
} }

10
Packages/com.unity.shadergraph/Editor/Data/Nodes/Utility/SubGraphNode.cs

@ -106,14 +106,8 @@ namespace UnityEditor.ShaderGraph
[SerializeField] [SerializeField]
List<string> m_DropdownSelectedEntries = new List<string>(); List<string> m_DropdownSelectedEntries = new List<string>();
public override string documentationURL {
get {
// TODO: There should be a way for unity authored and distributed subgraphs to provide custom doc links.
if (m_SubGraph?.name.Contains("SpeedTree8") ?? false)
return Documentation.GetPageLink("SpeedTree8-SubGraphAssets");
else return Documentation.GetPageLink("Sub-graph");
}
}
public override string documentationURL =>
Documentation.GetPageLink(string.IsNullOrEmpty(m_SubGraph.documentationPath)? "Sub-graph-Node" : m_SubGraph.documentationPath);
public string subGraphGuid public string subGraphGuid
{ {

2
Packages/com.unity.shadergraph/Editor/Data/SubGraph/SubGraphAsset.cs

@ -89,6 +89,8 @@ namespace UnityEditor.ShaderGraph
public string path; public string path;
public string documentationPath;
public List<FunctionPair> functions = new List<FunctionPair>(); public List<FunctionPair> functions = new List<FunctionPair>();
public IncludeCollection includes; public IncludeCollection includes;

8
Packages/com.unity.shadergraph/Editor/Importers/ShaderSubGraphImporter.cs

@ -24,6 +24,9 @@ namespace UnityEditor.ShaderGraph
[CoreRPHelpURL("Sub-graph", "com.unity.shadergraph")] [CoreRPHelpURL("Sub-graph", "com.unity.shadergraph")]
class ShaderSubGraphImporter : ScriptedImporter class ShaderSubGraphImporter : ScriptedImporter
{ {
[SerializeField, HideInInspector]
private string documentationPath;
public const string Extension = "shadersubgraph"; public const string Extension = "shadersubgraph";
const string IconBasePath = "Packages/com.unity.shadergraph/Editor/Resources/Icons/sg_subgraph_icon.png"; const string IconBasePath = "Packages/com.unity.shadergraph/Editor/Resources/Icons/sg_subgraph_icon.png";
@ -87,7 +90,7 @@ namespace UnityEditor.ShaderGraph
try try
{ {
ProcessSubGraph(graphAsset, graphData, importLog);
ProcessSubGraph(graphAsset, graphData, importLog, documentationPath);
} }
catch (Exception e) catch (Exception e)
{ {
@ -171,7 +174,7 @@ namespace UnityEditor.ShaderGraph
} }
} }
static void ProcessSubGraph(SubGraphAsset asset, GraphData graph, ShaderGraphImporter.AssetImportErrorLog importLog)
static void ProcessSubGraph(SubGraphAsset asset, GraphData graph, ShaderGraphImporter.AssetImportErrorLog importLog, string documentationPath)
{ {
var graphIncludes = new IncludeCollection(); var graphIncludes = new IncludeCollection();
var registry = new FunctionRegistry(new ShaderStringBuilder(), graphIncludes, true); var registry = new FunctionRegistry(new ShaderStringBuilder(), graphIncludes, true);
@ -188,6 +191,7 @@ namespace UnityEditor.ShaderGraph
asset.inputStructName = $"Bindings_{asset.hlslName}_{asset.assetGuid}_$precision"; asset.inputStructName = $"Bindings_{asset.hlslName}_{asset.assetGuid}_$precision";
asset.functionName = $"SG_{asset.hlslName}_{asset.assetGuid}_$precision"; asset.functionName = $"SG_{asset.hlslName}_{asset.assetGuid}_$precision";
asset.path = graph.path; asset.path = graph.path;
asset.documentationPath = documentationPath;
var outputNode = graph.outputNode; var outputNode = graph.outputNode;

16
Packages/com.unity.shadergraph/Editor/ShaderGraphPreferences.cs

@ -32,6 +32,7 @@ namespace UnityEditor.ShaderGraph
internal const string zoomStepSize = "UnityEditor.ShaderGraph.ZoomStepSize"; internal const string zoomStepSize = "UnityEditor.ShaderGraph.ZoomStepSize";
internal const string graphTemplateWorkflow = "UnityEditor.ShaderGraph.GraphTemplateWorkflow"; internal const string graphTemplateWorkflow = "UnityEditor.ShaderGraph.GraphTemplateWorkflow";
internal const string openNewGraphOnCreation = "UnityEditor.ShaderGraph.OpenNewGraphOnCreation"; internal const string openNewGraphOnCreation = "UnityEditor.ShaderGraph.OpenNewGraphOnCreation";
internal const string newNodesPreview = "UnityEditor.ShaderGraph.NewNodesPreview";
} }
static bool m_Loaded = false; static bool m_Loaded = false;
@ -114,6 +115,13 @@ namespace UnityEditor.ShaderGraph
set => TrySave(ref m_OpenNewGraphOnCreation, value, Keys.openNewGraphOnCreation); set => TrySave(ref m_OpenNewGraphOnCreation, value, Keys.openNewGraphOnCreation);
} }
static bool m_NewNodesPreview = true;
internal static bool newNodesPreview
{
get => m_NewNodesPreview;
private set => TrySave(ref m_NewNodesPreview, value, Keys.newNodesPreview);
}
internal static bool GetOrPromptOpenNewGraphOnCreation() internal static bool GetOrPromptOpenNewGraphOnCreation()
{ {
if (!EditorPrefs.HasKey(Keys.openNewGraphOnCreation)) if (!EditorPrefs.HasKey(Keys.openNewGraphOnCreation))
@ -196,6 +204,13 @@ namespace UnityEditor.ShaderGraph
{ {
openNewGraphOnCreation = openNewGraphOnCreationValue; openNewGraphOnCreation = openNewGraphOnCreationValue;
} }
EditorGUI.BeginChangeCheck();
var newNodesPreviewValue = EditorGUILayout.Toggle(new GUIContent("Expand Node Preview on Node creation", "Choose whether newly added Nodes' Previews should be expanded."), newNodesPreview);
if (EditorGUI.EndChangeCheck())
{
newNodesPreview = newNodesPreviewValue;
}
} }
} }
@ -207,6 +222,7 @@ namespace UnityEditor.ShaderGraph
m_ZoomStepSize = EditorPrefs.GetFloat(Keys.zoomStepSize, defaultZoomStepSize); m_ZoomStepSize = EditorPrefs.GetFloat(Keys.zoomStepSize, defaultZoomStepSize);
m_GraphTemplateWorkflow = (GraphTemplateWorkflow)EditorPrefs.GetInt(Keys.graphTemplateWorkflow, (int)defaultGraphTemplateWorkflow); m_GraphTemplateWorkflow = (GraphTemplateWorkflow)EditorPrefs.GetInt(Keys.graphTemplateWorkflow, (int)defaultGraphTemplateWorkflow);
m_OpenNewGraphOnCreation = EditorPrefs.GetBool(Keys.openNewGraphOnCreation, true); m_OpenNewGraphOnCreation = EditorPrefs.GetBool(Keys.openNewGraphOnCreation, true);
m_NewNodesPreview = EditorPrefs.GetBool(Keys.newNodesPreview, true);
m_Loaded = true; m_Loaded = true;
} }

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8Billboard.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8CameraFacingLeafEffect.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8ColorAlpha.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8InterpolatedNormals.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8LODTransition.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree8Wind.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree9CameraFacingLeafEffect.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

1
Packages/com.unity.shadergraph/ShaderGraphLibrary/Nature/SpeedTree9Wind.shadersubgraph.meta

@ -8,3 +8,4 @@ ScriptedImporter:
assetBundleName: assetBundleName:
assetBundleVariant: assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3} script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}
documentationPath: SpeedTree8-SubGraphAssets

2
Packages/com.unity.shadergraph/package.json

@ -62,5 +62,5 @@
] ]
} }
], ],
"_fingerprint": "bd2576295577035a5a36b451e9fef739f1ef0948"
"_fingerprint": "3cfe1d1f3f8cb2a422448449ea422fa1a226fded"
} }

6
Packages/com.unity.ugui/Runtime/TMP/TMP_InputField.cs

@ -4476,6 +4476,12 @@ namespace TMPro
m_ShouldActivateNextUpdate = true; m_ShouldActivateNextUpdate = true;
SendOnSubmit(); SendOnSubmit();
#if PLATFORM_TVOS
// When a keyboard is open in tvOS, the submit button is used for typing.
// Only actually close the keyboard on tvOS if "Done" was pressed in the soft keyboard.
if (m_SoftKeyboard != null && m_SoftKeyboard.status == TouchScreenKeyboard.Status.Visible)
return;
#endif
DeactivateInputField(); DeactivateInputField();
eventData?.Use(); eventData?.Use();
} }

69
Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Graphic.cs

@ -298,6 +298,12 @@ namespace UnityEngine.UI
m_VertsDirty = true; m_VertsDirty = true;
CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this); CanvasUpdateRegistry.RegisterCanvasElementForGraphicRebuild(this);
#if PACKAGE_POLYSPATIAL
// [AVPB-860] When vertices are dirtied, mark the component itself
// dirty as well so that ObjectDispatcher picks it up
MarkDirty();
#endif
if (m_OnDirtyVertsCallback != null) if (m_OnDirtyVertsCallback != null)
m_OnDirtyVertsCallback(); m_OnDirtyVertsCallback();
} }
@ -858,52 +864,81 @@ namespace UnityEngine.UI
bool ignoreParentGroups = false; bool ignoreParentGroups = false;
bool continueTraversal = true; bool continueTraversal = true;
bool isParent = false;
while (t != null) while (t != null)
{ {
bool raycastValid = true;
bool hasMask = false;
bool maskableGraphicRaycastValid = true;
t.GetComponents(components); t.GetComponents(components);
for (var i = 0; i < components.Count; i++) for (var i = 0; i < components.Count; i++)
{ {
var canvas = components[i] as Canvas;
var component = components[i];
var canvas = component as Canvas;
if (canvas != null && canvas.overrideSorting) if (canvas != null && canvas.overrideSorting)
continueTraversal = false; continueTraversal = false;
var filter = components[i] as ICanvasRaycastFilter;
var filter = component as ICanvasRaycastFilter; // Image, Mask, RectMask2D, CanvasGroup
if (filter == null) if (filter == null)
continue; continue;
if (ignoreMasks && components[i] is Mask or RectMask2D)
if (ignoreMasks && component is Mask or RectMask2D)
continue; continue;
var raycastValid = true;
var group = components[i] as CanvasGroup;
if (group != null)
if (component is CanvasGroup group)
{ {
if (!group.enabled) if (!group.enabled)
continue; continue;
if (ignoreParentGroups == false && group.ignoreParentGroups)
if (ignoreParentGroups == false)
{ {
ignoreParentGroups = true;
if (group.ignoreParentGroups)
ignoreParentGroups = true;
raycastValid = filter.IsRaycastLocationValid(sp, eventCamera); raycastValid = filter.IsRaycastLocationValid(sp, eventCamera);
if (!raycastValid)
break;
} }
else if (!ignoreParentGroups)
raycastValid = filter.IsRaycastLocationValid(sp, eventCamera);
} }
else else
{ {
if (isParent && component is Graphic graphic && !graphic.raycastTarget)
continue;
hasMask |= component is Mask;
raycastValid = filter.IsRaycastLocationValid(sp, eventCamera); raycastValid = filter.IsRaycastLocationValid(sp, eventCamera);
}
if (!raycastValid)
{
ListPool<Component>.Release(components);
return false;
// Try to early-out if the raycast is not valid
if (!raycastValid)
{
// Cache the raycast result for parent MaskableGraphics and continue processing components
// unless we already found a Mask and are not ignoring masks
if (isParent && component is MaskableGraphic)
{
maskableGraphicRaycastValid = raycastValid;
if (ignoreMasks || !hasMask)
{
raycastValid = true;
continue;
}
}
break;
}
} }
} }
if (!raycastValid || (hasMask && !maskableGraphicRaycastValid))
{
ListPool<Component>.Release(components);
return false;
}
t = continueTraversal ? t.parent : null; t = continueTraversal ? t.parent : null;
isParent = true;
} }
ListPool<Component>.Release(components); ListPool<Component>.Release(components);
return true; return true;

6
Packages/com.unity.ugui/Runtime/UGUI/UI/Core/Image.cs

@ -1925,12 +1925,6 @@ namespace UnityEngine.UI
float x = local.x / activeSprite.texture.width; float x = local.x / activeSprite.texture.width;
float y = local.y / activeSprite.texture.height; float y = local.y / activeSprite.texture.height;
// Locations outside the image are always considered valid.
// This guarantees that the behavior remains consistent with the case where alphaHitTestMinimumThreshold <= 0.
// Without this check, we would continue to sample a pixel outside the texture.
if (x < 0 || x > 1 || y < 0 || y > 1)
return true;
try try
{ {
return activeSprite.texture.GetPixelBilinear(x, y).a >= alphaHitTestMinimumThreshold; return activeSprite.texture.GetPixelBilinear(x, y).a >= alphaHitTestMinimumThreshold;

5
Packages/com.unity.ugui/Runtime/UGUI/UnityEngine.UI.asmdef

@ -40,6 +40,11 @@
"name": "com.unity.inputsystem", "name": "com.unity.inputsystem",
"expression": "1.7.0", "expression": "1.7.0",
"define": "PACKAGE_INPUTSYSTEM" "define": "PACKAGE_INPUTSYSTEM"
},
{
"name": "com.unity.polyspatial",
"expression": "2.0.0",
"define": "PACKAGE_POLYSPATIAL"
} }
], ],
"noEngineReferences": false "noEngineReferences": false

114
Packages/com.unity.ugui/Tests/Runtime/UGUI/EventSystem/GraphicRaycasterButtonTests.cs

@ -0,0 +1,114 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.TestTools;
using UnityEngine.UI;
internal class GraphicRaycasterButtonTests
{
Camera m_Camera;
EventSystem m_EventSystem;
Canvas m_Canvas;
Button m_ParentButton;
Button m_ChildButton;
Sprite m_Sprite;
const int TextureSize = 64;
readonly Texture2D texture = new Texture2D(TextureSize, TextureSize);
[UnitySetUp]
public IEnumerator TestSetup()
{
m_Camera = new GameObject("Camera").AddComponent<Camera>();
m_Camera.transform.position = new Vector3(0, 0, -10);
m_Canvas = new GameObject("Canvas").AddComponent<Canvas>();
m_Canvas.renderMode = RenderMode.ScreenSpaceOverlay;
m_Canvas.gameObject.AddComponent<GraphicRaycaster>();
m_EventSystem = new GameObject("Event System").AddComponent<EventSystem>();
Color[] colors = new Color[TextureSize * TextureSize];
for (int y = 24; y < 40; y++)
for (int x = 0; x < TextureSize; x++)
colors[y + TextureSize * x] = colors[x + TextureSize * y] = Color.red;
texture.SetPixels(colors);
texture.Apply();
m_Sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100);
var parentImage = new GameObject("ParentButton", typeof(RectTransform)).AddComponent<Image>();
parentImage.transform.SetParent(m_Canvas.transform);
parentImage.rectTransform.anchoredPosition = new Vector2(0, 0);
parentImage.sprite = m_Sprite;
parentImage.SetNativeSize();
m_ParentButton = parentImage.gameObject.AddComponent<Button>();
// Duplicate Button as a child GO
m_ChildButton = Object.Instantiate(m_ParentButton, m_ParentButton.transform);
m_ChildButton.name = "ChildButton";
var childImage = m_ChildButton.GetComponent<Image>();
childImage.rectTransform.anchoredPosition = new Vector2(8, 50);
parentImage.alphaHitTestMinimumThreshold = 0.5f;
childImage.alphaHitTestMinimumThreshold = 0.5f;
// Yield one frame so that all tests below work.
yield return null;
}
[Test]
[TestCase( 0f, -40f, false, false, TestName = "Should not hit either button (outside of both boundaries)")]
[TestCase( 0f, 0f, true, false, TestName = "Should hit the parent (opaque pixel), but not the child (outside)")]
[TestCase(-30f, -30f, false, false, TestName = "Should not hit the parent (transparent pixel), nor the child (outside)")]
[TestCase( 10f, 30f, false, true, TestName = "Should not hit the parent (transparent pixel), but hit the child (opaque pixel),")]
[TestCase( 5f, 30f, true, true, TestName = "Should hit the parent (opaque pixel), and the child (opaque pixel)")]
[TestCase( -5f, 30f, true, false, TestName = "Should hit the parent (opaque pixel), but not the child (transparent pixel)")]
[TestCase(-10f, 30f, false, false, TestName = "Should not hit the parent (transparent pixel), nor the child (transparent pixel)")]
[TestCase( 8f, 50f, false, true, TestName = "Should not hit the parent (outside), but hit the child (opaque pixel)")]
[TestCase(-10f, 30f, false, false, TestName = "Should not hit the parent (outside), nor the child (transparent pixel)")]
public void GraphicRaycaster_ChildButtonOutsideOfParentButton(float x, float y, bool hitParent, bool hitChild)
{
var results = new List<RaycastResult>();
var pointerEvent = new PointerEventData(m_EventSystem)
{
position = new Vector2(Screen.width / 2f + x, Screen.height / 2f + y)
};
m_EventSystem.RaycastAll(pointerEvent, results);
if (hitParent == false && hitChild == false)
{
Assert.IsEmpty(results, "Expected no results from a raycast.");
}
else
{
if (hitParent && hitChild)
Assert.AreEqual(2, results.Count, "Expected 2 results from a raycast.");
else
Assert.AreEqual(1, results.Count, "Expected 1 result from a raycast.");
int hitIndex = 0;
if (hitChild)
{
Assert.AreSame(m_ChildButton.gameObject, results[hitIndex].gameObject);
hitIndex++;
}
if (hitParent)
{
Assert.AreSame(m_ParentButton.gameObject, results[hitIndex].gameObject);
}
}
}
[TearDown]
public void TearDown()
{
Object.DestroyImmediate(m_Camera.gameObject);
Object.DestroyImmediate(m_EventSystem.gameObject);
Object.DestroyImmediate(m_Canvas.gameObject);
}
}

2
Packages/com.unity.ugui/Tests/Runtime/UGUI/EventSystem/GraphicRaycasterButtonTests.cs.meta

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 53ee1d135588bf447a7af7ba2e8709d7

137
Packages/com.unity.ugui/Tests/Runtime/UGUI/Graphic/ImageTests.cs

@ -1,7 +1,6 @@
using NUnit.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine.EventSystems;
namespace UnityEngine.UI.Tests namespace UnityEngine.UI.Tests
{ {
@ -9,29 +8,29 @@ namespace UnityEngine.UI.Tests
internal class ImageTests internal class ImageTests
{ {
Image m_Image; Image m_Image;
private Sprite m_Sprite;
private Sprite m_OverrideSprite;
Texture2D texture = new Texture2D(128, 128);
Texture2D overrideTexture = new Texture2D(512, 512);
Sprite m_Sprite;
Sprite m_OverrideSprite;
readonly Texture2D texture = new Texture2D(128, 128);
readonly Texture2D overrideTexture = new Texture2D(512, 512);
bool m_dirtyVert; bool m_dirtyVert;
bool m_dirtyLayout; bool m_dirtyLayout;
bool m_dirtyMaterial; bool m_dirtyMaterial;
Camera m_camera; Camera m_camera;
GameObject m_CanvasRoot;
Canvas m_CanvasRoot;
[SetUp] [SetUp]
public void TestSetup() public void TestSetup()
{ {
m_CanvasRoot = new GameObject("Canvas", typeof(RectTransform), typeof(Canvas));
var canvasGO = new GameObject("Canvas", typeof(RectTransform), typeof(Canvas));
m_CanvasRoot = canvasGO.GetComponent<Canvas>();
GameObject gameObject = new GameObject("Image", typeof(RectTransform), typeof(Image)); GameObject gameObject = new GameObject("Image", typeof(RectTransform), typeof(Image));
gameObject.transform.SetParent(m_CanvasRoot.transform); gameObject.transform.SetParent(m_CanvasRoot.transform);
m_Image = gameObject.GetComponent<Image>();
m_camera = new GameObject("Camera", typeof(Camera)).GetComponent<Camera>(); m_camera = new GameObject("Camera", typeof(Camera)).GetComponent<Camera>();
m_Image = gameObject.GetComponent<Image>();
Color[] colors = new Color[128 * 128]; Color[] colors = new Color[128 * 128];
for (int y = 0; y < 128; y++) for (int y = 0; y < 128; y++)
for (int x = 0; x < 128; x++) for (int x = 0; x < 128; x++)
@ -61,11 +60,13 @@ namespace UnityEngine.UI.Tests
[TearDown] [TearDown]
public void TearDown() public void TearDown()
{ {
Object.DestroyImmediate(m_CanvasRoot.gameObject);
Object.DestroyImmediate(m_camera.gameObject);
m_Image = null; m_Image = null;
m_Sprite = null; m_Sprite = null;
GameObject.DestroyImmediate(m_CanvasRoot);
GameObject.DestroyImmediate(m_camera.gameObject);
m_OverrideSprite = null;
m_CanvasRoot = null;
m_camera = null; m_camera = null;
} }
@ -124,9 +125,8 @@ namespace UnityEngine.UI.Tests
[Test] [Test]
public void RaycastOverImageWithNonZeroSpritePosition_AlphaHitTestMinimumThreshold() public void RaycastOverImageWithNonZeroSpritePosition_AlphaHitTestMinimumThreshold()
{ {
var canvas = m_CanvasRoot.GetComponent<Canvas>();
canvas.renderMode = RenderMode.ScreenSpaceCamera;
canvas.worldCamera = m_camera;
m_CanvasRoot.renderMode = RenderMode.ScreenSpaceCamera;
m_CanvasRoot.worldCamera = m_camera;
// Create a square sprite (64x64) in the middle of a transparent area (128x128). // Create a square sprite (64x64) in the middle of a transparent area (128x128).
Color[] colors = new Color[128 * 128]; Color[] colors = new Color[128 * 128];
@ -150,10 +150,74 @@ namespace UnityEngine.UI.Tests
Assert.True(m_Image.Raycast(new Vector2(Screen.width / 2.0f, Screen.height / 2.0f), m_camera), "Expected raycast to hit when clicking center of screen."); Assert.True(m_Image.Raycast(new Vector2(Screen.width / 2.0f, Screen.height / 2.0f), m_camera), "Expected raycast to hit when clicking center of screen.");
} }
[Test]
public void RaycastOverImageWithTransparentPixels_AlphaHitTestMinimumThreshold()
{
m_CanvasRoot.renderMode = RenderMode.ScreenSpaceCamera;
m_CanvasRoot.worldCamera = m_camera;
// Create a 128x128 sprite that has a red dash "-" which is 32px tall. Remaining pixels are transparent.
Color[] colors = new Color[128 * 128];
for (int y = 48; y < 80; y++)
for (int x = 0; x < 128; x++)
colors[x + 128 * y] = Color.red;
texture.SetPixels(colors);
texture.Apply();
var sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100);
var parentImage = m_Image;
parentImage.sprite = sprite;
parentImage.alphaHitTestMinimumThreshold = 0.5f;
parentImage.SetNativeSize();
// Duplicate Image as a child GO
var childImageGO = Object.Instantiate(parentImage.gameObject, parentImage.transform);
var childImage = childImageGO.GetComponent<Image>();
childImage.alphaHitTestMinimumThreshold = 0.5f; // Also set the threshold on the child, this property is not serialized.
childImage.rectTransform.anchoredPosition = new Vector2(0, 160);
// Parent Image Raycasts
var parentCenter = new Vector2(Screen.width / 2.0f, Screen.height / 2.0f);
Assert.True(parentImage.Raycast(parentCenter, m_camera), "Expected raycast to hit when clicking on a non-transparent pixel of the image.");
Assert.False(parentImage.Raycast(parentCenter + new Vector2(60, 60), m_camera), "Expected raycast to fail when clicking on a transparent pixel of the image.");
Assert.True(parentImage.Raycast(parentCenter + new Vector2(70, 0), m_camera), "Expected raycast to hit when clicking outside the image, next to a non-transparent area.");
Assert.False(parentImage.Raycast(parentCenter + new Vector2(70, 60), m_camera), "Expected raycast to fail when clicking outside the image, next to a transparent area.");
// Child Image Raycasts
var childCenter = parentCenter + childImage.rectTransform.anchoredPosition;
Assert.True(childImage.Raycast(childCenter, m_camera), "Expected raycast to hit when clicking on a non-transparent pixel of the child image.");
Assert.False(childImage.Raycast(childCenter + new Vector2(60, 60), m_camera), "Expected raycast to fail when clicking on a transparent pixel of the child image.");
Assert.True(childImage.Raycast(childCenter + new Vector2(70, 0), m_camera), "Expected raycast to hit when clicking outside the child image, next to a non-transparent area.");
Assert.False(childImage.Raycast(childCenter + new Vector2(70, 60), m_camera), "Expected raycast to fail when clicking outside the child image, next to a transparent area.");
}
[Test]
public void RaycastOverImageWithPreserveAspectRatio_AlphaHitTestMinimumThreshold()
{
m_CanvasRoot.renderMode = RenderMode.ScreenSpaceCamera;
m_CanvasRoot.worldCamera = m_camera;
texture.wrapMode = TextureWrapMode.Clamp;
m_Image.sprite = m_Sprite;
m_Image.alphaHitTestMinimumThreshold = 0.5f;
m_Image.preserveAspect = true;
// Make the image 100 units wider than the sprite's original size.
m_Image.SetNativeSize();
m_Image.rectTransform.sizeDelta += new Vector2(100, 0);
// Parent Image Raycasts
var imageCenter = new Vector2(Screen.width / 2.0f, Screen.height / 2.0f);
Assert.True(m_Image.Raycast(imageCenter + new Vector2(-40, 0), m_camera), "Expected raycast to hit when clicking on a non-transparent pixel of the image.");
Assert.False(m_Image.Raycast(imageCenter + new Vector2(40, 0), m_camera), "Expected raycast to fail when clicking on a transparent pixel of the image.");
Assert.False(m_Image.Raycast(imageCenter + new Vector2(80, 0), m_camera), "Expected raycast to fail when clicking outside the sprite but still inside the image.");
Assert.False(m_Image.Raycast(imageCenter + new Vector2(120, 0), m_camera), "Expected raycast to fail when clicking outside the image, next to a transparent area.");
}
[Test] [Test]
public void RaycastOverImage_IgnoresDisabledCanvasGroup() public void RaycastOverImage_IgnoresDisabledCanvasGroup()
{ {
var canvasGroup = m_CanvasRoot.AddComponent<CanvasGroup>();
var canvasGroup = m_CanvasRoot.gameObject.AddComponent<CanvasGroup>();
canvasGroup.blocksRaycasts = false; canvasGroup.blocksRaycasts = false;
canvasGroup.enabled = false; canvasGroup.enabled = false;
@ -167,21 +231,38 @@ namespace UnityEngine.UI.Tests
[TestCase(typeof(RectMask2D), false, true)] [TestCase(typeof(RectMask2D), false, true)]
public void RaycastImageOutsideOfMaskWithMaskableSet_ReturnsExpected(Type maskType, bool maskable, bool expectedHit) public void RaycastImageOutsideOfMaskWithMaskableSet_ReturnsExpected(Type maskType, bool maskable, bool expectedHit)
{ {
var maskGameObject = new GameObject("Mask", typeof(RectTransform), maskType);
maskGameObject.transform.SetParent(m_CanvasRoot.transform);
var mask = maskGameObject.GetComponent(maskType);
m_Image.transform.SetParent(maskGameObject.transform);
m_CanvasRoot.renderMode = RenderMode.ScreenSpaceCamera;
m_CanvasRoot.worldCamera = m_camera;
var maskRect = mask.GetComponent<RectTransform>();
maskRect.position = new Vector3(0, 0, 0);
maskRect.sizeDelta = new Vector2(100, 100);
m_Image.rectTransform.position = new Vector3(500, 500, 0);
m_Image.rectTransform.sizeDelta = new Vector2(10, 10);
var maskRT = new GameObject("Mask", typeof(RectTransform), maskType).GetComponent<RectTransform>();
maskRT.SetParent(m_CanvasRoot.transform, false);
maskRT.anchoredPosition = Vector2.zero;
maskRT.sizeDelta = new Vector2(100, 100);
m_Image.transform.SetParent(maskRT);
m_Image.rectTransform.anchoredPosition = new Vector2(500, 500);
m_Image.rectTransform.sizeDelta = new Vector2(10, 10);
m_Image.maskable = maskable; m_Image.maskable = maskable;
bool raycast = m_Image.Raycast(new Vector2(505, 505), m_camera);
Assert.AreEqual(expectedHit, raycast);
var imagePosition = RectTransformUtility.WorldToScreenPoint(m_camera, m_Image.rectTransform.position);
bool raycast = m_Image.Raycast(imagePosition, m_camera);
Assert.AreEqual(expectedHit, raycast, "Raycast is not working as expected when Image doesn't have a Sprite.");
m_Image.sprite = m_Sprite;
// Image raycast returns true when alphaHitTestMinimumThreshold = 0
m_Image.alphaHitTestMinimumThreshold = 0f;
raycast = m_Image.Raycast(imagePosition, m_camera);
Assert.AreEqual(expectedHit, raycast, "Raycast is not working as expected when Image has a Sprite.");
m_Image.alphaHitTestMinimumThreshold = 0.1f;
raycast = m_Image.Raycast(imagePosition, m_camera);
Assert.AreEqual(expectedHit, raycast, "Raycast is not working as expected when Image has a Sprite and clickin on a more transparent pixel than alphaHitTestMinimumThreshold.");
m_Image.alphaHitTestMinimumThreshold = 0.8f;
raycast = m_Image.Raycast(imagePosition, m_camera);
Assert.False(raycast, "Expected raycast to fail when clicking on a pixel that is more transparent than alphaHitTestMinimumThreshold.");
} }
[Test] [Test]

2
Packages/com.unity.ugui/package.json

@ -19,5 +19,5 @@
"com.unity.modules.ui": "1.0.0", "com.unity.modules.ui": "1.0.0",
"com.unity.modules.imgui": "1.0.0" "com.unity.modules.imgui": "1.0.0"
}, },
"_fingerprint": "4ee0fac0c6e4c152adcf1ae6457981f8a39985db"
"_fingerprint": "52e65280e89ee09a5b287dc793f9464bcd213b41"
} }

1
Packages/com.unity.visualeffectgraph/Editor/SamplesLinkPackageManagerExtension.cs

@ -19,6 +19,7 @@ class SamplesLinkPackageManagerExtension : IPackageManagerExtension
{ {
samplesButton = new Button(); samplesButton = new Button();
samplesButton.text = SAMPLEBUTTON_TEXT; samplesButton.text = SAMPLEBUTTON_TEXT;
samplesButton.style.whiteSpace = WhiteSpace.Normal; // Allow wrapping
samplesButton.clickable.clicked += () => Application.OpenURL(GITHUB_URL); samplesButton.clickable.clicked += () => Application.OpenURL(GITHUB_URL);
return samplesButton; return samplesButton;
} }

12
Packages/com.unity.visualeffectgraph/Editor/ShaderGraph/Templates/VFXConfig.template.hlsl

@ -60,6 +60,16 @@ UNITY_INSTANCING_BUFFER_END(PerInstance)
#define VFX_GET_INSTANCE_ID(i) input.instanceID #define VFX_GET_INSTANCE_ID(i) input.instanceID
#endif #endif
// These are supposed to be passed as a instanced constant property (unity_SpriteFlipArray) for sprites, but it doesn't work for VFX Shadergraph mesh outputs
// because the instancing constant arrays (UNITY_DEFINE_INSTANCED_PROP...) are used for per-effect instancing in VFX, not per-particle instancing.
// In any case, the value passed for VFX is always (1,1) currently, and not user-modifiable, so no need to get it from a constant buffer.
#define unity_SpriteProps float4(1,1,1,1)
#ifdef unity_SpriteColor
#undef unity_SpriteColor
#endif
#define unity_SpriteColor float4(1,1,1,1)
$splice(VFXPerBlockDefines) $splice(VFXPerBlockDefines)
$splice(VFXSRPCommonInclude) $splice(VFXSRPCommonInclude)
@ -218,7 +228,7 @@ void GetElementData(inout AttributesElement element)
#if !VFX_HAS_INDIRECT_DRAW && !HAS_STRIPS #if !VFX_HAS_INDIRECT_DRAW && !HAS_STRIPS
if (attributes.alive) if (attributes.alive)
#endif
#endif
{ {
$splice(VFXProcessBlocks) $splice(VFXProcessBlocks)
} }

2
Packages/com.unity.visualeffectgraph/Editor/Utilities/pCache/BakeTool/PointCacheBakeTool.cs

@ -33,7 +33,7 @@ namespace UnityEditor.Experimental.VFX.Utility
static partial class Contents static partial class Contents
{ {
public static GUIContent title = new GUIContent("pCache Tool");
public static GUIContent title = new GUIContent("Point Cache Tool");
public static GUIContent mode = new GUIContent("Bake Mode"); public static GUIContent mode = new GUIContent("Bake Mode");
} }
} }

6
Packages/com.unity.visualeffectgraph/Shaders/ParticleLines/PassForwardCommon.template

@ -24,6 +24,8 @@ struct ps_output
float4 color : SV_Target0; float4 color : SV_Target0;
#if VFX_FEATURE_MOTION_VECTORS_FORWARD #if VFX_FEATURE_MOTION_VECTORS_FORWARD
float4 motionVector : SV_Target1; float4 motionVector : SV_Target1;
#elif VFX_WRITE_RENDERING_LAYERS
uint outRenderingLayers : SV_Target1;
#endif #endif
}; };
@ -73,6 +75,10 @@ ps_output frag(ps_input i)
o.motionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass o.motionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
o.outRenderingLayers = EncodeMeshRenderingLayer();
#endif
${VFXUnlitDebugDisplay} ${VFXUnlitDebugDisplay}
return o; return o;

6
Packages/com.unity.visualeffectgraph/Shaders/ParticleLinesSW/PassForwardCommon.template

@ -33,6 +33,8 @@ struct ps_output
float4 color : SV_Target0; float4 color : SV_Target0;
#if VFX_FEATURE_MOTION_VECTORS_FORWARD #if VFX_FEATURE_MOTION_VECTORS_FORWARD
float4 motionVector : SV_Target1; float4 motionVector : SV_Target1;
#elif VFX_WRITE_RENDERING_LAYERS
uint outRenderingLayers : SV_Target1;
#endif #endif
}; };
@ -91,6 +93,10 @@ ps_output frag(ps_input i)
o.motionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass o.motionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
o.outRenderingLayers = EncodeMeshRenderingLayer();
#endif
${VFXUnlitDebugDisplay} ${VFXUnlitDebugDisplay}
return o; return o;

7
Packages/com.unity.visualeffectgraph/Shaders/ParticleMeshes/PassForwardCommon.template

@ -64,7 +64,10 @@ struct ps_output
float4 color : SV_Target0; float4 color : SV_Target0;
#if VFX_FEATURE_MOTION_VECTORS_FORWARD #if VFX_FEATURE_MOTION_VECTORS_FORWARD
float4 outMotionVector : SV_Target1; float4 outMotionVector : SV_Target1;
#elif VFX_WRITE_RENDERING_LAYERS
uint outRenderingLayers : SV_Target1;
#endif #endif
}; };
#define VFX_VARYING_PS_INPUTS ps_input #define VFX_VARYING_PS_INPUTS ps_input
@ -156,6 +159,10 @@ ps_output frag(ps_input i)
o.outMotionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass o.outMotionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
o.outRenderingLayers = EncodeMeshRenderingLayer();
#endif
${VFXUnlitDebugDisplay} ${VFXUnlitDebugDisplay}
return o; return o;

6
Packages/com.unity.visualeffectgraph/Shaders/ParticlePlanarPrimitives/PassForwardCommon.template

@ -56,6 +56,8 @@ struct ps_output
float4 color : SV_Target0; float4 color : SV_Target0;
#if VFX_FEATURE_MOTION_VECTORS_FORWARD #if VFX_FEATURE_MOTION_VECTORS_FORWARD
float4 outMotionVector : SV_Target1; float4 outMotionVector : SV_Target1;
#elif VFX_WRITE_RENDERING_LAYERS
uint outRenderingLayers : SV_Target1;
#endif #endif
}; };
@ -152,6 +154,10 @@ ps_output frag(ps_input i,
o.outMotionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass o.outMotionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
o.outRenderingLayers = EncodeMeshRenderingLayer();
#endif
${VFXUnlitDebugDisplay} ${VFXUnlitDebugDisplay}
return o; return o;

6
Packages/com.unity.visualeffectgraph/Shaders/ParticlePoints/PassForwardCommon.template

@ -27,6 +27,8 @@ struct ps_output
float4 color : SV_Target0; float4 color : SV_Target0;
#if VFX_FEATURE_MOTION_VECTORS_FORWARD #if VFX_FEATURE_MOTION_VECTORS_FORWARD
float4 motionVector : SV_Target1; float4 motionVector : SV_Target1;
#elif VFX_WRITE_RENDERING_LAYERS
uint outRenderingLayers : SV_Target1;
#endif #endif
}; };
@ -75,6 +77,10 @@ ps_output frag(ps_input i)
o.motionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass o.motionVector.a = o.color.a < i.VFX_VARYING_ALPHATHRESHOLD ? 0.0f : 1.0f; //Independant clipping for motion vector pass
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
o.outRenderingLayers = EncodeMeshRenderingLayer();
#endif
${VFXUnlitDebugDisplay} ${VFXUnlitDebugDisplay}
return o; return o;

6
Packages/com.unity.visualeffectgraph/Shaders/VFXCommon.hlsl

@ -1,6 +1,12 @@
// Required for the correct use of cross platform abstractions. // Required for the correct use of cross platform abstractions.
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
// Configuration check
#if VFX_FEATURE_MOTION_VECTORS_FORWARD && VFX_WRITE_RENDERING_LAYERS
//VFX_FEATURE_MOTION_VECTORS_FORWARD is HDRP only, _WRITE_RENDERING_LAYERS is URP only, both can't be defined at same time
#error Unexpected configuration VFX_FEATURE_MOTION_VECTORS_FORWARD & VFX_WRITE_RENDERING_LAYERS
#endif
//Helper to disable bounding box compute code //Helper to disable bounding box compute code
#define USE_DYNAMIC_AABB 1 #define USE_DYNAMIC_AABB 1

8
Packages/com.unity.visualeffectgraph/Shaders/VFXPassDepthCommonFragmentUnlit.template

@ -44,6 +44,10 @@ void frag(ps_input i
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_SHADOW #elif VFX_PASSDEPTH == VFX_PASSDEPTH_SHADOW
, out float4 dummy : SV_Target0 , out float4 dummy : SV_Target0
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
, out uint outRenderingLayers : SV_Target1
#endif
) )
{ {
UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i);
@ -102,4 +106,8 @@ void frag(ps_input i
#else #else
#error VFX_PASSDEPTH undefined #error VFX_PASSDEPTH undefined
#endif #endif
#if VFX_WRITE_RENDERING_LAYERS
outRenderingLayers = EncodeMeshRenderingLayer();
#endif
} }

2
Packages/com.unity.visualeffectgraph/package.json

@ -36,5 +36,5 @@
] ]
} }
], ],
"_fingerprint": "cf393c26ba9954fad48284ac88434a5e280e0ecb"
"_fingerprint": "a6483769d4fcddbd5a94cc537e11d08913261435"
} }
Loading…
Cancel
Save