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
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961