Skip to content

Commit c0553ae

Browse files
mrdoobclaude
andcommitted
WebGLOutput: Add DepthTexture to scene render target
Attach a DepthTexture to the primary render target so post-processing effects passed to setEffects() can read scene depth. Also fix a missing dispose call for the depth texture. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 87c407b commit c0553ae

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/renderers/webgl/WebGLOutput.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Float32BufferAttribute } from '../../core/BufferAttribute.js';
1515
import { RawShaderMaterial } from '../../materials/RawShaderMaterial.js';
1616
import { Mesh } from '../../objects/Mesh.js';
1717
import { OrthographicCamera } from '../../cameras/OrthographicCamera.js';
18+
import { DepthTexture } from '../../textures/DepthTexture.js';
1819
import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
1920
import { ColorManagement } from '../../math/ColorManagement.js';
2021

@@ -34,7 +35,8 @@ function WebGLOutput( type, width, height, depth, stencil ) {
3435
const targetA = new WebGLRenderTarget( width, height, {
3536
type: type,
3637
depthBuffer: depth,
37-
stencilBuffer: stencil
38+
stencilBuffer: stencil,
39+
depthTexture: depth ? new DepthTexture( width, height ) : undefined
3840
} );
3941

4042
const targetB = new WebGLRenderTarget( width, height, {
@@ -255,6 +257,7 @@ function WebGLOutput( type, width, height, depth, stencil ) {
255257

256258
this.dispose = function () {
257259

260+
if ( targetA.depthTexture ) targetA.depthTexture.dispose();
258261
targetA.dispose();
259262
targetB.dispose();
260263
geometry.dispose();

0 commit comments

Comments
 (0)