-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Don't alter the scene's active cameras in the middle of taking a scre… #13040
Conversation
…enshot with RenderTargetTexture, because we can just set the RTT active camera instead.
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Just need to clean up the file (unused imports) |
Unfortunately this change won't work because the list of meshes as seen by the screenshot camera is not refreshed correctly. Try this PG: https://playground.babylonjs.com/#85EGZM#22 There is a sphere on the left but not visible by the main scene camera. When taking a screenshot (hit Spacebar and look at the browser console), you should see: because the screenshot camera is put on the right of the box and is looking down the -x axis, so the sphere is visible. With the PR, you won't see the sphere because the list of meshes that is used to render into the RTT is the list of active meshes of the main scene camera (so only the box in the PG). It is this line of code in const defaultRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data; That's why the current screenshot code is replacing the scene camera by the screenshot camera and is doing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flag as request changes to prevent merge following @Popov72 comments
In this case, could we add the scene's meshes explicitly to the RTT? Like this: for (const node of scene.getNodes()) {
if (node instanceof AbstractMesh) {
texture.renderList?.push(node);
}
} |
Yes, I think that should do it. However, you can do it in a simpler way: texture.renderList = scene.meshes.slice(); The only thing is that frustum culling is not applied on those meshes, so they will be sent to the GPU even if they are not visible. I guess it's not really a problem for a screenshot. If it is, you will have to perform a loop instead and call |
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13040/merge/index.html#WGZLGJ#4600 Links to test babylon tools with this snapshot: https://playground.babylonjs.com/?snapshot=refs/pull/13040/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/13040/merge#BCU1XR#0 |
Don't alter the scene's active cameras in the middle of taking a scre… Former-commit-id: 0749c6ed850b52ee56366604e5c52ca717d90140
…enshot with RenderTargetTexture, because we can just set the RTT active camera instead.
Related to: https://forum.babylonjs.com/t/how-to-freeze-the-camera/34284/10 so we don't need to manually set the scene's active camera after taking a screenshot.