Skip to content

Commit 3ecf962

Browse files
authored
Merge pull request #8116 from Unity-Technologies/internal/master
Internal/master
2 parents 0ad4df7 + 7356826 commit 3ecf962

449 files changed

Lines changed: 120467 additions & 2000 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# Scriptable Render Pipeline callbacks reference
2-
3-
When working with SRP, use these to make Unity call your C# code at specific times.
4-
5-
* [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.
6-
* 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:
7-
* [beginFrameRendering](xref:UnityEngine.Rendering.RenderPipeline.BeginFrameRendering(UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])) - **Note:** This can generate garbage. Use `beginContextRendering` instead.
8-
* [endFrameRendering](xref:UnityEngine.Rendering.RenderPipeline.EndFrameRendering(UnityEngine.Rendering.ScriptableRenderContext,UnityEngine.Camera[])) - **Note:** This can generate garbage. Use `endContextRendering` instead.
9-
* [beginContextRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginContextRendering.html)
10-
* [endContextRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-endContextRendering.html)
11-
* [beginCameraRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginCameraRendering.html)
12-
* [endCameraRendering](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/Rendering.RenderPipelineManager-endCameraRendering.html)
1+
# Use Scriptable Render Pipeline callbacks
2+
3+
To make Unity call your C# code at specific times, use the following APIs.
4+
5+
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.
6+
7+
To execute custom code at specific points in the render loop, subscribe to the following events in the [RenderPipelineManager](xref:UnityEngine.Rendering.RenderPipelineManager) class:
8+
9+
* [beginContextRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginContextRendering.html)
10+
* [endContextRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-endContextRendering.html)
11+
* [beginCameraRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-beginCameraRendering.html)
12+
* [endCameraRendering](https://docs.unity3d.com/6000.1/Documentation/ScriptReference/Rendering.RenderPipelineManager-endCameraRendering.html)

Packages/com.unity.render-pipelines.core/Documentation~/srp-creating-render-pipeline-asset-and-render-pipeline-instance.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ The following example shows how to create a `RenderPipelineAsset` script that de
109109
renderPipelineAsset = asset;
110110
}
111111
112-
protected override void Render(ScriptableRenderContext context, Camera[] cameras) {
112+
protected override void Render(ScriptableRenderContext context, List<Camera> cameras) {
113113
// This is an example of using the data from the Render Pipeline Asset.
114114
Debug.Log(renderPipelineAsset.exampleString);
115115

Packages/com.unity.render-pipelines.core/Documentation~/srp-creating-simple-render-loop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ To clear the render target in the Scriptable Render Pipeline, you do the followi
120120
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)).
121121
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).
122122

123-
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:
123+
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:
124124

125125
```lang-csharp
126126
/*

Packages/com.unity.render-pipelines.core/Documentation~/srp-using-scriptable-render-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class ExampleRenderPipeline : RenderPipeline
3232
public ExampleRenderPipeline() {
3333
}
3434
35-
protected override void Render(ScriptableRenderContext context, Camera[] cameras) {
35+
protected override void Render(ScriptableRenderContext context, List<Camera> cameras) {
3636
// Create and schedule a command to clear the current render target
3737
var cmd = new CommandBuffer();
3838
cmd.ClearRenderTarget(true, true, Color.red);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ internal bool PrepareAPVBake()
10151015
if (AdaptiveProbeVolumes.partialBakeSceneList.Count == activeSet.sceneGUIDs.Count)
10161016
AdaptiveProbeVolumes.partialBakeSceneList = null;
10171017

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

10211021
// Layout has changed and is incompatible.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
area: Material
1+
area: Materials
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
area: Material
1+
area: Materials

Packages/com.unity.render-pipelines.core/Editor/Volume/VolumeParameterDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public VolumeParameterDrawerAttribute(Type parameterType)
3535
/// parameter this drawer is for.
3636
/// </summary>
3737
/// <remarks>
38-
/// If you do not provide a custom editor for a <see cref="VolumeParameter"/>, Unity uses the buil-in property drawers to draw the
38+
/// If you do not provide a custom editor for a <see cref="VolumeParameter"/>, Unity uses the built-in property drawers to draw the
3939
/// property as-is.
4040
/// </remarks>
4141
/// <example>

Packages/com.unity.render-pipelines.core/Runtime/Common/ReloadAttribute.cs

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,52 @@
33
namespace UnityEngine.Rendering
44
{
55
/// <summary>
6-
/// Attribute specifying information to reload with <see cref="ResourceReloader"/>. This is only
7-
/// used in the editor and doesn't have any effect at runtime.
6+
/// The <see cref="ReloadAttribute"/> attribute specifies paths for loading or reloading resources and has no direct action.
7+
/// Used with the <see cref="ResourceReloader"/> to define where to load data for null fields.
88
/// </summary>
9+
/// <remarks>
10+
/// This attribute is designed for use in the Unity Editor and has no effect at runtime.
11+
///
12+
/// <see cref="IRenderPipelineResources"/> have their own attribute <see cref="ResourcePathAttribute"/> to do this.
13+
/// When using them, resource reloading is handled automatically by the engine and does not require calling ResourceReloader.
14+
///
15+
/// While ResourceReloader was originally created for handling Scriptable Render Pipeline (SRP) resources, it has been replaced by <see cref="IRenderPipelineResources"/>.
16+
/// The <see cref="ResourceReloader"/>, <see cref="ResourceReloader"/> and <see cref="ReloadGroupAttribute"/> remain available for for user-defined assets.
17+
/// </remarks>
918
/// <seealso cref="ResourceReloader"/>
1019
/// <seealso cref="ReloadGroupAttribute"/>
20+
/// <example>
21+
/// <para> This shows how to use the attribute in the expected scenario. This is particularly useful for content creators.
22+
/// 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>
23+
/// <code>
24+
///using UnityEngine;
25+
///using UnityEditor;
26+
///
27+
///public class MyResourcesAsset : ScriptableObject
28+
///{
29+
/// [Reload("Shaders/Blit.shader")]
30+
/// public Shader blit;
31+
///
32+
/// // Added in version 2
33+
/// [Reload("Shaders/betterBlit.shader")]
34+
/// public Shader betterBlit;
35+
///}
36+
///
37+
///public static class MyResourceHandler
38+
///{
39+
/// public static MyResourcesAsset GetAndReload()
40+
/// {
41+
/// var resources = AssetDatabase.LoadAssetAtPath&lt;MyResourcesAsset&gt;("MyResources.asset");
42+
///
43+
/// // Ensure that update of the data layout of MyResourcesAsset
44+
/// // will not result in null value for asset already existing.
45+
/// // (e.g.: added betterBlit in the case above)
46+
/// ResourceReloader.ReloadAllNullIn(resources, "Packages/com.my-custom-package/");
47+
/// return resources;
48+
/// }
49+
///}
50+
/// </code>
51+
/// </example>
1152
[AttributeUsage(AttributeTargets.Field)]
1253
public sealed class ReloadAttribute : Attribute
1354
{
@@ -52,6 +93,23 @@ public enum Package
5293
/// </summary>
5394
/// <param name="paths">Search paths</param>
5495
/// <param name="package">The lookup method</param>
96+
/// <example>
97+
/// <para> This example demonstrates how to handle arrays with different resource paths. </para>
98+
/// <code>
99+
///using UnityEngine;
100+
///
101+
///public class MyResourcesAsset : ScriptableObject
102+
///{
103+
/// [ResourcePaths(new[]
104+
/// {
105+
/// "Texture/FilmGrain/Thin.png",
106+
/// "Texture/FilmGrain/Medium.png",
107+
/// "Texture/FilmGrain/Large.png",
108+
/// })]
109+
/// public Texture[] filmGrains;
110+
///}
111+
/// </code>
112+
/// </example>
55113
public ReloadAttribute(string[] paths, Package package = Package.Root)
56114
{
57115
#if UNITY_EDITOR
@@ -65,6 +123,18 @@ public ReloadAttribute(string[] paths, Package package = Package.Root)
65123
/// </summary>
66124
/// <param name="path">Search path</param>
67125
/// <param name="package">The lookup method</param>
126+
/// <example>
127+
/// <para> This example shows how to directly specify the path of an asset. </para>
128+
/// <code>
129+
///using UnityEngine;
130+
///
131+
///public class MyResourcesAsset : ScriptableObject
132+
///{
133+
/// [Reload("Shaders/Blit.shader")]
134+
/// public Shader blit;
135+
///}
136+
/// </code>
137+
/// </example>
68138
public ReloadAttribute(string path, Package package = Package.Root)
69139
: this(new[] { path }, package)
70140
{ }
@@ -77,6 +147,22 @@ public ReloadAttribute(string path, Package package = Package.Root)
77147
/// <param name="rangeMin">The array start index (inclusive)</param>
78148
/// <param name="rangeMax">The array end index (exclusive)</param>
79149
/// <param name="package">The lookup method</param>
150+
/// <example>
151+
/// <para> This example demonstrates handling arrays with resource paths that share a common format, differing only by an index. </para>
152+
/// <code>
153+
///using UnityEngine;
154+
///
155+
///public class MyResourcesAsset : ScriptableObject
156+
///{
157+
/// // The following will seek for resources:
158+
/// // - Texture/FilmGrain/Thin1.png
159+
/// // - Texture/FilmGrain/Thin2.png
160+
/// // - Texture/FilmGrain/Thin3.png
161+
/// [ResourcePaths("Texture/FilmGrain/Thin{0}.png", 1, 4)]
162+
/// public Texture[] thinGrains;
163+
///}
164+
/// </code>
165+
/// </example>
80166
public ReloadAttribute(string pathFormat, int rangeMin, int rangeMax,
81167
Package package = Package.Root)
82168
{

Packages/com.unity.render-pipelines.core/Runtime/Common/ReloadGroupAttribute.cs

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,57 @@
11
using System;
2+
using UnityEditor;
3+
using static UnityEngine.Rendering.DebugUI.Table;
24

35
namespace UnityEngine.Rendering
46
{
57
/// <summary>
6-
/// Attribute specifying that it contains element that should be reloaded.
7-
/// If the instance of the class is null, the system will try to recreate
8-
/// it with the default constructor.
9-
/// Be sure classes using it have default constructor!
8+
/// Attribute specifying that fields of this type should be inspected in depth by the <see cref="ResourceReloader"/>.
9+
/// If the associated class instance is null, the system attempts to recreate it using its default constructor.
1010
/// </summary>
11+
/// <remarks>
12+
/// Make sure classes using it have a default constructor!
13+
/// </remarks>
14+
/// <seealso cref="ResourceReloader"/>
1115
/// <seealso cref="ReloadAttribute"/>
16+
/// <example>
17+
/// <para> This shows how to use the attribute in the expected scenario. This is particularly useful for content creators.
18+
/// 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>
19+
/// <code>
20+
///using UnityEngine;
21+
///using UnityEditor;
22+
///
23+
///[ReloadGroup]
24+
///public class MyShaders
25+
///{
26+
/// [Reload("Shaders/Blit.shader")]
27+
/// public Shader blit;
28+
///}
29+
///
30+
///public class MyResourcesAsset : ScriptableObject
31+
///{
32+
/// // Object used for contextualizing would resolve to be null in already existing
33+
/// // instance of MyResourcesAsset that already exists.
34+
/// public MyShaders shaders;
35+
///
36+
/// [Reload("Textures/BayerMatrix.png")]
37+
/// public Texture2D bayerMatrixTex;
38+
///}
39+
///
40+
///public static class MyResourceHandler
41+
///{
42+
/// public static MyResourcesAsset GetAndReload()
43+
/// {
44+
/// var resources = AssetDatabase.LoadAssetAtPath&lt;MyResourcesAsset&gt;("MyResources.asset");
45+
///
46+
/// // Ensure that update of the data layout of MyResourcesAsset
47+
/// // will not result in null value for asset already existing.
48+
/// // (e.g.: adding new field in MyResourcesAsset or MyShaders classes)
49+
/// ResourceReloader.ReloadAllNullIn(resources, "Packages/com.my-custom-package/");
50+
/// return resources;
51+
/// }
52+
///}
53+
/// </code>
54+
/// </example>
1255
[AttributeUsage(AttributeTargets.Class)]
1356
public sealed class ReloadGroupAttribute : Attribute
1457
{ }

0 commit comments

Comments
 (0)