# DirectX/10.0/Direct3D/Light Maps

Light mapping in DirectX 11 is the process of using a secondary texture or data file to create a fast look up table to create unique lighting effects that require very little processing. Because we use a secondary source as the basis for our lighting we can remove any other light calculations from our application. This can gain us incredible speed.
As we covered multitexturing in the last tutorial we only need to change that code slightly to implement light mapping in this tutorial.
With light mapping we require two textures. The first texture is the base color texture. The one we will use in this tutorial is the following:
The second texture we need is the light map. Usually this is just a black and white texture with white representing the intensity of the light at each pixel. I created a spotlight style light map that we will use in this tutorial:
Once we have our color texture and our light map we can combine them in the pixel shader to produce the light mapped texture. The shader is very simple as we just multiply the two pixels together which will produce the following output:

## Lightmap.vs

The light map vertex shader is the same as the multitexture vertex shader from the previous tutorial.
The only thing that has changed is the name.

## Lightmap.ps

The light map pixel shader is very simple. It multiplies the color texture pixel and the light map texture value to get the desired output. This is not much different from just a regular multitexture blend other than there is no need to correct for gamma.

## Lightmapshaderclass.h

The LightMapShaderClass is just the MultiTextureShaderClass from the previous that has now been updated for light mapping.

## Lightmapshaderclass.cpp

I will just go over the changes since the previous tutorial. Other than the name of the functions there are only a couple changes.
We now load in the lightmap.vs and lightmap.ps HLSL shader files.
The light map vertex shader is loaded here.
The light map pixel shader is loaded here.
The texture array is set the same as the previous tutorial. However instead of two color textures there is now just one color texture and the second texture in the array is a light map.

## Graphicsclass.h

The header for the LightMapShaderClass is now included in the GraphicsClass header file.
We have a new variable for the LightMapShaderClass object.

## Graphicsclass.cpp

I will just cover the functions that have changed since the previous tutorial.
The new LightMapShaderClass object is initialized in the class constructor.
The ModelClass object takes as input the new light01.dds light map texture for the light map shading on this model.
The new LightMapShaderClass object is created and initialized here.
The LightMapShaderClass object is released here in the Shutdown function.
The model is rendered here using the light map shader.

## Summary

This tutorial isn't much different than the previous blending tutorial but produces a very useful effect that can be very efficient in terms of processing speed.

## To Do Exercises

1. Recompile the code and ensure you get a light mapped texture on the screen.
2. Create some of your own light maps and try them out.
3. Multiply the final output pixel in the pixel shader by 2.0. Notice you can create stronger and softer lighting effects by doing this.