Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal/master #8116

Merged
merged 52 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3b58dd5
Fix shader warning
alelievr Nov 28, 2024
b457877
Graphics/SRP/RPF - [UUM-65578] Renabling non-RG testing for 275_RGBA1…
axoloto Nov 28, 2024
e3e1633
The Baked Lightmap debug doesnt work with HDRP terrains
SuminCho1 Nov 28, 2024
5afb27d
Graphics docs feedback fixes November 2024 (part 6)
markg-unity Nov 28, 2024
b1c8f27
docg-5368: Specify location of ambient occlusion properties
ocarrere Nov 28, 2024
b3bed68
Shadergraph support for spacewarp
lpledouxUnity Nov 29, 2024
1580968
[SRPF] GUIView update in the Building time could cause a failing SRP …
kirill-titov-u Nov 29, 2024
f23ea61
docg-5264: Update AxF-material-inspector-reference
ocarrere Nov 29, 2024
1a1b0aa
Graphics docs feedback fixes November 2024 (part 5)
markg-unity Nov 29, 2024
769e0e3
[HDRP] Reenable 3 graphics tests after stability fixes.
IonutNedelcuUnity Nov 29, 2024
104a37d
[Port] [Forward] [UUM-83862] Fix sorting the Reflection Probe by reso…
svc-reach-platform-support Nov 29, 2024
187a5f7
APV bug fixes
pmavridis Dec 2, 2024
a179332
Graphics docs feedback fixes November 2024 (part 8)
markg-unity Dec 2, 2024
2ffbc96
docg-4941: document Hair Master Stack Shader graph Fragments
ocarrere Dec 2, 2024
e2d3204
[VFX] Compilation Optimisation - Generate less DXR related code when …
ludovic-theobald Dec 3, 2024
8dd47cb
Fix color pyramid sampling UV when distortion is enabled
alelievr Dec 3, 2024
6a357fd
[6000.1][UUM-86922] Fix clear flags when post processing is used and …
kennytann Dec 3, 2024
71cf7fc
Fix for avoid warnings when using the NormalFromTexture node in Shade…
victor-riascos Dec 3, 2024
a7a887b
Variable shading rate init fix
eh-unity Dec 3, 2024
e9d5918
UUM75017 - Fix material changes impacting draw instances being ignore…
olivierprat Dec 3, 2024
a8bfe2a
Disable test for rendering layers on Switch
Adrian1066 Dec 4, 2024
4c0e650
HDRP Wizard FixAll button hide when no fix available
RSlysz Dec 4, 2024
338213e
[VFX/Docs] CustomHLSL & RWTexture
PaulDemeulenaere Dec 4, 2024
378382c
docg-5646 Fix typo
ocarrere Dec 5, 2024
3c9a145
[DocsQualityWeek2024] Improving documentation for VolumeComponents an…
ellioman Dec 5, 2024
4731ffb
Disable unstable test
ericksson Dec 5, 2024
f9e6d1e
[VFX] [Docs] Improved VFXTemplateDescriptor documentation
julienamsellem Dec 6, 2024
e0e96f7
docg-4944
ocarrere Dec 6, 2024
db4d1a5
[VFX] Enable instancing support for VFX using GPU events
gabrieldelacruz Dec 6, 2024
96d27ea
[VFX] Compilation Optimisation - Implement an include cache for SG ge…
ludovic-theobald Dec 6, 2024
c04ab13
[ShaderGraph] Prevent issues from multi-target property conflicts
Dec 6, 2024
ebd3a5f
Add vector4 as default into a sub-graph on converting from a node
Dec 6, 2024
42ef1da
Bicubic lightmap sampling for URP and HDRP
pema99 Dec 6, 2024
d18dd70
6.1 URP Deferred+
Dec 6, 2024
2ea3893
[VFX] [Doc] Added an example for VisualEffect.SetFloat
julienamsellem Dec 7, 2024
94e446f
[HDRP] Adding cave scene in water samples
remi-chapelain Dec 7, 2024
309bdc0
Render Graph - Add CullContext with Culling APIs
YohannVaastUnity Dec 7, 2024
283d125
Variable Rate Shading Custom Pass support for HDRP.
eh-unity Dec 9, 2024
8f6db0e
Graphics/foundation/update render api
RSlysz Dec 9, 2024
63448a9
[content automatically redacted] touching PlatformDependent folder
Dec 10, 2024
1e2cd0d
URP samples - Fix wrong GameObject names
YohannVaastUnity Dec 10, 2024
7128a4d
[HDRP] Disable 2 unstable graphics tests from HDRP_DXR project.
IonutNedelcuUnity Dec 11, 2024
dff9fab
Docsweek - Improve RenderingLayerMask enum docs and related API
laylaarab Dec 11, 2024
4e1a424
Graphics docs feedback fixes November 2024 (part 9 - VFX Graph fixes)
markg-unity Dec 12, 2024
d683d53
[Docs]Improving API docs for Debug Manager classes.
alex-vazquez-unity3d Dec 12, 2024
5cf397c
[URP] Added Support to Toggle Reflection Probe Atlas for Forward+
jrs-unity Dec 13, 2024
054e65b
DOCG-6165 Add horizontal deformation to HDRP water docs
markg-unity Dec 14, 2024
1072e93
[DocsQualityWeek2024] Updating UniversalAdditionalCameraData and Came…
ellioman Dec 16, 2024
dd1dd8b
DOCG-6335 Change references from Render (context, camera array) to Re…
markg-unity Dec 17, 2024
4d17614
Update ReloadAttribute documentation and linked documentation
RSlysz Dec 18, 2024
f990d81
DOCG-6338 Remove GPU Event experimental message and limitation
markg-unity Dec 18, 2024
7356826
Fix invalid area name
MindWrapper Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Scriptable Render Pipeline callbacks reference

When working with SRP, use these to make Unity call your C# code at specific times.

* [RenderPipeline.Render](xref:UnityEngine.Rendering.RenderPipeline.Render(UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])) is the main entry point to the SRP. Unity calls this method automatically. If you are writing a custom render pipeline, this is where you begin to write your code.
* The [RenderPipelineManager](xref:UnityEngine.Rendering.RenderPipelineManager) class has the following events that you can subscribe to, so that you can execute custom code at specific points in the render loop:
* [beginFrameRendering](xref:UnityEngine.Rendering.RenderPipeline.BeginFrameRendering(UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])) - **Note:** This can generate garbage. Use `beginContextRendering` instead.
* [endFrameRendering](xref:UnityEngine.Rendering.RenderPipeline.EndFrameRendering(UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])) - **Note:** This can generate garbage. Use `endContextRendering` instead.
* [beginContextRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginContextRendering.html)
* [endContextRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-endContextRendering.html)
* [beginCameraRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginCameraRendering.html)
* [endCameraRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-endCameraRendering.html)
# Use Scriptable Render Pipeline callbacks

To make Unity call your C# code at specific times, use the following APIs.

To write your custom render pipeline code, use the [RenderPipeline.Render](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipeline.Render.html) API. This method is the main entry point to the SRP, and Unity calls it automatically.

To execute custom code at specific points in the render loop, subscribe to the following events in the [RenderPipelineManager](xref:UnityEngine.Rendering.RenderPipelineManager) class:

* [beginContextRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginContextRendering.html)
* [endContextRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-endContextRendering.html)
* [beginCameraRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginCameraRendering.html)
* [endCameraRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-endCameraRendering.html)
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ The following example shows how to create a `RenderPipelineAsset` script that de
renderPipelineAsset = asset;
}

protected override void Render(ScriptableRenderContext context, Camera[] cameras) {
protected override void Render(ScriptableRenderContext context, List<Camera> cameras) {
// This is an example of using the data from the Render Pipeline Asset.
Debug.Log(renderPipelineAsset.exampleString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ To clear the render target in the Scriptable Render Pipeline, you do the followi
2. Add the `CommandBuffer` to the queue of commands on the `ScriptableRenderContext`; to do this, call [ScriptableRenderContext.ExecuteCommandBuffer](xref:UnityEngine.Rendering.ScriptableRenderContext.ExecuteCommandBuffer(UnityEngine.Rendering.CommandBuffer)).
3. Instruct the graphics API to perform the queue of commands on the `ScriptableRenderContext`; to do this, call [ScriptableRenderContext.Submit](xref:UnityEngine.Rendering.ScriptableRenderContext.Submit).

As with all Scriptable Render Pipeline operations, you use the [RenderPipeline.Render](xref:UnityEngine.Rendering.RenderPipeline.Render(UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])) method as the entry point for this code. This example code demonstrates how to do this:
As with all Scriptable Render Pipeline operations, you use the [RenderPipeline.Render](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipeline.Render.html) method as the entry point for this code. This example code demonstrates how to do this:

```lang-csharp
/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ExampleRenderPipeline : RenderPipeline
public ExampleRenderPipeline() {
}

protected override void Render(ScriptableRenderContext context, Camera[] cameras) {
protected override void Render(ScriptableRenderContext context, List<Camera> cameras) {
// Create and schedule a command to clear the current render target
var cmd = new CommandBuffer();
cmd.ClearRenderTarget(true, true, Color.red);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ internal bool PrepareAPVBake()
if (AdaptiveProbeVolumes.partialBakeSceneList.Count == activeSet.sceneGUIDs.Count)
AdaptiveProbeVolumes.partialBakeSceneList = null;

if (ProbeReferenceVolume.instance.supportLightingScenarios && !activeSet.m_LightingScenarios.Contains(activeSet.lightingScenario))
if (ProbeReferenceVolume.instance.supportLightingScenarios && !activeSet.m_LightingScenarios.Contains(activeSet.lightingScenario) && activeSet.m_LightingScenarios.Count > 0)
activeSet.SetActiveScenario(activeSet.m_LightingScenarios[0], false);

// Layout has changed and is incompatible.
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
area: Material
area: Materials
Original file line number Diff line number Diff line change
@@ -1 +1 @@
area: Material
area: Materials
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public VolumeParameterDrawerAttribute(Type parameterType)
/// parameter this drawer is for.
/// </summary>
/// <remarks>
/// If you do not provide a custom editor for a <see cref="VolumeParameter"/>, Unity uses the buil-in property drawers to draw the
/// If you do not provide a custom editor for a <see cref="VolumeParameter"/>, Unity uses the built-in property drawers to draw the
/// property as-is.
/// </remarks>
/// <example>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,52 @@
namespace UnityEngine.Rendering
{
/// <summary>
/// Attribute specifying information to reload with <see cref="ResourceReloader"/>. This is only
/// used in the editor and doesn't have any effect at runtime.
/// The <see cref="ReloadAttribute"/> attribute specifies paths for loading or reloading resources and has no direct action.
/// Used with the <see cref="ResourceReloader"/> to define where to load data for null fields.
/// </summary>
/// <remarks>
/// This attribute is designed for use in the Unity Editor and has no effect at runtime.
///
/// <see cref="IRenderPipelineResources"/> have their own attribute <see cref="ResourcePathAttribute"/> to do this.
/// When using them, resource reloading is handled automatically by the engine and does not require calling ResourceReloader.
///
/// While ResourceReloader was originally created for handling Scriptable Render Pipeline (SRP) resources, it has been replaced by <see cref="IRenderPipelineResources"/>.
/// The <see cref="ResourceReloader"/>, <see cref="ResourceReloader"/> and <see cref="ReloadGroupAttribute"/> remain available for for user-defined assets.
/// </remarks>
/// <seealso cref="ResourceReloader"/>
/// <seealso cref="ReloadGroupAttribute"/>
/// <example>
/// <para> This shows how to use the attribute in the expected scenario. This is particularly useful for content creators.
/// Adding a new field to a class that defines an asset results in null values for existing instances missing the field in their serialized data. Therefore, when a new field is added, a system for reloading null values may be necessary. </para>
/// <code>
///using UnityEngine;
///using UnityEditor;
///
///public class MyResourcesAsset : ScriptableObject
///{
/// [Reload("Shaders/Blit.shader")]
/// public Shader blit;
///
/// // Added in version 2
/// [Reload("Shaders/betterBlit.shader")]
/// public Shader betterBlit;
///}
///
///public static class MyResourceHandler
///{
/// public static MyResourcesAsset GetAndReload()
/// {
/// var resources = AssetDatabase.LoadAssetAtPath&lt;MyResourcesAsset&gt;("MyResources.asset");
///
/// // Ensure that update of the data layout of MyResourcesAsset
/// // will not result in null value for asset already existing.
/// // (e.g.: added betterBlit in the case above)
/// ResourceReloader.ReloadAllNullIn(resources, "Packages/com.my-custom-package/");
/// return resources;
/// }
///}
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Field)]
public sealed class ReloadAttribute : Attribute
{
Expand Down Expand Up @@ -52,6 +93,23 @@ public enum Package
/// </summary>
/// <param name="paths">Search paths</param>
/// <param name="package">The lookup method</param>
/// <example>
/// <para> This example demonstrates how to handle arrays with different resource paths. </para>
/// <code>
///using UnityEngine;
///
///public class MyResourcesAsset : ScriptableObject
///{
/// [ResourcePaths(new[]
/// {
/// "Texture/FilmGrain/Thin.png",
/// "Texture/FilmGrain/Medium.png",
/// "Texture/FilmGrain/Large.png",
/// })]
/// public Texture[] filmGrains;
///}
/// </code>
/// </example>
public ReloadAttribute(string[] paths, Package package = Package.Root)
{
#if UNITY_EDITOR
Expand All @@ -65,6 +123,18 @@ public ReloadAttribute(string[] paths, Package package = Package.Root)
/// </summary>
/// <param name="path">Search path</param>
/// <param name="package">The lookup method</param>
/// <example>
/// <para> This example shows how to directly specify the path of an asset. </para>
/// <code>
///using UnityEngine;
///
///public class MyResourcesAsset : ScriptableObject
///{
/// [Reload("Shaders/Blit.shader")]
/// public Shader blit;
///}
/// </code>
/// </example>
public ReloadAttribute(string path, Package package = Package.Root)
: this(new[] { path }, package)
{ }
Expand All @@ -77,6 +147,22 @@ public ReloadAttribute(string path, Package package = Package.Root)
/// <param name="rangeMin">The array start index (inclusive)</param>
/// <param name="rangeMax">The array end index (exclusive)</param>
/// <param name="package">The lookup method</param>
/// <example>
/// <para> This example demonstrates handling arrays with resource paths that share a common format, differing only by an index. </para>
/// <code>
///using UnityEngine;
///
///public class MyResourcesAsset : ScriptableObject
///{
/// // The following will seek for resources:
/// // - Texture/FilmGrain/Thin1.png
/// // - Texture/FilmGrain/Thin2.png
/// // - Texture/FilmGrain/Thin3.png
/// [ResourcePaths("Texture/FilmGrain/Thin{0}.png", 1, 4)]
/// public Texture[] thinGrains;
///}
/// </code>
/// </example>
public ReloadAttribute(string pathFormat, int rangeMin, int rangeMax,
Package package = Package.Root)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,57 @@
using System;
using UnityEditor;
using static UnityEngine.Rendering.DebugUI.Table;

namespace UnityEngine.Rendering
{
/// <summary>
/// Attribute specifying that it contains element that should be reloaded.
/// If the instance of the class is null, the system will try to recreate
/// it with the default constructor.
/// Be sure classes using it have default constructor!
/// Attribute specifying that fields of this type should be inspected in depth by the <see cref="ResourceReloader"/>.
/// If the associated class instance is null, the system attempts to recreate it using its default constructor.
/// </summary>
/// <remarks>
/// Make sure classes using it have a default constructor!
/// </remarks>
/// <seealso cref="ResourceReloader"/>
/// <seealso cref="ReloadAttribute"/>
/// <example>
/// <para> This shows how to use the attribute in the expected scenario. This is particularly useful for content creators.
/// Adding a new field to a class that defines an asset results in null values for existing instances missing the field in their serialized data. Therefore, when a new field is added, a system for reloading null values may be necessary. </para>
/// <code>
///using UnityEngine;
///using UnityEditor;
///
///[ReloadGroup]
///public class MyShaders
///{
/// [Reload("Shaders/Blit.shader")]
/// public Shader blit;
///}
///
///public class MyResourcesAsset : ScriptableObject
///{
/// // Object used for contextualizing would resolve to be null in already existing
/// // instance of MyResourcesAsset that already exists.
/// public MyShaders shaders;
///
/// [Reload("Textures/BayerMatrix.png")]
/// public Texture2D bayerMatrixTex;
///}
///
///public static class MyResourceHandler
///{
/// public static MyResourcesAsset GetAndReload()
/// {
/// var resources = AssetDatabase.LoadAssetAtPath&lt;MyResourcesAsset&gt;("MyResources.asset");
///
/// // Ensure that update of the data layout of MyResourcesAsset
/// // will not result in null value for asset already existing.
/// // (e.g.: adding new field in MyResourcesAsset or MyShaders classes)
/// ResourceReloader.ReloadAllNullIn(resources, "Packages/com.my-custom-package/");
/// return resources;
/// }
///}
/// </code>
/// </example>
[AttributeUsage(AttributeTargets.Class)]
public sealed class ReloadGroupAttribute : Attribute
{ }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,70 @@ namespace UnityEngine.Rendering
using UnityObject = UnityEngine.Object;

/// <summary>
/// IDebugData interface.
/// Implementing this interface enables integration with Unity's Rendering debugger, providing a way to manage and control the state of debug data.
/// </summary>
///
/// <remarks>
/// Use the `IDebugData` interface to register custom debug data. You can reset the data when necessary, which makes it suitable for debugging scenarios
/// where you need to clear or reset specific data. For example, when the application state changes or during gameplay session resets,
/// or when the **Reset** button is selected in the **Rendering Debugger** window in the Editor or at runtime.
/// </remarks>
///
/// <example>
/// <code>
/// public class MyDebugData : IDebugData
/// {
/// private int _value;
///
/// /// Constructor of the debug data that will receive the reset callback
/// public MyDebugData()
/// {
/// _value = 0;
/// }
///
/// public Action GetReset()
/// {
/// /// Specify the callback when the reset operation is being called.
/// return () => _value = 0; // Resets the value to 0
/// }
/// }
/// </code>
/// </example>
public interface IDebugData
{
/// <summary>Get the reset callback for this DebugData</summary>
/// <summary>Provides the reset callback for resetting the debug data.</summary>
/// <returns>The reset callback</returns>
Action GetReset();
//Action GetLoad();
//Action GetSave();
}

/// <summary>
/// Manager class for the Debug Window.
/// The <see cref="DebugManager"/> class provides a centralized manager for handling Unity's Rendering debugger.
/// </summary>
/// <remarks>
/// The DebugManager allows you to register, unregister, and manipulate debug data, panels, and widgets for runtime or editor debugging.
/// - Register and manage debug panels and widgets.
/// - Refresh and reset the debug UI based on runtime changes.
/// - Provides a global instance for easy access from anywhere in the codebase.
/// </remarks>
///
/// <example>
/// <code>
/// {
/// /// Create a list to store the new DebugUI widgets
/// /// by creating different DebugUI.Values that display a label with a value.
/// var list = new System.Collections.Generic.List&lt;DebugUI.Widget&gt;
/// {
/// new DebugUI.Value { displayName = "Lighting Intensity", getter = () => 1.0f, setter = value => Debug.Log($"Lighting Intensity set to {value}") },
/// new DebugUI.Value { displayName = "Light Color", getter = () => Color.white, setter = value => Debug.Log($"Light Color set to {value}") }
/// };
/// var items = list.ToArray();
///
/// /// Obtain the panel from the DebugManager instance, and add the Widgets that we want to display there.
/// var panel = DebugManager.instance.GetPanel("Lighting", true);
/// panel.children.AddRange(items);
/// }
/// </code>
/// </example>
public sealed partial class DebugManager
{
static readonly Lazy<DebugManager> s_Instance = new Lazy<DebugManager>(() => new DebugManager());
Expand Down
Loading
Loading