Advanced Shading I: Shadow Rasterization Techniques

Transcription

Advanced Shading I: ShadowRasterization Techniques

Shadow Terminologyumbra: light totally blockedpenumbra: light partially blockedoccluder: object blocking light

Shadow Terminologyumbra: light totally blockedpenumbra: light partially blockedoccluder: object blocking lightpoint lights haveno penumbra

Shadow RenderingHard shadows: umbra only easy with ray tracing (shadow rays)Soft shadows: penumbra and umbra very difficult without global illuminationToday: rasterizing hard shadows

Projection ShadowsEasiest case: one object one light shadow cast on flat ground

Projection ShadowsMain idea: render scene twice once as usual once with object shaded black andflattened onto plane

Projection Shadowsprojection of v lies along ray

Projection Shadowsprojection of v lies along ray

Projection Shadowsprojection of v lies along ray

Projection Shadowsprojection of v lies along rayhow to write as affinetransformation?

Projection OperationNeeded:

Projection OperationNeeded:

Projection Shadowsprojection of v lies along rayhow to write as affinetransformation?

Projection Shadowsprojection of v lies along ray

Projection ShadowsPros: easy to codeCons:

Projection ShadowsPros: easy to code, fastCons: only draws shadows on flat surfaces no soft shadows no self-shadows

Projection ShadowsMultiple lights? fake with alpha blendingFinal gotcha:

Shadow MapsRender scene from the light record depth onlywhy useful?

Shadow MapsTo shade a pixel, calculate: 1) pixel tolight distance; 2) shadow map value

Shadow Mapscompare pixel-to-lightdistance to shadow mapif equal, no shadowif greater, in shadow

What’s The Bug? Part I

What’s The Bug? Part IFloating point is very dangerous numerical floating-point error depth buffer has finite precision

What’s The Bug? Part IFloating point is very dangerous numerical floating-point error depth buffer has finite precisionFix by including tolerance (“bias”) in check

What’s The Bug? Part II

What’s The Bug? Part IIShadow map is too coarse shadows are aliased

What’s The Bug? Part IIShadow map is too coarse shadows are aliasedCascaded shadow maps: use higherresolution shadow map near eye

What’s The Bug? Part IIShadow map is too coarse shadows are aliasedCascaded shadow maps: use higherresolution shadow map near eye highest-quality fix complicated (have to partition shadow map)

Percentage Closer FilteringSample several nearby pixels on shadowmap instead of only one pixelSet shadow intensity proportional tonumber of “shadow” votes

Shadow MapsVery common real-time technique used in Unreal Engine, etcPros: works with curved objects works with self-shadowsCons:

Shadow MapsVery common real-time technique used in Unreal Engine, etcPros: works with curved objects works with self-shadowsCons: very prone to aliasing artifacts still no soft shadows

Shadow VolumesConsider single light, single triangle

Shadow VolumesMain idea: build 3D object representing theshadow volumeIf pixel is inside volume, it is in shadow

Shadow VolumesMain idea: build 3D object representing theshadow volumeIf pixel is inside volume, it is in shadow shoot ray from pixel to eye, countnumber of intersections odd in shadow

Shadow VolumesFor more complicated object, look only atsilhouette edges edges connectingfront-facing toback-facingtriangles

Shadow VolumesIncreasingly popular in real-time graphics

Shadow VolumesIncreasingly popular in real-time graphicsPros: high-quality shadows (no aliasing) self-shadows automatically includedCons:

Shadow VolumesIncreasingly popular in real-time graphicsPros: high-quality shadows (no aliasing) self-shadows automatically includedCons: slow and complicated shadows chunky if meshes too coarse still no soft shadows

Shadow map is too coarse shadows are aliased Cascaded shadow maps: use higher- . front-facing to back-facing triangles. Shadow Volumes Increasingly popular in real-time graphics. Shadow Vol