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

WebGPURenderer: copyFramebufferToTexture - support for post-rendering usage #29729

Merged
merged 5 commits into from
Oct 30, 2024

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Oct 23, 2024

Related issue: Fixes #29713

Description

Added support for post-rendering usage.

Copy link

github-actions bot commented Oct 23, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 691.67
171.43
691.67
171.43
+0 B
+0 B
WebGPU 820.19
221.32
820.85
221.46
+653 B
+140 B
WebGPU Nodes 819.7
221.19
820.36
221.32
+653 B
+137 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 463.82
112.17
463.82
112.17
+0 B
+0 B
WebGPU 541.03
146.24
541.68
146.38
+654 B
+143 B
WebGPU Nodes 497.03
136.06
497.68
136.21
+654 B
+145 B

@sunag sunag changed the title WebGPURenderer: copyFramebufferToTexture - support for post-rendering use WebGPURenderer: copyFramebufferToTexture - support for post-rendering usage Oct 23, 2024
@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 23, 2024

I'm testing with a WebGPU port of webgl_framebuffer_texture: https://jsfiddle.net/g0ahteof/1/

With this PR, I get the following runtime error with WebGPU:

Uncaught TypeError: Failed to execute 'copyTextureToTexture' on 'GPUCommandEncoder': Value is not of type 'unsigned long'.
    at WebGPUBackend.copyFramebufferToTexture (WebGPUBackend.js:1524:1)
    at WebGPURenderer.copyFramebufferToTexture (Renderer.js:1316:1)
    at Animation.animate [as animationLoop] (webgl_framebuffer_texture:186:14)
    at update (Animation.js:27:1)

The WebGL backend produces no error but the top left view is empty (so the copy does not work yet).

@sunag
Copy link
Collaborator Author

sunag commented Oct 23, 2024

The last commit fix the WebGPUBackend but seems that y-axis is fliped.

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 28, 2024

When I flip the uv coordinates of the sprite which displays the FramebufferTexture, the result is as expected. I'm using:

sprite.geometry = flipY( sprite.geometry );

function flipY( geometry ) {

	const uv = geometry.attributes.uv;

	for ( let i = 0; i < uv.count; i ++ ) {

		uv.setY( i, 1 - uv.getY( i ) );

	}

	return geometry;

}

@sunag sunag marked this pull request as ready for review October 30, 2024 01:02
@sunag
Copy link
Collaborator Author

sunag commented Oct 30, 2024

I would like to revisit this function of the API soon, there are still some revisions related to color outputs that need to be done.

@sunag sunag merged commit 09c38ab into mrdoob:dev Oct 30, 2024
12 checks passed
@sunag sunag deleted the dev-copyFramebufferToTexture branch October 30, 2024 01:22
@mrdoob mrdoob added this to the r170 milestone Oct 30, 2024
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.

WebGPURenderer: copyFramebufferToTexture() is broken when called outside of render().
3 participants