Rendering 10K Trees faster than Unity
- Ashwani Shahrawat
- Apr 27, 2023
- 1 min read
Updated: May 6, 2023
When Static, Dynamic, SRP Batching or GPU Instancing is not enough, There is still hope.
It's an attempt to render a huge set of naturally spread trees a lot faster than what we after basic round of optimizations like batching. So, this will include different techniques to bypass or optimize steps of rendering pipeline that I know so far.
I will compare the results with default method of rendering objects,
Where each object is represented by a "GameObject" which have "Transform", "MeshFilter" and a "MeshRenderer" using a "Standard" Shader provided by Unity.
Whatever API I am using to draw is provided by Unity, So I'm not basing on Unity at all. I'm working on Unity for past 10 years, and my love has only grown with time.
Also, All the techniques I will use are well known in gaming industry, It's just that a lot of people including me are not aware of them, Awareness is the true purpose of this topic.
[Extract for Experts]
Extract DrawCall data of all objects, It removes GameObjects from the equation.
Implement Octree Culling, Put objects in their respective Leaf/Cell, Resize to Encapsulate.
Create batches of objects collected from visible Cell. (every frame via frustum culling)
Now submit them for rendering via "Graphics.DrawMeshInstanced" provided by Unity. For most game, The massive speed benefit can easily account for all the flexibility we lost. Now we can also do further optimizations via Job/Burst Compiler and ComputeShaders.
If you understood all that, great!! See you tomorrow with a bigger smile, If you have no idea what encrypted spell was being chanted!
let's dismantle this topic into smaller digestive bits.
[Lets Begin]
WIP - hopefullybymonthend
Comments