How to ensure particles draw?
I've noticed on several projects (Unity 5) that when instantiating multiple of the same prefab with particles, the later instantiated particles fail to draw (render).
My instinct is that some sort of max particle cap is being hit, and stops drawing, but I'd be very surprised at this happening with a few trail renderers, smoke and sparks for two prefabs.
If I wait for the previous instantiated prefab particles to die, then instantiate the prefab again everything draws fine. But when a copy is instantiated before the previous particles clean up, the new particles do not render.
Is there a setting somewhere to ensure that particles always render?
EDIT I've discovered that the core issue lies within the additive particle shaders. There must be some sort of logic for culling particles that affects any renderers using particle additive materials.
Answer by Dante_CyberdeckGames · Mar 05, 2016 at 05:25 PM
The cause of this problem is that, by default, instantiating a prefab will use a shared material instance which for some reason will fail to render when multiple instances are on screen for certain shaders.
To fix this issue an instanced material must be used instead of a shared material. This can be accomplished by setting the material to itself or editing it.
// Force instancing of the material
Renderer renderer = GetComponent<Renderer>();
renderer.material = renderer.material
Your answer
Follow this Question
Related Questions
Particle System rendered in the camera view 2 Answers
Intersecting edge colliders cause particles to pass through one edge collider? 1 Answer
Emit Particles in 45 degree steps ? 1 Answer
is it a necessity to use particles effect in a game? 2 Answers
For the particle system, making my stars is an issue as the script command calls are now obsolete. 0 Answers