Skip to content

Commit 498fe87

Browse files
Merge pull request #8166 from Unity-Technologies/internal/2021.3/staging
Internal/2021.3/staging
2 parents ff9d7f6 + 4b206f1 commit 498fe87

File tree

6 files changed

+88
-5
lines changed

6 files changed

+88
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@
114114
* [URP unlit shader with color input](writing-shaders-urp-unlit-color.md)
115115
* [Drawing a texture](writing-shaders-urp-unlit-texture.md)
116116
* [Visualizing normal vectors](writing-shaders-urp-unlit-normals.md)
117+
* [Write depth only in a shader in URP](writing-shaders-urp-depth-only.md)
117118
* [Reconstruct the world space positions](writing-shaders-urp-reconstruct-world-position.md)
118119
* [Shader methods in URP](use-built-in-shader-methods.md)
119120
* [Import a file from the URP shader library](use-built-in-shader-methods-import.md)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ This section contains properties related to rendering.
5656
| Property | Description |
5757
|:-|:-|
5858
| **Rendering&#160;Path** | Select the Rendering Path.<br/>Options:<ul><li>**Forward**: The Forward Rendering Path.</li><li>**Deferred**: The Deferred Rendering Path. For more information, refer to [Deferred Rendering Path](rendering/deferred-rendering-path.md).</li></ul> |
59-
| &#160;&#160;**Depth&#160;Priming&#160;Mode** | Specify whether Unity uses scene depth data to identify pixels the camera can't see, then skips the shader fragment stage for those pixels. This speeds up rendering, but has an upfront memory and performance cost. The amount rendering speeds up depends on how many pixels are hidden, and the complexity of the fragment shader code Unity skips.<br/><br/>The options are:<ul><li>**Disabled**: Unity doesn't perform depth priming.</li><li>**Auto**: Unity performs depth priming only if it's already performed a depth prepass. A depth prepass renders scene depth data early in the render pipeline. This option is not supported on Android, iOS, and Apple TV.</li><li>**Forced**: Unity always performs a depth prepass and depth priming.</li></ul><br/>Depth priming isn't compatible with the following:<ul><li>Platforms that use tile-based rendering.</li><li>The Deferred rendering path.</li><li>Multisample anti-aliasing (MSAA).</li></ul> |
59+
| **Depth Priming Mode** | Skips drawing overlapping pixels, to speed up rendering. Unity uses the depth texture to check which pixels overlap. The rendering improvement depends on the number of overlapping pixels and the complexity of the pixel shaders.<br/><br/>**Note**: If you use custom shaders, Unity renders opaque objects as invisible unless you add passes with `DepthOnly` and `DepthNormals` tags. For more information, refer to [Write depth only in a shader](writing-shaders-urp-depth-only.md).<br/><br/>The options are:<ul><li>**Disabled**: Doesn't perform depth priming.</li><li>**Auto**: Performs depth priming only if a depth prepass already exists in the render pipeline. This setting isn't supported on Android, iOS and Apple TV platforms.</li><li>**Forced**: Adds a depth prepass to the render pipeline if it doesn't already exist, and performs depth priming. Adding the depth prepass has an impact on memory and performance.</li></ul>**Note**: Depth priming isn't supported if you use a [deferred rendering path](rendering/deferred-rendering-path-landing.md) or [Multisample Anti-aliasing](anti-aliasing.md#multisample-anti-aliasing-msaa), or at runtime on mobile devices that use tile-based deferred rendering (TBDR).|
6060
| &#160;&#160;**Accurate G-buffer normals** | Indicates whether to use a more resource-intensive normal encoding/decoding method to improve visual quality.<br /><br />This property is available only if **Rendering Path** is set to **Deferred**. |
6161
| **Depth Texture Mode** | Specifies the stage in the render pipeline at which to copy the scene depth to a depth texture. The options are:<ul><li>**After Opaques**: URP copies the scene depth after the opaques render pass.</li><li>**Force Prepass**: URP does a depth prepass to generate the scene depth texture. |
6262

Packages/com.unity.render-pipelines.universal/Documentation~/writing-custom-shaders-urp.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ The section contains the following topics:
1010
* [URP unlit shader with color input](writing-shaders-urp-unlit-color.md)
1111
* [Drawing a texture](writing-shaders-urp-unlit-texture.md)
1212
* [Visualizing normal vectors](writing-shaders-urp-unlit-normals.md)
13+
* [Write depth only in a shader in URP](writing-shaders-urp-depth-only.md)
1314
* [Reconstruct the world space positions](writing-shaders-urp-reconstruct-world-position.md)
1415
* [Built-in shader methods in URP](use-built-in-shader-methods.md)
1516

Packages/com.unity.render-pipelines.universal/Documentation~/writing-shaders-urp-basic-unlit-structure.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ This example shows a basic URP-compatible shader. This shader fills the mesh sha
44

55
To see the shader in action, copy and paste the following ShaderLab code into the Shader asset.
66

7-
```c++
7+
**Note**: If you enable **Depth Priming Mode** in the [URP asset](universalrp-asset.md), this shader renders opaque objects as invisible. For more information, refer to [Write depth only in a shader](writing-shaders-urp-depth-only.md).
8+
9+
``` lang-cpp
810
// This shader fills the mesh shape with a color predefined in the code.
911
Shader "Example/URPUnlitShaderBasic"
1012
{
@@ -143,8 +145,6 @@ This block contains the HLSL program code.
143145

144146
> **NOTE**: HLSL language is the preferred language for URP shaders.
145147
146-
> **NOTE**: URP supports the CG language. If you add the CGPROGRAM/ENDCGPROGRAM block in a shader, Unity includes shaders from the Built-in Render Pipeline library automatically. If you include shaders from the SRP shader library, some SRP shader macros and functions might conflict with the Built-in Render Pipeline shader functions. Shaders with the CGPROGRAM block are not SRP Batcher compatible.
147-
148148
This block contains the `#include` declaration with the reference to the `Core.hlsl` file.
149149

150150
```c++
@@ -164,6 +164,8 @@ Varyings vert(Attributes IN)
164164
}
165165
```
166166
167+
> **Note**: Don't import shader library files from both the Scriptable Render Pipeline (SRP) and the Built-In Render Pipeline in the same shader. Some SRP shader macros and functions might conflict with the Built-in Render Pipeline shader functions. For more information, refer to [Shader methods in URP](use-built-in-shader-methods) and [Import a file from the shader library in the Built-In Render Pipeline](../SL-BuiltinIncludes).
168+
167169
The fragment shader in this basic HLSL code outputs the single color predefined in the code:
168170
169171
```c++
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Write a depth-only pass in a Universal Render Pipeline shader
2+
3+
To create a depth prepass that writes the depth of objects before the opaque and transparent passes, add a shader pass that has the `DepthOnly` tag.
4+
5+
Add this pass if you enable a setting that requires a depth prepass, otherwise Unity might render incorrectly. For example, if you enable **Depth Priming** in the [Universal Render Pipleine (URP) Asset](urp-universal-renderer.md), opaque objects are invisible.
6+
7+
**Important**: To render correctly, make sure that every shader pass renders the same number of fragments in the same positions. For example, use an include or a macro to share the same code between passes, especially if you change the positions of vertices, use alpha clipping, or use effects like dithering.
8+
9+
## Add a depth-only pass
10+
11+
The following example shows how to add a depth-only pass to a shader:
12+
13+
```lang-hlsl
14+
Shader "Example/CustomShader"
15+
{
16+
SubShader
17+
{
18+
19+
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" }
20+
21+
// Add a depth-only pass
22+
Pass
23+
{
24+
Name "DepthOnlyPass"
25+
Tags { "LightMode" = "DepthOnly" }
26+
27+
// Write depth to the depth buffer
28+
ZWrite On
29+
30+
// Don't write to the color buffer
31+
ColorMask 0
32+
33+
...
34+
}
35+
36+
// The forward pass. This pass also writes depth by default.
37+
Pass
38+
{
39+
Name "ForwardPass"
40+
Tags { "LightMode" = "UniversalForward" }
41+
42+
...
43+
}
44+
}
45+
}
46+
```
47+
48+
## Add a depth and normals pass
49+
50+
The recommended best practice is to also add a pass that has the `DepthNormals` tag, to write both the depth and normals of objects. Otherwise, if you enable features like screen space ambient occlusion (SSAO), Unity might not render objects correctly.
51+
52+
For more information about outputting normals, refer to [Visualize normal vectors in a shader in URP](writing-shaders-urp-unlit-normals.md).
53+
54+
For example:
55+
56+
```lang-hlsl
57+
Pass
58+
{
59+
Name "DepthNormalsPass"
60+
Tags { "LightMode" = "DepthNormals" }
61+
62+
// Write depth to the depth buffer
63+
ZWrite On
64+
65+
...
66+
67+
float4 frag(Varyings input) : SV_TARGET
68+
{
69+
// Return the normal as a value between 0 and 1
70+
float3 normalWS = normalize(input.normalWS);
71+
return float4(normalWS * 0.5 + 0.5, 1);
72+
}}
73+
```
74+
75+
## Additional resources
76+
77+
- [ShaderLab Pass tags](urp-shaders/urp-shaderlab-pass-tags.md)
78+
- [Shader methods](use-built-in-shader-methods.md)
79+
- [Universal Render Pipleine (URP) Asset](urp-universal-renderer.md)

Packages/com.unity.visualeffectgraph/Documentation~/Operator-ProbabilitySampling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Menu Path : **Operator > Logic > Probability Sampling**
66

77
The **Probability Sampling** Operator performs a kind of switch/case operation where a weight controls the probability of selecting a case. If all weights are equal, this Operator produces a uniform distribution of the different output values.
88

9-
![img](Images/Operator-ProbabilitySamplingExample.gif)
9+
![A Random Selector Weighted Operator, and its effect on a 32 x 32 grid. In the Operator, Value 0 is red with a weight of 1, Value 1 is green with a weight of 0, and Value 2 is blue with a weight of 0. The grid is fully red. As the weight of Value 1 is dragged from 0 to 1, more red squares turn green. As the weight of Value 2 is then dragged from 0 to 1, more red and green squares turn blue.](Images/Operator-ProbabilitySamplingExample.gif)
1010

1111
## Operator settings
1212

0 commit comments

Comments
 (0)