Repository navigation
cvcGL: shadows at a city's scale -- a filtered depth lookup and a shadow focus - #946
Merged
Merged
Conversation
…dow focus VTK 9.5's shadow lookup is an exponential shadow map: the factor is exp(c * (occluder depth - receiver depth)) over the light camera's whole depth range, c = 11. Over a 3 km city lit from 4.7 km out a 50 m building dims the ground behind it by a fifth of the key and a 2 m vehicle by a hundredth, so nothing reads as shadow. - FilteredShadowMapPass reads VTK's maps (exp(c * depth)) back as depths and filters a depth test over a 16-tap Poisson disc, with a normal offset, a depth bias and a receiver-plane bias sized in shadow-map texels at the receiver; an empty texel reads lit and the shadow fades out at the map's border. SceneGraph::setShadowSoftness sets the disc. - StridedShadowBaker bakes through its own copy of VTK's bake loop, which puts the bake's shader keys on every prop it draws (VTK keys only the props the main camera kept, so a caster out of view drew its colour into the map) and clears the maps to 0. - SceneGraph::setShadowFocus aims each light's map at a sphere (a follow camera's subject) instead of fitting it to the whole scene; whatever lies between the light and the sphere still casts. - cvcgl_city_sun_shadows: a building's shadow over a 3 km ground, and a 2 m box's with the map focused on it.
On macOS (package-macos release-grpc jobs) the held-out calibration closes the dissipation to 0.152 against a 0.15 bound and its calibrated step's twist is 1% over the uncalibrated one's, and the gradient check's beta and gamma (a quarter of alpha there) flip sign against Jolt's finite differences while the gradient as a whole agrees (ratio 0.92). The calibration's margins are 0.2 and 5%; the per-bias checks apply to components at least a third of the largest (all three on Windows), and the whole-gradient check is unchanged.
…caster The renderer clears each shadow map to its background, not to the 0 the bake asked for, so on cvcdbg's pale sky (red 0.78) with a ground that casts nothing, every empty texel read as an occluder in front of everything and the open ground went dark (149 -> 94 luma). The bake now writes 1 + exp(c * depth) (at least 2, over a clear of at most 1) and the lookup decodes log(t - 1) / c; cvcgl_city_sun_shadows C checks that case.
vtkOpenGL{Clear,Check}ErrorMacro report only without NDEBUG, so VTK's own around its bake compile
away in the VTK libcvc links; in the fork they reported, in libcvc's Debug builds, the error VTK's
low-memory mapper raises on its own: GL_INVALID_OPERATION from six draws in the first bake after
vtkOpenGLShaderCache::ReleaseGraphicsResources() (cvcgl_lowmem_fastdraw's lifecycle step), on
VTK's stock draw path and through vtkShadowMapBakerPass::Render alike. That frame's main pass
raises GL_INVALID_VALUE too. cvcgl_lowmem_fastdraw failed 'no VTK errors' on package-linux Debug.
transfix
added a commit
that referenced
this pull request
Nov 1, 2026
The heat-stop check sent "stop" once fe.progress reached 1%. The first 3%
of a solve job's progress is the boundary walk before the solve, so on a
slow build (package-linux Debug-grpc) the stop landed there and the job
ended with nothing ('heat: stopped'), failing "heat.steps = 1e30 is
clamped, and stop interrupts it" (#944's CI, and twice on #946's).
Wait for fe.phase "stepping" instead: the time steps are under way, so a
stop ends the solve at a step, and a solve wrapped to one step is still
caught (done, busy 0, before the stop).
(cherry picked from commit 23eae43)
transfix
added a commit
that referenced
this pull request
Nov 1, 2026
Releases #946 (cvcGL shadows at a city's scale), which 3.7.6 shipped without.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
cvcdbg's demo3 has never shown a shadow. The cause is how VTK's shadow lookup behaves at a city's scale, plus a bug in VTK's bake. This fixes both, and adds a way to spend the shadow map where the camera looks.
Why nothing shadowed. VTK 9.5's
vtkShadowMapPassuses exponential shadow maps. The shadow factor isexp(c * (occluder depth - receiver depth)), with both depths normalised over the light camera's whole depth range and c = 11.Changes (all in
src/cvcGL/SceneGraph.cpp):FilteredShadowMapPass(avtkShadowMapPasssubclass, installed byinstallShadowPasses):exp(c * depth)). The lookup reads each tap back as a depth (log(texel) / c) and depth-tests it over a 16-tap Poisson disc (percentage-closer filtering).SceneGraph::setShadowSoftness(texels)sets the disc's radius (default 2).StridedShadowBakerbakes through its own copy of VTK's bake loop (BSD, attributed). Two changes against VTK:PreRender(&s2), where VTK hasPreRender(s)). VTK keys only the props the main camera kept after culling, so a caster out of view drew its colour, not its depth, into the map. The exponential lookup happened to read that as an occluder in front of everything, socvcgl_shadow_castersD's out-of-view slab shadowed. A depth lookup cannot read it that way.SceneGraph::setShadowFocus(x, y, z, radius)/clearShadowFocus(). Each light's map is aimed at a sphere instead of fitted to the whole scene:Tests
cvcgl_city_sun_shadows: a 3 km ground, a 50 m building and a 2 m box under demo3's rig (key 1.3 at azimuth -60, elevation 28, cone 62).cvcgl_shadow_casters(D's slab now shadows its footprint to 0 luma),_caster_growth,_pass_reuse,cvcgl_stage_caster_truth,cvcgl_shadow_volume,cvcgl_lighting,cvcgl_lowmem_fastdraw(traces and pixels on both draw paths),cvcgl_streaming_overlaysandcvcgl_rendererall pass.ctest -R cvcgl_: 82 of 84 pass.cvcgl_lowmem_fastdrawwas one of the 2, before the clear-to-0 fix; it passes now (above).cvcgl_fe_intervalwas the other. It runs libigl-only mesh ops outside its libigl guard, so it aborts on a build without libigl, as this tree is. Not this change; the FEM session is fixing the guard separately.