Skip to content

Commit

Permalink
Merge pull request #8100 from Unity-Technologies/internal/master
Browse files Browse the repository at this point in the history
Internal/master
  • Loading branch information
UnityAljosha authored Sep 19, 2024
2 parents 161b0bd + 28c0840 commit 3fb000d
Show file tree
Hide file tree
Showing 1,186 changed files with 334,053 additions and 150,760 deletions.
32 changes: 0 additions & 32 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -337,38 +337,6 @@ Editor/Resources/unity[[:space:]]editor[[:space:]]resources filter=lfs diff=lfs
**/SRP_SmokeTest/**/*.tiff filter=lfs diff=lfs merge=lfs -text
**/SRP_SmokeTest/**/*.ttf filter=lfs diff=lfs merge=lfs -text
**/SRP_SmokeTest/**/*.vfx filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.bytes filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.cube filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.dds filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.exp filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.FBX filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.fbx filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.hdr filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.jpeg filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.jpg filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.png filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.psd filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.tga filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.tif filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.tiff filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.ttf filter=lfs diff=lfs merge=lfs -text
**/UniversalGfxTestStereo/**/*.vfx filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.bytes filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.cube filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.dds filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.exp filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.FBX filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.fbx filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.hdr filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.jpeg filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.jpg filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.png filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.psd filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.tga filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.tif filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.tiff filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.ttf filter=lfs diff=lfs merge=lfs -text
**/UniversalUpgradeTest/**/*.vfx filter=lfs diff=lfs merge=lfs -text

**/com.unity.template-hd/Assets/Scenes/SampleScene/LightingData.asset filter=lfs diff=lfs merge=lfs -text
**/HDRP_PerformanceTests/Assets/Scenes/Lighting/Cloud.asset filter=lfs diff=lfs merge=lfs -text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
* [What's new](whats-new.md)
* [12](whats-new-12.md)
* [13](whats-new-13.md)
* [Creating a custom render pipeline](srp-custom.md)
* [Create a custom Scriptable Render Pipeline](srp-custom-getting-started.md)
* [Create a Render Pipeline Asset and Render Pipeline Instance in a custom render pipeline](srp-creating-render-pipeline-asset-and-render-pipeline-instance.md)
* [Create a simple render loop in a custom render pipeline](srp-creating-simple-render-loop.md)
* [Execute rendering commands in a custom render pipeline](srp-using-scriptable-render-context.md)
* [Scriptable Render Pipeline callbacks reference](srp-callbacks-reference.md)
* Camera components
* [Free Camera](Free-Camera.md)
* [Camera Switcher](Camera-Switcher.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# SRP Core

![](https://blogs.unity3d.com/wp-content/uploads/2018/01/image5_rs.png)

The Scriptable Render Pipeline (SRP) is a Unity feature that allows you to write C# scripts to control the way Unity renders each frame. SRP Core is a package that makes it easier to create or customize an SRP.

SRP Core contains reusable code, including boilerplate code for working with platform-specific graphics APIs, utility functions for common rendering operations, and the shader libraries used in the High Definition Render Pipeline (HDRP) and Universal Render Pipeline (URP).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
uid: um-srp-creating-render-pipeline-asset-and-render-pipeline-instance
---

# Create a Render Pipeline Asset and Render Pipeline Instance in a custom render pipeline

If you are creating your own render pipeline based on the Scriptable Render Pipeline (SRP), your Project must contain:

* A script that inherits from [RenderPipelineAsset](xref:UnityEngine.Rendering.RenderPipelineAsset) and overrides its `CreatePipeline()` method. This script defines your Render Pipeline Asset.
* A script that inherits from [RenderPipeline](xref:UnityEngine.Rendering.RenderPipeline), and overrides its `Render()` method. This script defines your Render Pipeline Instance, and is where you write your custom rendering code.
* A Render Pipeline Asset that you have created from your [RenderPipelineAsset](xref:UnityEngine.Rendering.RenderPipelineAsset) script. This asset acts as a factory class for your Render Pipeline Instance.

Because these elements are so closely related, you should create them at the same time.

## Creating a basic Render Pipeline Asset and Render Pipeline Instance

The following example shows how to create a script for a basic custom Render Pipeline Asset that instantiates the Render Pipeline Instance, a script that defines the Render Pipeline Instance, and the Render Pipeline Asset itself.

1. Create a C# script called _ExampleRenderPipelineAsset.cs_.

2. Copy and paste the following code into the new script:

```lang-csharp
using UnityEngine;
using UnityEngine.Rendering;
// The CreateAssetMenu attribute lets you create instances of this class in the Unity Editor.
[CreateAssetMenu(menuName = "Rendering/ExampleRenderPipelineAsset")]
public class ExampleRenderPipelineAsset : RenderPipelineAsset
{
// Unity calls this method before rendering the first frame.
// If a setting on the Render Pipeline Asset changes, Unity destroys the current Render Pipeline Instance and calls this method again before rendering the next frame.
protected override RenderPipeline CreatePipeline() {
// Instantiate the Render Pipeline that this custom SRP uses for rendering.
return new ExampleRenderPipelineInstance();
}
}
```
3. Create a C# script called _ExampleRenderPipelineInstance.cs_.
4. Copy and paste the following code into the new script:
```lang-csharp
using UnityEngine;
using UnityEngine.Rendering;
public class ExampleRenderPipelineInstance : RenderPipeline
{
public ExampleRenderPipelineInstance() {
}
protected override void Render (ScriptableRenderContext context, Camera[] cameras) {
// This is where you can write custom rendering code. Customize this method to customize your SRP.
}
}
```
5. In the Project view, either click the add (+) button, or open the context menu and navigate to **Create**, and then choose **Rendering** > **Example Render Pipeline Asset**. Unity creates a new Render Pipeline Asset in the Project view.
## Creating a configurable Render Pipeline Asset and Render Pipeline Instance
By default, a Render Pipeline Asset stores information about which Render Pipeline Instance to use for rendering, and the default Materials and Shaders to use in the Editor. In your `RenderPipelineAsset` script, you can extend your Render Pipeline Asset so that it stores additional data, and you can have multiple different Render Pipeline Assets with different configurations in your Project. For example, you might use a Render Pipeline Asset to hold configuration data for each different tier of hardware. The High Definition Render Pipeline (HDRP) and the Universal Render Pipeline (URP) include examples of this.
The following example shows how to create a `RenderPipelineAsset` script that defines a Render Pipeline Asset with public data that you can set for each instance using the Inspector, and a Render Pipeline Instance that receives a Render Pipeline Asset in its constructor and uses data from that Render Pipeline Asset.
1. Create a C# script called _ExampleRenderPipelineAsset.cs_.
2. Copy and paste the following code into the new script:
```lang-csharp
using UnityEngine;
using UnityEngine.Rendering;
// The CreateAssetMenu attribute lets you create instances of this class in the Unity Editor.
[CreateAssetMenu(menuName = "Rendering/ExampleRenderPipelineAsset")]
public class ExampleRenderPipelineAsset : RenderPipelineAsset
{
// This data can be defined in the Inspector for each Render Pipeline Asset
public Color exampleColor;
public string exampleString;
// Unity calls this method before rendering the first frame.
// If a setting on the Render Pipeline Asset changes, Unity destroys the current Render Pipeline Instance and calls this method again before rendering the next frame.
protected override RenderPipeline CreatePipeline() {
// Instantiate the Render Pipeline that this custom SRP uses for rendering, and pass a reference to this Render Pipeline Asset.
// The Render Pipeline Instance can then access the configuration data defined above.
return new ExampleRenderPipelineInstance(this);
}
}
```
3. Create a C# script called _ExampleRenderPipelineInstance.cs_.
4. Copy and paste the following code into the new script:
```lang-csharp
using UnityEngine;
using UnityEngine.Rendering;
public class ExampleRenderPipelineInstance : RenderPipeline
{
// Use this variable to a reference to the Render Pipeline Asset that was passed to the constructor
private ExampleRenderPipelineAsset renderPipelineAsset;
// The constructor has an instance of the ExampleRenderPipelineAsset class as its parameter.
public ExampleRenderPipelineInstance(ExampleRenderPipelineAsset asset) {
renderPipelineAsset = asset;
}
protected override void Render(ScriptableRenderContext context, Camera[] cameras) {
// This is an example of using the data from the Render Pipeline Asset.
Debug.Log(renderPipelineAsset.exampleString);
// This is where you can write custom rendering code. Customize this method to customize your SRP.
}
}
```
5. In the Project view, either click the add (+) button, or open the context menu and navigate to **Create**, and then choose **Rendering** > **Example Render Pipeline Asset**. Unity creates a new Render Pipeline Asset in the Project view.
Loading

0 comments on commit 3fb000d

Please sign in to comment.