GAM532 DPS932 – Week 7 Introduction to shadows
Shadow Effects Light Surface No Shadows Shadows
Types of Shadow Techniques Baked LightingBlob ShadowsShadows VolumesDepth Map Shadows Performant Immersive
Baked Lighting and Static Lights Lights and actors cannot move Static lights are not part of the scene Computations happen during development Almost costless Cannot change at runtime Can be very high detail
Blob Shadows Scene without shadow Scene with blob applied to underlying geometry Static Shadow Texture Light Dir: [ 0, -1, 0 ] Light Dir: [ 0.7, -0.7, 0 ] Shadows can move with the scene Low performance cost Shadows cannot change at runtime Low detail approximations Only works well with single simple light
Shadows Volumes Extrude Shadow VolumeRender Scene DepthRender Volume Stencil Shadowed Scene
Extruding Shadow Volumes Shadowed Scene Light Actor Shadow Volumes
Rendering Depth and Stencil Render Depth Render Volume Stencil A Front Face: Fail (-1) Back Face: Fail (+1) Stencil = 0 B Front Face: Pass (0) Back Face: Fail (+1) Stencil = 1 C Front Face: Pass (0) Back Face: Pass (0) Stencil = 0
Final Result Additive Blocks the light for each light pass Modulative Darkens the geometry after lighting pass CPU Intensive Modulative darkens scene with multiple lights Self Shadowing Dynamically changing Shadow Detail limited by mesh detail High Detail (model limited) Very expensive with high polygon meshs
Depth Texture Shadows Render scene depth from each light Render Scene from main camera for each light Compare depth from light’s depth target to each fragment
Render from Shadow Camera Render scene depth from each light Bind each shadow camera to a depth target (no color needed) struct Light { float3 position; float4 diffuse; float4 specular; float3 attenuation; float3 spot; }; Texture2D shadowTex : register(t0); SamplerState shadowSamp : register(s0); Bind each depth target to a slot in the shader
Render from Main Camera Render scene from the main camera Project the fragment position into the light’s space, using modified x,y for uv texcoords Compare depth stored in texture vs projected distance from the light
Final Result Translucency effects easily added Expensive (re-render scene for each light) Self Shadowing Dynamically changing Shadow Detail limited by texture size High Detail (texture limited) Point lights are very expensive to cast shadows from (6 renders per light)
Some Advanced Stuff Texture resolution can cause aliasing Sampling adjacent texels and blending can soften shadows Sampling many adjacent texels and applying noise algorith
When to Use Each Technique Baked LightingBlob ShadowsShadows VolumesDepth Map Shadows Areas where lighting and geometry won’t change [ceiling of a tall building] Objects that are too far away to need detail, but close enough to need shadows [distant trees, buildings] When you need to cast from point lights or when depth maps are too expensive [Small light points, candles] Areas that need high quality shadows from directional or spot lights [light from a window]
To Do Begin work on your enhancement Begin work on OpenGL labs Update wiki with all team related information Prepare for Mid-term (read study guide)