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

[Fix] Depth grab-pass wasn’t working correctly on WebGL1 in some cases #5464

Merged
merged 1 commit into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/scene/graphics/scene-grab.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,13 @@ class SceneGrab {
if (camera.renderSceneDepthMap) {

// reallocate RT if needed
if (!this.depthRenderTarget.depthBuffer || self.shouldReallocate(this.depthRenderTarget, camera.renderTarget?.depthBuffer)) {
this.depthRenderTarget.destroyTextureBuffers();
if (!this.depthRenderTarget?.colorBuffer || self.shouldReallocate(this.depthRenderTarget, camera.renderTarget?.depthBuffer)) {
this.depthRenderTarget?.destroyTextureBuffers();
this.depthRenderTarget = self.allocateRenderTarget(this.depthRenderTarget, camera.renderTarget, device, PIXELFORMAT_RGBA8, false, false, true);

// assign it so the render actions knows to render to it
// TODO: avoid this as this API is deprecated
this.renderTarget = this.depthRenderTarget;
}

// Collect all rendered mesh instances with the same render target as World has, depthWrite == true and prior to this layer to replicate blitFramebuffer on WebGL2
Expand Down