This is a weird one, I’ve been trying to diagnose if for the past two days and every time I discover something I get more confused. I’m not sure if anyone can help by looking at screenshots and reading my description alone, but maybe someone will notice something obvious that I’m missing.
I built some test trees which I thought were performing fine, until I realized that looking at them at some specific angles and distances cause quite severe frame drops (pic #1).
After viewing stats, I noticed that these frame drops were happening when RenderQuery Result appeared. The red bar doesn’t really fluctuate much, it is either there or not there, depending on which angle I look at the trees and only within a certain distance of them, for example in pic #2 where I look down by a few degrees and the performance increases and RenderQuery Result stops doing whatever it’s doing.
If I look at the trees from the other side, the performance is fine (pic #3). The left side of the building is less furnished and complete than the right side, which is possibly why, but still I don’t think it should be enough to cause those performance issues when looking at the right side of the building through the trees.
Some additional info -
• I’m using a post process shader to draw outlines on objects with custom depth enabled. Disconnecting this shader from the post process fixes the performance issue, but disabling objects in the scene from being affected by the shader by disabling custom depth doesn’t have any effect.
• The tree’s flowers are a two sided decal, changing the material to ‘one sided’ fixes the performance issue, and turning the flowers off all together fixes the performance issue
• Forcing the flowers to use their LOD1 mesh fixes the performance issue, but it doesn’t explain why there would be a performance issue only at certain angles with the LOD0 mesh, which usually performs very well even when ALL the trees are in view.
• There is some fairly heavy geometry inside the building, but checking those to be hidden in-game doesn’t have any effect on performance
I don’t really have a conclusion, other than it’s clearly the hi-res flower mesh that’s causing issues, possibly combined with my post process shader (which isn’t actually applied the flowers, but only the trees) but that doesn’t explain why only certain angles and distances are problematic. I can reduce the expensiveness of the flowers with some better LOD solution I guess and forget about the issue, but what I’d like to learn is what might cause RenderQuery Result to work so hard, so I can prevent it in the future.
Any help is seriously appreciated, I’m trying to get better at optimization and my game needs to run as lightly as possible, but this one has me stumped.