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