Originally did a PR for it but turns out that we can render 3D and texture arrays with MRT without any modifications to the WebGLRenderer. I made a demo to showcase
Demo - https://wizgrav.github.io/three-mrt/
Code snippet:
function renderTo3DTexture() {
// this sets layer 0 to COLOR_ATTACHMENT0
renderer.setRenderTarget( renderTarget );
const gl = renderer.getContext();
const drawBuffersArray = [ gl.COLOR_ATTACHMENT0 ];
const glTexture = renderer.properties.get( renderTarget.texture ).__webglTexture;
// set the rest of the layers to the corresponding attachments
for ( let i = 1; i < 4; i ++ ) {
gl.framebufferTextureLayer( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, glTexture, 0, i );
drawBuffersArray.push( gl.COLOR_ATTACHMENT0 + i );
}
// set draw buffers state for MRT
gl.drawBuffers( drawBuffersArray );
renderer.render( postProcessScene, postProcessCamera );
// restore draw buffers state
gl.drawBuffers( [ gl.COLOR_ATTACHMENT0 ] );
renderer.setRenderTarget( null );
}