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
WebGLRenderer: Calling "copyTextureToTexture" on an unused WebGLRenderTarget does nothing #28282
Comments
From what I understand, it can't work that way because your target.texture doesn't exist yet. |
What I'm suggesting is that the render target initialization should happen in the copyTextureToTexture if it hasn't happened already. What I have currently is more of a workaround. |
To do this you would also have to pass the renderTarget, scene and camera to copyTextureToTexture and then the 3 lines are executed in copyTextureToTexture. I personally don't think that's a good solution. |
It's actually not necessary to render the scene. Just setting the render target once (and then remove it so it is not bound) is sufficient to make sure In const renderTargetProperties = properties.get( renderTarget );
if ( renderTargetProperties.__webglFramebuffer === undefined ) {
textures.setupRenderTarget( renderTarget );
} But since you pass in a texture to |
Therefore the renderTarget should be able to be passed to copyTextureToTexture. You can do that and then check whether the renderTarget was also passed, but is that also wanted for a function called copyTextureToTexture? This is probably purely a matter of taste. It wouldn't bother me but I don't think it's necessary. There is a certain irony in the fact that passing renderTargets to readRenderTargetPixels in webgl instead of textures in readRenderTargetPixelsAsync for webgpu makes the issue #22403 so complicated. Precisely because it is handled so elementary in the node system and only textures are passed, it was quickly solvable very clean even for me, who is not that deep into the system code. |
I noticed this when looking through the code. In #28285 I've updated const target = new WebGLRenderTarget( 1, 1 );
// doesn't work because render target is uninitialized
renderer.copyTextureToTexture( box, position, srcTexture, target.texture );
// works because the render target can be initialized
renderer.copyTextureToTexture( box, position, srcTexture, target ); Maybe it's because my background is from Unity years ago (which had a RenderTexture API that extended from Texture) but I always found it odd that WebGLRenderTarget was considered separate and not usable in the same way as a three.js Texture and this might be a moment where thats surfacing. In my mind it makes sense to be able to use them interchangeably but I know there are larger architecture and implementations considerations that make this more difficult. |
As mentioned in #28285 (comment)
|
Description
Found during #28281
If you call
copyTextureToTexture
to copy data into a RenderTarget that hasn't been rendered to, yet, then nothing occurs and an error is logged:Reproduction steps
Code
Live example
https://jsfiddle.net/2yakmh60/3/
Screenshots
No response
Version
dev
Device
Desktop
Browser
Chrome
OS
MacOS
The text was updated successfully, but these errors were encountered: