Search Unity

Question Motion vectors

Discussion in 'High Definition Render Pipeline' started by Phantom_X, Jan 24, 2020.

  1. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    314
    Hi,
    is there any way of sampling the motion vector texture in a shadergraph or regular shader with HDRP?

    Thanks!
     
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,
    you could sample it from Shadergraph with a custom node or from a shader. See how motion blur shader or TAA shader sample it in HDRP, you can use similar pattern.
     
    Phantom_X likes this.
  3. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
  4. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    more en detail. The light geometry spheres and the the dots generated hair strand does not show any motion vectors in the material section in the debug rendering.



    MSAA in Forward is disabled.
    Moreover i really tried all the settings from the documentation in several iterations.
    e.g.
    The green light is an transparent lit shader
    The red light is an opaque lit shader
    The blonde hair down layer is an opaque hair sg shader
    The blonde hair upper layer is an transparent hair sg shader
    ....
     
    Last edited: Feb 23, 2020
  5. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,
    Try to use "Rendering" -> "Motion Vector" in Render Pipeline Debug:
    https://docs.unity3d.com/Packages/c...7/manual/Render-Pipeline-Debug-Rendering.html

    Motion vector on material aren't connected to any meaninful output currently. Will add that on our todo
     
  6. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    Thanks. Thats working.
    They are so powerful to get an deep understanding and for debugging.



    Does anyone nows why the hairs are displayed mostly green.
    Cannot really interpret the color coding.

    Is it somehow possible to call the Debug views in an development build?
     
    Last edited: Feb 26, 2020
  7. larsbertram1

    larsbertram1

    Joined:
    Oct 7, 2008
    Posts:
    6,902
    does anybody now how to render motion vectors for meshes drawn using Graphics.DrawMeshInstancedIndirect()?
     
    bluescrn and keeponshading like this.
  8. Pepe-Hoschi

    Pepe-Hoschi

    Joined:
    Feb 27, 2016
    Posts:
    8
    "does anybody now how to render motion vectors for meshes drawn using Graphics.DrawMeshInstancedIndirect()?"

    I would love to know this too. When I convert a GameObject to an Entity the Motion Vectors pass is skipped too. Without motion vectors TAA looks terrible when Per Object Motion is required.
     
  9. JPDoiron

    JPDoiron

    Joined:
    Jan 11, 2013
    Posts:
    16
    Here's how i do it to use the motion vector in the shadergraph: ( 2019.4f1 )

    upload_2020-7-30_20-58-33.png

    GetMotionVectorShaderFunction.hlsl

    Code (CSharp):
    1. void GetMotionVector_float (float2 UV, out float2 MotionVector)
    2. {
    3. #if SHADERGRAPH_PREVIEW
    4.     MotionVector = float2(0, 0);
    5. #else
    6.     DecodeMotionVector(LOAD_TEXTURE2D_X(_CameraMotionVectorsTexture, UV), MotionVector);
    7. #endif
    8. }
     
  10. chengk8y98123

    chengk8y98123

    Joined:
    Jun 16, 2020
    Posts:
    2
     
  11. chengk8y98123

    chengk8y98123

    Joined:
    Jun 16, 2020
    Posts:
    2
    I need some help, can you tell me how graph work
     
  12. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Kinda late to the party but yes you can.
    Just press Left CTRL + Backspace in a dev build, and then navigate the different tabs with page up / page down and using arrows inside. (Then CTRL + Backspace again to close the debug menu)
     
    Gooren and keeponshading like this.
  13. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    937
    This is really helpful. The party just started.

    Tried a while but cannot solve this behaviour.
    Unity 2021.10b2

    e.g

    When you navigate to

    • Lighting /Lighting Debug Mode
    and you use left or right,
    the next mode gets selected
    and the selection immidiately jumps back to the top of the menu.

    same for
    • Lighting/ Fullscreen Debug Mode

    So you cannot cycle through these modes with left or right.

    The selection jumps immidiately to the top (Shadows /Debug Mode)
    and you have to go down again to Lighting/ Fullscreen Debug Mode for every further left or right selection.

    Debug.JPG
     
    Last edited: Jan 17, 2021
    chap-unity likes this.
  14. chap-unity

    chap-unity

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    766
    Thanks, I've noted and reported them !
     
    keeponshading likes this.
  15. ND9H001

    ND9H001

    Joined:
    Jun 23, 2017
    Posts:
    2
    I need somehelp sir, i got error "undeclared identifier '_CameraMotionVectorsTexture'"

    Thank you very much
     
    akaBase likes this.