Quantcast
Channel: Questions in topic: "compute shader"
Viewing all articles
Browse latest Browse all 287

Callback when (compute) shader is reloaded

$
0
0
When you change the source of a shader during Play mode, Unity recompiles and hot swaps the shader. Unfortunately, it looks like compute shader properties are not restored after the hot swap. The textures that I set on my compute shader become null after the reload. Is there a way to be notified or detect a shader hot swap, so that I can reassign the shader properties? It seems like this is different from a full C# assembly hot swap. If you only change the shader code, the C# scripts are not reloaded and therefore, the usual solutions don't seem to work. Here's what I've tried so far: - [DidReloadScripts][1] annotation - [AssemblyReloadEvents.afterAssemblyReload][2] event - Use computeShader.[GetInstanceID][3]() and see if it changes after a hotswap (it doesn't). [1]: https://docs.unity3d.com/ScriptReference/Callbacks.DidReloadScripts.html [2]: https://docs.unity3d.com/ScriptReference/AssemblyReloadEvents-afterAssemblyReload.html [3]: https://docs.unity3d.com/ScriptReference/Object.GetInstanceID.html

Viewing all articles
Browse latest Browse all 287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>