Skip to content

Commit

Permalink
Fix screen capture bug with webgpu (#15693)
Browse files Browse the repository at this point in the history
* Fix screen capture bug with webgpu

* .
  • Loading branch information
deltakosh authored Oct 11, 2024
1 parent ef62567 commit 56dbb14
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions packages/dev/core/src/Misc/screenshotTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ export function CreateScreenshotUsingRenderTarget(
});
} else {
const importPromise = engine.isWebGPU ? import("../ShadersWGSL/pass.fragment") : import("../Shaders/pass.fragment");

importPromise.then(() =>
ApplyPostProcess("pass", texture.getInternalTexture()!, scene, undefined, undefined, undefined, finalWidth, finalHeight).then((texture) => {
engine._readTexturePixels(texture, finalWidth, finalHeight, -1, 0, null, true, false, 0, 0).then((data) => {
Expand All @@ -278,15 +277,11 @@ export function CreateScreenshotUsingRenderTarget(
);
}
});

// re-render the scene after the camera has been reset to the original camera to avoid a flicker that could occur
// if the camera used for the RTT rendering stays in effect for the next frame (and if that camera was different from the original camera)
scene.incrementRenderId();
scene.resetCachedMaterial();
texture.render(true);
engine.setSize(originalSize.width, originalSize.height);
camera.getProjectionMatrix(true); // Force cache refresh;
scene.render();
} else {
setTimeout(renderWhenReady, 16);
}
Expand Down

0 comments on commit 56dbb14

Please sign in to comment.