Shadows fading out with increased camera distance

I can see that this question has been asked before but none of the suggested fixes are working for us. If we have actors with huge static meshes (think over 2048 Unreal units in height) then their shadows tend to work correctly as the camera moves away from that actor. But any actors with smaller meshes have their shadow fading out very quickly!

Our game is a top-down “city-builder” so I’d imagine this isn’t the kind of problem a lot of people have. Still, it does appear to be related to the size of the static mesh - and it really affects the visual fidelity of the game.

Any ideas?

Well i can give you a hint, you might find something in advance graphics settings (console commands starting with r. , like r.MaxFPS). Here you have source file with those commands declere, it’s pretty much good documentation of them as you can also find help descriptions in there :stuck_out_tongue:

https://github.com/EpicGames/UnrealEngine/blob/6147965f2f00f9241542c3db41c57f9f74f76b08/Engine/Source/Runtime/Core/Private/HAL/ConsoleManager.cpp

Keep in mind that you need to have active subscribtion and GitHub account tied to your Unreal account (in Unreal’s account profile settings) to see unreal source code in github

Firstly, thanks for the hint! I actually spent all day doing exactly this - but I didn’t mention that in my question - so I appreciate you trying to help. :slight_smile:

Incidentally, an easier way than looking at the code is to type:

DumpConsoleCommands

I’m pretty sure that the problem is to do with cascading shadows and I’ll investigate that tomorrow - but I was hoping that somebody else may have solved this problem too!

Since a picture is worth a thousand words, here’s a video that shows the problem that I’m seeing.

As you can see, moving or rotating the camera makes the shadows disappear. I’ve tried adjusting all of the shadow and CSM options that I can access but nothing really changes.

Any help or ideas are definitely appreciated! :slight_smile:

Hi Neil -

Try playing with the following Console Variables, you can set the in your Engine\Config\ConsoleVaraibles.ini file.

r.Shadow.FadeResolution - controls how big the light has to be on the screen before it starts to fade out. - Default Value: 64 - Can lower this value to keep shadows from fading out at further distances

r.Shadow.MinResolution - controls how big the light has to be on the screen before it finishes fading out, at which point it no longer has cost. - Default Value: 32 - Lower values seem to increase shadow visibility.

r.Shadow.TexelsPerPixel - Causes a higher resolution to be assigned and then it should fade out less aggressively - Default Value: 1.27324 - Can increase this value to improve shadow rendering visibility & quality

r.Shadow.RadiusThreshold - Default Value: 0.03 - A lower value of 0.02 or 0.01 greatly increases shadow visibility at far camera distances (seems to have the most impact of all the console commands).

Useful Link: https://docs.unrealengine.com/latest/INT/Engine/Rendering/Scalability/ScalabilityReference/index.html

Thank You

Eric Ketchum

Hi Eric,

Thanks for the reply - I appreciate it!

Unfortunately I tried all of those options yesterday. Maybe there’s an upper limit that I haven’t been able to go beyond? I know that setting the FadeResolution lower made a difference (it made the problem worse!) - but making it higher than 64 had no discernible effect.

What was surprising is that I saw somebody else state that r.Shadow.RadiusThreshold had the most impact - sadly enough I found that it had no impact at all! :frowning:

It really feels like I’m brushing against some kind of upper limit here inside the engine - though I’m hoping that I’m wrong and somebody can tell me about a magical setting that solves my problem. :wink: If not then it’s time for me to crack open the engine source code and start exploring!

That is obviously cascades. Just play more with its settings :slight_smile:

Hi Neil -

So let me know about a few things in your level so I can help diagnosis what the issue is. What is the light source in your level, it looks like a directional light, but it is movable or stationary or static? Can you upload a screenshot of you light’s details panel? The floor which is holding your shadows is it a BSP geometry brush or a Static Mesh and what is the Lightmap resolution (or geometry brush resolution) for both the floor and your asset?

Thanks

Eric Ketchum

Thank you for agreeing with me, it’s definitely cascaded. :slight_smile: That’s why I was playing with the Cascaded Shadow Map options. I’ll get there in the end.

Thanks for your help! :slight_smile:

The same problems appear on other scales as well: I have a scene with small (a few cm / Unreal Units) movable items lit by a single directional light. Their shadows disappear quickly. Depending on the object size, even when the camera is only a meter away!

I’ve also tried all dynamic shadow settings at the light and the console variables mentioned here, but had no luck in changing the disappearance threshold distance at all.

Hi Eric,

You’re absolutely right, it’s a directional light (which is set to be movable). It’s also set to be the atmosphere light too!

Here is what my

for my directional light. I did try to override the Dynamic Shadow Distance Max to 100000 (from the default max of 20000) but that also had no effect.

The floor in the video was a static mesh - but this was just an example map. This happens in all of our regular maps - which are all BSP geometry brush based.

The lightmap resolution isn’t overridden - so it defaults to 64.

Thank you so much for your help so far!

Interesting! Have you tried scaling the Z component to make it taller? I’d be interested to know what you see when you do that. It seems to make a big difference in my testing - but maybe that’s a red herring?

Scaling makes a big difference - the shadow an object scaled to twice the size on all axes fades at about twice the distance. The effect isn’t unique to the Z component though, all axes behave the same.

Hi Neil -

So I tested with a fabricated model similar to yours in size and with the light settings listed above and here was my result:

9165-shadow.gif

I am getting the shadow disappearing which is expected behavior, but not the shadow popping that you are seeing. Is there anything else that you have applied to the world (like a post process volume etc.)? Or have you adjusted any render settings in the editor? And Finally if you could post your DXDIAG?

I am trying to cover a lot of possible bases here. Thank you for baring with me.

Eric Ketchum

Hi Eric,

No problem at all, I really appreciate your continuing help!

So it looks like there are two weird problems here then:

  1. The shadow popping
  2. The fact that I can’t increase the distance where shadows fade out

There is no post process volume and there is nothing else applied to the world - this happens on any new, empty map (and I’ve deleted any post processing actors just to be sure!). I will say though that the specific actor where you see the popping is made up out of multiple static mesh components - that may be part of the problem here. That, plus the size (the actor you see the effect on is 512x512 Unreal units) is the only difference I can think of from what I can see in your GIF.

No render settings have been adjusted in the editor either (I can send you my DefaultEngine.ini if you think it may help though?).

I’m attaching my dxdiag log but I’m not sure that it will help you - we have a range of hardware here with a mix of AMD, nVidia and Intel 3D hardware and the problem is consistent across all of them. Still, I’m happy to be wrong if we can fix the problem. :slight_smile:

Hey Neil -

Can you turn on Show >> Advanced >> Shadow Frustums and post a screenshot or video of the transition?

Thank You

Eric Ketchum

Hi Eric,

Of course! Please find that using this link. Now you’ll see the actor in the editor outside of the game so it will look different to the previous video - the game sets components visible (or not!) depending on neighboring actors.

Thanks!

Neil

Hi Eric,

What you’re seeing is an actor (so a blueprint) with multiple static mesh components. Those components are set as being visible (or not!) when the game is being played.

That said, our environment artist has a level where there are no actors at all, it’s just static meshes - and the problem occurs there too.

If you think it would help you to track it down, I can send you assets and/or anything else in order to reproduce this issue!

Hi Neil -

How are your objects generated in game? Are you placing the a static mesh in the level or is it a blueprint combining multiple meshes together?

Let me know -

Eric Ketchum

Hey Neil -

That would be great, you can PM through the forums with a link to download the mesh or upload it to a dropbox and link there or here.

Thank You

Eric Ketchum