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: incorrect texture dimensions in shaders #29851

Open
vlucendo opened this issue Nov 9, 2024 · 2 comments
Open

WebGPURenderer: incorrect texture dimensions in shaders #29851

vlucendo opened this issue Nov 9, 2024 · 2 comments
Labels

Comments

@vlucendo
Copy link
Contributor

vlucendo commented Nov 9, 2024

Description

When creating a texture node from a Rendertarget's texture and resizing it via .setSize, the texture size is not recognized by wgsl shaders when doing textureDimensions(...).

Reproduction steps

  1. Create a texture node from a RenderTarget's texture
  2. Create a wgsl shader that makes use of that texture node
  3. Make the shader behave in different ways depending on the size of the texture. It's always the same even if the size of the RenderTarget changes.

Code

See fiddle

Live example

  • WebGPURenderer - The color of the sphere should change from white to pink every 500ms, but it stays the same

Screenshots

No response

Version

r170

Device

Desktop

Browser

Chrome

OS

Windows

@Mugen87 Mugen87 added the TSL Three.js Shading Language label Nov 11, 2024
@sunag sunag added WebGPU and removed TSL Three.js Shading Language labels Nov 12, 2024
@sunag
Copy link
Collaborator

sunag commented Nov 12, 2024

The RenderTarget is not updated while it is not rendered, in normal situations this should not happen since the resized RenderTarget will need to be re-rendered after resized, otherwise it would return an empty texture.

const nScene = new THREE.Scene();
...

rt.setSize(size, size);

renderer.setRenderTarget( rt );
renderer.render( nScene, camera );
renderer.setRenderTarget( null );

@vlucendo
Copy link
Contributor Author

vlucendo commented Nov 13, 2024

Oh I see, thanks. My issue still shows up when I am trying to create a custom postprocessing node based on the code at: examples/jsm/tsl/display/SMAANode.js but using wgslFn instead.

When creating the node seems the input scene pass gets wrapped into a RTTNode, and when I use this node as a uniform for the shader that performs the operations, the correct texture size is only recognized at the first render.

Here's a minimal fiddle of what I'm experiencing: Custom postprocessing fiddle (overlay should go from red to yellow, but stays red)

I wonder if I'm missing something or if there's something not updating as expected internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants