The biggest inspiration for Trollskog, at least where the visual style is concerned, is the work of swedish artist John Bauer, whose work has informed much of the popular conception of swedish folklore.

The past few weeks, I’ve been thinking about the mood of John Bauers works, and the technology needed to try and convey it in the medium of a game.
A common element in his paintings is darkness. Whether set in a cave or a deep forest at twilight, the tales depicted are filled with mystery and wonder, and this feeling simply isn’t communicated effectively in bright, sunlit environments.

As counterintuitive as it sounds, to depict a scene at night convincingly requires more lighting than depicting the same scene during daytime. This is because there’s only one light source that matters during the day: the sun. You might think that transforming day to night is as simple as dimming the lights, but there are a lot of light sources that make themselves known when they’re no longer being drowned out by the sun. Especially in the work of John Bauer, there are many light sources of varying subtlety; important characters and objects light up the environment and create a feeling of magic.

The graphics engine of Trollskog was not equipped to deal with multiple light sources - a traditional “forward renderer”, every new light added to the scene increased the complexity: the scene needed to be redrawn for every light source, which quickly led to performance issues when rendering detailed environments. Fortunately, the technology to achieve high performance with many light sources has been around for a while, in the form of a “deferred renderer”.

There are a lot of online resources that describe this rendering technique, so I won’t dwell on the implementation details here. But here are three pictures that show the core concept: the geometry buffer:

Above: The screen-space normals - Here, we have normals for every visible surface. That is, the X, Y and Z component of the vector that points away from the surface, encoded as R, G, B colors.

Above: The albedo map - Simply, the color (or albedo) of each visible surface, as yet unaffected by lighting.

Above: The lighting map - Using the above two images, and the depth buffer, we can generate the light map independent of scene complexity.

And the final result - the combination of the above.

Finally, you can see the dynamic lighting effects in motion here: