Trending
Opinion: How will Project 2025 impact game developers?
The Heritage Foundation's manifesto for the possible next administration could do great harm to many, including large portions of the game development community.
Featured Blog | This community-written post highlights the best of what the game industry has to offer. Read more like it on the Game Developer Blogs or learn how to Submit Your Own Blog Post
Marcus writes about the dynamic lighting system in their indie adventure Unforeseen Incident (in Unity).
Hello dear friends of well-lit sceneries,
today I’d like to share some insights into the dynamic lighting system of Unforeseen Incidents. In modern adventure games with high-resolution 2D graphics, lighting is an essential element when it comes to creating atmosphere and mood. First, I recommend to have a look at Oliver Franzke's great article on the dynamic lighting system used in Broken Age. Oliver describes professional techniques for ambient and local lighting as they were used in Broken Age or Monkey Island 1 SE. For Unforeseen Incidents, we’re currently working with some different approaches. At first, let’s have a look at how our game looks like with lighting turned off in comparison to how it looks when we use various kinds of lighting techniques:
As you can see, there’s a huge difference on how our main character Harvey looks like when we turn the lighting effects on. How is this done?
How does one realize ambient lighting in 2D (in Unity)? First thing that comes in mind is using “real” lights in the scene and illuminate the sprites. And (spoiler alert) this is exactly what we’re doing. BUT: The problem is that using lights is expensive. When you use real lights, the effect on the surfaces is constantly changing and with growing sceneries and more lights, you can get a lot of draw calls. That of course depends on the amount of the lights (and sprites) and on what target platforms you’re aiming for. Our stats are still good, even with all necessary lights turned on. Thing is, using real lights make the best impression of lighting on the characters.
Nevertheless, we also tried a less expensive alternative:
The character is colored (completely) in a tint that is being computed using points (color sources) in the scene. At every point between two or more color sources the color in which the character is tinted is an interpolation between the light sources. This is similar to the Broken Age ambient lighting approach, with the difference that our character is colored completely, not with a gradient.
In comparison to using “real” lights, we can save draw calls using this method. But: real lights simply look better, because the lighting appears more dynamic and adjustable. As long as our stats are good and the game runs smoothly on all target platforms, we’ll stick with the real lights.
To add some more atmosphere, we’re experimenting with a refraction effect of volumetric 2D lights we put the layer behind Harvey. As you can see a shadowy effect on what seems to be fog is created. The light currently refracts on the character's silhouette (on the sprite). This way, we create a nice, atmospheric effect that underlines the different layers in 3D space. We are careful though, because the refraction is perspectively wrong. But as long as we keep this effect very slight, it provides a great mood.
We’re currently trying to use other, (culled) sprites than the character’s silhouette to refract the light and get a more 3D-ish refraction.
Furthermore, Harvey is currently lit by 3D point lights when the he walks in front of the car’s taillights. For this cool backlighting effect we’re using a normal map on the character. That way, we can have 3D lighting effects on 2D sprites. Normal maps keep information on how the surface of a 2D object is looking so that lights can illuminate them correctly, for example from the side, as in our scene.
So, all in all we’re currently having 3D spot and point lights for ambient lighting, 2D volumetric lights for backlight refractions and 3D point lights for dynamic backlight effects in our scene. The stats are okay, though the 2D refraction calculations seem pretty expensive. We still have to test how this performs on other machines.
I hope I was able to get some interesting insights into the current development of Unforeseen Incidents and it’s lighting system. Fellow indie game developers, especially Unity and Adventure Creator users may find our techniques interesting. If you have any ideas on how to improve our system, please feel free to leave a comment! If I inspired you to improve your own lighting system, please let me know and show what you did! Oh, one more thing: If you’re interested in dynamic 2D character lighting, you might find this project interesting.
Read more about:
Featured BlogsYou May Also Like