Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Compute Shader Updating Unpredictably when GameObject set to active

Discussion in 'Shaders' started by amasinton, Aug 13, 2019.

  1. amasinton


    Aug 12, 2006
    I have this lovely compute shader which does DrawMeshInstancedIndirect instancing of thousands of meshes based on a cloud of points. See more over here.

    The shader gets groups of points passed to it each frame from a c# script attached to a null GameObject with just a Transform and the instancing script. The script chooses from a list of groups of points at random at different time intervals - so the cloud of instanced meshes changes shape. It works great.

    However, if I turn off the GameObject and then turn it back on again, sometimes nothing renders, sometimes only a portion of a group of points. I have multiple GameObjects each with their own instancing script attached and all referencing the same material with the same instancing shader but using different lists of different point sets. If one GameObject starts inactive and is activated during play, I usually see nothing rendered, but sometimes the other GameObjects start to render only portions of identical clouds of points and do not change as time passes. Sometimes they simply stop rendering.

    I suspect I'm running into trouble by having multiple GameObjects all referencing a single material using this compute shader. Is it possible to do this, or does there need to be a unique material for each Game Object? Any thoughts on what's going on?