Why does FPS drop when looking away from SunSky?

I’ve got a simple landscape setup with some grass foliage scattered around the center of it. When I look towards the sun, I get a fairly high FPS, however, when I look away from the sun, I get a massive FPS drop. This happens even if there is less foliage when looking away from the sun. 110 FPS vs 70 FPS

You’ll notice in the two images, there is almost twice as much foliage in the direction towards the sun than away, in fact it goes until the culling begins, and yet the FPS remains quite high. And just to note, I’m in the center of of the landscape and I currently have Ray Tracing disabled.

I also tried removing the sun sky and just used a default directional light and ended up with the same results.


You need to profile your scene, at the very least use stat unit so you can see where your performance is going.

https://www…com/watch?v=SXLYy6D1y80

When you are looking away from the light, you have more objects rendering into the shadowmap.

It’s not looking away from the sky, it’s looking at the grass… :wink:

Thanks for the feedback everyone. On the GPU profiler it does show the ShadowDepths pass getting pretty massive when looking away from the sun. I guess it just took me by surprise how big of a difference turning from the light source had. I’ll have to keep playing and see if I can get the shadow performance improved with the grass somehow.

start by trying early z pass.
its within project settings.
Works OK for Epic’s default stuff usually.
Personally I don’t see a negative impact using it on high vertex stuff, but I don’t see a gain either.

Personally for grass and other minor foliage I’d turn shadows off.

I remember there is a bug with foliage grass tool in editor where tiles near the center of the level do not get de-spawned correctly. The grass instances still culled using distance culling, so they are often not visible, but they still remain spawned so when you look in a direction of a level center, you will get significant dip in framerate. Is there any chance you are experiencing similar issues? That it’s not really about the sky direction but rather if the camera is looking away from the level origin vs towards it?

That’s an interesting bug and thanks for bringing it up. Unfortunately that’s not the case because if I move even further back from the center and look at the sky over the center of the level, I still get less FPS when looking away from the sun than looking towards it. Also, the issue isn’t as relevant when I raise the sun higher in the sky because there is less shadowing happening in one direction. I included some shots with the sun high to showcase.

I’ll give this a try and see if it gives any positive effects, thanks!






How did you setup the mesh LOD?

May not have anything to do with the grass. Try rebuilding your lighting a couple of times. I know it sounds rediculous, but in the past ive had bugs where i build it one time and my draw calls went up by like 100k if i looked in 1 direction… then i build it another time right after and it self corrects whatever the problem was…

I was using some Megascans grass models with pretty strict LOD falloff. I think I had 4 levels of LOD. I’ve since moved to the UE4 acquired Project Nature grass since I can’t currently edit Megascans grass with Houdini to add pivot painter (Houdini’s pivot painter broke after a UE4 update to how it behaves) I made a few edits to make the LODs a little bit more strict, but the same issue occurred with all grass types. Once again, if I look at the sun I can have 10,0000 grass showing with great FPS, but when I look away even if I only have 1,000 or 2,000 grass showing the FPS drops quite a bit. I also did tests forcing min LOD to the lowest LODs but it had little effect on the issue.

Thanks for the tip, unfortunately it can’t be a light building issue as the entire scene is Dynamic lighting. In fact I have Static Lighting disabled on the project. I’ll keep this in mind for any future static light builds though :slight_smile:

It definitely has to do with shadow casting from a direct light low to the horizon.

Luckily since the main premise of my game will happen at night, it isn’t as big of an issue (below screenshots show 10fps loss vs 2 fps loss). I do want try and have the beginning of the game start a little before sunset however, so I’m just on a mission to see what I can do to help improve performance as I’ve found that to be the most expensive lighting.

Hmmm Did you check your light mass settings in world settings? How many Lights do you have? I recently had an fps issue and didnt reralize i accidentally copied my main light 2 times and it was rendering 2 lights.

in editor click on lit/optimization view modes/shader complexity and light map density. it may help to visualize where things can be overloading that are not visible in lit mode.

I just ran into this exact same problem and found the fix.

In my case, it was always when I was looking away from the sun. If I moved the sun to be overhead, it happened when I looked down.

It’s not early Z pass, not occlusion culling, not anything like that.

It’s actually that, when you’re using dynamic lighting, you need to set the sun (directional light) to MOVABLE or else it does thousands of ShadowDepth passes every frame (you can see that with stat drawcount). I spent a long time messing with the rendering settings and I couldn’t avoid this problem.

I have no idea why. If I was to make a guess, it’s that it seems like it’s expecting the baked shadow map to take care of the culling for shadow depth rendering, and if there’s no baked map available, it just does a full depth pass on everything that could possibly render a shadow into the view frustum. If the view frustum is pointing away from the sun, then that’s pretty much every shadow of every object in the scene (though the shadowdepths pass count seems to move around a bit as I wander around my map, so it’s doing some basic culling it seems).

You should be able to just turn up the dynamic shadow range on a stationary directional light and get the same effect without resorting to a movable directional light.

By default, stationary directional lights have their dynamic shadow range set to 0, which means they use inset shadows for moveable objects which can get expensive really quickly, as you have seen.