Search Unity

HDRP - Shader Graph - Vertex Displacement Linked to Camera Motion

Discussion in 'High Definition Render Pipeline' started by lcompton, Aug 19, 2020.

  1. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    BACKGROUND: Hey, folks. I have an HDRP shader created via Shader Graph that performs basic vertex displacement based on noise. Being new to both HDRP and Shader Graph, I based the shader on several tutorials. In the tutorials, the camera position is subtracted prior to being routed into the Vertex Position in the master node. I'm using HDRP 8.2.0 and subtracting the camera position didn't work. In fact, simply converting from World to Object space worked fine, contradicting what was mentioned in the tutorials.

    QUESTION: My game has a first person character controller, so the camera moves as the character moves. What I've noticed is that the vertex displacement works properly when the camera is stationary, but when the camera moves, there's a detectable acceleration/deceleration effect on the vertices. That implies that something still needs to be added to the shader to compensate for camera motion. Is there something that can be added to my shader to get the vertices to displace independent of the camera motion?

    An image of my shader is attached.

    DETAILS:
    • Unity 2020.1.2f1
    • HDRP/Shader Graph 8.2.0
    • Windows 10

    SHADER:
    vertex-displacement.png
     
  2. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    I figured it out. The Position nodes all need to be set to "Absolute World" rather than "World". The Transform node needs to transform from "Absolute World" to "Object". Works fine now. It looks like there were some changes in definitions and node semantics since the tutorials that I watched were made.
     
    RSArts and ArchVizPRO like this.
  3. Camarent

    Camarent

    Joined:
    Feb 19, 2014
    Posts:
    168
    PutridEx likes this.
  4. ArchVizPRO

    ArchVizPRO

    Joined:
    Apr 27, 2014
    Posts:
    457
    Thank you, you resolved my issue. :)
     
  5. Storoj_A

    Storoj_A

    Joined:
    Nov 25, 2021
    Posts:
    2
    Also having this problem and for me changing position to absolute world doesn't work. Any ideas?
    upload_2022-1-22_19-30-52.png
     
  6. REDACT3D_

    REDACT3D_

    Joined:
    Nov 8, 2020
    Posts:
    222
    Had the same issue, same solution that icompton had pointed out with setting everything to absolute world.
    Doh! lol

    Anyways here's what the graph looks like:
    Capture.PNG
     
  7. HIBIKI_entertainment

    HIBIKI_entertainment

    Joined:
    Dec 4, 2018
    Posts:
    595
    One important render pipeline feature that unity has in HDRP is camera relative rendering, this can change position/space node requirements a little compared to its BRP and URP counterparts.


    Added bonuses include less frequent requirements for world shifting ( 5km + easyish)
    slightly better world/screenspace handling
    Added negatives, multiple cameras are often more expensive even after custom frame settings
     
  8. toddw

    toddw

    Joined:
    May 9, 2010
    Posts:
    130
    Three years later, I'm super thankful for this post, I was in the weeds for days with this issue. Changing all my Position and Transform nodes to "Absolute World" did the trick.
     
  9. lcompton

    lcompton

    Joined:
    Mar 31, 2018
    Posts:
    102
    I'm glad it helped. Proof that community forums are useful. Cheers!