Advanced Light and Shadow Culling Methods Eric Lengyel

Download Advanced Light and Shadow Culling Methods Eric Lengyel

Post on 14-Jan-2016




0 download

Embed Size (px)


  • Advanced Light and Shadow Culling Methods

    Eric Lengyel

  • Fully Dynamic EnvironmentAnything in the world can moveCant precompute any visibility informationLights completely dynamicCant precompute any lighting informationShadows also completely dynamic

  • Problems to Be Solved at Run-timeDetermine the set of objects visible to the cameraDetermine the set of lights that can influence the region of space visible to the cameraFor each light, also determine what subset of the visible objects can be illuminated

  • Problems to Be Solved at Run-timeDetermine the set of objects that could possibly cast shadows into the region of space visible to the cameraA superset of the set of the illuminated objects that are visible to the camera

  • Visibility DeterminationOrganize the world in some wayTree structures (BSP, octree, etc.)Hierarchical bounding volumesPortal systemA combination of these can work extremely well

  • Portal SystemsWorld divided into zonesA zone is the region of space bounded by a convex polyhedronZones are connected by portalsA portal is a planar convex polygonFrom the front side, a portals vertices are wound CCW

  • Portal SystemsDuring visibility determination, only have to worry about zones that can be seen through a sequence of portalsFor each reachable zone, there is a convex region of space visible to the camera

  • Portal SystemsCamera

  • Portal SystemsThe visible regions form a tree structureThe region in the zone containing the camera is the root of the treeZones seen through n portals have regions at the n-th level in the tree

  • Portal SystemsCameraABCDABCD

  • Portal SystemsStart with view frustum in zone containing the cameraClip portals leading out of the zone against the view frustumFor any portals intersecting the view frustum, construct a new region by extruding clipped edges away from camera position

  • Portal SystemsEvery visibility region is bounded by a convex polyhedron defined by at least 4 planesAt least 3 lateral planesA back planeA front plane in non-root nodesPlane normals point inward

  • Portal SystemsAfter region tree has been built...Traverse the treeCollect objects in each zone that intersect the visible region of space for that zoneUse any frustum/bounding volume test, but test against regions planesThis is the visible object set

  • Light Region TreesPortals can be used to construct illumination treesSimilar to the visibility tree constructed for the cameraOne tree for each light sourceOnly recalculated when light movesEach node in the tree corresponds to a convex region of space

  • Light Region TreesThree fundamental light typesPoint lightSpot light, special case of point lightInfinite (directional) light

  • Light Region TreesPoint lightOmnidirectionalHas maximum rangeRoot illumination region bounded only be zone boundary and lights bounding sphere

  • Point Light TreeABCDBADC

  • Spot Light TreeSpot light almost same as point lightDifference is the root node of the illumination treeSpot light starts with a frustum, just like a camera doesPoint light affects entire root zone

  • Infinite Light TreeLight rays parallel for infinite lightThe lateral planes of each illumination region intersect at parallel linesThe extrusion of planes from a portal always goes in one direction instead of away from a point

  • Visible Light DeterminationEach zone keeps a linked list of illumination regionsOne or more region nodes for each light that can shine into the zoneEach region knows which light generated it

  • Visible Light DeterminationABCDLight 1Light 2Light 3For example, consider zone C

  • Visible Light DeterminationBADCABCDDCBALight 1Light 2Light 3

  • Visible Light DeterminationFor any given zone, we can walk the linked list of illumination regions and collect unique lightsRepeat process for all zones referenced in the cameras visibility treeWe now have the set of visible lights

  • Illuminated Object SetGiven one visible zone and one visible light shining into that zoneIlluminated objects are those which intersect both a camera region and a light region

  • Illuminated Object SetLightCamera

  • Illuminated Object SetObjects are often only partially within an illumination regionLighting the whole object wastes rendering time due to extra fillFortunately, hardware provides an opportunity for optimization

  • Lighting OptimizationUse hardware scissor rectangleCalculate intersections of camera regions and illumination regionsCamera-space bounding box determines scissor rectangleGL_EXT_depth_bounds_testWorks like a z axis for scissor box

  • Lighting OptimizationCameraImage PlaneMax DepthMin Depth

  • Lighting OptimizationScissor rectangle and depth bounds testLimits rendering for a single light to the maximal visible extentsCan also be applied to stencil shadow volumes

  • Shadow Map OptimizationSame optimization can be applied from lights perspective when rendering shadow mapsTransform vertices of region intersections into light spaceCalculate scissor rectangle and depth boundsReduces unnecessary depth fill

  • Shadow Map OptimizationLightImage PlaneMax DepthMin Depth

  • Shadow-Casting Object SetAll objects in the illuminated set are also in the shadow-casting setBut an object doesnt have to be visible to be casting a shadow into one of the visible camera regionsThe shadow-casting set is a superset of the illuminated set

  • Shadow-Casting Object SetNeed to find objects between visible regions and light sourceWe already have a structure in place to make this easyFrom an illumination region, walk up the lights tree to the root

  • Shadow-Casting Object SetCameraLightABCDECEBA

  • Shadow-Casting Object SetCollect objects in branch of illumination tree containing visible regionsCan use lateral bounding planes of deepest visible regions

  • Shadow-Casting Object SetCameraLightCulledCaster

  • Shadow-Casting Object SetWhere illumination regions and camera regions intersect...Some objects inside illumination region, but not between camera region and light source

  • Shadow-Casting Object SetExtraCaster

  • Shadow-Casting Object SetEliminating shadow-casting objects on wrong side of camera regionTest objects against planes of camera region having a positive dot product with light positionFor infinite light, use planes having a positive dot product with direction to light

  • Shadow-Casting Object Set

  • Demonstrations

  • Questions?

    Slides available at