New project blog 2

In a horror game you want to give the gamer the feeling that they are in the world of the game, you have to pull the gamer in. One way to do that is by giving the game some visuals that look good and give the game the atmosphere that it needs. Problem is, the more visual effects, models and textures we use the bigger the hit on performance wil become. Here are two techniques that I use to get the visuals that I want at the performance I want.

Work in progress exterior texturing and shading.
Render what you see

You would think that it's obvious that a game only renders that what you see. You are standing in a room, only looking at some objects in the room you are in, so why would the game render objects behind me or in other rooms that I'm not in. As obvious as it may seem the game doesn't sort that out, not by itself.

A lot of games made with Unity suffer from framerate loss, especially in scenes with a lot of objects that are not necessarily in sight. Now of course, I can't be a 100% certain on the cause of the framerate losses in games developed by others, but looking at the fact that it happens in dense scenes, and even when you are not looking at all objects at once it really seems like the game is 'thinking' about all objects when it really should not.

Unity, the engine that I work with, offers a feature named Occlusion Culling that disables rendering of objects when they are obscured by other objects. In combination with Frustum Culling, a feature that disables rendering of objects that are behind the player, you have two features that greatly improve the performance of the game.

Work in progress interior lighting.
Lighting is heavy

Some games have very impressive dynamic lighting effects. You can use these lights to render dynamic shadows and that way you can have shadows move allong with moving objects. I had a concept of how I wanted the game to look and I did some some tests to look how the game would perform and what it would look like using dynamic lights.

The effects were pretty nice, all objects that are moving have a shadow moving allong with it, you can turn lights on and off on the go and animate their brightness and color. So these dynamic lights gave me some nice options to make the environmets look a bit more dynamic. But there where two big drawbacks. The first major drawback was that dynamic lights have a big hit on performance. The game has to render the effects of a light every frame and when shadows are turned on it gets even worse. Having one or two dynamic lights in a scene (or around the player, like a flashlight) works good, but lighting a whole game with dynamic lights is just not working.

The second drawback (of lights in Unity in general really, both dynamic and static) is that they emit just one color. For lights placed in something like a lamp that's fine, but you don't want the whole environment to be lit by one color. If you look at the environment around you, every object that you see receives not only sunlight or light from a lamp, but is also lit by light that bounces of from other objects. If you have a green wall with a white door in it, the door appears to be a bit green as well because of the light that bounces of the wall.

So with that information I went for a different approach. In this situation the drawbacks of dynamic lights outweigh the benefits. I did some tests with an other lighting technique called image based lighting. This is a more static light system that does not use one color, but information from an image. On top of that I still place lamps around the environment, but they are not dynamic. A feature called lightbaking bakes all the light into the environment and in combination with Marmoset's image based lighting tool you can create some sweet sceneries. The drawback of this system is that it's static, so you don't have shadows moving all over the place. The benefit of this system is that it's baked into the environment so the game doesn't have to calculate all the lights every frame and that improves the performance.

So these are two of the techniques that help me to create environments that look pretty nice and give them the atmosphere that they need but still have the project running at a very smooth framerate.