Lesson 8 – Shadows PV227 – GPU Rendering Jiˇrí Chmelík, Jan ˇCejka Fakulta informatiky Masarykovy univerzity 24. 11. 2015 PV227 – GPU Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 1 / 13 Shadows “just” shadow mapping, hard shadows only. PV227 – GPU Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 2 / 13 Shadow Mapping projective shadowing, visibility by depth comparison. Figure: Shadow mapping. PV227 – GPU Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 5 / 13 Artifacts perspective aliasing, projective aliasing, shadow acne, Peter panning, animation artifacts (shimmering). PV227 – GPU Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 8 / 13 Shadow Acne errorneous self shadowing, caused by quantizing depth over entire texel, caused by floating point imprecission, solved by adding bias and making near and far planes as close as possible. Figure: Taken from microsoft.com PV227 – GPU Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 9 / 13 Peter Panning shadow detached from object, caused by too high bias for solving shadow acne, solved by limiting bias and making near and far planes as close as possible. Figure: Taken from microsoft.com PV227 – GPU Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 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 Rendering (FI MUNI) Lesson 8 – Shadows 24. 11. 2015 13 / 13