diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Widgets/DebugUIButton.prefab b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Widgets/DebugUIButton.prefab
index b9308fdb7d6..480dfbf43de 100644
--- a/Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Widgets/DebugUIButton.prefab
+++ b/Packages/com.unity.render-pipelines.core/Runtime/Debugging/Prefabs/Widgets/DebugUIButton.prefab
@@ -1,22 +1,12 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
---- !u!1001 &100100000
-Prefab:
- m_ObjectHideFlags: 1
- serializedVersion: 2
- m_Modification:
- m_TransformParent: {fileID: 0}
- m_Modifications: []
- m_RemovedComponents: []
- m_ParentPrefab: {fileID: 0}
- m_RootGameObject: {fileID: 1349998662384948}
- m_IsPrefabParent: 1
--- !u!1 &1346781532117404
GameObject:
m_ObjectHideFlags: 0
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
- serializedVersion: 5
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
m_Component:
- component: {fileID: 224019920140556580}
- component: {fileID: 222080438315005238}
@@ -28,44 +18,53 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
---- !u!1 &1349998662384948
-GameObject:
+--- !u!224 &224019920140556580
+RectTransform:
m_ObjectHideFlags: 0
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
- serializedVersion: 5
- m_Component:
- - component: {fileID: 224438017010656346}
- - component: {fileID: 222869912906783786}
- - component: {fileID: 114163390439191134}
- - component: {fileID: 114467080906542876}
- - component: {fileID: 114307598231942114}
- m_Layer: 5
- m_Name: DebugUI Button
- m_TagString: Untagged
- m_Icon: {fileID: 0}
- m_NavMeshLayer: 0
- m_StaticEditorFlags: 0
- m_IsActive: 1
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1346781532117404}
+ 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: 224438017010656346}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 1, y: 1}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 0}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &222080438315005238
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1346781532117404}
+ m_CullTransparentMesh: 1
--- !u!114 &114152708984687776
MonoBehaviour:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1346781532117404}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+ m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.8, g: 0.8, b: 0.8, a: 1}
m_RaycastTarget: 1
+ m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+ m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
- m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
- Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 74a5091d8707f334b9a5c31ef71a64ba, type: 3}
m_FontSize: 16
@@ -80,25 +79,74 @@ MonoBehaviour:
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Button
+--- !u!1 &1349998662384948
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 224438017010656346}
+ - component: {fileID: 222869912906783786}
+ - component: {fileID: 114163390439191134}
+ - component: {fileID: 114467080906542876}
+ - component: {fileID: 114307598231942114}
+ m_Layer: 5
+ m_Name: DebugUIButton
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!224 &224438017010656346
+RectTransform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1349998662384948}
+ 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:
+ - {fileID: 224019920140556580}
+ m_Father: {fileID: 0}
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+ m_AnchorMin: {x: 0, y: 0}
+ m_AnchorMax: {x: 0, y: 0}
+ m_AnchoredPosition: {x: 0, y: 0}
+ m_SizeDelta: {x: 0, y: 26}
+ m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &222869912906783786
+CanvasRenderer:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1349998662384948}
+ m_CullTransparentMesh: 1
--- !u!114 &114163390439191134
MonoBehaviour:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1349998662384948}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+ m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
+ m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+ m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
- m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
- Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: d49e78756811bfa4aafb8b6535417991, type: 3}
m_Type: 1
m_PreserveAspect: 0
@@ -107,33 +155,23 @@ MonoBehaviour:
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
---- !u!114 &114307598231942114
-MonoBehaviour:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
- m_GameObject: {fileID: 1349998662384948}
- m_Enabled: 1
- m_EditorHideFlags: 0
- m_Script: {fileID: 11500000, guid: 8bff080b4e3bae64c80b54402ced6cc6, type: 3}
- m_Name:
- m_EditorClassIdentifier:
- colorDefault: {r: 0.8, g: 0.8, b: 0.8, a: 1}
- colorSelected: {r: 0.25, g: 0.65, b: 0.8, a: 1}
- nameLabel: {fileID: 114152708984687776}
+ m_UseSpriteMesh: 0
+ m_PixelsPerUnitMultiplier: 1
--- !u!114 &114467080906542876
MonoBehaviour:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1349998662384948}
m_Enabled: 1
m_EditorHideFlags: 0
- m_Script: {fileID: 1392445389, guid: f70555f144d8491a825f0804e09c671c, type: 3}
+ m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 0
+ m_WrapAround: 0
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
@@ -143,71 +181,51 @@ MonoBehaviour:
m_NormalColor: {r: 0, g: 0, b: 0, a: 0.60784316}
m_HighlightedColor: {r: 0, g: 0, b: 0, a: 0.8666667}
m_PressedColor: {r: 0.28235295, g: 0.28235295, b: 0.28235295, a: 1}
+ m_SelectedColor: {r: 0, g: 0, b: 0, a: 0.8666667}
m_DisabledColor: {r: 0, g: 0, b: 0, a: 0.28627452}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
+ m_SelectedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
+ m_SelectedTrigger: Highlighted
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 114163390439191134}
m_OnClick:
m_PersistentCalls:
- m_Calls: []
- m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
- Culture=neutral, PublicKeyToken=null
---- !u!222 &222080438315005238
-CanvasRenderer:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
- m_GameObject: {fileID: 1346781532117404}
---- !u!222 &222869912906783786
-CanvasRenderer:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
- m_GameObject: {fileID: 1349998662384948}
---- !u!224 &224019920140556580
-RectTransform:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
- m_GameObject: {fileID: 1346781532117404}
- 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_Children: []
- m_Father: {fileID: 224438017010656346}
- m_RootOrder: 0
- m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 0}
- m_AnchorMax: {x: 1, y: 1}
- m_AnchoredPosition: {x: 0, y: 0}
- m_SizeDelta: {x: 0, y: 0}
- m_Pivot: {x: 0.5, y: 0.5}
---- !u!224 &224438017010656346
-RectTransform:
- m_ObjectHideFlags: 1
- m_PrefabParentObject: {fileID: 0}
- m_PrefabInternal: {fileID: 100100000}
+ m_Calls:
+ - m_Target: {fileID: 114307598231942114}
+ m_TargetAssemblyTypeName: UnityEngine.Rendering.UI.DebugUIHandlerButton,
+ Unity.RenderPipelines.Core.Runtime
+ m_MethodName: OnAction
+ m_Mode: 1
+ m_Arguments:
+ m_ObjectArgument: {fileID: 0}
+ m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
+ m_IntArgument: 0
+ m_FloatArgument: 0
+ m_StringArgument:
+ m_BoolArgument: 0
+ m_CallState: 1
+--- !u!114 &114307598231942114
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1349998662384948}
- 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_Children:
- - {fileID: 224019920140556580}
- m_Father: {fileID: 0}
- m_RootOrder: 0
- m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
- m_AnchorMin: {x: 0, y: 0}
- m_AnchorMax: {x: 0, y: 0}
- m_AnchoredPosition: {x: 0, y: 0}
- m_SizeDelta: {x: 0, y: 26}
- m_Pivot: {x: 0.5, y: 0.5}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 8bff080b4e3bae64c80b54402ced6cc6, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ colorDefault: {r: 0.8, g: 0.8, b: 0.8, a: 1}
+ colorSelected: {r: 0.25, g: 0.65, b: 0.8, a: 1}
+ nameLabel: {fileID: 114152708984687776}
diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs b/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs
index b37b43388a9..10e48ef41c8 100644
--- a/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs
+++ b/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandleSystem.cs
@@ -94,8 +94,7 @@ public void Dispose()
///
/// Initial reference rendering width.
/// Initial reference rendering height.
- /// Use legacy hardware DynamicResolution control in RTHandle system.
- public void Initialize(int width, int height, bool useLegacyDynamicResControl = false)
+ public void Initialize(int width, int height)
{
if (m_AutoSizedRTs.Count != 0)
{
@@ -110,10 +109,22 @@ public void Initialize(int width, int height, bool useLegacyDynamicResControl =
m_MaxWidths = width;
m_MaxHeights = height;
+ m_HardwareDynamicResRequested = DynamicResolutionHandler.instance.RequestsHardwareDynamicResolution();
+ }
+
+ ///
+ /// Initialize the RTHandle system.
+ ///
+ /// Initial reference rendering width.
+ /// Initial reference rendering height.
+ /// Use legacy hardware DynamicResolution control in RTHandle system.
+ [Obsolete("useLegacyDynamicResControl is deprecated. Please use SetHardwareDynamicResolutionState() instead.")]
+ public void Initialize(int width, int height, bool useLegacyDynamicResControl = false)
+ {
+ Initialize(width, height);
+
if (useLegacyDynamicResControl)
m_HardwareDynamicResRequested = true;
- else
- m_HardwareDynamicResRequested = DynamicResolutionHandler.instance.RequestsHardwareDynamicResolution();
}
///
diff --git a/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs b/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs
index abe4d091b36..77a0374c165 100644
--- a/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs
+++ b/Packages/com.unity.render-pipelines.core/Runtime/Textures/RTHandles.cs
@@ -1,3 +1,4 @@
+using System;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.Rendering
@@ -501,12 +502,23 @@ private static RTHandle Alloc(RTHandle tex)
return null;
}
+ ///
+ /// Initialize the default RTHandle system.
+ ///
+ /// Initial reference rendering width.
+ /// Initial reference rendering height.
+ public static void Initialize(int width, int height)
+ {
+ s_DefaultInstance.Initialize(width, height);
+ }
+
///
/// Initialize the default RTHandle system.
///
/// Initial reference rendering width.
/// Initial reference rendering height.
/// Use legacy hardware DynamicResolution control in the default RTHandle system.
+ [Obsolete("useLegacyDynamicResControl is deprecated. Please use SetHardwareDynamicResolutionState() instead.")]
public static void Initialize(int width, int height, bool useLegacyDynamicResControl = false)
{
s_DefaultInstance.Initialize(width, height, useLegacyDynamicResControl);
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md
index 0c4fe4febcb..b352d832ee0 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/TableOfContents.md
@@ -248,7 +248,13 @@
* [Depth of Field](Post-Processing-Depth-of-Field.md)
* [Film Grain](Post-Processing-Film-Grain.md)
* [Lens Distortion](Post-Processing-Lens-Distortion.md)
- * [Lens Flare (SRP)](shared/lens-flare/lens-flare-component.md)
+ * [Lens flares](shared/lens-flare/lens-flare.md)
+ * [Choose a lens flare type](shared/lens-flare/choose-a-lens-flare-type.md)
+ * [Add lens flares](shared/lens-flare/lens-flare-component.md)
+ * [Add screen space lens flares](shared/lens-flare/Override-Screen-Space-Lens-Flare.md)
+ * [Lens Flare (SRP) reference](shared/lens-flare/lens-flare-reference.md)
+ * [Lens Flare (SRP) Data Asset reference](shared/lens-flare/lens-flare-asset.md)
+ * [Screen Space Lens Flare override reference](shared/lens-flare/reference-screen-space-lens-flare.md)
* [Panini Projection](Post-Processing-Panini-Projection.md)
* [Vignette](Post-Processing-Vignette.md)
* [Motion effects](motion-effects.md)
@@ -299,6 +305,10 @@
* [Lighting environment reference](reference-lighting-environment.md)
* [Ambient Occlusion reference](reference-ambient-occlusion.md)
* [IES Importer reference](IES-Importer.md)
+ * [Lens flares reference](shared/lens-flare/lens-flare-lens-flares-reference.md)
+ * [Lens Flare (SRP) reference](shared/lens-flare/lens-flare-reference.md)
+ * [Lens Flare (SRP) Data Asset reference](shared/lens-flare/lens-flare-asset.md)
+ * [Screen Space Lens Flare override reference](shared/lens-flare/reference-screen-space-lens-flare.md)
* [Volumetric lighting reference](reference-volumetric-lighting.md)
* [Screen Space Global Illumination](reference-screen-space-global-illumination.md)
* [Screen Space Lens Flare](shared/lens-flare/reference-screen-space-lens-flare.md)
@@ -389,6 +399,5 @@
* [Rendering and post-processing reference](reference-rendering-post-processing.md)
* [Dynamic Resolution component reference](reference-dynamic-resolution.md)
* [High Dynamic Range (HDR) tonemapping reference](reference-hdr-tonemapping.md)
- * [Lens Flare (SRP) Data Asset reference](shared/lens-flare/lens-flare-asset.md)
* [Custom Pass reference](custom-pass-reference.md)
* [HDRP Glossary](Glossary.md)
\ No newline at end of file
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/Override-Screen-Space-Lens-Flare.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/Override-Screen-Space-Lens-Flare.md
index b030867ade9..2b0202333e4 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/Override-Screen-Space-Lens-Flare.md
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/Override-Screen-Space-Lens-Flare.md
@@ -1,4 +1,4 @@
-# Screen Space Lens Flare
+# Add screen space lens flares

@@ -50,7 +50,7 @@ To enable screen space lens flares, follow these steps:
If lens flares don't appear, check the settings of the **Bloom** override in the default volume in **Edit** > **Project Settings** > **Graphics** > **HDRP Global Settings** > **Frame Settings (Default Values)** > **Default Volume Profile Asset** > **Bloom**.
-For information about screen space lens flare properties, refer to [Screen Space Lens Flare reference](shared/lens-flare/reference-screen-space-lens-flare.md).
+For information about screen space lens flare properties, refer to [Screen Space Lens Flare reference](reference-screen-space-lens-flare.md).
[!include[](../../snippets/volume-override-api.md)]
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/choose-a-lens-flare-type.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/choose-a-lens-flare-type.md
new file mode 100644
index 00000000000..a58d0edbdb7
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/choose-a-lens-flare-type.md
@@ -0,0 +1,35 @@
+# Choose a lens flare type
+
+You can add the following types of lens flares:
+
+- [Lens flares](lens-flare-component.md) - use a **Lens Flare (SRP)** component to create lens flares for lights that have specific locations in your scene, for example the sun or bright bulbs.
+- [Screen space lens flares](Override-Screen-Space-Lens-Flare.md) - use a **Screen Space Lens Flare** override to create lens flares for emissive surfaces, bright spots, and onscreen lights.
+
+You can use both types in the same scene.
+
+Use the following table to help you choose a lens flare type:
+
+| Feature | Lens Flare (SRP) component | Screen Space Lens Flare override |
+|-|-|-|
+| Typical uses | Lens flares from the sun and specific lights, custom flare shapes, and cinematics | Lens flares on vehicles and water, first-person games, and science-fiction environments |
+| Supported platforms | All platforms except XR | All platforms |
+| CPU and GPU use | CPU and GPU | GPU |
+| Types of light | All Light objects, except Area Lights | All bright spots and visible lights |
+| Placement | Attach to individual lights. Place lens flares manually | Generate inside a volume. Place all lens flares automatically with a single setting |
+| Lens flares from offscreen lights | Yes | No |
+| Light streaks | No, unless you create them manually | Yes |
+| Configure flares | Configure per lens flare or per element | Configure for all lens flares together |
+| Configure flare elements | Configure many settings for each element, per lens flare | Configure several settings for elements, for all lens flares together |
+| Configure attenuation | Yes | No |
+| Affected by clouds, fog and water | Volumetric clouds and background clouds only | Yes |
+| Preserve aspect ratio | Yes | No |
+| Chromatic aberration | No | Yes |
+| Blend modes | Additive, Lerp, Premultiplied and Screen | Additive only |
+| Occlusion | Screen space occlusion, and geometric occlusion for offscreen lights. Configurable. Occlusion might not always work at the edge of the screen. | Screen space occlusion, generated from the color buffer. Not configurable |
+| Examples in [package samples](../../HDRP-Sample-Content.md) | Yes | No |
+
+## Additional resources
+
+- [Lens Flare (SRP) reference](lens-flare-srp-reference.md)
+- [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md)
+- [Screen Space Lens Flare override reference](reference-screen-space-lens-flare.md)
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-asset.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-asset.md
index 14954b00c8d..5fe0ce38b44 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-asset.md
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-asset.md
@@ -2,7 +2,7 @@
Unity’s [Scriptable Render Pipeline (SRP)](https://docs.unity3d.com/Manual/ScriptableRenderPipeline.html) includes the **Lens Flare Data** asset. You can use this asset to control the appearance of [Lens Flares](lens-flare-component.md) in your scene. This is the SRP equivalent of the Built-in Render Pipeline's [Flare](https://docs.unity3d.com/Manual/class-Flare.html) asset, which is incompatible with SRPs.
-To create a Lens Flare Data asset, select **Assets > Create > Lens Flare (SRP)**. To use this asset, assign it to the **Lens Flare Data** property of a [Lens Flare (SRP) component](lens-flare-component.md).
+To create a Lens Flare Data asset, select **Assets** > **Create** > **Lens Flare (SRP)**. To use this asset, assign it to the **Lens Flare Data** property of a [Lens Flare (SRP) component](lens-flare-component.md).
## Properties
@@ -38,7 +38,7 @@ The Lens Flare Element asset has the following properties:
#### Circle
-
+#### Circle
| **Property** | **Description** |
| ------------ | ------------------------------------------------------------ |
@@ -48,7 +48,7 @@ The Lens Flare Element asset has the following properties:
#### Polygon
-
+#### Polygon
| **Property** | **Description** |
| ------------ | ------------------------------------------------------------ |
@@ -60,8 +60,6 @@ The Lens Flare Element asset has the following properties:
## Color
-
-
| **Property** | **Description** |
| ----------------------- | ------------------------------------------------------------ |
| Tint | Changes the tint of the lens flare. If this asset is attached to the light, this property is based on the light tint. |
@@ -71,8 +69,6 @@ The Lens Flare Element asset has the following properties:
## Transform
-
-
| **Property** | **Description** |
| ----------------------- | ------------------------------------------------------------ |
| Position Offset | Defines the offset of the lens flare's position in screen space, relative to its source. |
@@ -83,7 +79,7 @@ The Lens Flare Element asset has the following properties:
## AxisTransform
-
+### Axis Transform
| **Property** | **Description** |
| ----------------- | ------------------------------------------------------------ |
@@ -95,8 +91,6 @@ The Lens Flare Element asset has the following properties:
## Distortion
-
-
| **Property** | **Description** |
| --------------- | ------------------------------------------------------------ |
| Enable | Set this property to True to enable distortion. |
@@ -116,8 +110,7 @@ The Lens Flare Element asset has the following properties:
| Length Spread | Controls how spread out multiple lens flare elements appear. |
| Relative To Center | If true the distortion is relative to center of the screen otherwise relative to lensFlare source screen position. |
-### Uniform
-
+#### Uniform
| **Property** | **Description** |
| --------------- | ------------------------------------------------------------ |
@@ -126,7 +119,7 @@ The Lens Flare Element asset has the following properties:
### Curve
-
+#### Curve
| **Property** | **Description** |
| ---------------- | ------------------------------------------------------------ |
@@ -137,7 +130,7 @@ The Lens Flare Element asset has the following properties:
### Random
-
+#### Random
| **Property** | **Description** |
| ------------------- | ------------------------------------------------------------ |
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-component.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-component.md
index 84d9b3ed903..b78e3fa3881 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-component.md
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-component.md
@@ -1,4 +1,4 @@
-# Lens Flare (SRP)
+# Add lens flares

@@ -10,7 +10,7 @@ Use the Lens Flare (SRP) component to create lens flares for lights that have sp
## Create a lens flare in SRP
-The Lens Flare (SRP) component controls where the lens flare is as well as properties such as attenuation and whether the lens flare considers occlusion. For properties that define how the lens flare looks, SRP uses the [Lens Flare (SRP) Data](shared/lens-flare/lens-flare-asset.md) asset. Each Lens Flare (SRP) component must reference a Lens Flare (SRP) data asset to display a lens flare on-screen.
+The Lens Flare (SRP) component controls where the lens flare is as well as properties such as attenuation and whether the lens flare considers occlusion. For properties that define how the lens flare looks, SRP uses the [Lens Flare (SRP) Data](lens-flare-asset.md) asset. Each Lens Flare (SRP) component must reference a Lens Flare (SRP) data asset to display a lens flare on-screen.
To create a lens flare in a scene:
@@ -21,32 +21,7 @@ To create a lens flare in a scene:
5. In the Lens Flare (SRP) component Inspector, assign the new Lens Flare (SRP) Data asset to the **Lens Flare Data** property.
6. Select the Lens Flare (SRP) Data asset and, in the Inspector, add a new element to the **Elements** list. A default white lens flare now renders at the position of the Lens Flare (SRP) component. For information on how to customize how the lens flare looks, see [Lens Flare (SRP) Data](lens-flare-asset.md).
-## Properties
-
-### General
-
-| **Property** | **Description** |
-| --------------- | ------------------------------------------------------------ |
-| Lens Flare Data | Select the [Lens Flare (SRP) Data](lens-flare-asset.md) asset this component controls. |
-| Intensity | Multiplies the intensity of the lens flare. |
-| Scale | Multiplies the scale of the lens flare. |
-| Attenuation by Light Shape | Enable this property to automatically change the appearance of the lens flare based on the type of light you attached this component to. For example, if this component is attached to a spot light and the camera is looking at this light from behind, the lens flare will not be visible. This property is only available when this component is attached to a light. |
-| Attenuation Distance |The distance between the start and the end of the Attenuation Distance Curve. This value operates between 0 and 1 in world space. |
-| Attenuation Distance Curve | Fades out the appearance of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
-| Scale Distance | The distance between the start and the end of the **Scale Distance Curve**. This value operates between 0 and 1 in world space. |
-| Scale Distance Curve | Changes the size of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
-| Screen Attenuation Curve | Reduces the effect of the lens flare based on its distance from the edge of the screen. You can use this to display a lens flare at the edge of your screen |
-
-### Occlusion
-
-| **Property** | **Description** |
-| --------------- | ------------------------------------------------------------ |
-| Enable | Enable this property to partially obscure the lens flare based on the depth buffer |
-| Occlusion Radius | Defines how far from the light source Unity occludes the lens flare. This value is in world space. |
-| Sample Count | The number of random samples the CPU uses to generate the **Occlusion Radius.** |
-| Occlusion Offset | Offsets the plane that the occlusion operates on. A higher value moves this plane closer to Camera. This value is in world space. For example, if a lens flare is inside the light bulb, you can use this to sample occlusion outside the light bulb. |
-| Volumetric Cloud Occlusion | When enabled, HDRP uses the volumetric cloud texture to occlude the lens flare. HDRP always considers the lens flare to be behind the volumetric clouds because it calculates occlusion in screen space. |
-| Occlusion Remap Curve | Specifies the curve used to remap the occlusion of the flare. By default, the occlusion is linear, between 0 and 1. This can be specifically useful to occlude flare more drastically when behind clouds. |
-| Volumetric Cloud Occlusion | When enabled, HDRP uses the volumetric cloud texture to occlude the lens flare. HDRP always considers the lens flare to be behind the volumetric clouds because it calculates occlusion in screen space. |
-| Allow Off Screen | Enable this property to allow lens flares outside the Camera's view to affect the current field of view. |
+Refer to the following for more information:
+- [Lens Flare (SRP) reference](lens-flare-reference.md)
+- [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md)
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-reference.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-reference.md
new file mode 100644
index 00000000000..56e01ce6a4b
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-reference.md
@@ -0,0 +1,9 @@
+# Lens flares references
+
+Property descriptions for lens flares.
+
+| Page|
+|-|
+| [Lens Flare (SRP) reference](lens-flare-srp-reference.md) |
+| [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md) |
+| [Screen Space Lens Flare override reference](reference-screen-space-lens-flare.md) |
\ No newline at end of file
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-srp-reference.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-srp-reference.md
new file mode 100644
index 00000000000..000b28b70b7
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare-srp-reference.md
@@ -0,0 +1,31 @@
+# Lens Flare (SRP) component reference
+
+Refer to [Add lens flares](lens-flare-component.md) for information on how to use the Lens Flare (SRP) component.
+
+## General
+
+| **Property** | **Description** |
+| --------------- | ------------------------------------------------------------ |
+| Lens Flare Data | Select the [Lens Flare (SRP) Data](lens-flare-asset.md) asset this component controls. |
+| Intensity | Multiplies the intensity of the lens flare. |
+| Scale | Multiplies the scale of the lens flare. |
+| Light Override | Specifies the light component Unity gets the color and shape values from, if you enable **Modulate By Light Color** or **Attenuation By Light Shape**. If you don't specify a light component, Unity uses the Light component from this GameObject. |
+| Attenuation by Light Shape | Enable this property to automatically change the appearance of the lens flare based on the type of light you attached this component to. For example, if this component is attached to a spot light and the camera is looking at this light from behind, the lens flare is not visible. This property is only available when this component is attached to a light. |
+| Attenuation Distance |The distance between the start and the end of the Attenuation Distance Curve. This value operates between 0 and 1 in world space. |
+| Attenuation Distance Curve | Fades out the appearance of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
+| Scale Distance | The distance between the start and the end of the **Scale Distance Curve**. This value operates between 0 and 1 in world space. |
+| Scale Distance Curve | Changes the size of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
+| Screen Attenuation Curve | Reduces the effect of the lens flare based on its distance from the edge of the screen. You can use this to display a lens flare at the edge of your screen |
+
+## Occlusion
+
+| **Property** | **Description** |
+| --------------- | ------------------------------------------------------------ |
+| Enable | Enable this property to partially obscure the lens flare based on the depth buffer |
+| Background Clouds | When enabled, the occlusion is attenuated by background clouds and volumetric clouds. |
+| Occlusion Radius | Defines how far from the light source Unity occludes the lens flare. This value is in world space. |
+| Sample Count | The number of random samples the CPU uses to generate the **Occlusion Radius.** |
+| Occlusion Offset | Offsets the plane that the occlusion operates on. A higher value moves this plane closer to Camera. This value is in world space. For example, if a lens flare is inside the light bulb, you can use this to sample occlusion outside the light bulb. |
+| Occlusion Remap Curve | Specifies the curve used to remap the occlusion of the flare. By default, the occlusion is linear, between 0 and 1. This can be useful to occlude flare more drastically when behind clouds. |
+| Allow Off Screen | Enable this property to allow lens flares outside the Camera's view to affect the current field of view. |
+
diff --git a/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare.md b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare.md
new file mode 100644
index 00000000000..d5325ae9f64
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.high-definition/Documentation~/shared/lens-flare/lens-flare.md
@@ -0,0 +1,12 @@
+# Lens flares
+
+Lens flares simulate the effect of lights refracting inside a camera lens. Use lens flares to represent bright lights, or to add atmosphere to a scene.
+
+|Page|Description|
+|-|-|
+| [Choose a lens flare type](choose-a-lens-flare-type.md) | Understand the differences between lens flares and screen space lens flares. |
+| [Add lens flares](lens-flare-component.md) | Use the Lens Flare (SRP) component to create lens flares for lights that have specific locations in your scene, for example bright bulbs. |
+| [Add screen space lens flares](Override-Screen-Space-Lens-Flare.md) | Use the Screen Space Lens Flare override to create lens flares for emissive surfaces, bright spots in your scene that appear depending on the camera view, and all onscreen lights. |
+| [Lens Flare (SRP) reference](lens-flare-srp-reference.md) | Reference for the Lens Flare (SRP) component. |
+| [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md) | Reference for the Lens Flare (SRP) Data Asset. |
+| [Screen Space Lens Flare override reference](reference-screen-space-lens-flare.md) | Reference for the Screen Space Lens Flare override. |
diff --git a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl
index e3432e5a164..adc4bee1582 100644
--- a/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl
+++ b/Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl
@@ -681,7 +681,10 @@ float3 ComputeMainBaseColorInfluence(float influenceMask, float3 baseColor0, flo
// (baseColor - meanColor) + lerp(meanColor, baseColor0, inheritBaseColor) simplify to
// saturate(influenceFactor * (baseColor0 - meanColor) + baseColor);
// There is a special case when baseColor < meanColor to avoid getting negative values.
- float3 factor = baseColor > meanColor ? (baseColor0 - meanColor) : (baseColor0 * baseColor / max(meanColor, 0.001) - baseColor); // max(to avoid divide by 0)
+ float3 factor = (baseColor0 - meanColor);
+ factor.x = baseColor.x > meanColor.x ? factor.x : (baseColor0.x * baseColor.x / max(meanColor.x, 0.001) - baseColor.x); // max(to avoid divide by 0)
+ factor.y = baseColor.y > meanColor.y ? factor.y : (baseColor0.y * baseColor.y / max(meanColor.y, 0.001) - baseColor.y);
+ factor.z = baseColor.z > meanColor.z ? factor.z : (baseColor0.z * baseColor.z / max(meanColor.z, 0.001) - baseColor.z);
return influenceFactor * factor + baseColor;
}
#ifndef SHADER_STAGE_RAY_TRACING
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/TableOfContents.md b/Packages/com.unity.render-pipelines.universal/Documentation~/TableOfContents.md
index b3e70757a0c..7bf518556c3 100644
--- a/Packages/com.unity.render-pipelines.universal/Documentation~/TableOfContents.md
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/TableOfContents.md
@@ -73,7 +73,13 @@
* [Probe Volumes Options Override reference](probevolumes-options-override-reference.md)
* [Probe Adjustment Volume component reference](probevolumes-adjustment-volume-component-reference.md)
* [Reflection probes](lighting/reflection-probes.md)
- * [Lens Flare asset](shared/lens-flare/lens-flare-asset.md)
+ * [Lens flares](shared/lens-flare/lens-flare.md)
+ * [Choose a lens flare type](shared/lens-flare/choose-a-lens-flare-type.md)
+ * [Add lens flares](shared/lens-flare/lens-flare-component.md)
+ * [Add screen space lens flares](shared/lens-flare/post-processing-screen-space-lens-flare.md)
+ * [Lens Flare (SRP) reference](shared/lens-flare/lens-flare-srp-reference.md)
+ * [Lens Flare (SRP) Data Asset reference](shared/lens-flare/lens-flare-asset.md)
+ * [Screen Space Lens Flare override reference](shared/lens-flare/reference-screen-space-lens-flare.md)
* [Cameras](cameras.md)
* [The Universal Additional Camera Data component](universal-additional-camera-data.md)
* [Render Type](camera-types-and-render-type.md)
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/choose-a-lens-flare-type.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/choose-a-lens-flare-type.md
new file mode 100644
index 00000000000..a8fc2c5e96c
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/choose-a-lens-flare-type.md
@@ -0,0 +1,35 @@
+# Choose a lens flare type
+
+You can add the following types of lens flares:
+
+- [Lens flares](lens-flare-component.md) - use a **Lens Flare (SRP)** component to create lens flares for lights that have specific locations in your scene, for example the sun or bright bulbs.
+- [Screen space lens flares](post-processing-screen-space-lens-flare.md) - use a **Screen Space Lens Flare** override to create lens flares for emissive surfaces, bright spots, and onscreen lights.
+
+You can use both types in the same scene.
+
+Use the following table to help you choose a lens flare type:
+
+| Feature | Lens Flare (SRP) component | Screen Space Lens Flare override |
+|-|-|-|
+| Typical uses | Lens flares from the sun and specific lights, custom flare shapes, and cinematics | Lens flares on vehicles and water, first-person games, and science-fiction environments |
+| Supported platforms | All platforms except XR | All platforms |
+| CPU and GPU use | CPU and GPU | GPU |
+| Types of light | All Light objects, except Area Lights | All bright spots and visible lights |
+| Placement | Attach to individual lights. Place lens flares manually | Generate inside a volume. Place all lens flares automatically with a single setting |
+| Lens flares from offscreen lights | Yes | No |
+| Light streaks | No, unless you create them manually | Yes |
+| Configure flares | Configure per lens flare or per element | Configure for all lens flares together |
+| Configure flare elements | Configure many settings for each element, per lens flare | Configure several settings for elements, for all lens flares together |
+| Configure attenuation | Yes | No |
+| Affected by the environment | Yes | Yes |
+| Preserve aspect ratio | Yes | No |
+| Chromatic aberration | No | Yes |
+| Blend modes | Additive, Lerp, Premultiplied and Screen | Additive only |
+| Occlusion | Screen space occlusion, and geometric occlusion for offscreen lights. Configurable. Occlusion might not always work at the edge of the screen. | Screen space occlusion, generated from the color buffer. Not configurable |
+| Examples in [package samples](../../package-samples.md) | Yes | No |
+
+## Additional resources
+
+- [Lens Flare (SRP) reference](lens-flare-srp-reference.md)
+- [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md)
+- [Screen Space Lens Flare override reference](post-processing-screen-space-lens-flare.md)
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-asset.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-asset.md
index cac98e63951..b6dfe7e95a9 100644
--- a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-asset.md
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-asset.md
@@ -4,7 +4,7 @@ Unity’s [Scriptable Render Pipeline (SRP)](https://docs.unity3d.com/Manual/Scr
For examples of how to use Lens Flares, refer to the [Lens Flare samples in URP Package Samples](../../package-sample-urp-package-samples.md#lens-flares).
-To create a Lens Flare Data asset, select **Assets > Create > Lens Flare (SRP)**. To use this asset, assign it to the **Lens Flare Data** property of a [Lens Flare (SRP) component](lens-flare-component.md).
+To create a Lens Flare Data asset, select **Assets** > **Create** > **Lens Flare (SRP)**. To use this asset, assign it to the **Lens Flare Data** property of a [Lens Flare (SRP) component](lens-flare-component.md).
## Properties
@@ -31,7 +31,7 @@ The Lens Flare Element asset has the following properties:
#### Image
-
+#### Image
| **Property** | **Description** |
| --------------------- | ------------------------------------------------------------ |
@@ -40,7 +40,7 @@ The Lens Flare Element asset has the following properties:
#### Circle
-
+#### Circle
| **Property** | **Description** |
| ------------ | ------------------------------------------------------------ |
@@ -50,7 +50,7 @@ The Lens Flare Element asset has the following properties:
#### Polygon
-
+#### Polygon
| **Property** | **Description** |
| ------------ | ------------------------------------------------------------ |
@@ -62,8 +62,6 @@ The Lens Flare Element asset has the following properties:
## Color
-
-
| **Property** | **Description** |
| ----------------------- | ------------------------------------------------------------ |
| Tint | Changes the tint of the lens flare. If this asset is attached to the light, this property is based on the light tint. |
@@ -73,8 +71,6 @@ The Lens Flare Element asset has the following properties:
## Transform
-
-
| **Property** | **Description** |
| ----------------------- | ------------------------------------------------------------ |
| Position Offset | Defines the offset of the lens flare's position in screen space, relative to its source. |
@@ -85,8 +81,6 @@ The Lens Flare Element asset has the following properties:
## AxisTransform
-
-
| **Property** | **Description** |
| ----------------- | ------------------------------------------------------------ |
| Starting Position | Defines the starting position of the lens flare relative to its source. This value operates in screen space. |
@@ -97,8 +91,6 @@ The Lens Flare Element asset has the following properties:
## Distortion
-
-
| **Property** | **Description** |
| --------------- | ------------------------------------------------------------ |
| Enable | Set this property to True to enable distortion. |
@@ -119,8 +111,6 @@ The Lens Flare Element asset has the following properties:
| Relative To Center | If true the distortion is relative to center of the screen otherwise relative to lensFlare source screen position. |
### Uniform
-
-
| **Property** | **Description** |
| --------------- | ------------------------------------------------------------ |
| Colors | The range of colors that this asset applies to the lens flares. |
@@ -128,7 +118,7 @@ The Lens Flare Element asset has the following properties:
### Curve
-
+#### Curve
| **Property** | **Description** |
| ---------------- | ------------------------------------------------------------ |
@@ -139,7 +129,7 @@ The Lens Flare Element asset has the following properties:
### Random
-
+#### Random
| **Property** | **Description** |
| ------------------- | ------------------------------------------------------------ |
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-component.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-component.md
index 88d4a98857a..4c9eac85351 100644
--- a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-component.md
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-component.md
@@ -1,4 +1,4 @@
-# Lens Flare (SRP) component
+# Add lens flares

@@ -19,29 +19,7 @@ To create a lens flare in a scene:
5. In the Lens Flare (SRP) component Inspector, assign the new Lens Flare (SRP) Data asset to the **Lens Flare Data** property.
6. Select the Lens Flare (SRP) Data asset and, in the Inspector, add a new element to the **Elements** list. A default white lens flare now renders at the position of the Lens Flare (SRP) component. For information on how to customize how the lens flare looks, refer to [Lens Flare (SRP) Data](lens-flare-asset.md).
-## Properties
-
-### General
-
-| **Property** | **Description** |
-| --------------- | ------------------------------------------------------------ |
-| Lens Flare Data | Select the [Lens Flare (SRP) Data](lens-flare-asset.md) asset this component controls. |
-| Intensity | Multiplies the intensity of the lens flare. |
-| Scale | Multiplies the scale of the lens flare. |
-| Attenuation by Light Shape | Enable this property to automatically change the appearance of the lens flare based on the type of light you attached this component to. For example, if this component is attached to a spot light and the camera is looking at this light from behind, the lens flare will not be visible. This property is only available when this component is attached to a light. |
-| Attenuation Distance |The distance between the start and the end of the Attenuation Distance Curve. This value operates between 0 and 1 in world space. |
-| Attenuation Distance Curve | Fades out the appearance of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
-| Scale Distance | The distance between the start and the end of the **Scale Distance Curve**. This value operates between 0 and 1 in world space. |
-| Scale Distance Curve | Changes the size of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
-| Screen Attenuation Curve | Reduces the effect of the lens flare based on its distance from the edge of the screen. You can use this to display a lens flare at the edge of your screen |
-
-### Occlusion
-
-| **Property** | **Description** |
-| --------------- | ------------------------------------------------------------ |
-| Enable | Enable this property to partially obscure the lens flare based on the depth buffer |
-| Occlusion Radius | Defines how far from the light source Unity occludes the lens flare. This value is in world space. |
-| Sample Count | The number of random samples the CPU uses to generate the **Occlusion Radius.** |
-| Occlusion Offset | Offsets the plane that the occlusion operates on. A higher value moves this plane closer to Camera. This value is in world space. For example, if a lens flare is inside the light bulb, you can use this to sample occlusion outside the light bulb. |
-| Occlusion Remap Curve | Allow the occlusion [from 0 to 1] to be remap with any desired shape. |
-| Allow Off Screen | Enable this property to allow lens flares outside the Camera's view to affect the current field of view. |
+Refer to the following for more information:
+
+- [Lens Flare (SRP) reference](lens-flare-srp-reference.md)
+- [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md)
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-srp-reference.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-srp-reference.md
new file mode 100644
index 00000000000..9727462a8b2
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare-srp-reference.md
@@ -0,0 +1,29 @@
+# Lens Flare (SRP) component reference
+
+Refer to [Add lens flares](lens-flare-component.md) for information on how to use the Lens Flare (SRP) component.
+
+## General
+
+| **Property** | **Description** |
+| --------------- | ------------------------------------------------------------ |
+| Lens Flare Data | Select the [Lens Flare (SRP) Data](lens-flare-asset.md) asset this component controls. |
+| Intensity | Multiplies the intensity of the lens flare. |
+| Scale | Multiplies the scale of the lens flare. |
+| Light Override | Specifies the light component Unity gets the color and shape values from, if you enable **Modulate By Light Color** or **Attenuation By Light Shape**. If you don't specify a light component, Unity uses the Light component from this GameObject. |
+| Attenuation by Light Shape | Enable this property to automatically change the appearance of the lens flare based on the type of light you attached this component to. For example, if this component is attached to a spot light and the camera is looking at this light from behind, the lens flare is not visible. This property is only available when this component is attached to a light. |
+| Attenuation Distance |The distance between the start and the end of the Attenuation Distance Curve. This value operates between 0 and 1 in world space. |
+| Attenuation Distance Curve | Fades out the appearance of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
+| Scale Distance | The distance between the start and the end of the **Scale Distance Curve**. This value operates between 0 and 1 in world space. |
+| Scale Distance Curve | Changes the size of the lens flare over the distance between the GameObject this asset is attached to, and the Camera. |
+| Screen Attenuation Curve | Reduces the effect of the lens flare based on its distance from the edge of the screen. You can use this to display a lens flare at the edge of your screen |
+
+## Occlusion
+
+| **Property** | **Description** |
+| --------------- | ------------------------------------------------------------ |
+| Enable | Enable this property to partially obscure the lens flare based on the depth buffer |
+| Occlusion Radius | Defines how far from the light source Unity occludes the lens flare. This value is in world space. |
+| Sample Count | The number of random samples the CPU uses to generate the **Occlusion Radius.** |
+| Occlusion Offset | Offsets the plane that the occlusion operates on. A higher value moves this plane closer to Camera. This value is in world space. For example, if a lens flare is inside the light bulb, you can use this to sample occlusion outside the light bulb. |
+| Occlusion Remap Curve | Allow the occlusion [from 0 to 1] to be remap with any desired shape. |
+| Allow Off Screen | Enable this property to allow lens flares outside the Camera's view to affect the current field of view. |
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare.md
new file mode 100644
index 00000000000..7fb4f6878f3
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/lens-flare.md
@@ -0,0 +1,12 @@
+# Lens flares
+
+Lens flares simulate the effect of lights refracting inside a camera lens. Use lens flares to represent bright lights, or to add atmosphere to a scene.
+
+|Page|Description|
+|-|-|
+| [Choose a lens flare type](choose-a-lens-flare-type.md) | Understand the differences between lens flares and screen space lens flares. |
+| [Add lens flares](lens-flare-component.md) | Use the Lens Flare (SRP) component to create lens flares for lights that have specific locations in your scene, for example bright bulbs. |
+| [Add screen space lens flares](post-processing-screen-space-lens-flare.md) | Use the Screen Space Lens Flare override to create lens flares for emissive surfaces, bright spots in your scene that appear depending on the camera view, and all onscreen lights. |
+| [Lens Flare (SRP) reference](lens-flare-srp-reference.md) | Reference for the Lens Flare (SRP) component. |
+| [Lens Flare (SRP) Data Asset reference](lens-flare-asset.md) | Reference for the Lens Flare (SRP) Data Asset. |
+| [Screen Space Lens Flare override reference](reference-screen-space-lens-flare.md) | Reference for the Screen Space Lens Flare override. |
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/post-processing-screen-space-lens-flare.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/post-processing-screen-space-lens-flare.md
index 63f214f205c..9beb5db0f3b 100644
--- a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/post-processing-screen-space-lens-flare.md
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/post-processing-screen-space-lens-flare.md
@@ -1,4 +1,4 @@
-# Screen Space Lens Flare
+# Add screen space lens flares

@@ -47,51 +47,3 @@ To add **Screen Space Lens Flare** to a Volume:
Some lens flares only appear, or only appear at full intensity, if you enable High Dynamic Range (HDR) rendering on your camera. To enable HDR, refer to [the **Output** section of the Camera component reference](../../camera-component-reference.md#output).
-## Properties
-
-| **Property** | **Description** |
-| - | - |
-| **Intensity** | Set the strength of all the types of lens flares. If the value is 0, URP doesn't calculate or render any lens flares. The default is 0. |
-| **Tint Color** | Set the color URP uses to tint all the types of lens flares. The default is white. |
-| **Bloom Mip Bias** | Set the mipmap level URP uses to sample the Bloom pyramid and create the lens flares. The higher the mipmap level, the smaller and more pixelated the sample source, and the blurrier the result. The range is 0 through 5. 0 is the full-resolution mipmap level. The default is 1. Refer to [Mipmaps introduction](https://docs.unity3d.com/2023.1/Documentation/Manual/texture-mipmaps-introduction.html) for more information. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
-
-### Flares
-
-Use the **Flares** settings to control regular flares, reversed flares and warped flares.
-
-| **Property** || **Description** |
-|-|-|-|
-| **Regular Multiplier** || Set the strength of regular flares. If the value is 0, URP doesn't calculate or render regular flares. The default is 1. |
-| **Reversed Multiplier** || Set the strength of reversed flares. If the value is 0, URP doesn't calculate or render reversed flares. The default is 1. |
-| **Warped Multipler** || Set the strength of warped flares. If the value is 0, URP doesn't calculate or render warped flares. The default is 1. |
-|| **Scale** | Scale the width (**x**) and height (**y**) of warped flares. The defaults are 1. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
-| **Samples** || Set the number of times URP repeats the regular, reversed and warped flares. The range is 1 through 3. The default is 1. Increasing **Samples** has a big impact on performance. |
-|| **Sample Dimmer** | Set the strength of the lens flares URP adds if you set **Samples** to 2 or 3. The higher the value, the less intense the flares. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
-| **Vignette Effect** || Set the strength of the regular, reversed and warped flares in a circular area in the center of the screen. Use **Vignette Effect** to avoid lens flare obscuring the scene too much. The default value is 1, which means URP doesn't render flares at the center of the screen. |
-| **Starting Position** || Control how far the position of the regular, reversed and warped flares differ from the bright area they're sampled from, in metres. If the value is 0, URP places the lens flares at the same position as the bright areas they're sampled from. The range is 1 through 3. The default is 1.25. |
-| **Scale** || Set the size of regular, reversed and warped lens flares. The range is 1 through 4. The default is 1.5. |
-
-### Streaks
-
-Use the **Streaks** settings to control flares stretched in one direction.
-
-| **Property** || **Description** |
-|-|-|-|
-| **Multiplier** || Set the strength of streaks. If the value is 0, URP doesn't calculate or render streaks. The default is 1. |
-|| **Length** | Set the length of streaks. The range is 0 through 1. 1 is the approximate width of the screen. The default value is 0.5. |
-|| **Orientation** | Set the angle of streaks, in degrees. The default value is 0, which creates horizontal streaks. |
-|| **Threshold** | Control how localized the streak effect is. The higher the **Threshold**, the more localized the effect. The range is 0 through 1. The default value is 0.25. |
-|| **Resolution** | Control the resolution detail of streaks. URP renders lower-resolution streaks faster. The options are **Half**, **Quarter** and **Eighth** full resolution. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
-
-
-The effect of changing **Threshold** from 0 (a larger flare effect) to 1 (a smaller flare effect).
-
-### Chromatic Aberration
-
-Use the **Chromatic Aberration** settings to control chromatic aberration on all the lens flare types. Chromatic aberration splits light into its color components, which mimics the effect that a real-world camera produces when its lens fails to join all colors to the same point.
-
-The chromatic aberration effect is strongest at the edges of the screen, and decreases in strength towards the center of the screen.
-
-| **Property** | **Description** |
-|-|-|
-| **Intensity** | Set the strength of the chromatic aberration effect. If the value is 0, URP doesn't split the colors. |
diff --git a/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md
new file mode 100644
index 00000000000..5d386ea61ff
--- /dev/null
+++ b/Packages/com.unity.render-pipelines.universal/Documentation~/shared/lens-flare/reference-screen-space-lens-flare.md
@@ -0,0 +1,52 @@
+# Screen Space Lens Flare override reference
+
+Refer to [Add screen space lens flares](post-processing-screen-space-lens-flare.md) for more information.
+
+## Properties
+
+| **Property** | **Description** |
+| - | - |
+| **Intensity** | Set the strength of all the types of lens flares. If the value is 0, URP doesn't calculate or render any lens flares. The default is 0. |
+| **Tint Color** | Set the color URP uses to tint all the types of lens flares. The default is white. |
+| **Bloom Mip Bias** | Set the mipmap level URP uses to sample the Bloom pyramid and create the lens flares. The higher the mipmap level, the smaller and more pixelated the sample source, and the blurrier the result. The range is 0 through 5. 0 is the full-resolution mipmap level. The default is 1. Refer to [Mipmaps introduction](https://docs.unity3d.com/2023.1/Documentation/Manual/texture-mipmaps-introduction.html) for more information. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
+
+### Flares
+
+Use the **Flares** settings to control regular flares, reversed flares and warped flares.
+
+| **Property** || **Description** |
+|-|-|-|
+| **Regular Multiplier** || Set the strength of regular flares. If the value is 0, URP doesn't calculate or render regular flares. The default is 1. |
+| **Reversed Multiplier** || Set the strength of reversed flares. If the value is 0, URP doesn't calculate or render reversed flares. The default is 1. |
+| **Warped Multipler** || Set the strength of warped flares. If the value is 0, URP doesn't calculate or render warped flares. The default is 1. |
+|| **Scale** | Scale the width (**x**) and height (**y**) of warped flares. The defaults are 1. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
+| **Samples** || Set the number of times URP repeats the regular, reversed and warped flares. The range is 1 through 3. The default is 1. Increasing **Samples** has a big impact on performance. |
+|| **Sample Dimmer** | Set the strength of the lens flares URP adds if you set **Samples** to 2 or 3. The higher the value, the less intense the flares. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
+| **Vignette Effect** || Set the strength of the regular, reversed and warped flares in a circular area in the center of the screen. Use **Vignette Effect** to avoid lens flare obscuring the scene too much. The default value is 1, which means URP doesn't render flares at the center of the screen. |
+| **Starting Position** || Control how far the position of the regular, reversed and warped flares differ from the bright area they're sampled from, in metres. If the value is 0, URP places the lens flares at the same position as the bright areas they're sampled from. The range is 1 through 3. The default is 1.25. |
+| **Scale** || Set the size of regular, reversed and warped lens flares. The range is 1 through 4. The default is 1.5. |
+
+### Streaks
+
+Use the **Streaks** settings to control flares stretched in one direction.
+
+| **Property** || **Description** |
+|-|-|-|
+| **Multiplier** || Set the strength of streaks. If the value is 0, URP doesn't calculate or render streaks. The default is 1. |
+|| **Length** | Set the length of streaks. The range is 0 through 1. 1 is the approximate width of the screen. The default value is 0.5. |
+|| **Orientation** | Set the angle of streaks, in degrees. The default value is 0, which creates horizontal streaks. |
+|| **Threshold** | Control how localized the streak effect is. The higher the **Threshold**, the more localized the effect. The range is 0 through 1. The default value is 0.25. |
+|| **Resolution** | Control the resolution detail of streaks. URP renders lower-resolution streaks faster. The options are **Half**, **Quarter** and **Eighth** full resolution. This property only appears if you open the **More** (⋮) menu and select **Show Additional Properties**. |
+
+
+The effect of changing **Threshold** from 0 (a larger flare effect) to 1 (a smaller flare effect).
+
+### Chromatic Aberration
+
+Use the **Chromatic Aberration** settings to control chromatic aberration on all the lens flare types. Chromatic aberration splits light into its color components, which mimics the effect that a real-world camera produces when its lens fails to join all colors to the same point.
+
+The chromatic aberration effect is strongest at the edges of the screen, and decreases in strength towards the center of the screen.
+
+| **Property** | **Description** |
+|-|-|
+| **Intensity** | Set the strength of the chromatic aberration effect. If the value is 0, URP doesn't split the colors. |
diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs b/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs
index 0f80ce4f5fb..d3be95f0acb 100644
--- a/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs
+++ b/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Drawers.cs
@@ -286,31 +286,10 @@ static void DrawRenderingContent(UniversalRenderPipelineSerializedLight serializ
}
}
- var rendererList = UniversalRenderPipeline.asset.rendererDataList;
- bool hasNonForwardPlusRenderer = false;
- foreach (var r in rendererList)
- {
- if (r is UniversalRendererData ur)
- {
- if (ur.renderingMode != RenderingMode.ForwardPlus)
- {
- hasNonForwardPlusRenderer = true;
- break;
- }
- }
- else
- {
- hasNonForwardPlusRenderer = true;
- break;
- }
- }
-
- GUI.enabled = hasNonForwardPlusRenderer;
- EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, hasNonForwardPlusRenderer ? Styles.CullingMask : Styles.CullingMaskDisabled);
- GUI.enabled = true;
+ EditorGUILayout.PropertyField(serializedLight.settings.cullingMask, Styles.CullingMask);
if (serializedLight.settings.cullingMask.intValue != -1)
{
- EditorGUILayout.HelpBox(Styles.CullingMaskWarning.text, MessageType.Warning);
+ EditorGUILayout.HelpBox(Styles.CullingMaskWarning.text, MessageType.Info);
}
}
diff --git a/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs b/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs
index f83b50baac9..8ec562c50a1 100644
--- a/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs
+++ b/Packages/com.unity.render-pipelines.universal/Editor/Lighting/UniversalRenderPipelineLightUI.Skin.cs
@@ -21,9 +21,8 @@ private static class Styles
public static readonly GUIContent BakingWarning = EditorGUIUtility.TrTextContent("Light mode is currently overridden to Realtime mode. Enable Baked Global Illumination to use Mixed or Baked light modes.");
public static readonly GUIContent DisabledLightWarning = EditorGUIUtility.TrTextContent("Lighting has been disabled in at least one Scene view. Any changes applied to lights in the Scene will not be updated in these views until Lighting has been enabled again.");
public static readonly GUIContent SunSourceWarning = EditorGUIUtility.TrTextContent("This light is set as the current Sun Source, which requires a directional light. Go to the Lighting Window's Environment settings to edit the Sun Source.");
- public static readonly GUIContent CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "Specifies which layers will be affected or excluded from the light's effect on objects in the scene. This only applies to objects rendered using the Forward rendering path, and transparent objects rendered using the Deferred rendering path.\n\nUse Rendering Layers instead, which is supported across all rendering paths.");
- public static readonly GUIContent CullingMaskDisabled = EditorGUIUtility.TrTextContent("Culling Mask", "Culling Mask is disabled. This is because all active renderers use the Forward+ rendering path, which doesn't support Culling Mask. Use Rendering Layers instead, which is supported across all rendering paths.");
- public static readonly GUIContent CullingMaskWarning = EditorGUIUtility.TrTextContent("Culling Mask only works with Forward rendering. Instead, use Rendering Layers on the Light, and Rendering Layer Mask on the Mesh Renderer, which will work across Deferred, Forward, and Forward+ rendering.");
+ public static readonly GUIContent CullingMask = EditorGUIUtility.TrTextContent("Culling Mask", "Specifies which lights are culled per camera. To control exclude certain lights affecting certain objects, use Rendering Layers instead, which is supported across all rendering paths.");
+ public static readonly GUIContent CullingMaskWarning = EditorGUIUtility.TrTextContent("Culling Mask should be used to control which lights are culled per camera. If you want to exclude certain lights from affecting certain objects, use Rendering Layers on the Light, and Rendering Layer Mask on the Mesh Renderer.");
public static readonly GUIContent ShadowRealtimeSettings = EditorGUIUtility.TrTextContent("Realtime Shadows", "Settings for realtime direct shadows.");
public static readonly GUIContent ShadowStrength = EditorGUIUtility.TrTextContent("Strength", "Controls how dark the shadows cast by the light will be.");
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/LightUtility.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/LightUtility.cs
index 6d21ce98d48..a92b6956af0 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/LightUtility.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/LightUtility.cs
@@ -259,6 +259,8 @@ static void TransferToMesh(NativeArray vertices, int vertexCoun
public static Bounds GenerateShapeMesh(Light2D light, Vector3[] shapePath, float falloffDistance, float batchColor)
{
const float kClipperScale = 10000.0f;
+
+ var restoreState = Random.state;
Random.InitState(123456); // for deterministic output
// todo Revisit this while we do Batching.
@@ -414,6 +416,7 @@ public static Bounds GenerateShapeMesh(Light2D light, Vector3[] shapePath, float
TransferToMesh(outVertices, vcount, outIndices, icount, light);
}
+ Random.state = restoreState;
return light.lightMesh.GetSubMesh(0).bounds;
}
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs
index 5a29bfa67ba..913aabcb5bf 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/2D/Passes/Utility/RendererLighting.cs
@@ -575,7 +575,7 @@ internal static void RenderNormals(this IRenderPass2D pass, ScriptableRenderCont
var msaaEnabled = renderingData.cameraData.cameraTargetDescriptor.msaaSamples > 1;
var storeAction = msaaEnabled ? RenderBufferStoreAction.Resolve : RenderBufferStoreAction.Store;
var clearFlag = pass.rendererData.useDepthStencilBuffer ? ClearFlag.All : ClearFlag.Color;
- clearFlag = bFirstClear ? clearFlag : ClearFlag.None;
+ clearFlag = bFirstClear ? clearFlag : ClearFlag.Color;
bFirstClear = false;
if (depthTarget != null)
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs
index 97864710d03..d637c4ac1be 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/AdditionalLightsShadowCasterPass.cs
@@ -689,6 +689,11 @@ void RenderAdditionalShadowmapAtlas(RasterCommandBuffer cmd, ref PassData data,
using (new ProfilingScope(cmd, ProfilingSampler.Get(URPProfileId.AdditionalLightsShadow)))
{
+ // For non-RG, need set the worldToCamera Matrix as that is not set for passes executed before normal rendering,
+ // otherwise shadows will behave incorrectly when Scene and Game windows are open at the same time (UUM-63267).
+ if (!useRenderGraph)
+ ShadowUtils.SetWorldToCameraMatrix(cmd, renderingData.cameraData.GetViewMatrix());
+
bool anyShadowSliceRenderer = false;
int shadowSlicesCount = m_ShadowSliceToAdditionalLightIndex.Count;
for (int globalShadowSliceIndex = 0; globalShadowSliceIndex < shadowSlicesCount; ++globalShadowSliceIndex)
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs
index cb7033e391f..fb7588af3ee 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MainLightShadowCasterPass.cs
@@ -243,8 +243,13 @@ void RenderMainLightCascadeShadowmap(RasterCommandBuffer cmd, ref PassData data,
using (new ProfilingScope(cmd, ProfilingSampler.Get(URPProfileId.MainLightShadow)))
{
- // Need to start by setting the Camera position as that is not set for passes executed before normal rendering
- cmd.SetGlobalVector(ShaderPropertyId.worldSpaceCameraPos, renderingData.cameraData.worldSpaceCameraPos);
+ // Need to start by setting the Camera position and worldToCamera Matrix as that is not set for passes executed before normal rendering
+ ShadowUtils.SetCameraPosition(cmd, renderingData.cameraData.worldSpaceCameraPos);
+
+ // For non-RG, need set the worldToCamera Matrix as that is not set for passes executed before normal rendering,
+ // otherwise shadows will behave incorrectly when Scene and Game windows are open at the same time (UUM-63267).
+ if (!isRenderGraph)
+ ShadowUtils.SetWorldToCameraMatrix(cmd, renderingData.cameraData.GetViewMatrix());
for (int cascadeIndex = 0; cascadeIndex < m_ShadowCasterCascadesCount; ++cascadeIndex)
{
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MotionVectorRenderPass.cs b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MotionVectorRenderPass.cs
index 4486c535c12..47579e140b3 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MotionVectorRenderPass.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/Passes/MotionVectorRenderPass.cs
@@ -24,9 +24,9 @@ sealed class MotionVectorRenderPass : ScriptableRenderPass
#endregion
#region Constructors
- internal MotionVectorRenderPass(Material cameraMaterial)
+ internal MotionVectorRenderPass(RenderPassEvent evt, Material cameraMaterial)
{
- renderPassEvent = RenderPassEvent.BeforeRenderingPostProcessing;
+ renderPassEvent = evt;
m_CameraMaterial = cameraMaterial;
m_PassData = new PassData();
base.profilingSampler = ProfilingSampler.Get(URPProfileId.MotionVectors);
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs b/Packages/com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs
index a88b4496fd3..d4d611c9f66 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/ShadowUtils.cs
@@ -415,15 +415,44 @@ public static void SetupShadowCasterConstantBuffer(CommandBuffer cmd, ref Visibl
internal static void SetupShadowCasterConstantBuffer(RasterCommandBuffer cmd, ref VisibleLight shadowLight, Vector4 shadowBias)
{
- cmd.SetGlobalVector("_ShadowBias", shadowBias);
+ SetShadowBias(cmd, shadowBias);
// Light direction is currently used in shadow caster pass to apply shadow normal offset (normal bias).
Vector3 lightDirection = -shadowLight.localToWorldMatrix.GetColumn(2);
- cmd.SetGlobalVector("_LightDirection", new Vector4(lightDirection.x, lightDirection.y, lightDirection.z, 0.0f));
+ SetLightDirection(cmd, lightDirection);
// For punctual lights, computing light direction at each vertex position provides more consistent results (shadow shape does not change when "rotating the point light" for example)
Vector3 lightPosition = shadowLight.localToWorldMatrix.GetColumn(3);
- cmd.SetGlobalVector("_LightPosition", new Vector4(lightPosition.x, lightPosition.y, lightPosition.z, 1.0f));
+ SetLightPosition(cmd, lightPosition);
+ }
+
+ internal static void SetShadowBias(RasterCommandBuffer cmd, Vector4 shadowBias)
+ {
+ cmd.SetGlobalVector(ShaderPropertyId.shadowBias, shadowBias);
+ }
+
+ internal static void SetLightDirection(RasterCommandBuffer cmd, Vector3 lightDirection)
+ {
+ cmd.SetGlobalVector(ShaderPropertyId.lightDirection, new Vector4(lightDirection.x, lightDirection.y, lightDirection.z, 0.0f));
+ }
+
+ internal static void SetLightPosition(RasterCommandBuffer cmd, Vector3 lightPosition)
+ {
+ cmd.SetGlobalVector(ShaderPropertyId.lightPosition, new Vector4(lightPosition.x, lightPosition.y, lightPosition.z, 1.0f));
+ }
+
+ internal static void SetCameraPosition(RasterCommandBuffer cmd, Vector3 worldSpaceCameraPos)
+ {
+ cmd.SetGlobalVector(ShaderPropertyId.worldSpaceCameraPos, worldSpaceCameraPos);
+ }
+
+ internal static void SetWorldToCameraMatrix(RasterCommandBuffer cmd, Matrix4x4 viewMatrix)
+ {
+ // There's an inconsistency in handedness between unity_matrixV and unity_WorldToCamera
+ // Unity changes the handedness of unity_WorldToCamera (see Camera::CalculateMatrixShaderProps)
+ // we will also change it here to avoid breaking existing shaders. (case 1257518)
+ Matrix4x4 worldToCameraMatrix = Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)) * viewMatrix;
+ cmd.SetGlobalMatrix(ShaderPropertyId.worldToCameraMatrix, worldToCameraMatrix);
}
private static RenderTextureDescriptor GetTemporaryShadowTextureDescriptor(int width, int height, int bits)
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs
index 3b57f5c9b8a..fb298f720bc 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipeline.cs
@@ -204,8 +204,7 @@ public UniversalRenderPipeline(UniversalRenderPipelineAsset asset)
// Initial state of the RTHandle system.
// We initialize to screen width/height to avoid multiple realloc that can lead to inflated memory usage (as releasing of memory is delayed).
- // Note: Use legacy DR control. Can be removed once URP integrates with core package DynamicResolutionHandler
- RTHandles.Initialize(Screen.width, Screen.height, useLegacyDynamicResControl: true);
+ RTHandles.Initialize(Screen.width, Screen.height);
GraphicsSettings.useScriptableRenderPipelineBatching = asset.useSRPBatcher;
@@ -396,6 +395,13 @@ protected override void Render(ScriptableRenderContext renderContext, Camera[] c
UniversalRenderPipelineDebugDisplaySettings.Instance.UpdateDisplayStats();
#endif
+ // URP uses the camera's allowDynamicResolution flag to decide if useDynamicScale should be enabled for camera render targets.
+ // However, the RTHandle system has an additional setting that controls if useDynamicScale will be set for render targets allocated via RTHandles.
+ // In order to avoid issues at runtime, we must make the RTHandle system setting consistent with URP's logic. URP already synchronizes the setting
+ // during initialization, but unfortunately it's possible for external code to overwrite the setting due to RTHandle state being global.
+ // The best we can do to avoid errors in this situation is to ensure the state is set to the correct value every time we perform rendering.
+ RTHandles.SetHardwareDynamicResolutionState(true);
+
SortCameras(cameras);
#if UNITY_2021_1_OR_NEWER
for (int i = 0; i < cameras.Count; ++i)
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs
index b042bf27064..a55af780841 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderPipelineCore.cs
@@ -948,6 +948,10 @@ internal static class ShaderPropertyId
public static readonly int worldToCameraMatrix = Shader.PropertyToID("unity_WorldToCamera");
public static readonly int cameraToWorldMatrix = Shader.PropertyToID("unity_CameraToWorld");
+ public static readonly int shadowBias = Shader.PropertyToID("_ShadowBias");
+ public static readonly int lightDirection = Shader.PropertyToID("_LightDirection");
+ public static readonly int lightPosition = Shader.PropertyToID("_LightPosition");
+
public static readonly int cameraWorldClipPlanes = Shader.PropertyToID("unity_CameraWorldClipPlanes");
public static readonly int billboardNormal = Shader.PropertyToID("unity_BillboardNormal");
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs
index f475f290ee1..25a8e132ff3 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs
@@ -242,7 +242,6 @@ public UniversalRenderer(UniversalRendererData data) : base(data)
#endif
m_DepthPrepass = new DepthOnlyPass(RenderPassEvent.BeforeRenderingPrePasses, RenderQueueRange.opaque, data.opaqueLayerMask);
m_DepthNormalPrepass = new DepthNormalOnlyPass(RenderPassEvent.BeforeRenderingPrePasses, RenderQueueRange.opaque, data.opaqueLayerMask);
- m_MotionVectorPass = new MotionVectorRenderPass(m_CameraMotionVecMaterial);
if (renderingModeRequested == RenderingMode.Forward || renderingModeRequested == RenderingMode.ForwardPlus)
{
@@ -284,13 +283,17 @@ public UniversalRenderer(UniversalRendererData data) : base(data)
m_RenderOpaqueForwardWithRenderingLayersPass = new DrawObjectsWithRenderingLayersPass(URPProfileId.DrawOpaqueObjects, true, RenderPassEvent.BeforeRenderingOpaques, RenderQueueRange.opaque, data.opaqueLayerMask, m_DefaultStencilState, stencilData.stencilReference);
bool copyDepthAfterTransparents = m_CopyDepthMode == CopyDepthMode.AfterTransparents;
+ RenderPassEvent copyDepthEvent = copyDepthAfterTransparents ? RenderPassEvent.AfterRenderingTransparents : RenderPassEvent.AfterRenderingSkybox;
m_CopyDepthPass = new CopyDepthPass(
- copyDepthAfterTransparents ? RenderPassEvent.AfterRenderingTransparents : RenderPassEvent.AfterRenderingSkybox,
+ copyDepthEvent,
m_CopyDepthMaterial,
shouldClear: true,
copyResolvedDepth: RenderingUtils.MultisampleDepthResolveSupported() && copyDepthAfterTransparents);
+ // Motion vectors depend on the (copy) depth texture. Depth is reprojected to calculate motion vectors.
+ m_MotionVectorPass = new MotionVectorRenderPass(copyDepthEvent + 1, m_CameraMotionVecMaterial);
+
m_DrawSkyboxPass = new DrawSkyboxPass(RenderPassEvent.BeforeRenderingSkybox);
m_CopyColorPass = new CopyColorPass(RenderPassEvent.AfterRenderingSkybox, m_SamplingMaterial, m_BlitMaterial);
#if ADAPTIVE_PERFORMANCE_2_1_0_OR_NEWER
@@ -1508,7 +1511,11 @@ private RenderPassInputSummary GetRenderPassInputs(ref RenderingData renderingDa
// Motion vectors imply depth
if (inputSummary.requiresMotionVectors)
+ {
inputSummary.requiresDepthTexture = true;
+ inputSummary.requiresDepthTextureEarliestEvent = (RenderPassEvent)Mathf.Min((int)m_MotionVectorPass.renderPassEvent, (int)inputSummary.requiresDepthTextureEarliestEvent);
+ }
+
return inputSummary;
}
diff --git a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs
index 3b7379713ca..245ad37227a 100644
--- a/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs
+++ b/Packages/com.unity.render-pipelines.universal/Runtime/UniversalRendererRenderGraph.cs
@@ -823,6 +823,16 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co
m_CopyDepthPass.Render(renderGraph, cameraDepthTexture, activeDepthTexture, ref renderingData, true);
}
+ // Depends on the camera (copy) depth texture. Depth is reprojected to calculate motion vectors.
+ if (renderPassInputs.requiresMotionVectors && m_CopyDepthMode != CopyDepthMode.AfterTransparents)
+ {
+ TextureHandle cameraDepthTexture = resources.GetTexture(UniversalResource.CameraDepthTexture);
+ TextureHandle motionVectorColor = resources.GetTexture(UniversalResource.MotionVectorColor);
+ TextureHandle motionVectorDepth = resources.GetTexture(UniversalResource.MotionVectorDepth);
+ // Depends on camera depth
+ m_MotionVectorPass.Render(renderGraph, cameraDepthTexture, motionVectorColor, motionVectorDepth, ref renderingData);
+ }
+
if (requiresColorCopyPass)
{
TextureHandle activeColor = activeColorTexture;
@@ -866,7 +876,8 @@ private void OnMainRendering(RenderGraph renderGraph, ScriptableRenderContext co
// TODO: Postprocess pass should be able configure its render pass inputs per camera per frame (settings) BEFORE building any of the graph
// TODO: Alternatively we could always build the graph (a potential graph) and cull away unused passes if "record + cull" is fast enough.
// TODO: Currently we just override "requiresMotionVectors" for TAA in GetRenderPassInputs()
- if (renderPassInputs.requiresMotionVectors)
+ // Depends on camera depth
+ if (renderPassInputs.requiresMotionVectors && m_CopyDepthMode == CopyDepthMode.AfterTransparents)
{
TextureHandle cameraDepthTexture = resources.GetTexture(UniversalResource.CameraDepthTexture);
TextureHandle motionVectorColor = resources.GetTexture(UniversalResource.MotionVectorColor);
diff --git a/Packages/com.unity.visualeffectgraph/Editor/Debug/VFXUIDebug.cs b/Packages/com.unity.visualeffectgraph/Editor/Debug/VFXUIDebug.cs
index 8e8167d73be..416cc4d9723 100644
--- a/Packages/com.unity.visualeffectgraph/Editor/Debug/VFXUIDebug.cs
+++ b/Packages/com.unity.visualeffectgraph/Editor/Debug/VFXUIDebug.cs
@@ -613,7 +613,7 @@ void Efficiency()
var settingsBox = SetSettingsBox();
var plotArea = SetPlotArea(m_DebugDrawingBox, Yaxis);
var title = SetSystemInfosTitle();
- m_SystemInfosContainer = SetSystemInfosContainer();
+ m_SystemInfosContainer = new VisualElement { name = "debug-system-stat-container" };
m_DebugContainer.Add(settingsBox);
m_DebugContainer.Add(plotArea);
@@ -636,7 +636,7 @@ void Alive()
var settingsBox = SetSettingsBox();
var plotArea = SetPlotArea(m_DebugDrawingBox, Yaxis);
var title = SetSystemInfosTitle();
- m_SystemInfosContainer = SetSystemInfosContainer();
+ m_SystemInfosContainer = new VisualElement { name = "debug-system-stat-container" };
m_DebugContainer.Add(settingsBox);
m_DebugContainer.Add(plotArea);
@@ -745,13 +745,6 @@ VisualElement SetPlotArea(Box debugDrawingBox, VisualElement Yaxis)
return plotArea;
}
- VisualElement SetSystemInfosContainer()
- {
- var scrollerContainer = new ScrollView();
- scrollerContainer.name = "debug-system-stat-container";
- return scrollerContainer;
- }
-
VisualElement SetSystemInfosTitle()
{
var toggleAll = new Toggle();
@@ -776,9 +769,7 @@ VisualElement SetSystemInfosTitle()
SystemInfoEfficiency.name = "debug-system-stat-title";
SystemInfoEfficiency.text = "Efficiency";
- var titleContainer = new VisualElement();
- titleContainer.name = "debug-system-stat-entry-container";
-
+ var titleContainer = new VisualElement { name = "debug-system-stat-entry-container" };
titleContainer.Add(toggleAll);
titleContainer.Add(SystemInfoName);
titleContainer.Add(SystemInfoAlive);
@@ -790,8 +781,8 @@ VisualElement SetSystemInfosTitle()
void AddSystemInfoEntry(string systemName, int id, Color color)
{
- var statContainer = new VisualElement();
- statContainer.name = "debug-system-stat-entry-container";
+ var statContainer = new VisualElement { name = "debug-system-stat-entry-container" };
+ statContainer.AddToClassList("row");
m_SystemInfosContainer.Add(statContainer);
var toggle = new Toggle();
@@ -813,8 +804,8 @@ void AddSystemInfoEntry(string systemName, int id, Color color)
VisualElement maxAlive;
if (isSystemInSubgraph)
{
- var maxAliveButton = new Button();
- maxAliveButton.name = "debug-system-stat-entry";
+ var maxAliveButton = new Button { name = "debug-system-stat-entry" };
+ maxAliveButton.tooltip = "Set system capacity";
maxAliveButton.text = "0";
maxAliveButton.SetEnabled(m_Graph.visualEffectResource != null && m_Graph.visualEffectResource.IsAssetEditable());
maxAliveButton.clickable.clickedWithEventInfo += setCapacity;
diff --git a/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs b/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs
index 7c70b958acb..3740d87e43e 100644
--- a/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs
+++ b/Packages/com.unity.visualeffectgraph/Editor/GraphView/VFXComponentBoard.cs
@@ -169,7 +169,6 @@ public VFXComponentBoard(VFXView view)
m_Step.clickable.clicked += EffectStep;
m_Restart = this.Query