I have a script which sets a global texture for use in some shaders. Now, originally it was set each frame, in the Update() function, but I changed it to Start(), because I suspected it to be a lasting value.
Now it doesn’t work. The shaders using this texture doesn’t get it. Here’s my question:
We load everything from bundles, and so objects might be loaded later than this setting is set. Could that be the problem? Would it be possible that an object with a given shader HAS to be present when the SetGlobalTexture() is called, to detect the existance of the property? Or is there some way to set it in a more clever way?
The call will not cache as such it will not impact future assets.
But you can have your code that loads the asset potentially store this ‘global texture’ too and assign it to only the assets it loads as it knows what it loaded.
Thx for the input. The biggest problem here is actually bad design of our pipeline. At the moment I have no way of knowing, on my side, when an object is loaded, as this happens from some bigger system, detached entirely from my little effects So I just need to go to our programmers and get them to create some sort of “EverythingIsLoaded” event, and then use that…
When it is shaders you are loading, you should cook them first before any actual game scene, so you wont have glitches or slow downs with your graphics.
While cooking them in an initial loading scene, you can also set your textures after all shaders are loaded.