PV227 GPU programming Marek Vinkler Department of Computer Graphics and Design PV227 GPU programming 1 / 13 Shadows “just” shadow mapping, hard shadows only. PV227 GPU programming 2 / 13 Shadow mapping projective shadowing, visibility by depth comparison. Figure: Shadow mapping. PV227 GPU programming 3 / 13 Basic Theory scene rendered from the light (depth saved), scene rendered from the camera (depth compared). Figure: Taken from nvidia.com PV227 GPU programming 4 / 13 More Theory separate shadow map for each light, only objects casting shadows need to be rendered, recomputed each time the light or the scene changes. Figure: Taken from github.io PV227 GPU programming 5 / 13 Artifacts perspective aliasing, projective aliasing, shadow acne, Peter panning, animation artifacts (shimmering). PV227 GPU programming 6 / 13 Perspective aliasing caused by mapping of pixels to shadow map texels, worse near the camera (many-to-one), solved by remapping the texture: Perspective Shadow Maps (PSMs), Logarithmic Perspective Shadow Maps (LogPSMs), Cascaded Shadow Maps (CSMs), . . . Figure: Taken from microsoft.com PV227 GPU programming 7 / 13 Projective aliasing caused by orientation of geometry to light (parallel rays), same solution as in the previous slide. Figure: Taken from microsoft.com PV227 GPU programming 8 / 13 Shadow acne errorneous self shadowing, caused by quantizing depth over entire texel, caused by floating point imprecission, solved by adding bias, making near and far planes as close as possible. Figure: Taken from microsoft.com PV227 GPU programming 9 / 13 Peter panning shadow detached from object, caused by too high bias for solving shadow acne, solved by limiting bias, making near and far planes as close as possible. Figure: Taken from microsoft.com PV227 GPU programming 10 / 13 Slope scaled bias adding bias depending on the orientation of the geometry, high for parallel, small for orthogonal directions, glPolygonOffset. Figure: Taken from microsoft.com PV227 GPU programming 11 / 13 Shimmering shadow edges animation artifact, brightening and darkening of shadow edges, caused by recalculation of shadow matrix, Figure: Taken from microsoft.com PV227 GPU programming 12 / 13 Sources http://msdn.microsoft.com/en-us/library/ windows/desktop/ee416324%28v=vs.85%29.aspx more discussion, other artifact elimination techniques. PV227 GPU programming 13 / 13