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

Resolved Loading shader graph material in code breaks transparency?

Discussion in 'High Definition Render Pipeline' started by xytor500, Apr 10, 2023.

  1. xytor500

    xytor500

    Joined:
    Mar 29, 2017
    Posts:
    73
    I have a shader graph material that I am passing to my script through the unity editor inspector that creates and renders objects. It works really well for transparent materials:



    However, I want to make my game data-driven and load them from file:

    Code (CSharp):
    1. Material nodeMaterial = new Material(Resources.Load<Shader>("Art/Misc/NodeShaderGraph"));
    This does load the material, but the transparency is broken.

    What am I doing wrong?
     
  2. akent99

    akent99

    Joined:
    Jan 14, 2018
    Posts:
    588
    Did you set any of the other material/shader properties? (Do you need to? Or all the defaults what you need?)
     
  3. xytor500

    xytor500

    Joined:
    Mar 29, 2017
    Posts:
    73
    No, the answer was that I just needed to create separate materials using the shader, instead of using the shader graph autogenerated material.
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    703
  5. xytor500

    xytor500

    Joined:
    Mar 29, 2017
    Posts:
    73
    No, I'm saying that I solved the problem by creating a material. Before, I was just using the default material that's attached to the shader graph, and now it's a separate material, which works well.