Skip to content

WebGLRenderer: add copyFramebufferToTexture3D()#21734

Draft
DavidPeicho wants to merge 5 commits intomrdoob:devfrom
DavidPeicho:feature/copy-framebuffer-texture3d
Draft

WebGLRenderer: add copyFramebufferToTexture3D()#21734
DavidPeicho wants to merge 5 commits intomrdoob:devfrom
DavidPeicho:feature/copy-framebuffer-texture3d

Conversation

@DavidPeicho
Copy link
Copy Markdown
Contributor

Description

This PR adds support to copy from the framebuffer to a 3D texture at a given offset. This is similar to the already existing copyFramebufferToTexture.

@Mugen87 Mugen87 added this to the r129 milestone Apr 30, 2021
@DavidPeicho
Copy link
Copy Markdown
Contributor Author

Any chance this gets merged before the next release cycle? ❤️

@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented May 11, 2021

Definitely!

May I ask again for also adding an example of usage though? 😇

@DavidPeicho
Copy link
Copy Markdown
Contributor Author

I thought I could sneak under the example 🏴‍☠️ Let me add one yes 😄

@DavidPeicho DavidPeicho changed the title WebGLRenderer: add copyFramebufferToTexture3D() WIP: WebGLRenderer: add copyFramebufferToTexture3D() May 14, 2021
@DavidPeicho
Copy link
Copy Markdown
Contributor Author

Okay I went a bit crazy on the example but I am doing a simple shadow volume. It will use the copyFramebufferToTexture3D() method obviously.

Might be a good idea to take the cloud shader out maybe? I am using it here as well and we have like 3 examples with their own version. I need a slight modification here I can hide that beyond some #define maybe

@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented May 27, 2021

Is this still WIP?

@Mugen87 Mugen87 changed the title WIP: WebGLRenderer: add copyFramebufferToTexture3D() WebGLRenderer: add copyFramebufferToTexture3D() May 27, 2021
@DavidPeicho
Copy link
Copy Markdown
Contributor Author

The example isn't ready yet. If we want to merge I should maybe split that into two PRs.

Important note: copyFramebufferToTexture3D doesn't work with ANGLE backend. It's the same bug preventing to render to texture 3D. More info here.

I will add a note in the doc as well concerning that issue.

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented May 27, 2021

In this case let's convert it into a draft PR for now.

@Mugen87 Mugen87 marked this pull request as draft May 27, 2021 08:03
@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented May 27, 2021

@DavidPeicho Sorry for pushing this to the next release. I think it'd be good to have some clarity regarding ANGLE.

@mrdoob mrdoob modified the milestones: r129, r130 May 27, 2021
@mrdoob
Copy link
Copy Markdown
Owner

mrdoob commented May 27, 2021

@kenrussell Is this the same issue as #21893?

@kenrussell
Copy link
Copy Markdown

@mrdoob sorry for delay replying - no, this is a different problem. It's KhronosGroup/WebGL#2558 , https://crbug.com/1131224 , and https://crbug.com/angleproject/5009 .

It should be possible to work around this by using the same kind of texture everywhere - i.e., TEXTURE_2D_ARRAY for both the color and depth attachments. Is that feasible?

@DavidPeicho
Copy link
Copy Markdown
Contributor Author

DavidPeicho commented Jun 12, 2021

@kenrussell Thanks for replying. The goal of this particular PR was to implement a generic method to copy from a framebuffer attachement with layers, so TEXTURE_3D or TEXTURE_2D_ARRAY . The day the bug is fixed in ANGLE basically we can give this method to users.

On a personal note (not related to Three.js), I can't use TEXTURE_2D_ARRAY. I technically could, but the entire medical pipeline I worked on is based on TEXTURE_3D.

In the meantime, we can keep this PR on stall until the bug is fixed. Otherwise, I guess we could add a disclaimer in the doc saying it doesn't work with the ANGLE backend. I understand though if you don't want to do that @mrdoob and if you prefer to just wait

@mrdoob mrdoob modified the milestones: r130, r131 Jun 30, 2021
@mrdoob mrdoob modified the milestones: r131, r132 Jul 28, 2021
@mrdoob mrdoob modified the milestones: r132, r133 Aug 26, 2021
@mrdoob mrdoob added this to the r149 milestone Dec 22, 2022
@mrdoob mrdoob modified the milestones: r149, r150 Jan 26, 2023
@mrdoob mrdoob modified the milestones: r150, r151 Feb 23, 2023
@mrdoob mrdoob modified the milestones: r151, r152 Mar 30, 2023
@mrdoob mrdoob modified the milestones: r152, r153 Apr 27, 2023
@Mugen87 Mugen87 modified the milestones: r153, r154 Jun 1, 2023
@mrdoob mrdoob modified the milestones: r154, r155 Jun 29, 2023
@mrdoob mrdoob modified the milestones: r155, r156 Jul 27, 2023
@mrdoob mrdoob modified the milestones: r156, r157 Aug 31, 2023
@mrdoob mrdoob modified the milestones: r157, r158 Sep 28, 2023
@mrdoob mrdoob modified the milestones: r158, r159 Oct 27, 2023
@mrdoob mrdoob modified the milestones: r159, r160 Nov 30, 2023
@mrdoob mrdoob modified the milestones: r160, r161 Dec 22, 2023
@mrdoob mrdoob modified the milestones: r161, r162 Jan 31, 2024
@gkjohnson
Copy link
Copy Markdown
Collaborator

Just coming across this - with the recent changes to copyTextureToTexture it's not possible to copy data between both 2d and 3d render target textures and normal textures. It seems like it should handle this use case? This line:

renderer.copyFramebufferToTexture3D( srcPos, dstPos, shadowVolume.texture );

would turn into:

renderer.copyTextureToTexture( shadowRenderTarget.texture, shadowVolume.texture, box_bounds_2d, dst_pos_3d );

Looking at FramebufferTexture and copyFramebufferToTexture it seems the use cases basically encompass a subset of what you can do with copyTextureToTexture, now, aside from copying data from the screen buffer (ie setting the active render target to null). I'm wondering if we can remove the FramebufferTexture functions / classes with another change or two?

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.

5 participants