Hi there, i know i should profile this but maybe someone already have the answer.
So, we have;
Static Batch;
Combine all posibles mesh in one big mesh, Unity also create index of vertex for culling (camera). Done build timesave date in scene.
Dynamic;
Combine at run time mesh, increase memory. no idea about index of vertex for culling; Limit 900 vertex, is kinda heavy for CPU (If your bootle neck is cpu side)
GPU Instancing;
Send directly to GPU, they are no culled even outside the camera, not Ztest.
But what about memory usage? There is a limit of instance of 1023, thats meshs? If my index format is 16 bit (target device) i would get one draw call every 16 bits (65535 vertices)?
Im trying to check the memory size of 16 bit mesh, (Normals and UV).
One file from maya give me 9mb and one mesh create in unity is 4.5 mb.
Profiler.GetRuntimeMemorySizeLong(mesh);
Why im askign this, what if i spaw a lot of mesh, that go up 16 bits * 4, i would get arounf 20MB (using unitymesh size) used on my device memory? as the instancing are not culled the memory usage would be fixed, right?
thanks ;D
so i did profie.
I created a tool that spawn a quad mesh, Grass
One using gpu Instancing shader by script (update);
Graphics.DrawMeshInstanced(meshToSpawn, 0, material, matrixList[i]);
The matrixList is create at the first frame.
And the other tool create a mesh cluster a little bigger than the camera frustrum (it bake all the grass in one mesh 16 bits index maximun) at the first frame of the app, and i use the camera frustrum so i can cull it.
After profiling the GPU instancing use more memory/cpu/gpu.
The mesh bake aproach was faster, less memory. (same technique i use in previous game, one quad mesh duplicated and position in shader or not, work on OpenGL2)
Im missing something?
I check Frame debugger and i’m instacing the grass in less draw, the amount of draw inside unity and mobile are diferent (i suposse is about mobile GPU)
Dont get me wrong, the GPU instancing did reduce the draw calls (lets say 1000 > 10), but baking the mesh by script gave me a lot better results (lets say 1000 > 1).
The phone is previously warmed for more real case results
I couldnt add the same amount of mesh for GPU instancing, i had to reduce it half for profiling. One idea was creatig big chunks of mesh and instanciate the chunk but it would be less editable depending on the the terrain shape.
Bake Tool - 40 fps
GPU Instancing - 20 fps