Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

URP New Motion Vectors Not Renderering

Discussion in 'Universal Render Pipeline' started by GoGoGadget, Nov 9, 2021.

  1. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    855
    Hi all,

    Upgraded to Unity 2021.2, been trying to get the new motion vectors working without much luck.

    So far, I can see that "_MotionVectorTexture" in my shader (which happens after everything) is a non-default texture, but it's pure black - no data in it.

    In frame debugger, I can see that Unity does perform a Motion Vectors pass (using the CameraMotionVectors shader) but doesn't write anything to the target.

    Camera depth texture mode is set to motion:
    m_Camera.depthTextureMode = DepthTextureMode.MotionVectors;

    and my script is trying to flag that it needs motion vectors:
    public override ScriptableRenderPassInput input => ScriptableRenderPassInput.Motion;
    (without this set, "_MotionVectorTexture" becomes default grey)

    Any guidance here from anyone who's managed to get the new motion vectors working in URP would be appreciated!
     
  2. troyspencer

    troyspencer

    Joined:
    Sep 7, 2019
    Posts:
    2
    While building out my minimal Application SpaceWarp implementation (which requires shader motion vectors) I came across this GitHub post which explains what might be missing from your script: https://github.com/Oculus-VR/Unity-Graphics/issues/3#issuecomment-1010389466
    the depth texture mode should be
    Code (CSharp):
    1. mainCamera.depthTextureMode |= (DepthTextureMode.MotionVectors | DepthTextureMode.Depth);
     
  3. StaggartCreations

    StaggartCreations

    Joined:
    Feb 18, 2015
    Posts:
    2,133
    Try adjusting the levels slider in the frame debugger, when viewing the motion vector texture. The values of this texture tend to be rather small, which makes it appear mostly black. It's not until something moves quite fast that you start to see some vectors.

    Or do you mean there isn't anything being rendered into the texture? I'm not sure camera motion has any effect though. At least for the motion blur effect this is handled separately.

    The "depthTextureMode" property actually no longer applies in URP. Setting a ScriptableRenderPassInput with the ConfigureInput function will correctly prompt the motion vector pass, as you have already done.
     
  4. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    362
    Couldn't get the motion vectors working, it's just black. So I'm using this now:
    https://github.com/Kink3d/kMotion
    (Needs some minor fixes in the shader, but this is easily done, just double defined stuff).
    This gives the right results, like builtin or HDRP.
     
  5. Slaktus

    Slaktus

    Joined:
    Dec 5, 2012
    Posts:
    58
    I tried this in Unity 2021.3 using URP 12.1, and I can't get it to work. Do I need to change the double defined variables to something else, or simply comment them out?
     
  6. Nexusmaster

    Nexusmaster

    Joined:
    Jun 13, 2015
    Posts:
    362
    Last edited: Apr 6, 2023