Soft Shadow Mapping using Percentage Closer Filter

Final Project
Advanced Computer Graphic I
Chunk Hansen
Fall 2005
Text Box: Linh Ha, PhD Graduate student 
School of Computing
University of Utah
lha@cs.utah.edu
 
Text Box: Linh Ha, PhD Graduate student 
School of Computing
University of Utah
lha@cs.utah.edu
 

1. Introduction

     Hard shadows destroy the realism of a scene.  Soft shadows give a better clue about relation ship between objects in scene than hard shadows, the shadows become shaper when objects contact with others and softer when they goes away.  Hence, we need soft shadows in order to improve the visual quality of the scene. In my final project I try to implement the Percentage Closer Soft Shadow method (PCSS)  that combine hardware shadow mapping with adaptive percentage closer filter to archive a perceptually  accurate soft  shadow. That method was proposed by Randima Fernando from NVIDIA Corporation, in the paper "Percentage-Closer Soft Shadows". This approach has  some advantages:

  1. Fast rendering time : this method can be done in hardware and for real-time applications like games as shadow map has fixed size, the complexity of algorithms is linear depend on the average depth complexity of the scene not the whole scene complexity

  2. Generates perceptually accurate soft shadows

  3. Easy setup : Requires no preprocessing, post-processing, or additional geometry (like in shadow volume)

  4. Uses a single light source sample : one shadow map

  5. Ease of integration : works with alpha testing, displacement mapping, bump mapping

2. PCSS Algorithm

The idea of PCSS is based on the observation that when the size of Percentage Closer Filter increases, the resulting shadow become softer, so that we could simulate the soft shadow by adaptive changing the size of filter. The algorithm requires 3 steps :

  1. Blocker search :search the shadow map and average the depths that are closer to the light source than to the point being shaded

  2. Penumbra estimation : Using a parallel planes approximation,  we estimate the penumbra width based on the light size  and blocker/receiver distances from the light

  3. Filtering: perform a typical PCF on the shadow map using a kernel size proportional to the penumbra estimate from Step 2

2. Implementation:

    2.1 Development Platform

    2.2 Compile

To make the demonstration more interesting (like in a real games) I have incorporated the shadow mapping with some special effects like:

                        Complete reflect image / refract image with the same index for each color components RGB

Partial reflect/refract image with the same index for each color components RGB

Fresnel Reflection image with the different index for each color components RGB

The idea is quite simple, however it 's not easy to implement. To archive the fast rendering time for real time applications we have to implement this algorithm in hardware shading language. There are 3 common use hardware languages: HLSL developed by Microsoft that well incorporated with Direct X, CG from Nvidia work well both with DirectX and OpenGL and especially for Nvidia Card, and GLSL (OpenGL Shading Language) defined by the Architectural Review Board of OpenGL a new standard to the OpenGL 2.0 which includes the GPU based shading into the traditional OpenGL pipeline. These shading languages generally very similar include those function call. However, from a language point of view, I personally find GLSL a little nicer some some reasons:

    Learning experiences:

    Working with shading languages is not easy, there's some common difficulties:

    Debugging time take more than 60% time I spend for project (approximately 30 hours). It takes time to learn a new languages and more time to use it efficiently.

3. Demonstration results:

a. Hard shadow Mapping  (size of light source is approximately 0)

the light appear as a small dot on the screen

                                                                            b. Fake soft shadow using uniform PCF filter

The shadow edge become softer every where even where two object get in touch, it still look good for most of the games.

A good new is that uniform PCF filter now can be apply with no cost with new graphic card from nVida and ATI.

c. Soft Shadow using Adaptive PCF filter with different light size

the shadow become softer at the edge especially for edges near the light (shadow edges near the viewer) and near the hard shadow for edges that touch other objects

an even become more softer with the change of size of the light source

A current updated demo results:

4. What to do next:

    One of the problem with shadow mapping method is that when the light source is very far away like sun like the resolution of shadow map goes down so that the result is become more coarse, shadow quality reduce a lot. There are some solution for this problem such as Perspective Shadow Mapping, or Trapezoidal Shadow Maps. Other approach are hybrid method that integrate both shadow mapping and shadow volume to reach higher shadow qualities. I would like to try all this method, and do some research to make a comparison and may find a better (quality/speed) for shadow issue.

5. References:

FERNANDO, R, Percentage-Closer Soft Shadows, NVIDIA Corporation

HASENFRATZ, J., A Survey of Real Time Soft Shadow Algorithms. Computer Graphics Forum, Vol. 22, No. 4 (December 2003)

Light House, GLSL Turorial, www.lighthouse3d.com/opengl/glsl

EVERITT , Hardware Shadow Mapping , http://developer.nvidia.com/object/hwshadowmap_paper.html

MARCO, Skyboxes without Seams, http://home.planet.nl/~monstrous/skybox.html

DREIJER, Bump Mapping Using CG, http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php

WLOKA, M., Freshnel Reflection , NVIDIA Corporation