# Instanced foliage is causing massive performance drop when changing visibility of ordinary static meshes

**URL:** <https://forums.unrealengine.com/t/instanced-foliage-is-causing-massive-performance-drop-when-changing-visibility-of-ordinary-static-meshes/263335>\
**Category:** Platform & Builds\
**Tags:** unreal-engine, Performance, UE5-0\
**Created:** [November 30, 2021, 2:06am UTC](https://forums.unrealengine.com/t/instanced-foliage-is-causing-massive-performance-drop-when-changing-visibility-of-ordinary-static-meshes/263335 "2021-11-30T02:06:01Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Jimbohalo10](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jimbohalo10/32/961440_2.png) [@Jimbohalo10](https://forums.unrealengine.com/u/Jimbohalo10)\
**Post date:** [February 8, 2022, 2:22pm UTC](https://forums.unrealengine.com/t/instanced-foliage-is-causing-massive-performance-drop-when-changing-visibility-of-ordinary-static-meshes/263335/3 "2022-02-08T14:22:17Z")

</div>

> [@Patryk\_Walewski](#):
>
> Is there any way we can currently prevent this issue to happen? Maybe there is a setting or a CVar that we are missing or can change that will help with the instancing affecting the performance in such a heavy way?

In the source code Engine\Source\Runtime\Renderer\Private\GPUScene.cpp for 4.26/4.27/UE5.0, there are CVar functions  
r.GPUScene.UploadEveryFrame=0 // that means EveryFrame is uploaded

r.GPUScene.ValidatePrimitiveBuffer = 0 // that means not validating GPU buffer, but if you do set this performance does not exist, maybe it’s for RTX debug?

r.GPUScene.MaxPooledUploadBufferSize= 256000 //Maximum size of GPU Scene upload buffer size to pool  
The code for UE 5 is here same as 4.27

 ![Screenshot (148)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/9/7/297841fa1145c0db06e72a20f8e6151460673d27.png)

I am not anywhere near an expert in UE5 just an indie coder and VS2022 fan!  
So I just know where to find the code.  
The code changes considerably  
the real problem is that the code is checked in GPU, presumably for RTX?.  
Rather worrying is for some reason the logging has been commented out

 ![Screenshot (149)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/3/e83fbf770f6b48b01fbc86d54a29c8e0a449a3c0.png)

If you uncommented this you could at least see if this was the code causing the problem .

 ![Screenshot (150)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/e/d1ed6ed53a53f0ed2ce2f90938a78dec660d5b1b.png)

I have no way of checking as I am not a graphics designer and don’t build my own graphics projects just test others

Can I also suggest you look at  
[ShadowDepths in GPU visualizer hurting performance](https://forums.unrealengine.com/t/shadowdepths-in-gpu-visualizer-hurting-performance/73584/4)

The YouTube video is really interesting by

> sg.shadowquality 0 where value is between 1 and 4

I know I get a 25% increase and the example is for UE4, but this works with UE5 as well WITH Nanite and Lumen and it’s really **sg.shadowquality** that’s the problem. When you pull out from the temple you get 78FPS on my under minimum spec GeForce GTX 1050  
This is [Sun Temple](https://www.unrealengine.com/marketplace/en-US/product/sun-temple?lang=en-US&sessionInvalidated=true) running twice FPS with StatGroup\_GPU

 ![Screenshot (151)](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/f/3/9f3c266307a106402d7ff00b22023277da0b78bb.jpeg)  
All that’s needed is to learn LumenSceneLighting

Maybe this affects your other question  
[Foliage light problem depending on the orientation of the camera - Unreal Engine 5 Early Access](https://forums.unrealengine.com/t/foliage-light-problem-depending-on-the-orientation-of-the-camera/258123/5)

If you want to build UE5 code please see the post on how to  
[Visual Studio 2022 builds and runs UE5.0](https://forums.unrealengine.com/t/visual-studio-2022-rc-2-builds-and-runs-ue5-0/255060)

---

_[View the full topic](https://forums.unrealengine.com/t/instanced-foliage-is-causing-massive-performance-drop-when-changing-visibility-of-ordinary-static-meshes/263335)._
