How to block sunlight from beneath landscape in Open Worlds (and speed up build times)

So this seems to be a pretty common issue as I read around online. People set up a day/night cycle, then the sun reflects from underground off their foliage, and I’ve seen a lot of complex discussions about how to fix it.

I’ll share how I fixed it (and cut my build times down by about 1/6th in the process.) Turning on two-sided shadows was not enough, as anything intersecting the landscape by a centimeter too much would have a bright seem if it had a smooth normal map (grass, BSP blocks, etc.) But I found a manner just as simple:

I put a stock plane at the center of my world in game. Moved it down to below the landscape. Scaled it up to 20,000 on X and Y. Flipped the normal (Lighting -> Reverse Culling in Details Panel.)

Done. Blocks light from below the landscape, and due to the inverted normals, is also invisible in the event a player somehow gets under there to look down at the sun below the earth in the middle of the night. I no longer have bright seams or reflected lights on my foliage.

Additionally, it serves as a sort of simplified photon blocker for 1/6th of my scene, which has effectively sped up my build times by not calculating the complex angles of the underside of my landscape anymore as photons are caught before ever reaching it.

And lastly, if you need to make underground networks, just lower the plane further, then add 4 more as “walls” around the edge, to block the sun from creeping in the seams where parts of the landscape may be higher, just align them with your ocean floor.

Seeing as this was apparently a big problem for a lot of people and the discussions were evolving into building a rocket to fly to Mars in search of a solution, figured it was worth making a searchable post for others of a much simpler way to fix it.

You should be using a box with 1m or more depth rather then a plane, because of light leaking. But yes, short of completely turning off the light after it goes past the horizon a light blocking volume is a decent solution.

I’ll swap that then, thanks. What is “light leaking” btw? I mean, I get the general idea. But is there a technical reason for why it happens?

In a baked environment yes, when/if the light source hits the edge the light will leak out from that corner and paint the object.

And/or if you have perfectly aligned meshes making up a box, but they are just single planes with no depth, the light will shade the corners because it “leaks” in.
Adding a bit of depth (10cm is common for a regular wall), solves the leak (and allows you to be more lax on snapping objects).

How does that any to a dynamic day cycle? Not sure, but I recall that using a plane wasn’t cutting it. A box did.

I ended up adding the bp logic to turn off the light when it dips below the horizon.

1 Like

The problem is if anything relies on that light level, such as emissions from the SkySphere clouds, you would have to rework it to have a second event tracking the value you just killed.

In my case, many AI have bio-luminescent shading which scales inversely to the current sunlight intensity during day or night as my weather systems also affect skylight intensity. And so I’d either have to create individual events per creature (performance hit) or create a function that clones the current intensity level of the sun when the sun is disabled. I also have a weather system with ties into all of that, and any changes to the sun would require turning 1 blueprint into 3+, each of which would be ticking 10 times per second. A single global system at 10 ticks per second sending out events at thresholds has been performance friendly, all other options seem too convoluted, prone to instability, and more performance intensive.

So in my case, having so many things dependent on current dynamic directional light intensity, it was best to just block the light without changing how it works. And if I made a system that works that way, I’m sure others will as well. So I felt like sharing the solution worked well.

Additionally, my blocking volume is used as a respawn trigger for anything which may glitch below the map, so it serves a double function. That was added several days after this initial post. But it was a happy accident to solve two problems with 5 cubes.