Hardware implementation of Deep Shadow Maps
Project Description:
We are doing an implementation of the deep shadow map algorithm proposed by Lokovic and Veach in SIGGRAPH 2000 . For this implementation we are using a setting of a ‘hair’ mesh projecting shadows over a wall and floor.
To implement shadow maps, we followed the following steps:
a. Developed the basic DirectX scene that loads the meshes and displays the spot light
b. Setup the framework to incorporate shader files (.fx)
c. The shader file consisted of the following methods: Vertshadow, Pixshadow, Vertscene and Pixscene. The algorithm was as follows:
• Vertshadow and Pixshadow are the vertex and pixel shaders to generate the shadow map. Vertshadow simply transforms the set of vertices to the lightview, and Pixshadow simply stores the depth (instead of the color) of the vertices from the Vertex Shader.
• Vertscene and Pixscene are used for the next ‘pass’. Vertscene transforms the vertices for the camera’s point of view. Also, additionally, it generates the “look up” co-ordinates.
• Pixscene is where the algorithm for the shadow map is implemented. Here, the lookup is performed and the z value of the pixel is compared with the texture “looked up” value. If it is lesser, the pixel is occluded, else it is not and its value needs to be calculated using diffuse lighting.
Step 2] Deep Shadow Maps
Once the shadow maps got to work, we worked on extending them to deep shadow maps
The approach used was as follows:
a. Deep Shadow Maps, unlike Shadow Maps don’t store one “z” value in the shadow map. It instead stores a function of z value, which is the visibility of the pixel at different values of z.
b. Mapping a continuous function in hardware for each pixel is not possible. Hence, we needed to use a discrete representation of the same function.
c. For this purpose, we intended to sample the z values at each pixel 16 times.
d. In Pixel Shader 2.0, a maximum of a 32 bit value can be associated with each pixel. This means that, if we want to use a 32-bit representation of the z-value, we will need as many shadow maps as the number of samples of z we want to sample.
e. However, in Pixel Shader 3.0, a 32 bit ARGB value can be associated with each pixel. Which means that now, we can have 4 separate 32 bit values for each pixel using only one texture. Thus, to implement 16 samples, we would need 4 shadow maps.
f. Given the hardware limitation, we had two approaches. One was to use 4 textures each of a 32-bit value, or 4 textures and use each of the 8 bit values in each texture as a z value (hence getting a total of 16 samples).
g. The code uses the first approach, ie only 4 samples for the z values at each pixel. Hopefully, would be able to extend it to the other approach.
h. To choose the z samples, instead of using uniform samples between z near and z far, we choose to have the samples around the “hair” mesh. To do that, we computed the bounding volume of the hair mesh. The first sample would be at the end closest to the light, the 3rd at the end of the bounding volume farthest from the light, and the last one would be the z-far plane.
i. Thus, to implement the above, we used an array of textures in the DirectxX code file. The shader file was also modified to have 4 different samplers for the shadow now.
j. The pixel shader that computes the final pixel values, first checks the incoming z value of the pixel. Given that, it compares that z value with the samples of the z values taken during the build of the shadow map. After it finds out that range, it uses that particular shadow map to compute the shadow. On addition, if we have instructions left for our pixel shader after we compute 16 samples, we can linearly interpolate between the z values for partial visibility. However, we don’t expect improvement in quality as those 16 samples would have a much lower 8 bit precision.
Results:
We were able to get shadow maps correctly. However, we werent able to get very accurate deep shadow maps, mainly I think because we used too few samples.

Contact
Venkat Krishnaraj
venkat.krishnaraj@gmail.com
Masters,
Computer Science
Cornell University