Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,40 @@ Motion vectors capture the per-pixel, screen-space motion of GameObjects from on

HDRP uses motion vectors for various effects such as [temporal anti-aliasing (TAA)](Glossary.md#TemporalAntiAliasing) and motion blur.

## Using motion vectors
HDRP calculates motion vectors in two stages:

To use motion vectors in HDRP, you must enable them:
1. HDRP first calculates object motion vectors. Object motion vectors are motion vectors that HDRP calculates based on the screen-space movement of GameObjects.
2. HDRP then calculates camera motion vectors. These are motion vectors caused by the movement of the Camera. HDRP calculates camera motion vectors for pixels that did not write motion vectors during the first stage.

1. In your Unity Project’s [HDRP Asset](HDRP-Asset.md)
2. In your [Frame Settings](Frame-Settings.md)
## Using motion vectors

In the Inspector for your HDRP Asset, navigate to the **Rendering** section and enable the **Motion Vectors** checkbox. You can then either enable motion vectors for all Cameras or on an individual, per-Camera level. To enable motion vectors for all Cameras, navigate to **Default Frame Settings For > Rendering** and enable the **Motion Vectors** checkbox. This enables Camera motion vectors. Now you can also enable the **Object Motion Vectors** checkbox. If you do this, HDRP calculates object motion vectors. If you keep this checkbox disabled, HDRP only calculates Camera motion vectors.
To use motion vectors in HDRP, you must first enable them:

HDRP calculates motion vectors in two stages:
1. In your Unity Project’s [HDRP Asset](HDRP-Asset.md):
1. Select the HDRP Asset and view it in the Inspector window.
2. Go to the **Rendering** section and enable **Motion Vectors**.
2. In [Frame Settings](Frame-Settings.md). You can either enable motion vectors for all Cameras or on an individual, per-Camera level.
1. To enable motion vectors for all Cameras, open the [HDRP Default Settings](Default-Settings-Window.md) Project Settings tab (menu: **Edit** > **Project Settings** > **HDRP Default Settings**), then set **Default Frame Settings For** to **Camera**. To enable motion vectors for a particular Camera, select the Camera and, in the Inspector, enable **Custom Frame Settings**.
3. In the **Rendering Section**, enable **Motion Vectors**. This enables camera motion vectors.
3. To enable motion vectors for opaque GameObjects, enable **Opaque Object Motion**. To enable motion vectors for transparent GameObjects, enable **Transparent Object Motion**.

1. HDRP first calculates object motion vectors. To make a Mesh Renderer write object motion vectors, in its Inspector, go to **Additional Settings** and select **Per Object Motion** from the **Motion Vectors** drop-down. HDRP now calculates object motion vectors for this Mesh Renderer, if you enable **Object Motion Vectors** in the Frame Settings.
![](Images/MotionVectors1.png)
2. HDRP then calculates Camera motion vectors, which are caused by the movement of the Camera. This is for pixels that did not write motion vectors during the first stage. To make HDRP calculate Camera motion vectors for a Mesh Renderer, in the Inspector for the Mesh Renderer, go to **Additional Settings** and select **Camera Motion Only** from the **Motion Vectors** drop-down.

If you do not want HDRP to calculate motion vectors for a Mesh Renderer at all, in the Inspector for the Mesh Renderer, go to **Additional Settings** and select **Force No Motion** from the **Motion Vectors** drop-down.
HDRP can now render motion vectors. If you enabled object motion vectors, be aware that, by default, new Mesh Renderers write object motion vectors. To change this behavior, select the Mesh Renderer and, in the Inspector, change the value of the **Motion Vectors** property.<br/>![](Images/MotionVectors1.png)
The options are:

* **Camera Motion Only**: HDRP only calculates camera motion vectors for the area of the screen this GameObject fills.
* **Per Object Motion**: HDRP calculates motion vectors for this GameObject if:
* The GameObject moves and the camera does not.
* The camera moves and the GamaObject does not.
* Both the GameObject and the camera move.
* **Force No Motion**: HDRP does not calculate any motion vectors for the area of the screen this GameObject fills.

## Motion vectors for transparent objects

By default, HDRP does not render motion vectors for transparent Materials. This is because motion vectors from transparent GameObjects overwrite motion vectors for GameObjects behind them. For example, a window would overwrite the motion vectors for a bird flying behind it.

To make HDRP render motion vectors for transparent Materials:

1. In the Inspector for your HDRP Asset, go to **Default Frame Settings For > Rendering** and enable the **Transparent Writes Motion Vectors** checkbox.
2. In the Inspector for your transparent Material, go to **Surface Options** and enable the **Transparent Writes Motion Vectors** checkbox.

![](Images/MotionVectors2.png)
To make HDRP render motion vectors for transparent Materials, see the steps in [Using motion vectors](#using-motion-vectors) and enable **Transparent Object Motion**.

When transparent objects write motion vectors on a given pixel, they replace that pixel’s previous motion vectors. This is particularly useful for Materials that use alpha clipping, such as hair.

If you use motion blur in conjunction with transparent GameObjects, be aware that motion blur also uses depth information. This means that you should make the Material write depth information too. To do this, go to **Surface Options** and enable the **Transparent Depth Postpass** checkbox.