Search Unity

Bug Accessing pre-modified vertex position

Discussion in 'Shader Graph' started by JoeGrainger, Apr 27, 2021.

  1. JoeGrainger

    JoeGrainger

    Joined:
    Oct 20, 2012
    Posts:
    19
    I can't seem to find a way to retrieve the original object/world position of a vertex inside of Shader Graph when it's position is modified at any point within the same graph.

    It appears if a vertex modification step is included within the shader this will be performed and applied to the vertex position first. All subsequent uses of position have this modification applied (regardless of how the nodes are connected together).

    Perhaps during the compilation step that Shader Graph then optimizes any calls to the position node to a single call, which returns the modified version of the position.

    There doesn't seem to be a way to specify at what stage you want to retrieve the position information, and attempting to store the position in a separate sub-graph/vector3 node still returns the modified position.

    I believe @Jick87 had the same issue back in Dec, 2018 and there was no response I could see as to how this could be resolved.

    What I have done to work around this for now is to bake the world positions in to spare UV channels within the original meshes, but this comes with plenty of drawbacks.

    Before shader graph I would've simply stored the position property prior to any modifications, and use it later in the program - I'm surprised this isn't possible and so I can only assume it's a bug.

    Unity Version 2019.4.9f1
    Universal RP (7.5.1)
    Shader Graph (7.5.1)
     
  2. Shack_Man

    Shack_Man

    Joined:
    Jun 7, 2017
    Posts:
    372
    Is there still no easy solution to this? Would be so freaking useful to have that option in the position node, like 'Original world position' so you can use that for adjusting colors/emission etc.