13 May2010

Download the PDF Version of this tutorial here

Assets needed for this tutorial

Getting Started

In the download you will find two folders, a package and a scene. Inside the scene there is the start and end file to this tutorial.

Let’s get started. Launch the UDK and opening up the “LightMapping_Start.udk” located inside your scene folder. This is a very simple scene consisting of a subtracted cube and a single spotlight as shown in Figure 1 below.

Figure 1

Setting up the Scene

Go ahead and open up the content browser and load the “LightMapping.upk” package located in the package folder. Figure 2. Inside you will find two static meshes, a cube named ‘base’ which we will be using for the floor where our shadows are going to be projecting, and a circular tube shaped mesh named ‘tube’ which will be the mesh casting the shadows.

Figure 2

Select that base mesh and drag it over to your scene as shown in Figure 3.

Figure 3

Next we’re going to drag the tube into the scene. Make sure that you leave a reasonable amount of space between the meshes so that you can get a pretty clear shadow. See Figure 4.

Figure 4

Testing Out Our Lighting:

Let’s go ahead and test the lighting and see what we get. Make sure to turn off Lightmass. This will greatly reduce your build time and at this point we don’t really need that. Use the settings in Figure 5.

Figure 5

You should get something similar to Figure 6. The shadows just seem to soften up and be very subtle. But why are there no shadows on our base mesh? That’s what we’re going to explore.

Figure 6

Setting up the UVs

Every single static mesh that is imported into Unreal has its own unique UV set that is set up and used to apply textures. To get the desired effect that we’re looking for we’re going to have to make a brand new UV set that will be used to save the shadows of your Lightmap, currently we only have one (see Figure 7).

Figure 7

To create this new UV set we’re going to go to Mesh > Generate Unique UVs…

Figure 8

This will open a small submenu for UV generation. Since these are going to only be used for shadow there is no need any more to take the extra time in Max or Maya to create a new UV channel for all your meshes.

Unreal reads UV channels starting from ‘0’ so your first UV channel will be ‘0’. The one that we’re creating has to be on its own so in the field “UV channel to save results to” make sure it’s set to ‘1’

In the “Limit maximum stretching (0-1)” leave that at the “0.500000” default. That seems to work great for me and I really never found much of a reason to change it.

When you have the entire settings ready hit “Apply” see Figure 9 for all the settings.

Figure 9

Let’s look at our results. You can see that Unreal has created a 2nd UV set (Figure 10) for us to use for our shadow. Now we have to let Unreal know that we are going to be using this new UV set for Light Mapping.

To do this go to the field titled ‘Light Map Coordinate Index’ and set that to ‘1’ as you are letting unreal know that you will be using that channel. (Figure 10 on the right)

Now we have to set up the resolution for these light maps. For that go to the Field titled ‘Light Map resolution’ and lets go ahead and set that to 512 (Figure 10 on the right). That should give us pretty good looking shadows.

Figure 10

Designating What Mesh Receives Light Maps

Now that we set up our mesh for light mapping there’s just one thing left to do and that is to let the engine know which of the meshes are going to be able to receive light maps based on the setting that we gave them.

The reason for this set is simply to elevate the engine of unnecessary processing and calculation and also save on build time. You can have 50 of the same Meshes in a scene but only want 10 to have very detailed shadows. You would designate them to receive shadows based on your set up and rest will be calculated on Unreal’s default shadow system.

Designating light maps is very simple. Right click on your object and bring up its properties (Shortcut F4) and scroll to where it says ‘StaticMeshActor.’ Click on it to open it’s properties then scroll to where it says ‘StaticMeshComponent’ and click that to open It’s properties.

Here you will find a few properties but we’re only going to be adjusting two of them. First we want to make sure that Override Light Maps is checked and finally, just like when we were setting up the mesh, in the Overridden Light Map field lets set that to 512. (Figure 11)

Figure 11

Results

Now just as before hit the Build Light button and use the same settings that we set up before. Remember to uncheck Lightmass to save on build time for this demonstration.

Your final image should look something like Figure 12 below

Figure 12

I hope this demonstration was helpful if you have any questions feel free to email me or check out site or artist blog all listed below.

Website http://Jarlanperez.com
Email: Jarlanperez@hotmail.com
Artist Blog http://jarlanperez.com/?cat=10

If you enjoyed this post, make sure you subscribe to my RSS feed!

Post discussion

Leave a comment

Socialize with me
Looking for something?

Have a look around.