Grass Tool causing massive performance drop

There is a comment above in this thread saying that there was massive performance drop for the Kite demo when moving from 4.14 to 4.15. I don’t know if this is related to foliage or other, but I believe this should be investigated (maybe by opening a new bug ticket for this specific issue?)

Yes you should enter one specific to KiteDemo

Here is what i see on my side when doing some test in a map with the shown landscape settings and 1 directional light and light in the back of the camera (for worst case):

Painted Foliage:

Grass:

As you can see both are quite similar in performance, i’m using a mesh(the engine content cone) with 3 LOD, for sure if your mesh only have 1 LOD you will have massive performance issue.

In both example you can see i’m drawing +500k instances with similar density, shadow depth is high at 8ms but it’s the same for both system.

Unless there is something missing, i don’t see the performance issue you’re seeing(i.e grass specific issue)?

Thanks

Thanks!

I think it will be useful to help finally resolve this issue :slight_smile:

Hi there,

Like stated in my previous post, “(around 170 tris per instance)”. Usually a grass patch goes up to +500 Tris for LOD0 and goes down in other LODs. Here I’m just using a single bush without any LODs since LOD0 is already low.

However, my ferns had 4 LODs + Billboard so the issue can’t be related to LODs or tri count. What I do suspect is that the frame rate drops happen when the used mesh has a masked material on it. I did give it a try using a cone and wasn’t getting hit as hard as I do when using a mesh that uses masked material with 2 Sided foliage shading model.

I’m going to setup a demo scene with actual grass and post my results + dropbox link to the project for you to have a look at.

Alright here’s a grass patch with LODs, Grass density set to 30.

https://i.imgur.com/doD4yov.jpg

There’s about 9ms increase.
Here’s the project. I’ve also included a camera you can pilot to have the exact same view as I do.

My specs:

GTX 970
16GB RAM
i7 4790K
1080p

Thanks.

@ When you say there is about 9ms increase, compared to what? no grass at all or compared to painted foliage?

Compared to no grass.

I went ahead and placed same amount of grass using foliage painter and am getting the same ~9ms hit, can’t spot the performance difference we were having back in the day. But is this cost normal?

The main issue is that scattering several meshes is basically preventing us from achieving a solid 60 fps still without anything else going on in the scene. This is a roadblock for us working on an open world/outdoor game.

The cost we’re seeing here for having foliage instances is actually more than the cost we’d have been paying for something like SVOGI (if it was still kept in the engine) and this is all basically coming from ShadowDepths, which is exactly the same issue with landscape tessellation bug reports.

I’m sorry I’m an artist and don’t know much about the technical aspects for these systems I just can say that this is a solid STOP sign for ourdoor projects as many have agreed. There’s definitely something messing with performance there.

This is good to hear, that you are getting the same result for grass or painted. As for is 9ms normal for what you’re doing? I would say it depend on the GPU/platform, as on my side the cost is only 3ms for your scene. Keep in mind that each primitive need to be rendered more than once, so the higher the prim count the higher the cost.

I’ll see if i can do something on this end, but it might simply be “normal”, try being more aggressive with your primitive count in your LOD, you should see the cost come down a lot. Maybe you could try disabling the shadow on the “grass” and use the landscape lightmap instead, (i’m not an artist so it might not give the result you want to achieve)

Also i think one of the big issue regarding this system, is missing doc explaining on how to properly configure it to achieve a good ratio of perf vs visual quality.

As for being the same problem with the landscape, keep in mind that the optim i made are on many front, but one of them is sending appropriate data to the GPU either for normal render pass or shadow pass.

Well what i’m doing for landscape (that will be in another checkin) is that i lower the LOD used to render the shadow. For example, if you render with a LOD2 your landscape, depending on calculation i might use LOD3 or 4 for the shadow rendering this reduce the cost of shadow depth A LOT with real visual difference, in my test case.

As for grass, i’ll have to check but maybe i could do something similar, as the one costing the most of the shadow cost are the really far away one, in most case you don’t see enough details to justify the cost of rendering with normal LOD.

P.S what is the solution you found for doing something as you described?

Thanks for the help.
Also is it possible to have a simplified mesh cast shadow -for- a mesh instead of the LOD0 itself?
For example disabling “cast shadow” on a grass that is 3000 tris, and have a grass that’s 500 tris to cast shadow instead, while not being rendered.

Edit: Found the solution to that. That’s probably going to help reducing shadowdepths cost. But really looking forward to see if you can come up with a better solution. Thanks.

By checking “Hidden Shadow” and “Actor Hidden In Game” I can make a mesh cast shadow while not being rendered, however, I can’t access this feature because these:


Are not accessible when a mesh is placed using Grass Tool or Foliage Painter so I’m stuck.

But, if you can make it as simple as allowing the specified LOD i.e LOD 5 to cast shadow for other LODs instead of each LOD having it’s own shadow casting, that should significantly reduce the shadow cost while not making much visible difference.

If that actually come true, we’d be able to use it for pretty much everything i.e have our rock LOD 5 cast shadow for rock LOD 0, applying this technique would tremendously help with battling the ShadowDepths cost specially in outdoors where there are lots of rocks, trees, ground cover etc.

Thanks.

Thank you for the effort being put into resolving this issue. I hope we are getting to the bottom of it soon.

I once ran into an issue, where landscape grass was being rendered 4 times for each shadow cascade. That was around 4.14. I believe it was project specific, since I was not able to reproduce it in a clean project with stock assets. The issue resolved on its own after deleting and re-importing landscape and never re-occurred in newer versions so I believe it has not much to do with this question, but might be worth mentioning.

Overall, high shadow rendering cost seems to be caused by sub-optimal landscape size/ shadow cascade settings. Smaller components, coupled with increased shadow distance and sharper cascade transitions should help.

@Deathrey
Each visible mesh will be rendered once for each pass + for each shadow cascade that they are included in up to the max specified in the light settings. So this is normal, pre 4.19 the shadow cost was high due to the way we were handling that, it was fixed for 4.19.

The overall cost is much lower, but the same issue currently persist for foliage, each foliage instance is rendered for each render pass + for each shadow cascade which add up to a lot when using dynamic light, this will be looked up hopefully for 4.20.

@Michel.Dupuis I did actually mean that each grass cluster was drawn 4 times for each shadow cascade, totaling 16 shadow depth draws per cluster for a 4-cascade setup. But it was clearly project/scene/engine build-specific bug, so it is not that relevant. Looking forward to the changes.

On a side node about shadows, have you considered some sort of shadowcaster occlusion culling/shadow receiver tests?

Ive just ran into this bug too. Grass landscape, made in 4.16 , when imported into 4.18.2 and along a few thousand foliage units tanks to 15 fps. 64 components i think. Will try turning off grass shadows entirely as per suggestions, really needs fixing asap