Skip to content

Commit 2338c99

Browse files
markg-unityEvergreen
authored andcommitted
[Backport] [2022.3] Improve URP blitting docs (from DOCG-6282)
This is an **edited backport** of https://github.cds.internal.unity3d.com/unity/unity/pull/58119, which fixes some issues with the blitting documentation in URP. Jira ticket: https://jira.unity3d.com/browse/DOCG-6268
1 parent 41c9c02 commit 2338c99

13 files changed

+199
-1190
lines changed

Packages/com.unity.render-pipelines.universal/Documentation~/TableOfContents.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,9 @@
148148
* [Introduction to Scriptable Renderer Features](renderer-features/scriptable-renderer-features/intro-to-scriptable-renderer-features.md)
149149
* [Inject a custom render pass using a Scriptable Renderer Feature](renderer-features/scriptable-renderer-features/inject-a-pass-using-a-scriptable-renderer-feature.md)
150150
* [Apply a Scriptable Renderer Feature to a specific camera type](renderer-features/scriptable-renderer-features/apply-scriptable-feature-to-specific-camera.md)
151-
* [Example of a complete Scriptable Renderer Feature](renderer-features/create-custom-renderer-feature.md)
151+
* [Example of a complete Scriptable Renderer Feature](renderer-features/how-to-fullscreen-blit.md)
152152
* [Using textures](working-with-textures.md)
153-
* [URP blit best practices](customize/blit-overview.md)
154-
* [Perform a full screen blit in URP](renderer-features/how-to-fullscreen-blit.md)
153+
* [Blit](customize/blit-overview.md)
155154
* [Blit input and output textures](customize/blit-to-rthandle.md)
156155
* [Blit multiple RTHandle textures](customize/blit-multiple-rthandles.md)
157156
* [Injection points reference](customize/custom-pass-injection-points.md)
Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
1-
# URP blit best practices
1+
# Blit in URP
22

3-
A blit operation is a process of copying a source texture to a destination texture.
3+
To blit from one texture to another in a custom render pass in the Universal Render Pipeline (URP), use the [Blitter API](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest?subfolder=/api/UnityEngine.Rendering.Blitter.html) from the Core Scriptable Render Pipeline (SRP).
44

5-
This page provides an overview of different ways to perform a blit operation in URP and best practices to follow when writing custom render passes.
5+
The shader you use with the `Blitter` API must be a hand-coded shader. [Shader Graph](https://docs.unity3d.com/2022.3/Documentation/Manual/shader-graph.html) shaders aren't compatible with the `Blitter` API.
66

7-
## The legacy CommandBuffer.Blit API
7+
**Note:** The recommended best practice is not to use the `CommandBuffer.Blit` or `Graphics.Blit` APIs with URP, or APIs that use them internally such as `RenderingUtils.Blit`. These APIs might break XR rendering, and aren't compatible with native render passes. You can still use `CommandBuffer.Blit` and `Graphics.Blit` with the Built-In Render Pipeline.
88

9-
Avoid using the [CommandBuffer.Blit](https://docs.unity3d.com/2022.1/Documentation/ScriptReference/Rendering.CommandBuffer.Blit.html) API in URP projects.
9+
For example, add the following:
1010

11-
The [CommandBuffer.Blit](https://docs.unity3d.com/2022.1/Documentation/ScriptReference/Rendering.CommandBuffer.Blit.html) API is the legacy API. It implicitly runs extra operations related to changing states, binding textures, and setting render targets. Those operations happen under the hood in SRP projects and are not transparent to the user.
11+
```c#
12+
{
13+
Blitter.BlitCameraTexture(commandBuffer, sourceTexture, destinationTexture, materialToUse, passNumber);
14+
}
15+
```
1216

13-
The API has compatibility issues with the URP XR integration. Using `cmd.Blit` might implicitly enable or disable XR shader keywords, which breaks XR SPI rendering.
17+
For a full example, refer to [Example of a complete Scriptable Renderer Feature](../renderer-features/how-to-fullscreen-blit.md).
1418

15-
The [CommandBuffer.Blit](https://docs.unity3d.com/2022.1/Documentation/ScriptReference/Rendering.CommandBuffer.Blit.html) API is not compatible with `NativeRenderPass` and `RenderGraph`.
19+
## Additional resources
1620

17-
Similar considerations apply to any utilities or wrappers relying on `cmd.Blit` internally, `RenderingUtils.Blit` is one such example.
18-
19-
## SRP Blitter API
20-
21-
Use the [Blitter API](https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.Rendering.Blitter.html) in URP projects. This API does not rely on legacy logic, and is compatible with XR, native Render Passes, and other SRP APIs.
22-
23-
The shader you use with the `Blitter` API must be a hand-coded shader. [Shader Graph](xref:um-shader-graph) shaders aren't compatible with the `Blitter` API.
24-
25-
## Custom full-screen blit example
26-
27-
The [How to perform a full screen blit in URP](../renderer-features/how-to-fullscreen-blit.md) example shows how to create a custom Renderer Feature that performs a full screen blit. The example works in XR and is compatible with SRP APIs.
21+
- The blit examples in the [URP Package Samples](../package-sample-urp-package-samples.md)
22+
- [Custom render pass workflow](../renderer-features/custom-rendering-pass-workflow-in-urp.md)
23+
- [Using textures](../working-with-textures.md)

Packages/com.unity.render-pipelines.universal/Documentation~/post-processing/custom-post-processing.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ The following pages describe different approaches to creating custom post-proces
1313
| [Create a low-code custom post-processing effect](post-processing-custom-effect-low-code.md) | How to use a Full Screen Render Pass to create a low-code custom post-processing effect. |
1414
| [Full Screen Pass Renderer Feature reference](../renderer-features/renderer-feature-full-screen-pass.md) | Understand the Full Screen Pass Renderer Feature. |
1515
| [Creating a full-screen shader in Shader Graph in URP](../urp-shaders/fullscreen-master-stack-urp.md) | Resources for working with the Fullscreen Master Stack to create full screen shaders in Shader Graph. |
16-
| [Example of a complete Scriptable Renderer Feature](../renderer-features/create-custom-renderer-feature.md) | You can use a custom Renderer Feature with a Volume component support for implementing custom post-processing effects. |
16+
17+
## Additional resources
18+
19+
- [Example of a complete Scriptable Renderer Feature](../renderer-features/how-to-fullscreen-blit.md)
20+

0 commit comments

Comments
 (0)