Light bleeding with static mesh and BSPs

Hi,

being new to Unreal Engine 4 I built a building using only BSPs Boxes (Walls, floors, ceilings, doors, windows). My goal is to do this with some other buildings as well and then convert them into a single static mesh to be able to place them in one piece.

However, I am experiencing light bleeding at edges between two boxes, for example wall and floor and even across the whole ceiling. I tried some solutions from other questions, such as messing with shadow bias and shadow filter sharpen, but nothing really seemed to work out well. I converted the bsp boxes to one single static mesh, which has the exact same bleeding.
25371-
Anything else I could try?

Hi AdipFTW,

I do have a couple of things you can try and information you can provide that would help me offer some other solutions as well.

  • Is your light source set to Static, Stationary, or Movable?
  • Is this a static mesh or a BSP, because you indicated that it was converted, but I’d like to be sure?

If this is a static mesh, you may just need to up the lightmap resolution, which is defaulted to 64. Since this is a larger meshes it will need to be higher since the UVs are using more space in the lightmap texture.

If this is still a BSP, select all the box brushes (excluding the subtractive brushes) and go to the details panel and set the lightmap resolution to 16, 12, 8, or 4. BSP’s work in reverse of what static meshes do for their lightmap. A lower resolution will give you better shadows with this. Try 16 and work your way down until you find a resolution that works for you.

Something else to try is to build lighting on Production mode vs the default Preview mode. The lighting and shadow quality is much higher here. Often using production will block light bleed that happens in lower levels.

Give this a try and let me know.

Tim

Hi Tim,

thank you for suggestions! Concerning your questions:

  • I have only one light, which is set to movable, as the goal is a day/night cycle.
  • I modeled the building using BSPs first, then selected all of them and converted them into a single static mesh (is that the right way to do it?) to see, if differences occur.

On the static mesh I set Overriden Light Map Res (correct one?) to 1024 from 64. It resulted in no difference after rebuilding lighting, whether in preview or production quality.

Reducing the Lightmap Resolution Down to 4 with your suggested steps also results in no difference…

Best Regards
Julius

Ah, Well since you’re using a movable (dynamic) light there is no need for lightmaps. Those are specifically for lights being build with Static or Stationary. This will bake all the shadows from the scene into lightmaps associated with each mesh. Dynamic lighting doesn’t do this.

To affect the light bleed you’ll want to adjust the shadow bias and the shadow filter. It will never be perfect though and at further distances it the crisper shadows will fade bringing some of the light bleed back. This is not a “bug” but a limitation of using dynamic lighting with cascaded shadow maps. The value of performance verses what looks good is a tricky trade off to have. It’s going to be about finding a balance between using Dynamic Shadow distance (Values lower than 20000, which is the max, tend to work better), shadow bias (lower values, but not bottomed out because you’ll get cascade line artifacts), and shadow filter sharpness (default is 3, but using 2 can get you softer shadows at the low of sharpness).

Also take a look at the documentation for Ray Traced Distance Field Soft Shadows. This is still somewhat experimental and has some limitations but the dynamic shadow quality is must better with it. In the future it may take the place of cascaded shadow maps but that has yet to be determined.

I hope this helps. :slight_smile:

Tim

Hi Tim,
thanks again for helping me out, things start to look better. :slight_smile:
After messing around with some settings I achieved this:

http://puu.sh/e1KCd/37a6081f58.jpg

However, as you can see, there still is small light bleeding at the corners of the pillars, which I cant remove unless i bottom the shadow bias, but this of course is not an option. Furthermore I somehow added this waveform to the shadows, it appears to be related to the ‘Dynamic Shadow Distance MovableLight’ option on my lightsource, where a bigger number results in bigger waves, smaller numbers in smaller waves, but also lower visibility distance:

http://puu.sh/e1LRH/e4d728b5a2.jpg

http://puu.sh/e1LW1/ff2e90115d.jpg

Any way to refine those shadows further?

For the best result and to not use Dyanmic shadow distance maps is to turn that down to 0 and leave the Ray Traced Distance Field shadows at 30000. Turn the dynamic distance to 0 will eliminate these types of results from cascaded shadows.

The only other option would be to tweak settings between the dynamic shadow distance, sharpen and shadow bias until you get a result that fits your needs.

Thanks!

Tim

But if I set Dynamic Shadow Distance MovableLight to 0 all shadows disappear…

Does that mean I’m stuck with the other option?

EDIT:
The shadows DO appear with static meshes, they just disappeared in my first BSP-only building. However I got some really bad artifacts…

http://puu.sh/e9vaF/375415a9e2.jpg

Actually that’s right. Sorry, I had forgotten that BSP does not support Distance Field Soft Shadows. I don’t often use BSP so it had slipped my mind. :confused:

If you’re going to use Distance Field Soft Shadows and Cascaded Dynamic Shadows you’ll need to find a balance by adjusting the distance for the dynamic shadows. It won’t be perfect due to its limitations though.

For static meshes, distance fields do require some tweaking.

You can go to the show button in the viewport > Visualize > Mesh Distance Fields.

This will change the buffer view and show how the shadows are made based on distance fields. If you look at your mesh and see holes or things that look odd (If you want post a screen shot and I can help diagnose) you’ll need to adjust the resolution of them.

To do this open the mesh in the mesh editor > in the details panel on the right > LOD0 > go to Build Settings > Distance Field Resolution. The default is set to 1.0. Try changing this to 2 or 3. You can go higher but it may not be necessary unless there are still issues.

This is still an experimental feature of sorts so there are known issues, but for most uses it works well and is being actively used in Epics latest game in development, Fortnite.

Let me know! :slight_smile:

Tim

We’re getting closer, step by step. :slight_smile:
Increasing the Distance Field Resolution to 2 got rid of those artifacts on the wall. However, there still remains ‘shadow bleed’ as seen on the following picture:

http://puu.sh/ebEq5/84de7a1f06.jpg

While increasing the Distance Field Resolution to 2 brought better results, there are no noticeable differences between a value of 2 and 100.

I dont really understand, what I see, if I visualize those Mesh Distance Fields, it simply looks my mesh, but with rounder egdes. It got closer to the original, when I increased the Distance Field Resolution to 2, but what do I see here? In the following, you see the fields with a resolution of 1, 2 and 100 in order:

http://puu.sh/ebEnP/1ce447b943.jpg

http://puu.sh/ebElV/421d0a125a.jpg

http://puu.sh/ebEr1/65fa704aa3.jpg

Take a look at this video: - YouTube

Daniel Wright (Senior Rendering programmer behind DFS) talks about DFS and the “how” and “why” of it all. This DFS view is a way to see the representation of the meshes that will cast the shadows.

Can you post a picture of your dynamic light setup as well. It looks like you’re still using dynamic shadow distance under the Cascaded shadow maps tab in the details panel. If so, that would create that type of bleed.

When you post the screen shot from the details panel, in the top right of that panel is an eye. Click that and set it to “Show Modified only.” That way I know exactly what settings are being used.

Lighting can be tricky to setup in any game engine when you’re new to it. No matter if it’s dynamic or static. There is not always a 1 or 2 click process to get everything perfect. Thanks for your patience. :slight_smile:

Tim

Here are the ‘modified-only’ settings of my light source:

http://puu.sh/efcVJ/843d240e49.png

Thanks for that video, it was very informative!! If I understood it correctly Distance Field Ambient Occlusion is a form of GI? Would be good to know, since I will probably try to get that in there as well at a later point.

Ambient Occlusion detects the proximity distance between objects and removes light where GI would inject light into a scene.

You can see the Distant Field GI work being done here. As Daniel notes, this is still early on.

If you want AO, add a skylight and set it to movable.

To the original matter with the edge issue at that corner. I was able to reproduce that as well, but only with BSP converted to a static mesh.

I was able to clear it up by increasing the distance field on my end.

The best result I got though was making the same shaped mesh in my modeling program (3Ds Max). The way that BSP converts to static mesh can leave odd cuts for the polygons vs being able to determine those cuts myself in a modeling program.

As Daniel mentioned in the video as well, it’s better to have more uniform kinds of models when doing this. You’ll get better results.

Here are the results I had with a BSP converted to Static Mesh:

This was just a single wall with a hold cut out that was converted.

Distance Field Resolution: 1

Distance Field Resolution: 75

Next this is one I created in 3Ds max:

Distance Field Resolution: 1

Distance Field Resolution: 6

As you can see it’s much better to use a custom made static mesh. It probably helps to that my static mesh made outside of the editor was more uniform as well.

This system still has some improvements coming as it’s being developed that should help with some of these things.

Tim

It indeed seems better to create the mesh in another programm like 3ds Max. Do you know of a way to export my mesh from UE4 to 3ds Max, so i can adjust the ploygon cuts there and then reimport it into UE4? This would save me a lot of time, since I have already made several meshes…

Yeah, You can right click on the static mesh in the Content Browser > Asset Actions > Export

My workflow if I’ve created something in the level and want to edit it to use BSP as my block out/prototype and then export and rebuild in Max. It’s a definite way for me to keep proportions if I don’t have specifics in mind from the get-go.

Tim

Nice! When I import the static mesh to 3ds Max, it looks like this:

http://puu.sh/ehzQD/50f6c169f3.png

Now what is my goal? You said something about odd cuts, so aalll those triangles should be rectangles instead?

I hate to say, but it may be a little bit of work to get something like that done. Typically things that complex will be built in a modeling program from the start.

Going back to the Distance Fields though, using smaller pieces and breaking the building up into more modular pieces would result in better shadows. This would explain why you turned it to 100 for the DFS resolution and didn’t see any significant change.

But, here is my before and after:

][1]

As seen on your ‘before’ piece, my faces consist of triangles as well. I have removed the middle edges to make them rectangles again, for now just around that paticular corner to see, if it works:

http://puu.sh/ehSU3/15d1e223f7.png

However, still the same bleed :frowning:

http://puu.sh/ehSLz/e6f6117f09.jpg

Edit: this is with a resolution of 10.