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

Framebuffer re-use WIP #13492

Closed
wants to merge 9 commits into from
Closed

Conversation

grimdeathr
Copy link

…py to texture, opaque object copier before transparent objects are rendered
@bjsplat
Copy link
Collaborator

bjsplat commented Feb 1, 2023

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 Feb 1, 2023

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 1, 2023

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13492/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 1, 2023

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13492/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

@grimdeathr
Copy link
Author

I don't get why my builds are failing. Seem to work earlier. Job description on CI is unclear..

@sebavan sebavan requested a review from Popov72 February 1, 2023 17:17
@sebavan
Copy link
Member

sebavan commented Feb 1, 2023

Every imports should be relative and complete (I mean to the file itself) like import { Engine } from "core/Engines/engine"; should be import { Engine } from "../Engines/engine"; maybe with more ../ depending on the hierarchy.

The formatting / linting should be according the rules in the repo (there are npm tasks to help fixing them)

Comments (in ts doc style) should be added.

@Popov72
Copy link
Contributor

Popov72 commented Feb 1, 2023

Let us know when you have validated all your code and the PR is ready for review.

General comments:

  • onBeforeTransparentRendering already exists in the RenderingGroup class. Be sure to call the existing callback in your own callback, in case onBeforeTransparentRendering is not undefined.
  • The standard and PBR materials must be updated to use the default refraction texture of the scene (as is done for the env texture).
  • The purpose of the PR is to copy the existing data from the framebuffer to the RTT, not to render the scene in the RTT.
  • We don't want to recreate a new render target texture every time, this should be a parameter we pass instead.
  • There is also WebGPU support to add
  • As @sebavan said, you need to format and document the code according to our rules and you also need to fix the imports.

@sebavan
Copy link
Member

sebavan commented Feb 1, 2023

@grimdeathr , you also need to add a test, you can use the code you are using to validate your PR as I wonder how it could work in the current state.

I will actually move it to draft as it is not ready to be reviewed.

@sebavan sebavan marked this pull request as draft February 1, 2023 19:16
… use existing callback for onBeforeTransparentRendering
@grimdeathr
Copy link
Author

Thanks @sebavan @Popov72 for the feedback. Appreciate it.

This is supposed to be a draft yes, I originally intended to PR to my own fork but ended up here. I will move to review when ready fully.

@sebavan
Copy link
Member

sebavan commented Feb 1, 2023

@grimdeathr I will close the PR for now to prevent other ppl to spend time on early review. I let you reopen it once ready.

This commit 85e212c is not the right approach, you need to copy the GPU content of the texture not the CPU references to it.

@sebavan sebavan closed this Feb 1, 2023
@bjsplat
Copy link
Collaborator

bjsplat commented Feb 1, 2023

Visualization tests for webgl1 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13492/merge/testResults/webgl1/index.html

If tests were successful afterwards, this report might not be available anymore.

@bjsplat
Copy link
Collaborator

bjsplat commented Feb 1, 2023

Visualization tests for webgl2 have failed. If some tests failed because the snapshots do not match, the report can be found at

https://babylonsnapshots.z22.web.core.windows.net/refs/pull/13492/merge/testResults/webgl2/index.html

If tests were successful afterwards, this report might not be available anymore.

@grimdeathr
Copy link
Author

grimdeathr commented Feb 1, 2023

So using engine._currentFramebuffer; is wrong? @Popov72

Is engine.readPixels better?

Theres no early review but I will be asking a bunch of questions..

@sebavan
Copy link
Member

sebavan commented Feb 1, 2023

_currentFramebuffer is a cached value of the currently bound frameBuffer and can not be assigned as you do to a texture. You cast it to assign it to a texture (not making a copy but swapping it) by passing important type checking which was probably letting you know of the error.

As @Popov72 mentioned, the purpose of the PR is to copy the existing data from the framebuffer to the RTT, not to render the scene in the RTT.

Basically, copy the GPU content of the current frame buffer inside of the RTT GPU content. readPixels won t be better as it is highly inefficient and will need to copy the data from GPU to CPU and then back to GPU. You want to do the copy GPU side.

The bounty is not necessarily an easy one if you never developed with Babylon or WebGL in the past. It would be great if you can show us a working Draft we would grow from.

@grimdeathr
Copy link
Author

Thanks for the detailed response.

I will continue with this in my fork. I've developed extensively with BabylonJS and WebGL, albeit mostly working on games and experiences.

I will update the story on the original bounty issue.

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.

None yet

4 participants