Search Unity

Question World Space Pixel Position Custom Pass

Discussion in 'High Definition Render Pipeline' started by Deleted User, Apr 19, 2020.

  1. Deleted User

    Deleted User

    Guest

    I've tried googling this quite a few times and always came up with results that predated HDRP / SRP in general or the question would go unanswered, so sorry if I missed a post when attempting to find out any information on this.

    I'm trying to render a custom renderers pass that displays all the pixel world space positions. I know FragInputs contains positionRWS but I believe this is the relative world space position to the camera that is doing the rendering due to the fact the color output changes as the camera moves. Plus, the R before WS makes sense to mean relative.

    I'm assuming I could get the world space position by multiplying positionRWS by the inverse of whatever is putting it into camera relative space, but I'm not sure what matrix that is or if that world work entirely due to my lack of understanding.

    So, if anyone could point me in the right direction I would greatly appreciate it.
     
  2. Deleted User

    Deleted User

    Guest

    For anyone wondering, there is exactly what I thought there'd be: a helper function.

    Using the aptly named, GetAbsolutePositionWS just pass in the camera-relative world space position and it gives you the absolute position.

    I didn't even think about looking at the camera-relative rendering documentation, but of course it was in there.
     
  3. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Yes there's a few of those functions that work at least quite easy in post-processing. I've not tried them in custom pass though. Documentation has next to nothing about these features... I've been just going through the HDRP code and making notes but that's quite the reverse how things should be. I guess we should compile a list of helper functions somewhere.
     
  4. Frostlandia

    Frostlandia

    Joined:
    Sep 19, 2015
    Posts:
    3
    It's been quite some time, but do you have a snippit of the finished shader? Writing a similar shader and running into a similar issue even using GetAbsolutePositionWS.
     
  5. Frostlandia

    Frostlandia

    Joined:
    Sep 19, 2015
    Posts:
    3
    Ah my issue was forgetting to add a #define VARYINGS_NEED_POSITION_WS