Skip to content

Commit a290067

Browse files
Merge pull request #8187 from Unity-Technologies/internal/2021.3/staging
Internal/2021.3/staging
2 parents 9881ea1 + 68d0918 commit a290067

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+866
-182
lines changed

Packages/com.unity.render-pipelines.high-definition/Documentation~/Override-Contact-Shadows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Contact Shadows
2-
The Contact Shadows [Volume Override](Volume-Components.md) specifies properties which control the behavior of Contacts Shadows. Contact Shadows are shadows that The High Definition Render Pipeline (HDRP) [ray marches](Glossary.md#RayMarching) in screen space inside the depth buffer. The goal of using Contact Shadows is to capture small details that regular shadow mapping algorithms fail to capture.
2+
Contact Shadows are shadows that HDRP [ray marches](Glossary.md#RayMarching) in screen space, inside the depth buffer, at a close range. Use Contact Shadows to provide shadows for geometry details that regular shadow mapping algorithms usually fail to capture.
33

44

55
## Enabling Contact Shadows
-17.9 KB
Loading
Lines changed: 39 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,65 @@
1-
# Example: How to create a custom rendering effect using the Render Objects Renderer Feature
1+
---
2+
uid: urp-how-to-custom-effect-render-objects
3+
---
24

3-
URP draws objects in the **DrawOpaqueObjects** and **DrawTransparentObjects** passes. You might need to draw objects at a different point in the frame rendering, or interpret and write rendering data (like depth and stencil) in alternate ways. The [Render Objects Renderer Feature](renderer-feature-render-objects.md) lets you do such customizations by letting you draw objects on a certain layer, at a certain time, with specific overrides.
5+
# Example of creating a custom rendering effect using a Render Objects Renderer Feature in URP
46

5-
The example on this page describes how to create a custom rendering effect with the Render Objects Renderer Feature.
7+
The [Render Objects Renderer Feature](renderer-feature-render-objects) lets you draw objects at a specific point in the frame rendering loop. You can interpret and write rendering data such as depth and stencil in different ways, or draw a set of GameObjects at a certain time.
68

7-
## Example overview
9+
The following example uses a Render Objects Renderer Feature to draw a GameObject in a different color if it's behind other GameObjects.
810

9-
The example on this page demonstrates how to implement the following effect:
11+
![A character created from 3 simple capsules for the body and arms. The character is red, but as it moves behind a wall, the hidden parts are rendered blue.](../Images/how-to-render-objects/character-goes-behind-object.gif)
1012

11-
* There is a character in the Scene.
13+
First, create a GameObject and attach it to a new [layer](https://docs.unity3d.com/Manual/Layers.html).
1214

13-
![Character](../Images/how-to-render-objects/character.png)
15+
1. Create a GameObject in your scene.
16+
1. In the **Inspector** window, open the **Layer** dropdown and add a new layer. You can call the layer **DrawBehind**.
17+
1. Set the GameObject to the new layer.
1418

15-
* When the character goes behind GameObjects, Unity draws the character silhouette with a different Material.
19+
Next, create a Render Objects Renderer Feature that renders only the new layer, on top of the scene.
1620

17-
![Character goes behind GameObjects](../Images/how-to-render-objects/character-goes-behind-object.gif)
21+
1. In the **Project** window, select the [URP Renderer asset](../universalrp-asset) your project uses, for example **Settings** > **PC_Renderer**.
22+
1. To create a Render Objects Renderer Feature, select **Add Renderer Feature** in the **Inspector** window, then select **Render Objects**.
23+
1. To make the Renderer Feature draw only the layer with the GameObject, open the **Render Objects (Render Objects)** dropdown, then set **Layer Mask** to the layer.
24+
1. Set **Event** to the **AfterRenderingOpaques** injection point. For more information about custom pass injection points, refer to [Custom Pass injection points](../customize/custom-pass-injection-points).
1825

19-
## Prerequisites
26+
Next, adjust the Renderer Feature so it renders only the parts hidden behind other GameObjects, and in a different color.
2027

21-
This example requires the following:
28+
1. Open the **Overrides** dropdown, then select **Depth** and set **Depth Test** to **Greater**.
2229

23-
* A Unity project with the URP package installed.
30+
The Renderer Feature now only renders a pixel if its depth is greater than the current pixel in the depth buffer, which means the new pixel is behind another GameObject.
2431

25-
* The **Scriptable Render Pipeline Settings** property refers to a URP asset (**Project Settings** > **Graphics** > **Scriptable Render Pipeline Settings**).
32+
1. [Create a new material](../shaders-in-universalrp) that uses the **Universal Render Pipeline/Unlit** shader.
33+
1. Set the **Base Map** color to a color of your choice.
34+
1. In the Renderer Feature, in the **Overrides** section, set **Material** to the material you created.
2635

27-
## Create example Scene and GameObjects<a name="example-objects"></a>
36+
When you move the GameObject behind other GameObjects, Unity now renders the hidden parts in the color you selected.
2837

29-
To follow the steps in this example, create a new Scene with the following GameObjects:
38+
![The red characters moves behind a wall. Unity renders the hidden parts using a blue material.](../Images/how-to-render-objects/character-depth-test-greater.gif)
3039

31-
1. Create a Cube. Set its **Scale** values so that it looks like a wall.
40+
## Fix overlapping areas of a GameObject
3241

33-
![Cube that represents a wall](../Images/how-to-render-objects/rendobj-cube-wall.png)
42+
If you use a complex GameObject, the Renderer Feature might draw overlapping parts as though they're hidden. This is because the depth of one part is greater than the overlapping part.
3443

35-
2. Create a Material and assign it the `Universal Render Pipeline/Lit` shader. Select the base color (for example, red). Call the Material `Character`.
44+
![A capsule with a smaller capsule attached. The Renderer Feature renders part of the larger capsule using the blue material, because it's behind the smaller part.](../Images/how-to-render-objects/rendobj-depth-greater-see-through.png)
3645

37-
3. Create a basic character and assign it the Character Material. In this example, the character consists of three capsules: the big capsule in the center represents the body, and the two smaller capsules represent the hands.
46+
To fix this issue, disable rendering the whole GameObject, and create a new Renderer Feature that renders the non-hidden parts. Follow these steps:
3847

39-
![The character consisting of three capsules](../Images/how-to-render-objects/character-views-side-top-persp.png)
48+
1. In the URP Renderer asset, open the **Opaque Layer Mask** dropdown and disable the layer you added.
4049

41-
To make it easier to manipulate the character in the Scene, add the three Capsules as child GameObjects under the Character GameObject.
50+
Unity now doesn't draw the layer in the opaque render pass. The Renderer Feature still draws the hidden parts, because it's in a different render pass.
4251

43-
![Character objects in Hierarchy](../Images/how-to-render-objects/character-in-hierarchy.png)
52+
![Unity does not draw the character unless it's behind an object](../Images/how-to-render-objects/rendobj-character-only-behind.png)
4453

45-
4. Create a Material and assign it the `Universal Render Pipeline/Unlit` shader. Select the base color that you would like the character to have when it's behind GameObjects (for example, blue). Call the Material `CharacterBehindObjects`.
54+
1. Add a new Render Objects Renderer Feature.
55+
1. Set **Layer Mask** to the new layer, so this Renderer Feature draws the GameObject.
56+
1. Set **Event** to the **AfterRenderingOpaques** injection point.
57+
1. To avoid the first Renderer Feature affecting the depth calculations in the new Renderer Feature, disable **Write Depth** in the **Overrides** section of the first Renderer Feature.
4658

47-
Now you have the setup necessary to follow the steps in this example.
59+
The first Renderer Feature draws the hidden parts, and the second Renderer Feature draws the rest of the GameObject.
4860

49-
## Example implementation
61+
![A character created from 3 simple capsules for the body and arms. The character is red, but as it moves behind a wall, the hidden parts are rendered blue.](../Images/how-to-render-objects/character-goes-behind-object.gif)
5062

51-
This section assumes that you created a Scene as described in section [Example Scene and GameObjects](#example-objects).
63+
## Additional resources
5264

53-
The example implementation uses two Render Objects Renderer Features: one to draw parts of the character that are behind other GameObjects, and another one to draw the parts of the character that are in front of other GameObjects.
54-
55-
### Create a Renderer Feature to draw the character behind GameObjects
56-
57-
Follow these steps to create a Renderer Feature to draw the character behind GameObjects.
58-
59-
1. Select a URP Renderer.
60-
61-
![Select a URP Renderer](../Images/how-to-render-objects/rendobj-select-urp-renderer.png)
62-
63-
2. In the Inspector, click **Add Renderer Feature** and select **Render Objects**.
64-
65-
![Add Render Object Renderer Feature](../Images/how-to-render-objects/rendobj-add-rend-obj.png)
66-
67-
Select the **Name** field and enter the name of the new Renderer Feature, for example, **DrawCharacterBehind**.
68-
69-
3. This example uses Layers to filter the GameObjects to render. Create a new Layer and call it **Character**.
70-
71-
![Create new Layer called Character](../Images/how-to-render-objects/rendobj-new-layer-character.png)
72-
73-
4. Select the **Character** GameObject and assign it to the `Character` Layer. To do this, open the Layer drop down and select `Character`.
74-
![Assign Character GameObject to Character Layer](../Images/how-to-render-objects/rendobj-assign-character-gameobject-layer.png)
75-
76-
5. In the `DrawCharacterBehind` Renderer Feature, in **Filters** > **Layer Mask**, select `Character`. With this setting, this Renderer Feature renders GameObjects only in the Layer `Character`.
77-
78-
6. In **Overrides** > **Material**, select the `CharacterBehindObjects` Material.
79-
80-
The Renderer Feature overrides the Material of a GameObject with the selected Material.
81-
82-
![Layer Mask, Material Override](../Images/how-to-render-objects/rendobj-change-layer-override-material.png)
83-
84-
7. The intended behavior is that the Renderer Feature renders the character with the `CharacterBehindObjects` Material only when the character is behind other GameObjects.
85-
86-
To achieve this, select the **Depth** check box, and set the **Depth Test** property to **Greater**.
87-
88-
![Set Depth Test to Greater](../Images/how-to-render-objects/rendobj-depth-greater.png)
89-
90-
With these settings, Unity renders the character with the `CharacterBehindObjects` Material only when the character is behind another GameObject. However, Unity also renders parts of the character using the `CharacterBehindObjects` Material, because some parts of the character occlude the character itself.
91-
92-
![Unity renders parts of the character using the `CharacterBehindObjects` Material](../Images/how-to-render-objects/character-depth-test-greater.gif)
93-
94-
### Create an extra Renderer Feature to avoid the self see-through effect
95-
96-
The settings in the previous section result in the self see-through effect for the following reason:
97-
98-
* When performing the Opaque rendering pass of the URP Renderer, Unity renders all GameObjects belonging to the character with the `Character` Material and writes depth values to the Depth buffer. This happens before Unity starts executing the `DrawCharacterBehind` Renderer Feature, because, by default, new Render Objects Renderer Features have the value **AfterRenderingOpaques** in the **Event** property.
99-
100-
The **Event** property defines the injection point where Unity injects Render Passes from the Render Objects Renderer Feature. The event when URP Renderer draws GameObjects in the **Opaque Layer Mask** is the **BeforeRenderingOpaques** event.
101-
102-
* When executing the `DrawCharacterBehind` Renderer Feature, Unity performs the depth test using the condition specified in the **Depth Test** property. In the following screenshot, a bigger capsule occludes part of the smaller capsule, and the depth test passes for that part of the smaller capsule. The Renderer Feature overrides the Material for that part.
103-
104-
![Self see-through effect](../Images/how-to-render-objects/rendobj-depth-greater-see-through.png)
105-
106-
The following steps describe how to avoid such behavior and ensure that Unity draws all parts of the character with proper Materials.
107-
108-
1. In the URP asset, in **Filtering** > **Opaque Layer Mask**, clear the check mark next to the `Character` Layer.
109-
110-
![Clear the check mark next to the `Character` Layer](../Images/how-to-render-objects/rendobj-in-urp-asset-clear-character.png)
111-
112-
Now Unity does not render the character unless it's behind a GameObject.
113-
114-
![Unity does not render the character unless it's behind an object](../Images/how-to-render-objects/rendobj-character-only-behind.png)
115-
116-
2. Add a new Render Objects Renderer Feature, and call it `Character`.
117-
118-
3. In the `Character` Renderer Feature, in **Filters** > **Layer Mask**, select the `Character` Layer.
119-
120-
![Set Layer Mask Filter to Character Layer](../Images/how-to-render-objects/rendobj-render-objects-character.png)
121-
122-
Now Unity renders the character with the `Character` Material even when the character is behind GameObjects.
123-
124-
This happens because the `DrawCharacterBehind` Renderer Feature writes values to the depth buffer. When Unity executes the `Character` Renderer Feature, the pixels on the character appear to be in front of the pixels that Unity has drawn previously, and Unity draws on top of those pixels.
125-
126-
4. In the `DrawCharacterBehind` Renderer Feature, In **Overrides** > **Depth**, clear the **Write Depth** check box. With this setting, the `DrawCharacterBehind` Renderer Feature does not make changes to the depth buffer and the `Character` Renderer Feature does not draw the character when it's behind GameObjects.
127-
128-
![Clear Write Depth](../Images/how-to-render-objects/rendobj-render-objects-no-write-depth.png)
129-
130-
The example is complete. When the character goes behind GameObjects, Unity draws the character silhouette with the `CharacterBehindObjects` Material.
131-
132-
![Character goes behind objects](../Images/how-to-render-objects/character-goes-behind-object.gif)
133-
134-
With the extra `Character` Renderer Feature, Unity renders GameObjects as follows:
135-
136-
1. URP Renderer does not render the `Character` GameObject in the **BeforeRenderingOpaques** event, because the `Character` Layer is excluded from the **Opaque Layer Mask** list.
137-
138-
2. The `DrawCharacterBehind` Renderer Feature draws parts of the character that are behind other GameObjects. This happens in the **AfterRenderingOpaques** event.
139-
140-
3. The `Character` Renderer Feature draws parts of the character that are in front of other GameObjects. This happens in the **AfterRenderingOpaques** event, and after executing the `DrawCharacterBehind` Renderer Feature.
141-
142-
To see another use case of the Render Objects Renderer Feature, refer to the **Object Occlusion** Scene in the [Universal Rendering Examples](https://github.com/Unity-Technologies/UniversalRenderingExamples) project.
65+
- [Renderer Objects Renderer Feature reference](renderer-feature-render-objects)

Packages/com.unity.render-pipelines.universal/Documentation~/shader-terrain-lit.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Terrain Lit shader
22

3-
URP uses the Terrain Lit shader for Unity Terrain. This shader is a simpler version of the [Lit shader](lit-shader.md). A Terrain can use a Terrain Lit Material with up to eight [Terrain Layers](https://docs.unity3d.com/Manual/class-TerrainLayer.html).
3+
URP uses the Terrain Lit shader for Unity Terrain. This shader is a simpler version of the [Lit shader](lit-shader).
4+
5+
For more information about Terrain Layers, refer to [Terrain Layers](../class-TerrainLayer.md).
46

57
![A Terrain GameObject rendered with the Terrain Lit shader.](Images/terrain/terrain-rendered-with-terrain-lit.png)<br/>*A Terrain GameObject rendered with the Terrain Lit shader.*
68

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Arithmetic Operators
2+
3+
Perform mathematical calculations on input data.
4+
5+
| **Page** | **Description** |
6+
| --- | --- |
7+
| [Absolute](Operator-Absolute.md) | Calculate the absolute value of an input. |
8+
| [Add](Operator-Add.md) | Calculate the sum of all inputs. |
9+
| [Divide](Operator-Divide.md) | Divide the first input sequentially by all other inputs. |
10+
| [Fractional](Operator-Fractional.md) | Extract the fractional part of an input. |
11+
| [Inverse Lerp](Operator-InverseLerp.md) | Calculate the fraction representing how far a value is between two values. |
12+
| [Lerp](Operator-Lerp.md) | Calculate a linear interpolation between two values. |
13+
| [Modulo](Operator-Modulo.md) | Calculate the remainder of dividing of one value by another. |
14+
| [Multiply](Operator-Multiply.md) | Multiply all inputs together. |
15+
| [Negate](Operator-Negate.md) | Multiply an input value by -1 to invert its sign. |
16+
| [One Minus](Operator-OneMinus.md) | Subtract an input value from one. |
17+
| [Power](Operator-Power.md) | Raise one input to the power of another input. |
18+
| [Reciprocal](Operator-Reciprocal.md) | Calculate the result of dividing 1 by an input value. |
19+
| [Sign](Operator-Sign.md) | Return whether an input is positive, negative, or 0. |
20+
| [Smoothstep](Operator-Smoothstep.md) | Calculate smooth Hermite interpolation between two values. |
21+
| [Square Root](Operator-SquareRoot.md) | Calculate the square root of an input. |
22+
| [Step](Operator-Step.md) | Compare an input value to a threshold and return whether an input is above or below the threshold |
23+
| [Subtract](Operator-Subtract.md) | Subtract one or more inputs from another input. |
24+
25+
## Additional resources
26+
27+
- [Clamp](Clamp.md)
28+
- [Remap](Remap.md)
29+
- [Math](Math.md)
30+
31+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Attribute Blocks
2+
3+
Write values to the [Attributes](Attributes.md) of particles.
4+
5+
| **Page** | **Description** |
6+
| --- | --- |
7+
| [Curve](Block-SetAttributeFromCurve.md) | Write values to an attribute based on a sample from an Animation Curve or Gradient. |
8+
| [Derived > Calculate Mass from Volume](Block-CalculateMassFromVolume.md) | Set the mass of a particle based on its scale and density. |
9+
| [Map](Block-SetAttributeFromMap.md) | Sample data from textures and store them in attributes. |
10+
| [Set](Block-SetAttribute.md) | Write values to an attribute directly, or use random modes to set attributes to random values. |
11+
12+
## Additional resources
13+
14+
- [Attributes](Attributes.md)
15+
- [Standard Attribute Reference](Reference-Attributes.md)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Bitwise Operators
2+
3+
Perform bitwise logical operations on inputs.
4+
5+
| **Page** | **Description** |
6+
| --- | --- |
7+
| [And](Operator-BitwiseAnd.md) | Perform a bitwise AND operation, which outputs 1 if both bits are 1. |
8+
| [Complement](Operator-BitwiseComplement.md) | Perform a bitwise NOT operation to invert each bit. |
9+
| [Left Shift](Operator-BitwiseLeftShift.md) | Shift an input value left by a specified number of bits. |
10+
| [Or](Operator-BitwiseOr.md) | Perform a bitwise OR operation, which outputs 1 if either bit is 1. |
11+
| [Right Shift](Operator-BitwiseRightShift.md) | Shift an input value right by a specified number of bits. |
12+
| [Xor](Operator-BitwiseXor.md) | Perform a bitwise XOR operation, which outputs 1 if only one bit is 1. |
13+
14+
## Additional resources
15+
16+
- [Logic Operators](Logic.md)
17+
- [Math Operators](Math.md)
18+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Collision Blocks reference
2+
3+
Configure how particles collide with shapes or the depth buffer.
4+
5+
| **Page** | **Description** |
6+
| --- | --- |
7+
| [Collide with AABox](Block-CollideWithAABox.md) | Define an axis-aligned box volume that particles collide with. |
8+
| [Collide with Cone](Block-CollideWithCone.md) | Define a truncated cone volume that particles collide with. |
9+
| [Collide with Depth Buffer](Block-CollideWithDepthBuffer.md) | Make particles collide with the depth buffer of a camera. |
10+
| [Collide with Plane](Block-CollideWithPlane.md) | Define a flat plane with infinite extents that particles collide with. |
11+
| [Collide with Signed Distance Field](Block-CollideWithSignedDistanceField.md) | Create a complex shape that particles collide with. |
12+
| [Collide with Sphere](Block-CollideWithSphere.md) | Define a spherical volume that particles collide with. |
13+
14+
## Additional resources
15+
16+
- [Signed Distance Fields in the Visual Effect Graph](sdf-in-vfx-graph.md)
17+
- [VFX Graph Learning Templates](https://www.youtube.com/watch?v=DKVdg8DsIVY) on the Unity YouTube channel

0 commit comments

Comments
 (0)