Search Unity

Question Is there any reason using Material.GetTexture() should kill my shader?

Discussion in 'Shader Graph' started by Zillus, Jul 25, 2020.

  1. Zillus

    Zillus

    Joined:
    May 31, 2017
    Posts:
    24
    I am very confused.

    I am using a couple of unlit URP shadergraphs for a Fog of War system. I have it mostly working, but I am now trying to sample a pixel from a raycast to determine the transparency of the fog of war at that point to prevent the player from interacting with hidden objects.

    The problem is, the instant I call materialReference.GetTexture("NameOfTexture") the shader stops updating completely. I can get the texture, and interact with it, but only as it existed at the moment I got it, and nothing else in the shader updates ever again from that moment until I restart play mode.

    I know it doesn't make sense, the whole point of Get vs Set is that Get is read-only. Is there any reason that grabbing the texture could kill the rest of the shader?

    Thanks!