Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Enabling Motion Vector Pass For DrawProcedural?

Discussion in 'High Definition Render Pipeline' started by JM_CG, Jul 27, 2020.

  1. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,873
    typo... unity_MatrixPreviousMI
     
  2. pferri_immt

    pferri_immt

    Joined:
    Jul 30, 2020
    Posts:
    2
    Does the shader require anything specific to work in HDRP? Trying to render a simple mesh via Graphics.RenderPrimitives with motion vectors, and while the mesh shows up correctly, the motion vector debugger shows no motion vectors data. The shader and code use to render is from the Unity documentation for the RenderPrimitives function
     
  3. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    Why does MotionVectorGenerationMode have the modes ForceNoMotion, Camera and Object, but not Geometry?

    I can't get Graphics.RenderMeshIndirect to render motion vectors in Object mode. When I try to set unity_ObjectToWorld I get the undeclared identifyer error "Use_Macro_UNITY_MATRIX_M_instead_of_unity_ObjectToWorld".

    Are anyone else seeing that error?
     
  4. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,873
    try:

    Code (CSharp):
    1. #ifdef unity_ObjectToWorld
    2.         #undef unity_ObjectToWorld
    3.     #endif
    4.     #ifdef unity_WorldToObject
    5.         #undef unity_WorldToObject
    6.     #endif
    7.  
    8. //    Due to motion vectors!
    9.     #ifdef unity_MatrixPreviousM
    10.          #undef unity_MatrixPreviousM
    11.     #endif
    12.     #ifdef unity_MatrixPreviousMI
    13.         #undef unity_MatrixPreviousMI
    14.     #endif
     
    MagiJedi and cecarlsen like this.
  5. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    Thank you. Brilliant! I had no idea you could undefine.
     
  6. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    @larsbertram1 unfortunately I am still not getting anything in the motion vector debug view. MotionVectorGenerationMode is set to Object and I've tried to toggle on and off MotionVectorForVertexAnimation and AddPreComputedVelocity on the material as well as AddCustomVelocity in the ShaderGraph. The instanced objects are rendering fine, just without motion vectors. I wonder what I am missing.

    EDIT: I am of cause also setting unity_MatrixPreviousM and unity_MatrixPreviousMI in VertInstancingSetup in the CustomFunctionNode.
     
  7. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    383
    @cecarlsen

    Do you have Depth Prepass enabled in the HDRP global settings / camera frame settings?
     
    Last edited: Feb 21, 2023
  8. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    In my HDRenderPipelineAsset under Rendering these are enabled :
    - Motion Vectors
    - Transparent Depth Prepass

    In my HDRenderPipelineGlobalSettings under Rendering these are enabled:
    - Depth Prepass within Deferred
     
    Last edited: Feb 21, 2023
  9. sqallpl

    sqallpl

    Joined:
    Oct 22, 2013
    Posts:
    383
    Ok so it's definitely not related to this problem.

    BTW. What version of Unity are you on?
     
    Last edited: Feb 21, 2023
  10. cecarlsen

    cecarlsen

    Joined:
    Jun 30, 2006
    Posts:
    856
    2022.2.7

    Would be wonderful if anyone could post a working example. The documentation on this is pretty sparse.
     
  11. MattCarr

    MattCarr

    Joined:
    Jul 5, 2009
    Posts:
    339
    I referenced this thread last year to find the new 'RenderX" functions and RenderParams for procedural rendering and to get object motion vectors working on procedural geometry.

    This worked fine at the time up until 2022.2.0b3 and then stopped working on 2022.2.0b4 and all versions I've tested that are newer than that including 2023.

    You might be encountering the same regression bug. I have a thread about it here: https://forum.unity.com/threads/cus...-indirect-rendering-after-2022-2-0b3.1379979/

    and the Issue Tracker URL is here: https://issuetracker.unity3d.com/is...k-when-rendering-a-custom-shader-procedurally

    Considering it's approaching 1 year since I first attempted to submit the bug I'm not holding my breath for a fix, but hopefully someone ( @JarkkoUnity ?) can address it soon so I can update from 2022.2.0b3. Last year my bug report was mishandled on Unity's end and not properly submitted and its only been around a month since my resubmission has gone through the the Issue Tracker so fingers crossed.
     
    cecarlsen and PutridEx like this.
  12. JarkkoUnity

    JarkkoUnity

    Unity Technologies

    Joined:
    Feb 1, 2021
    Posts:
    17
    Thanks for reporting the regression @MattCarr! I heard about this issue yesterday as someone is already looking into it.
     
  13. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    834
    Hi will the CommandBuffer API also get updated with similar RenderX methods?
     
  14. Kasperrr

    Kasperrr

    Joined:
    Feb 23, 2019
    Posts:
    13
    Hey, any updates on that ? Issue still apear in 2022.3.12f using
    Graphics.DrawMeshInstancedIndirect()
     
  15. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,873
    Kasperrr likes this.