Search Unity

Question ShaderGraph works intermittently

Discussion in 'High Definition Render Pipeline' started by jeffcrouse, Mar 22, 2023.

  1. jeffcrouse

    jeffcrouse

    Joined:
    Apr 30, 2010
    Posts:
    18
    I have a simple Shader Graph that just has an HDR color that gets assigned to it via a script. The HRD color is connected to the Emission Color.

    Materials that use this Shader Graph get instantiated at runtime. I was pulling my hair out for hours because the shader only seemed to work intermittently (the object would glow). The rest of the time it had no glow at all. I could get it to work by re-saving the Shader Graph while the game was running. Also, strangely, it worked as expected in the Scene view, but not the Game View.

    On a hunch, I put an instance of the material into the game (ie: before runtime), and now it seems to work consistently. So, I have a workaround.

    But all of this leads me to believe that the problem is something having to do with Unity failing to compile the shader if it isn't already in the level before runtime.

    Has anyone else encountered this problem? It this a known issue? I would search for an existing bug report but I'm not exactly sure what to search for.

    Thanks!
     
  2. jeffcrouse

    jeffcrouse

    Joined:
    Apr 30, 2010
    Posts:
    18
    Well, I was mistaken -- having the shader graph in the scene before runtime doesn't reliably prevent this problem. So, I'm open to any suggestions people have.
     
  3. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    The Project Settings menu has a place you can list shaders that MUST be included.

    upload_2023-3-23_14-37-23.png

    That should get things working for you.