-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
Enhance WebGPU partial update texture example with random size option in GUI #30456
base: dev
Are you sure you want to change the base?
Conversation
…render target support
The approach used here uses more operations than necessary. In order to render to the render target in the first place you're already having to upload the data texture to the GPU which means you can render it directly to the target texture anyway. You can use a full screen quad and There shouldn't be reason to include a new render target or use "copyTextureToTexture". |
@gkjohnson Sorry I think i'm missing something with your approach.. I think it work only if the final texture is a RenderTarget no ? : renderer.setViewport( x, y, size, size );
renderer.render( rtQuad, rtCamera, rt ); // <-- we need a RenderTarget here , it will not work with a loaded texture for example ?
renderer.setViewport( 0, 0, window.innerWidth, window.innerHeight ); |
Oh I see, now, a normal texture is being targeted. Generally there's no reason why we shouldn't be able to bind a normal texture to a depth-less framebuffer and use it as a render surface for this kind of thing (and it will likely be needed for custom mip map generation in the future, see #29779) but this is something for the future, I suppose.
Can you make a PR with what you've tried? Perhaps others can help provide some insight on how this can be done more cleanly. I'd prefer to see a solution built into copyTextureToTexture if this is going to be considered a use case. Relatedly - can you explain what you're using this for in your application just so I have some more context? |
It was to draw texts & illustration texture into other texture to create customized "cards", it could have been done by drawing into rt, but i naturally though to copyTextureToTexture as the name of the function make it sounds perfect to do it. Maybe in the doc the alternative to use rt might be added ? Another usage I was thinking would be to draw into dynamic textureAtlas, but as you say it could be done using rt. |
@gkjohnson should I close this ? |
Yeah in my opinion I don't think we need an example on how to render to a render target and then copy. Rendering to a render target is demonstrated in many other areas. I'd prefer to see an enhancement to copy texture to texture if we're going to add something like this. |
Related issue: #30420
Description
Improve the example by adding the "Random Size" option to show how to use copyTextureToTexture when you want to resize your texture.
--
For context : I tried to add this functionality into the core of copyTexture2Texture but it was looking ugly on the WebGPURenderer and I think its better to put this showcase in this example.