Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Help Wanted Motion Vectors and Backfaces

Discussion in 'General Graphics' started by JamesMakesGamesLtd, Jul 28, 2021.

  1. JamesMakesGamesLtd

    JamesMakesGamesLtd

    Joined:
    Aug 22, 2012
    Posts:
    34
    Hello,

    I'm trying to disable motion blur for certain mesh renderers in my scene. On the mesh renderers in question I have Motion Vectors set to "Force No Motion" but I'm still getting motion blur for the _backfaces_ of these renderers. In other words "Force No Motion" only seems to disable motion vectors for front faces?

    If I use the Debug views in the post processing stack I can see motion vectors being generated for the backfaces of the renderers. Is this to be expected?

    Using Built in pipeline and a custom shader that is not culling the backfaces.
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    10,900
    Unfortunately Unity's built in rendering path doesn't support motion vectors on double sided materials. It will always only render motion vectors for the front faces of dynamic objects, and as best I can tell there's no way around this limitation. So the reason why you're still getting motion vectors "on back faces" is because those back faces aren't being rendered into the motion vector buffer with the motion zeroed out, only the front faces are.

    The only work around to this would be to not use double sided materials and to use meshes with doubled up faces.
     
    JamesMakesGamesLtd likes this.
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    10,900
    Oh, and a little bit of further explanation of how the back faces are showing up.

    Unity renders a camera depth texture using each shader's shadow caster pass. The motion vector pass is initially filled by rendering a full screen pass that uses that depth texture to add in the motion vectors that are only caused by the camera's motion. The depth texture is used because motion vectors are stored in screen space, so the objects in the distance can have different motion vectors than those close to the camera. Because this is using the depth texture, this includes dynamic objects that get their own motion vector pass! Presumably your double sided shader is also using a double sided shadow caster, so they appear in the depth texture, and thus the motion vector pass.

    After that each dynamic object is rendered into the motion vector buffer with that object's unique motion data, overwriting the original camera only motion vectors. This includes objects that are forced to have "no motion" vectors. But since they're always only rendering the front faces, the back faces that were already rendered due to the depth texture based pass aren't overwritten.
     
    JamesMakesGamesLtd likes this.
  4. JamesMakesGamesLtd

    JamesMakesGamesLtd

    Joined:
    Aug 22, 2012
    Posts:
    34
    Thanks for the detailed response bgolus.
    FWIW the renderers have shadow casting set to On, not Two Sided. But either way I guess they must still be using the depth texture for me to see these MVs.
     
    Last edited: Jul 29, 2021
unityunity