Skip to content

Upstream fixes to shadow rendering

  1. The PBR illumination model didn't account for non-positional lights. It would always compute the direction to the light from fragment to light position. But non-positional lights don't have a position to speak of. Instead, it should simply be the negative of the light direction; that is the definition of the direction to the light source for directional lights.
  2. The fragment shader has text search-and-replace games in two locations: vtkOpenGLPolyDataMapper and vtkShadowMapPass. The former introduces the lighting calculations to define "radiance", the latter updates the "radiance" definition to account for shadows. This update depends on the shadow map pass knowing what strings the data mapper uses. In this case, the strings that vtkShadowMapPass was expecting didn't cover all of the strings produced by vtkOpenGLPolyDataMapper. The latter has been updated.
  3. VTK Uses exponential shadow maps (ESM). That algorithm has a particular tuning constant. Ideally, the constant would be infinity (so that the approximation of a step function is perfect). Finite numerical precision makes that impossible. However, it should be as large a number as possible before numerical precision issues kick in. The authors of ESM recommend 80; VTK used 11 (leading to bizarre shadow behaviors where shadows were being strongly attenuated based on increased distance from the light). Allow this to be configured by applications that use more distant lighting sources.
  4. vtkShadowMapBakerPass does one rendering pass for each light to create a shadow map. Indirectly, this causes the light transform for each light to change, based on the camera associated with the light currently being rendered. For a light defined in the camera space, this would corrupt its transform matrix. When it comes time to render the shadow for that light, we'd have the wrong transform and we'd produce the wrong camera pose. Now, the shadow map baker caches the initial light transforms and resets the light's transform before creating its corresponding camera.

Upstreamed patch from TRI ref. https://github.com/RobotLocomotion/drake/issues/20874

/cc @SeanCurtis-TRI

Original ESM paper ref. https://www.researchgate.net/publication/32893024_Exponential_Shadow_Maps

Edited by Ryan Krattiger

Merge request reports