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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Render Graph Custom Post Process Motion vector reading support

Discussion in 'High Definition Render Pipeline' started by AydinDeveloper, May 15, 2021.

  1. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    89
    CTAA V3 have HDRP support, but it doesn't work because of HDRP render graph. Custom effects cannot read Motion Vector.

    upload_2021-5-15_12-7-34.png

    I added this in my local package. but HDRP has to support it.

     
    Ciderhelm likes this.
  2. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,658
    AydinDeveloper likes this.
  3. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    89

    I'm sure this is an issue with HDRP. When I look at the render graph code, I see that there is nothing related to motion vector for Custom effect pass (There are reading lines for depth and color)
    I examined how other effects read motion vector and added it to the CustomPP pass section. It works as seen in the video.
     
    Ciderhelm likes this.
  4. AydinDeveloper

    AydinDeveloper

    Joined:
    Sep 8, 2017
    Posts:
    89
  5. fct509

    fct509

    Joined:
    Aug 15, 2018
    Posts:
    108
    If you create a full screen shader, you can pull from
    _CameraMotionVectorsTexture
    , which is the global buffer where HDRP stores the motion vectors. I created custom pass that does a full screen render with a material that just reads from
    _CameraMotionVectorsTexture
    and passes the results to the screen.
     
  6. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    199
    Why writing a custom pass, just to get motion vectors, with the pull request above, that pass is done automatically (which should have been, which it was before rendergraph api)
     
    AydinDeveloper likes this.
  7. fct509

    fct509

    Joined:
    Aug 15, 2018
    Posts:
    108
    Writing a Custom Pass isn't the only way to get it; you can also use an AOV Request. I mentioned the Custom Pass first because there's more documentation for creating a Custom Pass. That said, an AOV Request might be better because tapping into the global motion vector buffer the way I did, will give you a buffer that's shared with other real time renderers. So, other cameras and real-time reflection probes can mess things up.

    The issue with AOV Requests is that the documentation sucks if you don't already know what you're doing, and you can only attach one list of AOV Requests to a camera. So, attaching a new list of AOV Requests can remove the previous list if you aren't careful. Even the AOV Request example code that was added for Unity's 2020.2's documentation isn't really enough to teach you what's going on. I had to look at this guy's code to get enough of an understanding of the AOV Request API to be able to use the documentation for the AOV Request API.

    My point is, there are ways to access the motion vectors buffer. And, if you can access it, then you can pass it along. The motion vectors buffer might not be directly accessible from the vfx with the nodes that they provide. But, you might be able to write a bit of hlsl that taps into the global buffers and throw that into a node. Or, you might be able to get the motion vectors with an AOV Request, and then pass that resulting render texture to the vfx graph. Even without direct access, sometimes there are roundabout ways to access what you need.

    The code might look fugly. But, if @AydinDeveloper needs access to the motion vectors right now, then there are ways to get that.
     
  8. merpheus

    merpheus

    Joined:
    Mar 5, 2013
    Posts:
    199
    I don't think this is an immediate request but rather a bug fix on hdrp code. But yeah, your suggestions will definitely help to people who need an immediate solution. :)
     
    fct509 likes this.