maandag 14 mei 2012

Lightmaps - Part 2

A light setup can make or brake a game environment. When done right a mediocre modeled environment can look great, but when done bad a great modeled environment can look ugly as hell. A real-time light setup can be very processor heavy which is something we don't want for our games. That's why we use a technique which pre-bakes the scenes lighting. This technique is called lightmapping. A while back I've already written a post about this, but there are a few more things I like to share with you.

In short a lightmap is a separate image which contains the shadow information of a 3D scene. In-game this image is multiplied on top of the environment's diffuse material (texture) to "simulate" the shadows. Here at Xform we create lightmaps by rendering two different light setups which are combined in Photoshop. After placing all our lights in 3D Studio max we first render the scene's "hard" shadows to an image using Ray-Tracing. As you can see in the image below the shadows are hard and the scene has a "clean" look.

We want to add some extra shadows to get rid of this clean look. We can do this by rendering the scene with a "skylight". A skylight simulates scattered atmosphere light. I won't go into detail about this, but the result can be seen below.

The shadows in this render are much softer, the inner corners are darker because the light can't completely reach them. To see the end result we combine the images into Photoshop.
When you look at this combined image you should notice the outside of the hangar looks good, but the inside is much too dark. This is the result of the skylight we've used.

The main drawback of a skylight is that the light can't reach the inside areas of a scene. Therefore these areas will be rendered completely black. This is something we don't want for our scene so instead of the skylight we'll render the scene with an Ambient Occlusion material, which only renders "shadows" in the scene's inner corners. It's actually faking the skylight.

Combining this texture with the ray-traced texture gives a much better result. Here both inside and outside of the hangar are looking good.

Now the scenes lightmap has been rendered and combined in Photoshop and it only needs to be color corrected to fit the final in-game scene. Here we've given the texture an orange tint which results in orange shadows in the final scene.

To finish this story check out the image below for the final result:


1 opmerking: