Shadows fading out with increased camera distance

#Feedback

@Neil,

Hi Neil! I’ve tried static, stationary, and movable lights, and I hit a max distance of 20,000 with all of them!

@Eric,

Eric, your video alone shows the behavior I am complaining about, the fact that the shadows are fading out as I get further way, and I want to increase the shadow distance so they do not fade out

If you watch my video, you see that I am try to extend the shadow distance to numbers much larger than 20,000, so that the shadows do not fade out as shown in your video.

I am having severe problems with this and myself and the other core members of my team all agree that you, Epic, really need to address this for our RTS game to be able to work.

Smaller meshes are affected more acutely, their shadows fade out faster, and the max distance of 20,000 cannot seem to be surmounted.

Eric, if you can post a video showing yourself extending the max shadow distance beyond 20,000, that is the kind of repro / resolution / fix that I and my team need to make an RTS game with UE4

#Exact Repro

In your test project, zoom out to the max range where shadows start to fade, then increase the shadow distance using stationary or movable directional light, to like 80,000

then go out further, till shadows start to fade, and go to like 120,0000 or 500,000

Shadows completely disappear for me when values like these are set

I need these sort of distances to be viable for my RTS game, because toward the edge of a top down view the Engine perceives a great distance indeed for the object to the camera, I need large values like 500,000 to be viable!

#I Tested Your Project Eric

I tested your exact project Eric

You can try this

~ Even at a shadow distance of 80,000,

a. the shadows start to lose quality when the camera is close to them

b. the shadows have not gained any additional viewing distance! It is capped at 20,000! 40,000 does note extend this range!

~As I keep doubling the shadow distance, while at the edge of where shadows start to disappear for the boxes, their shadows never become viewable at a great distance! All that happens is the way the shadows form changes, but the distance is clearly capped at 20,000

~ As I got very large values like 640000.0, shadows simply give up and stop occurring at all, but their viewable range never increased beyond the 20,000 level

This is unacceptable for an RTS top down game where objects at the edge of the camera are treated as very far away from the camera, and with a limit like 20,000 this compels me to keep the camera really close to the land, limiting the view of the scene, as well as the fact that smaller objects lose their shadows even faster, and there’s no way I can force the top down camera to be that close to the ground all the time!

#Summary

The max shadow distance for directional lights needs to be extended beyond 20,000 !

All that happens for values higher than 20,000 is the shadow shapes change and eventually start to fade out, even when not changing the viewing distance at all, till they simply disappear by the time you reach 640,000 or even sooner

#My Video

I showed all of this clearly in my video

#Picture

In case anyone is confused by what I mean when I say the shadow distance is limited to 20,000, this is the value I am talking about, member variable on Directional Light Component

#Any Update Eric?

I hope you are having a wonderful week! Let us know when you have an update!

#Those Two Console Vars Are Essential

Eric you wrote:

“The Dynamic Shadow Distance setting appears to be working as intended and the limit you are seeing is based on the size of your object to the distance from the camera”

“most of the people in this thread have been talking about an RTS which has the camera at a isometric angle to the playing space. This means that you are not measuring the straight downward vector for distance, but the hypotenuse vector and this amplifies the problem as now the items further back in the scene (which you would not have in the top down method) are actually further back and take up less screen space then the items in the foreground closer to the camera.”

“I know we all have had issues with setting these variables and this area is one in which I am still testing to make sure they are working as intended in 4.4.0.”

r.Shadow.FadeResolution - which says at which shadowmap resolution the fade begins

r.Shadow.MinResolution - which says at what resolution the fade ends

#My Analysis

So if we can get the two above variable to work, when dynamically set during runtime via the console,

Shouldn’t everything be just fine, I can change those values to enable smaller objects to have shadows at greater distances?

My ability to make an RTS without having to change maps just because I zoomed out from 2x to 3x view distance depends on these two console variables actually working properly!

#Between You and Me

Just so you know Eric I understand this issue is quite a large one and that you are just one person addressing this, so personally, thank you for looking into this and know that I am not expecting you to figure this out all by yourself!

I am however expecting Epic to address this issue since I am aware of many people who are making RTS projects and I am personally working on two different paid projects that are RTS :slight_smile:

Hey Everyone -

I want to address a few things as a means of an update on this issue. So, this is going to be a length response, hold on to your hats.

First, when I call it an issue I am referring to the popping in and out of shadows and not the fading out of shadows. Shadows will always fade out at an extreme distance, this has been a function of lighting in the Unreal Engine since UE3 and I do not see it changing until we all have the equivalent of Titan GPUs our higher as a standard in CPUs; and by that I mean it is a performance issue. BUT, before you mass email me with the hate mail, I want to explain how shadows are rendered in the engine so we can all be talking on the same page.

Shadows in UE4 whether Stationary or Movable are rendered on a per object basis and the resolution is derived from the caster’s screen size. The resolution of which is mapped to fade opacity by the two console variables:

r.Shadow.FadeResolution - which says at which shadowmap resolution the fade begins

r.Shadow.MinResolution - which says at what resolution the fade ends

I know we all have had issues with setting these variables and this area is one in which I am still testing to make sure they are working as intended in 4.4.0. However, it is the “derived from the caster’s screen size” that I want to focus on. If your object is, like the cube in our test map, 100 uu x 100 uu(Unreal Units) which is to say 1 m x 1 m in real world dimensions as 1 uu = 1 cm. Now, that box, let’s say fills the camera’s screen at a distance from the camera of 1 m or 100 uu. Obviously in that instance, shadows will render fine as the caster is close to or at 100% of the screen size; our shadows are taking up, let’s say 1000 pixels. However let’s pull our camera back in a straight line to say 100 m or 10,000 uu. The box is still 1 m x 1 m, but now it is taking up only 10% of the screen size, give or take a few % points; our same shadow must now take up only 100 pixels. To grossly over simplify the math done in the engine to derive the shadows, you are multiplying now by .1 and not by 1 (I cannot stress the gross oversimplification of this statement, but the principle stands.)

Lets take this to the extreme though, our same 1 m x 1 m cube with the camera at 1,000,000 uu (I do believe there is a View Limit well below this setting though). So now your cube is taking up only 0.000001 % which means your shadow must be rendered in 0.001 pixels. As we all know, we do not render at anything lower than 1 pixel, so the engine is culling the shadow completely.

In my example, we’ve been dealing with a straight camera move, so essentially a top down scenario, but as most of the people in this thread have been talking about an RTS which has the camera at a isometric angle to the playing space. This means that you are not measuring the straight downward vector for distance, but the hypotenuse vector and this amplifies the problem as now the items further back in the scene (which you would not have in the top down method) are actually further back and take up less screen space then the items in the foreground closer to the camera.

I can hear you all now, “But Eric, doesn’t that mean we cannot do an RTS?” No, it means we have to take advantage of LODs and gamestate changes to allow you to deal with larger items when we zoom out and smaller and more detailed items when zoomed in. You can see this sort of effect in most Sims or Sim City Games. You zoom out to a set distance and then the game will actually change states, will ask you if you want to proceed to city zone or world map. You get the illusion that you are zooming further out, but in fact you are changing to a different map with a different scale in models setup. Its these challenges which make an RTS a difficult game type to create.

Specifically to Neil though, the issue with your CubeBPs where the shadows are culled on a per object basis, there is a flag, checkbox, to force the light to treat as attachment. In the blueprint you will need to parent all the meshes to a base mesh(all cubes under one cube) then make sure that the “Light Attachment as Group” flag is checked true under Lighting in your Base Mesh’s properties. Remember, however, that what every your base mesh is will determine the shadow culling based on distance, so what your base mesh may be important.

In summary, I am still looking into the popping issue, but I feel that the ultimate result of this is going to be a screen size ratio issue with no fix. I am also looking into the use of those 2 console variables to ensure that they are working correctly. The Dynamic Shadow Distance setting appears to be working as intended and the limit you are seeing is based on the size of your object to the distance from the camera (with the exception of the popping in and out which is something, as I said, I am looking into.)

Thank You

Eric Ketchum

Hi Eric,

Thanks for your reply, it was very informative!

That said, it’s sounding more and more like the “proper” fix for us would be to expose some properties from inside the engine. We need to be able to control at what ratio of the screen size shadows fade/cull. Then the performance problems are on us - and not on Epic.

It sounds like r.Shadow.FadeResolution and r.Shadow.MinResolution are part of the solution - but not the whole solution.

Also - thanks for your specific answer, I appreciate it! Unfortunately I can’t take advantage of the “Light Attachment as Group” because all of my meshes are being rendered using Instanced Static Meshes for performance reasons - so the only fix I can hope for is being able to control the point at which shadows fade out and get culled.

Anyway, thank you for your help so far - I’m hopeful that we’ll reach a good solution soon!

Exactly. All the performance concerns are valid, but I still don’t see a good reason why we can’t get a few more parameters exposed to let us handle the decision as to when culling occurs (ideally, so we can tweak this at runtime, and let users with more powerful PCs see better shadows).

Quoting Neil:

“That said, it’s sounding more and more like the “proper” fix for us would be to expose some properties from inside the engine. We need to be able to control at what ratio of the screen size shadows fade/cull. Then the performance problems are on us - and not on Epic.”

Exactly!

So please Eric + Rest of Epic,

#Address this! So We can tell world how great UE4 is for making RTS Games!

Cause as it stands Eric, you are telling us that UE4 can’t make an RTS game without a Titan GPU

which just sounds strange to me, because its just a few shadows we are talking about here.

With great respect to you Eric, but please, you can’t tell me that rendering a shadow a few 100 additional units away from camera requires a Titan GPU. The shadow is pretty vague at this distance anyway, and is smaller than ever.

I dont know what all the real performance ramifications are, but I need the power to test this stuff myself and take the performance hit if I deem it necessary, rather than basically being told I can’t make an RTS game without changing the map when player goes from 2x to 3x distance zoom.

I have placed a Feature Request to expose the Shadow Culling and Fade Distance variables as TTP # 345053.

Had the exact same problem. It was obvious to me that the distance the shadows disappear is far from what I specified in the light. After some research I found solution to several of the problems mentioned here, decided to post for others so you can save time.

Small objects shadows disappear although all the other shadows in the scene are still present. The shadows were far from 1 pixel size, they were as big as the character mesh in our game, probably depends on the light angle. The solution was

r.Shadow.RadiusThreshold

It decides how big the object bounds must be in order to render the shadow at all. Default it is set to 0.03 and I suspect there might be a bug in this check, because my objects should not be smaller than 0.03 of uu, yet setting this to 0.00001 solved this issue completely. Then I decided to tweak it a bit and using 0.01 works for my project just fine. I know it’s been mentioned, but maybe none of you tried so low values? Or maybe it has been fixed and I simply don’t know about it.

Light Radius blocked at certain distance - my game does not suffer from this, the distances are relatively small. What I noticed however was the fact, that I had to set up this range gigantic anyway, to make it work. As itif something else messed with the distance, or maybe it was not measured in uu, but that sounded too weird. I don’t know if it helps you guys, but

r.Shadow.DistanceScale

It claims that default is 1, but for my project the default was 0.2 (set by scalability, not constructor), which made sense, since 1/5th of the range I specified was about what I typed there in the first place and expected it to work. All my settings are at ‘Epic’. There are some project specific changes in regards to view distance scalability, we enforce it to 1 all the time. No idea if that changes anything, but thought I’ll post that. Hope this helps. Maybe someone will look into the variables I posted and find something wrong there, since I am not a programmer myself.

EDIT: I deleted this at first, but well, I might not be the only one that makes mistakes. We did change that long ago, took some digging, had no idea where it is located, found it and it is changed. By default it is 1.0 only on epic, so you may still want to check this.

I am also curious how’s the progress on adding those 2 more variables that have been mentioned in the TTP.

Can the bounds scale under the rendering tab just be increased? That’s what I did to keep shadows on smaller objects from popping off. From what I understand, there is a performance hit, but it didn’t seem noticeable in my game at all. Is there any other unintended consequence by doing this?

#Epic Has Fixed This, Love You Epic!

Dear Community,

I am so utterly happy to say that Epic has entirely and completely addressed the issue of shadows fading out too quickly in RTS games and large open worlds games!

Here is my thank you to Epic

#Far Shadows

The new feature, Far Shadows, lets you pick such enjoyable HUGE numbers for shadow fade out distance that I almost cried.

Here’s a picture!

PS: Eric, sorry I was so loud about this but I really needed this addressed and oh my, oh my, so good, thank youuuu!

Hi Eric, sorry to dig up this old thread but it was the only way I found to talk to you. I’m creating a Real-Scale Environment and am running on a similar issue and would like to have your input on the matter, so I can understand if it is tweakable or simply an engine limitation to improve performance.

Down below you said “I have placed a Feature Request to expose the Shadow Culling and Fade Distance variables as TTP # 345053.” - Is this corrently available to tweak, as I’m unable to find anything related to Shadows Fade Distance, and it appears to be an engine hard cap limit in which the shadows begin to fade.

Please note that I’ve tested this for Penumbra Shadows only (e.g Earth to Moon Shadow coming from the Sun) If you’re reading this, please check my post describing the problem: https://answers.unrealengine.com/questions/979346/distance-field-shadows-fade-distance.html

Thank you.