Hi,
draw calls drive me crazy. I try to figure out but my technical understanding is limitid here.
Yesterday I begin with small optimization of my Project. I build ANYTHING Modular with 4x4 pieces and will Merge outside walls with same materials inst., detail pieces with same materials inst., interior walls… and so on.
Use ~5 material masters and many Material Instances.
I have done this now for some parts, got lower Mesh Draw count but in some parts of the Map, I recognize some shuttering or lagg with my mouse, the Mesh draws are low, but the Draw time per frame is high. In other parts I have 5500 Mesh draw calls if I facing the ground and dont see anything else.
I have Screenshots, Profiler Data and a Video for you. Hope you can get me an info.
Look at the Draw Calls and the Draw Time on the right. Theoretical, there are the same Meshes to render, but need on the other side so much more time on the CPU side. Why?
Each material instance you use will be a separate draw call.
5500 draw calls gives totally expected performance drop. You should optimize your scene further to bring it to something reasonable like 1k-1.5k
Also, double check the way your merge assets. If your merged mesh is too big, you will get less optimization from not rendering objects beyond camera frustum. As an example, merging all the rocks in your level into a single giant mesh is a pretty terrible idea overall.
yes I dont merge too big chunks together and seperate interior and exterior meshes.
I also merge only Meshes with the same Material instance so I get 1-2 Material Channels per Mesh after merging. Thats what I mean.
But why is the performance impact so “randomly”? Facing the Ground, only see the ground and get 300-4000 draw calls depends on my rotation is strange. And depending on the view side of the same Place without any background panorama, frame timings increase to 26 from 19ms.
I tried to understand the CPU Stall things and the other Data from the Profiler, but I don’t get it.
Is there a performance impact, if they are still many actors in the level even if they are unseen?
I don’t want to merge the rocks now, because I maybe change something later. But my fear is that i can’t optimize the level in the final pass enough.
Merged the most Actors in the scene now. Draw Calls still increase rediculous on a certain position. Normally I have ~ 600 Draws now.
I take a Picture for you that hopefully explain my problem.
Your scene does not have Draw Call bottleneck which is indicated by high “RenderQuery Result” stat time. This stat shows how much time render thread waits for GPU to finish frame processing.
Your scene is probably bound by GPU fillrate. You can check this by lowering resolution - if your GPU time goes down, then it is fillrate issue. In this case examine your shader complexity and overdraw.
In that screen - no. If there are no numbers displayed you can think they are very low. The stat just stays in the same line it was seen before.
In this case it is probably the draw calls bottleneck.
Materials themselves have nothing to do with draw calls, only the amount that is visible on screen matters. I think you get more draw calls when close to the ground because of dynamic shadows.
Each shadow casting object have to be rendered again for each light to have shadow. So if your building is built from many pieces it may be the case.
Ok nice. And I tested a bit more and see, the draw calls increase, if there are more Props “theoretical” in view, even if they are culled. Is the CPU still rendering Culled Props?
CPU Stall in the stats just means that cpu is idling and waiting for something to do.
In the stats file you provided, your game thread is idling most of the frame time.
Render thread timings seem ok but it spends quite some time on visibility and occlusion and culling and good deal of the latter one is regressed by slow occlusion query on gpu side. This is somewhat indicative that you are having too many / too complex objects to render.
Rest of the time render thread waits for GPU.
On a GPU side of things, your post process looks a bit heavy, and pre-lighting composition is oddly higher than I would expect, but otherwise nothing strange.
So far it looks like you are just trying to render much more than needed in problematic place of your level. For further assistance you should give a bit more info.
In particular, screen shot of ingame gpu profiler, shader and quad complexity view shot, number of lights/shadowcasting lights in the scene.
My wild guess would be that you have quite high dynamic shadow distance, coupled with low elevation of the place where you get this problem. Something forces your objects to pass view/shadow frustum check when looking down.
Is there a way to Disable some Meshes as Occluder? My walls are very simple and dont have any holes, so theoretical i can disable occlusion on the detailed Arches with 7000 Tris.
Can’t found a setting to do this on specific meshes.
And yes I see, Set shadow to Low, I only get 800 Draws on the previous 4000 Draws place. Thanks.
Found it. Clicking Actor, Rendering section. Expand Menu, “Use as Occluder”
So now. I Optimize the whole level now so good I can actually, reduced Draw Calls from 4000+ to 2000. BUT 2000 is still to much. I find out, that Objects that are Occluded, still rendering shadow. Its even rendering shadow when the shadows are not seen and the Landscape, Ground Planes etc. which recives the casted shadows are occluded.
How can I optimize this without reducing the shadow render distance? LODs that doesn’t cast shadows or is there a better option?
But I can have 800, if the shadow culling works like I want.
Tested a bit more with Shadows. Reduced the Draw Calls now to 1700 without reducing the shadow draw distance. And if I reduce the draw distance from the shadows to the point, that the visible meshes are shaded exactly like full range shadows, but the occluded meshes behind visible meshes are not in this range, I have 800 draw calls. So for me, its possible to have a very nice draw count, without any disadvantage in vision, if I get the shadows also occluded by occlusion culling.
I dont want to cap the shadow draw distance, because in some areas you have a nice panorama view which looks odd without long casting shadows.
For Example what my problem is: If you stand for a House without any windows, with 10000 shadow casting props inside which are occluded in this case, you get still the draw count for the shadow casting from the props, even if you cant see any shadow. If shadows occlude well like the props iself, you would have 1 draw call from the house.