three.js icon indicating copy to clipboard operation
three.js copied to clipboard

WebGLRenderer: add copyFramebufferToTexture3D()

Open DavidPeicho opened this issue 4 years ago • 12 comments

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.

DavidPeicho avatar Apr 27 '21 18:04 DavidPeicho

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

DavidPeicho avatar May 11 '21 11:05 DavidPeicho

Definitely!

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

mrdoob avatar May 11 '21 18:05 mrdoob

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

DavidPeicho avatar May 11 '21 19:05 DavidPeicho

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

DavidPeicho avatar May 15 '21 09:05 DavidPeicho

Is this still WIP?

mrdoob avatar May 27 '21 01:05 mrdoob

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.

DavidPeicho avatar May 27 '21 07:05 DavidPeicho

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

Mugen87 avatar May 27 '21 08:05 Mugen87

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

mrdoob avatar May 27 '21 08:05 mrdoob

@kenrussell Is this the same issue as #21893?

mrdoob avatar May 27 '21 08:05 mrdoob

@mrdoob sorry for delay replying - no, this is a different problem. It's https://github.com/KhronosGroup/WebGL/issues/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?

kenrussell avatar Jun 11 '21 23:06 kenrussell

@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

DavidPeicho avatar Jun 12 '21 16:06 DavidPeicho