Просмотр исходного кода

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>
Mr.doob 2 недель назад
Родитель
Сommit
c0553ae696
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      src/renderers/webgl/WebGLOutput.js

+ 4 - 1
src/renderers/webgl/WebGLOutput.js

@@ -15,6 +15,7 @@ import { Float32BufferAttribute } from '../../core/BufferAttribute.js';
 import { RawShaderMaterial } from '../../materials/RawShaderMaterial.js';
 import { Mesh } from '../../objects/Mesh.js';
 import { OrthographicCamera } from '../../cameras/OrthographicCamera.js';
+import { DepthTexture } from '../../textures/DepthTexture.js';
 import { WebGLRenderTarget } from '../WebGLRenderTarget.js';
 import { ColorManagement } from '../../math/ColorManagement.js';
 
@@ -34,7 +35,8 @@ function WebGLOutput( type, width, height, depth, stencil ) {
 	const targetA = new WebGLRenderTarget( width, height, {
 		type: type,
 		depthBuffer: depth,
-		stencilBuffer: stencil
+		stencilBuffer: stencil,
+		depthTexture: depth ? new DepthTexture( width, height ) : undefined
 	} );
 
 	const targetB = new WebGLRenderTarget( width, height, {
@@ -255,6 +257,7 @@ function WebGLOutput( type, width, height, depth, stencil ) {
 
 	this.dispose = function () {
 
+		if ( targetA.depthTexture ) targetA.depthTexture.dispose();
 		targetA.dispose();
 		targetB.dispose();
 		geometry.dispose();

粤ICP备19079148号