Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Subgraph error

Discussion in 'Shader Graph' started by stroibot, Aug 3, 2021.

  1. stroibot

    stroibot

    Joined:
    Feb 15, 2017
    Posts:
    91
    Hello,

    I have a Material that uses Shader created by Shader Graph. Let's call it a base.
    I want to add a pattern to my object on top of base Shader, I've created new Shader and Material from it.
    I tried to apply it to my Mesh Renderer and it gives me "This renderer has more materials...", ok.

    I remembered that there's a feature called "Subgraph" and I thought that this will be a great thing, I could use my base Shader as a Subgraph and then just call it in other Shaders to apply, like, pattern to it. Is this a right usage for Subgraphs?

    I tried doing this but I get an error:


    Is it me? Am I just don't understand how it supposed to work?
     
  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,753
    Can you try create new graph from scratch, and then create subgraph?

    I have experienced similar issue occasionally.
    Restarting Shader Graph, Unity, or even recreating graph sometimes help.
     
    Last edited: Aug 3, 2021
  3. stroibot

    stroibot

    Joined:
    Feb 15, 2017
    Posts:
    91
    I figured it out, I don't know why, but I gave all of my subgraph variables under score "_" to their reference names. if someone could explain why this worked I will be grateful.
     
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,753
    Hmm. Technically unless you use some specific keyword variables, that shouldn't matter.
    What if you remove "_", will it break again? Or if works, maybe some variable name ref wasn't updated correctly?
     
  5. stroibot

    stroibot

    Joined:
    Feb 15, 2017
    Posts:
    91
    Ok, I just checked "_" has nothing to do with this issue. Moreover, all nodes in subgraph show this error, buuuut when I use this subgraph in shader graph everything is ok.