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 Is there any reason using Material.GetTexture() should kill my shader?

Discussion in 'General Graphics' started by Zillus, Jul 24, 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!