feat(viewer): updates the IBL shadow on animations#18079
feat(viewer): updates the IBL shadow on animations#18079cournoll wants to merge 4 commits intoBabylonJS:masterfrom
Conversation
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Reviewer - this PR has made changes to one or more package.json files. |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18079/merge/index.html#WGZLGJ#4600 Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves): https://playground.babylonjs.com/?snapshot=refs/pull/18079/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/18079/merge#BCU1XR#0 If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools. |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
|
Discussing on the side, moving to draft for now. |
There was a problem hiding this comment.
Pull request overview
This PR targets the Babylon Viewer tool’s high-quality (IBL) shadows behavior so that shadows are refreshed when animated content changes, avoiding stale IBL shadow results during animation playback/scrubbing.
Changes:
- Adds an IBL-shadows voxelization trigger helper and calls it on animation progress changes and on pause.
- Adds an animation observer loop to periodically re-voxelize while animations are playing.
- Ensures the animation observer is stopped when shadows are disposed, and starts it when enabling high shadows during playback.
You can also share your feedback on Copilot code review. Take the survey.
| private _triggerIblShadowsVoxelization() { | ||
| if (this._shadowState.high && !this._shadowState.high.voxelizationInProgress) { | ||
| this._shadowState.high.voxelizationInProgress = true; | ||
| this._shadowState.high.pipeline.updateSceneBounds(); | ||
| this._shadowState.high.pipeline.updateVoxelization(); | ||
| this._shadowState.high.pipeline.onVoxelizationCompleteObservable.addOnce(() => { | ||
| if (this._shadowState.high) { | ||
| this._shadowState.high.voxelizationInProgress = false; | ||
| this._shadowState.high.pipeline.resetAccumulation(); | ||
| } | ||
| this._startIblShadowsRenderTime(); | ||
| }); | ||
| } |
There was a problem hiding this comment.
@cournoll can you just update the PR description? I guess it is out of date now.
| if (this._shadowState.high && !this._shadowState.high.voxelizationInProgress) { | ||
| this._shadowState.high.voxelizationInProgress = true; | ||
| this._shadowState.high.pipeline.updateSceneBounds(); | ||
| this._shadowState.high.pipeline.updateVoxelization(); | ||
| this._shadowState.high.pipeline.onVoxelizationCompleteObservable.addOnce(() => { | ||
| if (this._shadowState.high) { | ||
| this._shadowState.high.voxelizationInProgress = false; | ||
| this._shadowState.high.pipeline.resetAccumulation(); | ||
| } | ||
| this._startIblShadowsRenderTime(); | ||
| }); | ||
| } |
| public set animationProgress(value: number) { | ||
| if (this._activeAnimation) { | ||
| this._activeAnimation.goToFrame(value * (this._activeAnimation.to - this._activeAnimation.from)); | ||
| this.onAnimationProgressChanged.notifyObservers(); | ||
| this._autoRotationBehavior.resetLastInteractionTime(); | ||
| this._markSceneMutated(); | ||
| this._triggerIblShadowsVoxelization(); | ||
| } |
| if (frame++ % 2 === 0 && this._shadowState.high) { | ||
| this._shadowState.high.pipeline.updateVoxelization(); | ||
| this._shadowState.high.pipeline.resetAccumulation(); | ||
| this._startIblShadowsRenderTime(); | ||
| } |
|
Reviewer - this PR has made changes to one or more package.json files. |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
When using high quality shadows (IBL shadows) with an animated model, the shadow was not updated.
This PR adds a
_triggerIblShadowsVoxelization()method that runs a single voxelization pass and temporarily hides the shadow ground disc while it recomputes, to avoid showing a stale shadow. The ground is shown again once the new voxelization is ready.