Skip to content

feat(viewer): updates the IBL shadow on animations#18079

Open
cournoll wants to merge 4 commits intoBabylonJS:masterfrom
cournoll:fix/anim-ibl-shadows
Open

feat(viewer): updates the IBL shadow on animations#18079
cournoll wants to merge 4 commits intoBabylonJS:masterfrom
cournoll:fix/anim-ibl-shadows

Conversation

@cournoll
Copy link
Contributor

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.

@sebavan sebavan requested a review from ryantrem March 12, 2026 15:48
@sebavan
Copy link
Member

sebavan commented Mar 12, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2026

Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s).
To prevent this PR from going to the changelog marked it with the "skip changelog" label.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2026

Snapshot stored with reference name:
refs/pull/18079/merge

Test environment:
https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18079/merge/index.html

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
https://sandbox.babylonjs.com/?snapshot=refs/pull/18079/merge
https://gui.babylonjs.com/?snapshot=refs/pull/18079/merge
https://nme.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.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 12, 2026

@ryantrem ryantrem marked this pull request as draft March 13, 2026 21:43
@ryantrem
Copy link
Member

Discussing on the side, moving to draft for now.

@ryantrem ryantrem marked this pull request as ready for review March 19, 2026 16:32
Copilot AI review requested due to automatic review settings March 19, 2026 16:32
@deltakosh deltakosh enabled auto-merge (squash) March 19, 2026 16:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +2453 to +2465
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();
});
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cournoll can you just update the PR description? I guess it is out of date now.

Comment on lines +2454 to +2465
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();
});
}
Comment on lines 1500 to 1507
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();
}
Comment on lines +2475 to +2479
if (frame++ % 2 === 0 && this._shadowState.high) {
this._shadowState.high.pipeline.updateVoxelization();
this._shadowState.high.pipeline.resetAccumulation();
this._startIblShadowsRenderTime();
}
@bjsplat
Copy link
Collaborator

bjsplat commented Mar 19, 2026

Reviewer - this PR has made changes to one or more package.json files.

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 19, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 19, 2026

@bjsplat
Copy link
Collaborator

bjsplat commented Mar 19, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants