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: Support for access previous frame textures using pass() #29069

Merged
merged 9 commits into from
Aug 6, 2024

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented Aug 5, 2024

Related issue: #29058 (comment)

Description

Add support for accessing previous textures, without needing special configuration, just like the syntax below:

const scenePass = pass( scene, camera );

const currentTexture = scenePass.getTextureNode();
const previousTexture = scenePass.getPreviousTextureNode();

postProcessing.outputNode = mix( currentTexture, previousTexture, .5 ); // simple motion blur

@sunag sunag added this to the r168 milestone Aug 5, 2024
Copy link

github-actions bot commented Aug 5, 2024

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
685.1 kB (169.6 kB) 685.1 kB (169.6 kB) +0 B

🌳 Bundle size after tree-shaking

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

Filesize dev Filesize PR Diff
462 kB (111.5 kB) 462 kB (111.5 kB) +0 B

@sunag sunag changed the title WebGPURenderer: Support for previous frame textures WebGPURenderer: Support for access previous frame textures using pass() Aug 5, 2024
@sunag
Copy link
Collaborator Author

sunag commented Aug 6, 2024

Several revisions have been made, now MRT is working on WebGLBackend as shown in the screenshots.

@sunag sunag marked this pull request as ready for review August 6, 2024 04:55
@sunag sunag merged commit fffc941 into mrdoob:dev Aug 6, 2024
12 checks passed
@sunag sunag deleted the dev-pass-previous branch August 6, 2024 04:56
@cmhhelgeson
Copy link
Contributor

cmhhelgeson commented Aug 6, 2024

I'm getting an error on this code ( just modifying the after image sample ):

const scenePass = pass( scene, camera );
const scenePassColor = scenePass.getTextureNode();
const scenePassPrevColor = scenePass.getPreviousTextureNode();

// combinedPass = scenePassColor;
// combinedPass = combinedPass.afterImage( params.damp );

postProcessing.outputNode = scenePassPrevColor; //combinedPass;
three.js.examples.-.Google.Chrome.2024-08-05.23-05-57.mp4

Full error is as follows. As expected, the error and flickering goes away when antialiasing is turned off since the default sample count for the WebGPUBackend is 1.

The depth stencil attachment [TextureView of Texture "depth"] sample count (4) does not match the sample count of the other attachments (1).
 - While validating depthStencilAttachment.
 - While encoding [CommandEncoder "renderContext_1"].BeginRenderPass([null]).

@sunag
Copy link
Collaborator Author

sunag commented Aug 6, 2024

I think it is { antialias: true }, WebGPURenderer does not yet fully support this

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.

2 participants