-
-
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
Add possibility to bind 3D textures and 2D textures array as color attachment to framebuffer #20111
Conversation
It would be better if I could fit the render target in the already existing |
Yes, I was thinking that. I wonder if it would be possible to just have a single Not sure if that would work for |
As a first step in this process, how about removing this hack:
Make |
@Mugen87 Yep! I guess if we give that a go we'll have a better picture of whether the idea is viable or not. |
@DavidPeicho Do you want to investigate this or should I have a look? 😇 |
100% what I was thinking. Doing that makes it much easier to have any texture attached as a render target.
Not sure yet, I have to check! I am not sure you can multisample a 3D texture.
I can give it a look. I will need your opinions on some stuff obviously especially regarding the API. So let me try to use the original |
I think I would start with a fresh PR which only introduces |
Wouldn't it be better to try to also migrate I feel the concept of render target should be dissociated from the texture type it has. It's obviously hard now to make that without a breaking change, but we can keep the current behavior and maybe add
|
Not sure if we can do this change for backwards compatibility reasons. Keep in mind that users create instances of I would focus on integrating |
Yes, that's why I was thinking about maybe letting the user set its own |
First try: #20182 |
Okay great, thanks! I tried to re-work the more general case, allowing Basically, now you can set your texture via: const renderTargetTexture = new THREE.DataTexture2DArray();
renderTargetTexture.format = ...;
renderTargetTexture.type = ...;
const rt = new THREE.WebGLRenderTarget();
rt.setTexture( renderTargetTexture );
rt.setSize( 100, 100, 50 ); This sounds pretty reasonable to me. It doesn't introduce any API break change. The few things I am not 100% fan are:
function WebGLRenderTarget( width, height, options ) {
if ( !isNaN( options ) ) {
this.depth = options;
}
...
}
|
dbd25ea
to
53fe881
Compare
I actually found today that using ANGLE, rendering to 3D textures will fail on a layer != 0. I tried on a Windows machine and it failed. Links: |
Any news on how you want me to proceed API-wise? |
|
||
if ( renderTarget ) { | ||
|
||
isRenderTarget3D = renderTarget.is3D(); |
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.
Instead of adding is3D
to WebGLRenderTarget
I think I would rather add the code here:
isRenderTarget3D = renderTarget.texture.isDataTexture3D || renderTarget.texture.isDataTexture2DArray;
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'll see if I can resolve the change and fix this on my end.
Aaaand merged. Thanks! |
@DavidPeicho Seems like it's black though... https://raw.githack.com/mrdoob/three.js/dev/examples/webgl2_rendertarget_texture2darray.html |
Hi! I will have a look in the next fews days. I let that on the side because of the bug in ANGLE. I will fix the black screen no worries |
Thanks! |
Hi,
This PR includes the changes:
WebGLLayeredRenderTarget
⟶ adds the possibility to render to 3d texture and 2d texture arrays.WebGLRenderer.setRenderTarget
to choose the layer to which the rendering should occurWebGLLayeredRenderTarget
. The example is simply based on the Texture 2D array example, and is mostly useful for debugging. In the future, I can replace it with something fancier.Why?
Having the possibility to render to volume allows for instance to:
Improvements
There are a couple of things that aren't nice and look pretty dirty for now:
WebGLLayeredRenderTarget
could call this function.WebGLRenderTarget
is made to only acceptTexture
.activeCubeFace
as the layer selector. I believe it could makes sense maybe to have a separate function for cube / layered render target?Let me know what you think. I know this is delicate because it touches to some of the internals.