Easy3D 2.5.3
SoftShadow Class Reference

An implementation of the Percentage-Closer Soft Shadows. More...

#include <easy3d/renderer/soft_shadow.h>

Inheritance diagram for SoftShadow:
Shadow

Public Types

enum  SamplePattern {
  SP_Poisson_25_25 = 0 , SP_Poisson_32_64 = 1 , SP_Poisson_64_128 = 2 , SP_Poisson_100_100 = 3 ,
  SP_Regular_49_225 = 4
}
 

Public Member Functions

 SoftShadow (Camera *cam)
 Constructor. More...
 
float softness () const
 
void set_softness (float s)
 
SamplePattern sample_pattern () const
 
void set_sample_pattern (SamplePattern pattern)
 
- Public Member Functions inherited from Shadow
 Shadow (Camera *cam)
 Constructor. More...
 
bool virtual_background () const
 
void set_virtual_background (bool b)
 Enable/Disable the virtual background. More...
 
const vec4virtual_background_color (const vec4 &c)
 Query the virtual background color.
 
void set_virtual_background_color (const vec4 &c)
 Set the virtual background color.
 
int shadow_map_size () const
 Query the size of the shadow map. The shadow is assumed to be square.
 
void set_shadow_map_size (int size)
 Set/Change the size of the shadow map. The shadow is assumed to be square. Default: 1024 by 1024.
 
float light_distance () const
 The distance of the light source to the scene scene (w.r.t the scene radius).
 
void set_light_distance (float dist)
 
float darkness () const
 
void set_darkness (float darkness)
 
void draw (const std::vector< TrianglesDrawable * > &surfaces)
 Rendering the surfaces.
 

Detailed Description

An implementation of the Percentage-Closer Soft Shadows.

SoftShadow implements the Percentage-Closer Soft Shadows technique. See

— Overview — This sample demonstrates two techniques for rendering soft shadows: Percentage Closer Filtering (PCS) with a uniform kernel size and Percentage-Closer Soft Shadows (PCSS) with a variable kernel size. This sample is assuming the shadow map is a regular depth buffer (non-linear depths), and the shadow-map is generated using a perspective projection with the center of projection at the center of the area light simulated by PCSS. The sample uses a gradient-based depth bias to scale the depth bias based on the uv-space distance from the center of the kernel. To avoid self-shadowing artifacts, an additional depth bias may also been applied while writing depth into the shadow map.

— Percentage Closer Filtering (PCF) — The Percentage Closer Filtering technique uses a uniform size filter kernel, resulting in shadows with a uniformly soft edge. The PCF algorithm is very straightforward and fast, but does not achieve a realistic contact hardening effect. Also, while the kernel size and penumbra width is uniform, the kernel can be scaled to accommodate different sized lights.

— Percentage-Closer Soft Shadows (PCSS) — Soft shadows are typically rendered in games by using shadow mapping and Percentage Closer Filtering with a uniform kernel size. The Percentage-Closer Soft Shadows (PCSS) algorithm computes a variable kernel size based on the distance between the relative position of the receiver point, an approximation of the blocker, and the area light. It produces perceptually plausible soft shadows that harden on contact.

Optimization tips: rendering with multi-effects (e.g., shadowing, SSAO) can benefit from sharing the same geometry pass.

Examples
Tutorial_503_SoftShadow.

Constructor & Destructor Documentation

◆ SoftShadow()

SoftShadow ( Camera cam)
explicit

Constructor.

Parameters
camThe camera used in the view

The documentation for this class was generated from the following files: