Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yet another voxelization fix for IBL shadows #15825

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class _IblShadowsVoxelRenderer {
private _voxelMrtsYaxis: MultiRenderTarget[] = [];
private _voxelMrtsZaxis: MultiRenderTarget[] = [];
private _isVoxelGrid3D: boolean = true;
private _renderInFlight = false;
private _voxelMaterial: ShaderMaterial;
private _voxelSlabDebugMaterial: ShaderMaterial;

Expand Down Expand Up @@ -629,9 +628,12 @@ export class _IblShadowsVoxelRenderer {
if (this._voxelDebugEnabled) {
this._addRTsForRender([this._voxelSlabDebugRT], includedMeshes, this._voxelDebugAxis, 1, true);
}
this._scene.onAfterRenderObservable.addOnce(this._renderVoxelGrid.bind(this));
this._renderVoxelGridBound = this._renderVoxelGrid.bind(this);
this._scene.onAfterRenderObservable.add(this._renderVoxelGridBound);
}

private _renderVoxelGridBound: () => void;

private _renderVoxelGrid() {
if (this._voxelizationInProgress) {
let allReady = this.getVoxelGrid().isReady();
Expand All @@ -644,7 +646,6 @@ export class _IblShadowsVoxelRenderer {
allReady &&= rttReady;
}
if (allReady) {
this._renderInFlight = false;
this._renderTargets.forEach((rt) => {
rt.render();
});
Expand All @@ -655,12 +656,8 @@ export class _IblShadowsVoxelRenderer {
}
this._generateMipMaps();
this._copyMipMaps();
this._scene.onAfterRenderObservable.removeCallback(this._renderVoxelGridBound);
this._voxelizationInProgress = false;
} else if (!this._renderInFlight) {
this._renderInFlight = true;
setTimeout(() => {
this._renderVoxelGrid();
}, 16);
}
}
}
Expand Down