-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
enable mrt on array texture and texture3d render targets #30151
base: dev
Are you sure you want to change the base?
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
||
for ( let i = 0; i < renderTarget.textures.length; i ++ ) { | ||
|
||
_gl.framebufferTextureLayer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0 + i, textureProperties.__webglTexture, activeMipmapLevel || 0, layer + i ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't layer + i
be layer
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
without the "+ i" it would attach the same layer of the texture to all COLOR_ATTACHMENTs. This way it will attach layer on ATTACHMENT0, layer + 1 on ATTACHMENT1 etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it's not so intuitive to implicitly offset the bound layer for each MRT-attached 3d texture. I think this should be set to layer
as Renaud has suggested under the assumption that each MRT texture is different.
And if there's a strong use case that requires binding different layers of the same 3d texture with MRT then that should be discussed in a separate issue so each layer is user-configurable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gkjohnson this was the only way that it would work with no changes/additions to the three api. We could have explicit assignment of layers to attachments by also allowing an array of indices as the layer argument. I can do the change but is this something that would be acceptable for the WebGLRenderer @Mugen87 ?
@gkjohnson turns out that 3d and array textures can be drawn with MRT without any change in the renderer at all. This way is as flexible as you want it to be. I've updated the example for reference, here's the snippet
|
This may work but generally the project shouldn't be promoting directly setting gl state separately from the renderer since it can result in state conflicts. As mentioned in #30151 (comment) I think we can adjust 3d textures so MRT is supported in alignment with the existing three.js APIs. And then a more practical use case for binding separate 3d texture layers for MRT should be described either here or in another issue so we can discuss what an API for binding different layers might look like. The demo added in this PR feels more like a toy demonstration so I'm curious to how this would be used in a real world use case. |
@gkjohnson the state will be fine as long as you restore it when done rendering. The demo is indeed a toy because I based it on the existing single layer example which doesn't make sense in the first place, it's just meant to showcase. The practical use case is GPGPU and I'm working on something delicious |
turns out that 3d and array textures can be drawn with MRT without any change in the renderer and this way is as flexible as you want it to be. I've updated the example for reference and uploaded using vanilla three on github pages,
here's the relevant snippet