Search Unity

2 models using the same shader which uses Object Node not working

Discussion in 'Shaders' started by robloz, Nov 13, 2018.

  1. robloz

    robloz

    Joined:
    Apr 27, 2013
    Posts:
    10
    I am not sure why my shader doesn't work when there is 2 models using it.
    My shader uses Object node to get the position of the object but when this shader is using by two or more models seems like it is not working. Any ideas why this is happening?

    Thanks
     

    Attached Files:

    • img1.png
      img1.png
      File size:
      160.6 KB
      Views:
      612
    • img2.png
      img2.png
      File size:
      135.7 KB
      Views:
      654
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,341
    For vertex fragment shaders this is a problem caused by batching, but with Shader Graph it appears the object node is broken when instancing is enabled as well.
     
    robloz likes this.
  3. robloz

    robloz

    Joined:
    Apr 27, 2013
    Posts:
    10
    For what I have seen, one way to fix it for vertex fragment shaders is disabled batching, adding a tag like this in the shader:

    Tags { "DisableBatching" = "True" }

    I couldn't find any where to add that tag with Shader Graph. Are there any way around to do it without having
    to create an new instance of the material that use that shader for each model in the scene?
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,341
    Yep. You'd have to modify the generated shader code to add that, but it won't help at all. Unity doesn't use batching for the LW or HD pipelines, so it's not an issue in the same way that it was / is for the built in forward and deferred render paths. This is unfortunately just a bug that Unity needs to fix themselves.
     
    robloz likes this.