WebGPUTextureRenderer: Get Depth buffer as TextureNode
See original GitHub issueIs your feature request related to a problem? Please describe.
For advanced post-processing with a fullscreen quad like in the webgpu_rtt.html example, it is also necessary to have access to the depth buffer of the Rendertarget from the WebGPUTextureRenderer. If I did not miss anything, it is currently not possible to access the depth buffer.
Describe the solution you’d like
It would be great to have something for the WebGPUTextureRenderer like:
let depthTextureNode = new Nodes.TextureNode( textureRenderer.getDepthTexture() );
Describe alternatives you’ve considered
Similar as in the webgl_depth_texture.html example, I tried to get a DepthTexture
from a RenderTarget, which didn´t work:
//create a WebGPUTextureRenderer and set a DepthTexture
textureRenderer = new WebGPUTextureRenderer(renderer);
textureRenderer.setSize(window.innerWidth * window.devicePixelRatio, window.innerHeight * window.devicePixelRatio);
let depthTexture = new THREE.DepthTexture();
textureRenderer.renderTarget.texture.minFilter = THREE.NearestFilter;
textureRenderer.renderTarget.texture.magFilter = THREE.NearestFilter;
textureRenderer.renderTarget.stencilBuffer = false;
textureRenderer.renderTarget.depthTexture = depthTexture;
textureRenderer.renderTarget.depthTexture.format = THREE.DepthFormat;
textureRenderer.renderTarget.depthTexture.type = THREE.UnsignedShortType;
// set up FX
cameraFX = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
sceneFX = new THREE.Scene();
const geometryFX = new THREE.PlaneGeometry(2, 2);
const materialFX = new Nodes.MeshBasicNodeMaterial({
side: THREE.DoubleSide
});
// this returns an error: "Multiple aspects selected in [TextureView] While validating [BindGroupDescriptor] against [BindGroupLayout]"
materialFX.colorNode = new Nodes.OperatorNode( '*', new Nodes.TextureNode( textureRenderer.renderTarget.depthTexture ), new Nodes.ColorNode( new THREE.Color("green") ) );
const quad = new THREE.Mesh(geometryFX, materialFX);
sceneFX.add(quad);
Additional context
@sunag , maybe you could have a look at this? Many thanks in advance!
Issue Analytics
- State:
- Created 2 years ago
- Comments:13 (4 by maintainers)
Top GitHub Comments
Many thanks, I’ll try it out today!
@geolehmann No problems, anyway it’s important to have some examples using WGSL with textures.