Hi all,
I’m trying to get a depth texture that contains only opaque objects and color texture contains all. I do as follows:
let target = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight );
target.texture.minFilter = THREE.NearestFilter;
target.texture.magFilter = THREE.NearestFilter;
target.depthTexture = new THREE.DepthTexture();
target.depthTexture.format = THREE.DepthFormat;
target.depthTexture.type = THREE.UnsignedShortType;
//set transparent objects material.depthWrite = false
renderer.setRenderTarget(renderTarget);
renderer.render(scene, camera);
// reset transparent objects material.depthWrite
In this way, I can get desired depth texture and color(only drew the scene once).The only problem is transparent objects will be drawn in the wrong order.
So there is a way to get the depth texture with opaque objects and draw the transparent component correctly(It’s better to draw scene only once)?
Any help greatly appreciated!