XRManager: Fix layer color correction.#31124
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
What exactly triggers the reallocation? I initially thought it's the different resolution of the layers since a resize triggers a dispose of the render target. But I didn't see in the code that the renderer is sized to the layer's render target resolution. Shouldn't there something like below be placed in renderer.setPixelRatio( 1 );
renderer.setSize( layer.renderTarget.width, layer.renderTarget.height, false );This entire situation with XR layers is a bit special since normally the output pass is one of the very last bits of a rendering pipeline that processes the entire image. That is unfortunately not true here. Ideally we could compose the entire XR image and then run the output pass but that doesn't work. As you mentioned there are multiple solutions for this problem:
|
_getFrameBufferTarget has a
Yes, I tried doing this last week but ran into more problems.
Yeah, I assumed that was a non-starter
I also tried this and got a bit further. One issue I ran into was that the multiview logic gets triggered. It likely points to an error in that codepath. I'll look more into this.
It requires quite a bit of changes on the Quest browser side but I got most of those done already. |
It's not obvious to me that any extension or browser changes would be needed to take the image formation code (exposure, tone mapping, conversion to output color space) and relocate it from a separate pass into the material fragment shaders. Possibly I've misunderstood something? |
Addresses comment from @mrdoob
@Mugen87 , this "fixes" the problem but still has bad performance. The issue seems to be coming from the single _frameBufferTarget in the renderer, as well as its single _quad.
Because of the single target, textures and shaders get reallocated constantly. Because of the single fixed size quad, the layers get rendered to a texture that is too big in the first pass.
Maybe we can give each layer its own renderer or maybe we can fix the renderer so it correctly caches/reallocates the resources for the second pass.