Unity: Difference between revisions

 
(One intermediate revision by the same user not shown)
Line 30: Line 30:
If you need multiple instances of the same object, make sure that the material is instanced so that all objects only consume one draw call.<br>
If you need multiple instances of the same object, make sure that the material is instanced so that all objects only consume one draw call.<br>
See [https://docs.unity3d.com/Manual/GPUInstancing.html Unity: GPUInstancing].<br>
See [https://docs.unity3d.com/Manual/GPUInstancing.html Unity: GPUInstancing].<br>
Do not attach scripts to thousands of objects. Instead use one script on one object.<br>
Do not attach scripts to thousands of objects. Instead use one script to control all instanced objects.<br>


====Merging Meshes====
====Merging Meshes====
Line 38: Line 38:
Be aware of the limitations of using a single draw call though; transparency can become tricky.
Be aware of the limitations of using a single draw call though; transparency can become tricky.


You can use a compute shader to animate and move the objects instead of using Unity scripts.   
After merging a mesh, you can use a compute shader to animate and move the objects instead of using Unity scripts.   
The compute shader edits a single compute buffer which can be read by your vertex or geometry shader without passing data back to the CPU.
The compute shader edits a single compute buffer which can be read by your vertex or geometry shader without passing data back to the CPU.