Search Unity

Question Can Reference Names Have Collisions

Discussion in 'Shader Graph' started by JG-Denver, Jan 18, 2021.

  1. JG-Denver

    JG-Denver

    Joined:
    Jan 4, 2013
    Posts:
    77
    The Reference Names on Shader Graph properties are always named by default with very random names. This looks like it might have been intentional to avoid naming collisions.

    I keep renaming then as most I am changing at runtime and want more standard names. However, this means I reuse names between different shaders.

    Is there any concern with naming collisions with Reference Names?

    Thank you
     
  2. JG-Denver

    JG-Denver

    Joined:
    Jan 4, 2013
    Posts:
    77
    I have found at least some scenarios where collisions can occur.

    For example, if you create a property called Offset and then set the Reference Name to "Offset" it will put the Shader Graph into a non-functional state. So this indicates there is at least the potential of internal shader name collisions.

    Also, I have seen references to accessing existing globals by simply putting the same name of the global in reference name, which is very useful, but undocumented.

    My biggest concern is still whether or not I can create collisions with properties between shaders with the same reference name.

    A little more elucidation around reference names would be appreciated and hopefully, this will make it to the official docs at some point.
     
  3. JG-Denver

    JG-Denver

    Joined:
    Jan 4, 2013
    Posts:
    77
    After further research and digging and I believe my concern about collisions of property reference names between shaders is not so much so. Shader Graph is implementing these as properties in shaderlab, which are local to the shader and should not collide.

    However, there appears to still be the potential issues of colliding with global or undocumented local names. So far it case seems to just crash the editor anyway, so it is noticeable.