Download

Resolving light bleeding for a movable, rotating, directional light

Dynamic lighting is a pain.

Or, in more detail: my current setup is having a day/night cycle with a rotating directional light, which is fully movable with dynamic lighting and shadowing, casting onto an environment of both interior (through windows) and exterior (viewed out of said windows).

I can get the shadows looking right at one time of day or another, but making them work through the whole cycle is proving next to impossible. If it looks good up close, it looks horrible 20 feet away. If it looks good 10 feet away, it looks horrible 40 feet away. If by some miracle it looks good at all distances, it looks horrible after the sun as moved ~10 degrees. I’ve played with all of the cascade settings, the shadow bias, everything that possibly relates to shadows. On top of that, there’s the issue of the cascade transitions. Hard as I try, I can’t get the transitions looking okay, with various exponent values.

The walls here are all 20 cm thick, for reference.

Examples, at various times of day, with various settings, showing what has been my life for the past few hours:




Assistance is requested.

Hey NovaSilisko,

Request denied…Just Kidding! I’m glad to help. :slight_smile:

With any light leaking in Dynamic lighting you’ll want to adjust the shadow bias and filter sharpen. These two will help block some of that light leaking you are seeing within reason. If you’re player character is never going outside of this building you can use other objects to block the light as well.

Also, be sure to take a look at our newly created Wiki lighting troubleshooting guide as this will be covered with the two topics in dynamic lighting area right now: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

Check back often as Eric and I are constantly updating it.

Let me know if this works for you.

Tim

Yeah, I was trying different values of bias and sharpen as well. The problem is, to get the bleeding to stop requires the bias to be set to a value low enough that you get lots of that nasty “striping” effect when the sun is low in the sky. And the sharpen setting makes the shadows from the window frames start looking a bit weird: http://i.imgur.com/cugq4Wp.png (and still there’s noticeable bleeding as well)

The player will be able to walk outside a little bit - just around an area adjacent to the building, but enough to see 3 of the 4 sides to it, and the vast majority of the surrounding scenery: http://i.imgur.com/GqSU10d.png

Also have been looking through the troubleshooting guide, it’s just still a problem of getting it to look good at most times of day…

I’ve only been testing it with a range of about 150 meters (15000 units), which seems to be a decent compromise for getting the lighting within the range of tolerability. Though, having shadows on the distant mountains would be nice too.

Edit: Another thing I’m having trouble figuring out is how to ease the honestly rather jarring difference between near and far shadows: https://i.imgur.com/qe5EIO0.png

There are alternatives to Cascaded shadow maps with dynamic lighting, like Distance Field soft shadows. This requires more modular level design and can work in most cases. There are limitations with it, just like the standard cascaded shadow maps.

The results you’re seeing are true of any game using dynamic shadows and far distances. I always use this as an example, but GTA V is a great example to see what other Tripple A games are doing with their engines. If you have played the game and look at any shadow detail you’ll notice it’s very similar if not a little worse for wear than what is offered in UE4. There is an option in either 4.7 or 4.8 (honestly can’t remember which) that I saw the other day for “Far Cascaded Shadows”, but I’ve yet to try the feature and test out what’s possible.

Epic is committed to making the development of large open worlds a reality for others. The engine is still heavily in development and new awesome feature are being added all the time. :slight_smile:

There are some other tricks that may help with your light leaking. I’ll see if I can find time tomorrow and setup a very simple example. I’ll need to test a couple of things because I can’t remember if it actually worked or not. I hesitate to suggest without having the editor open to test in front of me. I’ll post some screenshots when I get it setup and let you know with some examples.

Thanks. Hopefully something can be figured out here. The most important stuff for now is the shadows within the building, but I’m interested to see what the upcoming far cascades do.

I’ll look into the distance field shadows, as well. I remember giving them a glance but thought I read something about them only working properly with static lights, but maybe I read it wrong. I hope someday it can be made into something that works fully dynamically with procedural geometry, as that would be incredibly helpful for other things that need lighting here…

I’ll look at the far cascaded shadows tomorrow when I’m setting up something and see. There’s some cool new features coming that are already available in the Master Branch available on GitHub. This is a unstable build though since it’s all the latest code changes. Most new features I don’t typically give a full go until they’ve been released with the Binary build from the launcher though.

Distance Field shadows are a fully dynamic system. No static lighting required to use them. It generates a volume around the mesh that can have a set quality level for the volume to generate the shadow. This also works in conjunction with Distance Field AO. I’m a big fan of Daniel’s work with the distance field implementation! Again, there are some limitations, but I’ll post about those tomorrow as well with some samples with distance fields as well using the architecture wall assets from the Starter Content compared to Cascaded Shadow Maps.

I’ve not tried anything procedural with having meshes spawn with Distance Fields. I know that the DF has to be generated but not sure if during the spawning point it has to generate the DF before the shadow appears. DF representations can take a moment to compile, much like a shader, when being placed in the world. I’ll try this as well and see what I get. :wink:

I’ve taken a little bit of time and setup a simple scene.

By adjusting some of the settings available in the light under the tab for “Cascaded Shadow Maps” you can get more accuracy by adjusting some of these settings without the need to use Shadow Bias or Filter sharpen. Adjusting the shadow bias or filter sharpen can help in addition in some cases.

These are the settings:

8eda9d316e58f65e24ad63557e21f43c63f34f7d.png

The only option not available yet is the Far Cascaded Shadow distance options at the bottom.

You can play around with the settings for Num Dynamic Shadow Cascades, Distribution Exponent, and Transition Fraction to get better results. I had not really messed with these settings previously and will need to update the lighting guide I linked earlier after I mess around with this a bit more. These options were never really suggested when I used cascaded shadows before. Since this is adjusting your cascades it will limit things in other areas to get better results in another. There is trade off anyway you look at it.

Distance Fields don’t have as many options to tweak and can provide some good results pending you stay within it’s limitations. No significant non-uniform scaling of meshes, Doesn’t work with BSP, works well with modular meshes that are no overly large.

Here are my results before adjusting the settings for the cascades. This does not adjust the shadow bias or the filter sharpen.

After adjustment:

For the far shadows option in the first image. I couldn’t get this work. This may be the build I’m on. Not sure. I’ll have to take a look at this a little more as it develops.

I hope this has helped.

Bah. It’ll have to wait a while then as the scene is mostly BSP at this time.

Anyway, I’ll try the settings you’ve given and report how they work.

Edit: Well, it’s better than it was, but there’s unfortunately still some rather noticeable leakage:


This is with 0.4 bias and 0.05 sharpening, decreasing the bias any more yields very noticeable striping when the sun’s low in the sky as mentioned before…

Edit 2: and the editor crashed as I was playing with the settings leaving no particular error message :frowning:

You can always convert the BSP to Static Mesh as well. :wink:

Yeah, eventually I will, so I guess that’s when I’ll look into the distance fields.

Luckily, the other areas will be completely mesh-based so distance fields, assuming they can be made to work with procedural geometry, should be perfect.

There are a few concerns there though… the space scene has to co-exist on the same level with the headquarters scene, but unreal doesn’t have an object layering system so one will need to be constructed to set that up. I worry about how that will work with lighting, as it’s kind of a deep change to make. Or, maybe by some chance something like that is being worked on already and I don’t have to worry? I imagine you might know :stuck_out_tongue:

Just tested DF with spawning a mesh in. It works. I figured it would, but couldn’t say for sure last night since I’d not really done it. So I don’t think you’ll have any worries there.

As for Object Layering, are you talking about placing objects on a layer and being able to only control or adjust things for that layer? I’m a little confused by this. If you can explain further with maybe a clearer example I can help.

If it’s just a matter of separating objects for better control I’d suggest taking a look at levels. Have a base map for your persistent level that holds all your other sub-levels that occupy the space. Epic uses this in a lot of the projects that are available via the marketplace. These sub-levels will often be setup for a level specifically for VFX or Lights and so on.

That’s great to hear about the distance field shadowing. What sort of ranges would that work over? In the case here it will need to function over distances of at least around… let’s say 10 kilometers.

What I mean by layering is, for this game, the need of two co-existing “scenes”, occupying the same space at the same time in game, but not interacting with each other, or rendering together. A camera in one won’t render anything in the other, a light in one won’t light anything in the other, and so on. Unity (I know, that’s probably a dirty word around here) has a good example of what I mean. You can tell a camera to only render certain layers, physics objects to collide only with certain layers, etc. Maybe this is the wrong area of the forum to ask about that…

An addendum: how well do distance field shadows function with large point lights? And, for that matter, moving point lights?

Distance field shadows also suffers from light bleed even at resolution scale of 10.0

This depends on your mesh complexity, the size of the mesh, and the what the resulting DF resolution looks like in Show > Visualize > Mesh Distance Fields.

Check the Troubleshooting and Quality section for more details here: Distance Field Ambient Occlusion | Unreal Engine Documentation

If you’re still having trouble, feel free to post pictures of this view mode so that we can better help see what the problem you’re having is.

Thank you!

Tim