Actually is vesy basic.
For the material i take all rendering inside a layer and create a dictionary, then i just swap the materials, that give me a representation of how many unique materials i have per screen. I gather the materials by GetInstanceID so i dont end with copies.
if (m.GetInstanceID() == r.sharedMaterial.GetInstanceID())
{
//Already Have Material
haveMat = true;
break;
}
The materials output only color , one color per material.
I use the same for swaping all materials texture for checker texture (is not in the screen above).
The main idea is to have it running on actual machine and not editor. So i can check if the shaders on that layer are heavy, or the texture are heavy etc.
Had some cases that swaping all material inside layer (for example; small assets) gave me performance boost, or changing background layer textures from 512 > 256.
Bad is that it run only one frame, if you load any asset after you turn the viewer ON it wont be affected. (need to gather data again)
Overdraw is unity base implementation (replacement shaders, you can download unity shader library), i have updated it for URP like this;
public override void Create()
{
Material overrideMaterial = CoreUtils.CreateEngineMaterial(settings.overDrawShader);
RenderObjects.CustomCameraSettings cameraSettings = new RenderObjects.CustomCameraSettings();
FilterSettings filter = settings.filterSettings;
renderObjectsPass = new RenderObjectsPass("OverDraw", RenderPassEvent.AfterRenderingTransparents, null,
RenderQueueType.Transparent, filter.LayerMask, cameraSettings);
renderObjectsPass.overrideMaterial = overrideMaterial;
renderObjectsPass.overrideMaterialPassIndex = 0;
//Heat Map
blitRenderPass = new BlitHeatMapPass(RenderPassEvent.AfterRenderingTransparents, settings.heatMapShader);
}
HeatMap is an awful trick, is a map for overdraw.
First i decide my target device, then i do some calculations to check overdraw size ratio and performance (Snapdragon profiler, Adreno, Mali Graphic Profiler), after i get an aproximation of my target device i draw a certain amount of red for that fragment.
At the end i use post process to convert the black/red to ramp map (heat map). Not at all 100% (maybe 70+%?) correct but it work well for the target device.
We do computantion time per pixel using MOC and PVR Editor. but that depends on game resolution, amount of pixels to draw with that shader, culling, etc. So basicaly we have a list of heavy shaders with ID.
Vertex count is the basic, get gertices and actualmemory from object.
Memory, use native calls in java or object-c for ios.
Again, i think is the best to make all that stuff running on the device, if possible one frame so the next frame is clean. Profile after and before, compare.
All that data is gather inside a json file and sent to the server with cool visualization.
There is one guy inside the company who made a polyreduction, he take all mesh and reduce the vertices to check optimization. Im pretty sure he duplicate and remake the mesh at runtime, that will have a lot of overhead for profiling memory, but is good idea, bad is that you can crash the device.