Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  3. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

ShaderGraph Position Node Problem

Discussion in 'Graphics Experimental Previews' started by nttLIVE, Jun 18, 2019.

  1. nttLIVE

    nttLIVE

    Joined:
    Sep 13, 2018
    Posts:
    80
    I've been working on a water shader and I'm trying to make a point object match the Y position of the water waves at a given point/sample. The way the water shader works is with vertex displacement. I use the Position node with the "World" option to sample all the vertices of the plane.

    Water.gif

    The red object is a separate GameObject that samples a point (X,Z) with the same parameters as the water shader to get the correct Y position every frame.

    Now this all works fine until I scale or move the water plane object in my scene.

    Water Broken.gif

    I thought World Position node represented a vertex position in the world after all the transformations have been done to it from the "parented" object, but what I'm seeing is the shader acts as if there was no transform done on it so it calculates all the waves and then the transform is applied for rendering. Is there a way I can get a "World Position after transforms" in ShaderGraph?
     
    Last edited: Jun 18, 2019
  2. nttLIVE

    nttLIVE

    Joined:
    Sep 13, 2018
    Posts:
    80
    Found the solution. I just noticed there's an Object node with a Position + Scale. You can offset those values to the world position node to get the proper values.
     
  3. JJRivers

    JJRivers

    Joined:
    Oct 16, 2018
    Posts:
    137
    How do you offset it? I've seen that technique mentioned several times but it doesnt seem to work for me. HDRP 2020.3