I’m quite proud of Escape From Epstein Island’s lighting solution. When entities are at some distance from the lights, the shadowing looks gorgeous. Unfortunately, the mathematical abstraction of modeling actors as infinitesimally small points does not work when they’re almost directly overtop the light. It breaks the shadows in a very distracting and noticeable way.

I theorized about a few creative solutions to avoid the problem that were more design than programming. I had to either prevent the actors getting near enough to break the lighting, or figure out an excuse to turn the lights off when the actors are close. For example, turning the lights into a pillar with a candle at the top, thus ensuring distance, or the light is an orb of magical energy that damages actors within a very short range, but then temporarily powers down. 

Those certainly avoid the issue. However, those solutions have downsides. The pillar idea means that every place that emits light now also needs to be included in pathfinding, and probably blocks projectiles, which means that I can’t just place lights for lighting sake, I need to factor in the knock on gameplay effect. Likewise, even if the lights don’t damage the enemy, but can be turned off, the lighting can suddenly look really poor if a number of actors happen upon lights at the same time, which sacrifices consistency.

I do love creative design solutions to technical problems, but sometimes the best solution is technical. I didn’t want the stress of figuring out a partially diffuse shadowing system, but figured something a touch hacky shouldn’t be too difficult.

My original idea was to change the diminish the size and intensity of the light when an actor is within a very short range, as this simulates an actor blocking most of the light with their body. Above we see an early example of the effect. I coupled that by going into the shader code and allowing the strength of the shadows cast by actors to drop to zero, depending on the proximity of any individual actor. That, in combination with largely keeping the intensity of light, just dropping the size, gave me the result I desired. 

While the above does still look a touch artificial, once we add multiple overlapping lights any issues go away. In practice the effect is quite subtle, but you have to remember that this is largely about correcting a nasty artifact of the previous system, so subtle is good.

In comparison, here’s the old system, which looks quite artificial.

There are many improvements I could add to the lighting system. Proper diffusion, cumulative partial shadows, and I will eventually have to come up with an in-game design justification for the lights. Those additions are a low priority right now, considering how nice it looks. 

You may also like

Leave a reply

Your email address will not be published. Required fields are marked *

More in GDev