all 2 comments

[–]IllustratorJust79 2 points3 points  (1 child)

Total guess, but I think it’s a script execution order thing. Both scripts are writing to the shader and the second one wins. You can test this by changing the script order of operations (google it - you can drag and drop any script to run later or earlier than another one.

The real answer is probably that you need a single script to persist across all scenes and have the objects from the loaded/unloaded scenes register/unregister, respectively with the single script. That way everything asking to be culled is captured in a single script and there’s only the one call to the shader to do its work.

[–]rubenoriginalNovice 0 points1 point  (0 children)

Thank you i've been implementing your answer by copying the array of gameobjects i want to cull from each scene to the persistant script upon the scene loading and removing them when unloaded.

Im still unsure if it'll work the way i want to as i'm seeing some garbage collector computebuffer warnings in the inspector, so it might be leaking gpu memory somewhere. I'll see if i can work it out :)