Version: Unity 6 (6000.0)
Language : English
Output a motion vector texture in a custom shader in URP
Troubleshooting motion vectors in URP

Sample motion vectors in a shader in URP

Any ScriptableRenderPass implementation can request the motion vector texture as input. To do that, add the ScriptableRenderPassInput.Motion flag in the ScriptableRenderPass.ConfigureInput method in the AddRenderPasses callback of your custom Renderer Feature. If no other effect in the frame is using motion vectors, setting this input flag forces the URP renderer to inject the motion vector render pass into the frame.

To sample the motion vector texture in your shaderA program that runs on the GPU. More info
See in Glossary
pass, declare the shader resource for it in the HLSLPROGRAM section:

    TEXTURE2D_X(_MotionVectorTexture);
    SAMPLER(sampler_MotionVectorTexture);

To perform the sampling, use the following macro:

    SAMPLE_TEXTURE2D_X(_MotionVectorTexture, sampler_MotionVectorTexture, uv);

The _X postfix ensures that the texture is correctly declared and sampled when targeting XRAn umbrella term encompassing Virtual Reality (VR), Augmented Reality (AR) and Mixed Reality (MR) applications. Devices supporting these forms of interactive applications can be referred to as XR devices. More info
See in Glossary
platforms.

Output a motion vector texture in a custom shader in URP
Troubleshooting motion vectors in URP