Pixel Accurate Shadows with Shadow Mapping
        
        
               
        Overview
   
        
        
         
        Exact shadows are quite difficult for real-time rendering applications. 
        This projects experiences with some new approaches of generating exact shadows using different types of multi-pass shadow rendering. 
        A demo application has been developed to compare and benchmark these different approaches.
                       
        Screenshots
        
        
        
                
        Files
        
        
        
          Shadow_cescg.pdf  - Paper to the project
 Shadow_cescg.pdf  - Paper to the project 
        
        
          Shadow.avi  - Short video showcase
 Shadow.avi  - Short video showcase 
        
        
          Shadow.rar  - Demo application including source files
 Shadow.rar  - Demo application including source files
        
        
       
        
        Controls
        
        
        
          W,A,S,D       =  Move camera
  Left Mouse    =  Rotate light
  Middle Mouse  =  Slide camera along view plane
  Right Mouse   =  Rotate camera
  Hold STRG     =  Faster movement
  0-9           =  Select predefined camera and light setting
  Tab           =  Show/Hide menu
  Print         =  Save screenshot
  F10           =  Change resolution
  Alt+Return    =  Full screen
  ESC           =  Exit demo     
        
        Demo Interface
        
        
             
             
             
              
             
                
                    -  Scene: Selects the test scene, Terrain or PowerPlant.
-  Shadow Method:  The shadow technique to use. An additional menu with specific parameters will apear on the rigth. The following selections are possible:
                    
                        
                        - Common: Forward rendering and a single shadow map are used.
- Deferred: The scene is rendered with deferred shading and a single shadow map is used for the shadow.
- Confidence: The confidence-based shadow techniques are used.
- Z-Tiled: Uses frustum splitting to render the shadow.
- SM-Tiled: Shadow map tiling is used for the shadow.
 
-  Shadow Map Size: Shadow map size used with all methods, from 512 to 4096.
-  Const/Slope Bias: The constant and slope-scale bias values
-  Lambert: This factor is used to scale the Lambert term to emphasize the shadow. In some techniques it is used as factor for a wrap-around light. 
-  Use LiSPSM: Uses LiSPSM for shadow map rendering.
-  Draw Objects: Draws objects. (terrain scene only)
-  Update Objects: Objects position and animations are updated. (terrain scene only)
-  Visualization: Selects the visualization method. The output is only valid if the corresponding buffer is rendered and it does not work with common shadow mapping.
                    
                        
                        - Sample: Shows the projection of a 64x64 shadow map.
- Pass: Visualizes the pass where fragment has been shaded.
- FinalConf: Shows the confidence of the shadow result, it is red if converged. 
- OptConf: Shows the calculated optimal confidence. x-times the shadow map resolution (red), equal with the shadow map resolution (blue), red x-time the shadow map resolution, oversampling (green) 
- ID: Shows the ID values of the fragments.
- SSAO: Visualizes the screen space ambient occlusion pass.
 
-  Wireframe: Everything is rendered in wireframe.
-  Show ShadowMap: Renders the light-view to the frame-buffer. 
-  WorldPosType: Defines how the world position is stored/reconstructed for deferred shading:
                        
                        - Depth: Takes the non-linear projected depth value from the Z-buffer to recover the world position.
- LinearDepth: The distance to the camera plane is stored in a separate render target and used to recover the world position.
- WorldPos: The world position is directly stored in a render target.
 
-  ID Buffer: Enables the ID Buffer instead of the shadow depth test. Allows inter objects shadows without biasing problems. Combination of ID buffer and shadow map filtering is not implemented, will only use filtering then. 
-  Prim ID: Renders primitive ID instead of object ID to the ID Buffer. Enables to use ID test for selfshadowing.
-  Use Debug Cam: Switch between normal and debug camera. The debug camera also visualizes the view and light frustum.
-  SSAO: Enables screen space ambient occlusion. Does not work with the common shadow method.
-  SM Filtering: Enables shadow map filtering. A 3x3 Gaussian filter kernel is used. Does not work with confidence-based shadow methods.
-  Reset Cam: Sets the camera to its inital position.
-  Reload Shaders: Recompiles all changed shader files.
 
         
         Shadow Techniques
    
         
         
 
         
         
         
          
         
         Confidence-based Shadow
         
         This basic method covers four different confidence-based shadow techniques.
         Generally, they simulate a higher shadow map resolution through multiple jittered shadow maps, 
         which get accumulated in a screen space buffer. Thereby only fragments with the best confidence value, 
         which is defined by the distance of the sampling position to the nearest texel center, are preserved.
        
         
        
         
            -  ConfTech: The following techniques are implemented:
                
                - Simple: Only the high confident part of the shadow map samples is used to compose the shadow. The confidence threshold can be configured with the Conf parameter.
                
- Adapted: With this technique higher confidence of a shadow test overwrites a lower
                    on. The required confidence for each fragment is calculated and when it is reached,
                    it will not be overwritten anymore.
-  Reduction: Reduces the view frustum where a shadow map is applied every pass and
                    uses confidence based accumulation.
-  Reduction Dynamic: Reduces the view frustum only if a certain amount of fragments
                    in the part that is capped off has reached their required confidence.
 
-  Jitter Type: Sets the jittering method:
                
                - Random: Translational jittering with a series of random numbers for the offsets.
- Halton: Translational jittering with the Halton sequence numbers for the offsets.
- Rotation: The light view gets rotated, whereby the angles are given by the Halton
                    sequence.
- LiSPSM N: Additional to translational jittering with the Halton sequence, the LiSPSM 
                    n-Parameter is randomly jittered.
 
-  PCF Pre-Test: In the first pass the four nearest samples are tested
                and if they are consistent, the whole area is shadowed by the result. It drastically
                reduces the number of unconverged fragments in the first pass, but artifacts can occur. This
                is a suggestive option for the Simple method.
-  Conf: The confidence value. It is used in all techniques differently.
-  MaxPasses: Sets the limit of passes where the process should be aborted.
-  Stop t: Sets
                the lower limit of pixels that have refined in the last pass to trigger an abort.
-  Stop n: Sets
                the number of passes the number of refined pixels has to stay below the threshold.
 
         
         
         
          
         
         Frustum Splitting
         
         This technique is also called 
Parallel-Split Shadow Maps [Zhang et al.] or Cascaed Shadow Maps. 
         It slices the view frustum in several depth layers and renders a shadow map for each 
         to overcome perspective aliasing.
         
         
         
         
            -  Jitter Type: Sets the jitter method that is used when multiple passes are rendered per slice.
-  Tiles: Sets the number of slices. Also used as limit when
                AutoTiling is enabled.
-  TilePasses: Allows rendering of multiple jittered passes per slice.
-  Uni<->Log: Blending between uniform and logarithmic slicing scheme.
-  AutoTiling: Enables AutoTiling where the slices are set a distance where one fragment is still covered by a texel in the shadow map. 
                This behaviour can be tuned with FragSize. The value Tiles shows how many tiles actually have been used.
-  NoConfidence: When enabled only the according slice is selected and used to determine the shadow in it, 
                otherwise confidence-based accumulation is used in overlapping areas.
-  FragSize: Determines the ratio between sample/fragment for AutoTiling. 
-  ExactFilter: Filters shadow map samples according to how many fall on a fragment. 
                This allows filtering without emphasizing transitions and provides anti-aliased shadows.
 
         
         
         
          
         
         Shadow Map Tiling
         
         This technqiue is based on the paper 
Fitted Virtual Shadow Maps [Giegl et al.] 
         The shadow map gets tiled. Then the required shadow map resolution of the screen-space fragments is calculated and accumulated to its shadow map tile. 
         A pyramidal update structure is created and processed from top down and shadow maps are rendered until everything is covered.
         
         
         
         
            -  Tiling: The tiling factor for the shadow map
-  Xi: The quality trade-off parameter that shifts the required shadow map resolution by this factor
-  UseDownSampledReqRes: Defines if the scene should be down-sampled before the required resolution for each tile is calculated.
-  Max or Avg: Uses the maximum or average of the required resolutions for a tile. Averaging actually is not correct.
-  ReqResDSSize: The size to which the scene is down-sampled when
                UseDownSampledReqRes is enabled
            
         
        
         © Christian Luksch, Student at the Vienna University of Technology, Institute of Computer Graphics and Algorithms