- Home /
Shader global texture reset on scene load?
I'm generating a Texture3D with Perlin noise for use in a shader. It takes around 5-20 seconds depending on the resolution, so I'm doing so in a separate thread. Originally, I was generating the texture once the scene that uses it has loaded, but often the texture wouldn't be ready by the time I wanted it.
I changed the setup so that the texture is generated once when the game launches, and set like so:
Shader.SetGlobalTexture(PROP_NOISE_TEX, m_noiseTex);
However, after this change, the texture would sometimes be missing. I determined that the texture would only be correctly set if it completed generating after loading the scene that wants to use it. Any time I load a different scene, the texture seems to disappear and I need to run the above line of code again.
I can't find anything about this in the documentation, is this expected behaviour? Is it because an instance of the shader must be in use for the global properties to stay alive?
Your answer
![](https://koobas.hobune.stream/wayback/20220612175827im_/https://answers.unity.com/themes/thub/images/avi.jpg)