如何在不清除以前的渲染通道的情况下应用后处理的EffectComposer渲染通道?

时间:2019-04-16 15:29:26

标签: three.js 3d render post-processing

在three.js中,我的背景有一个红色的平面,前景中有一个旋转的白色立方体。我试图将 "=IF(VLOOKUP($A2,'Refined Raw'!$A:$AH,6,false)=0,"""",VLOOKUP($A2,'Refined Raw'!$A:$AH,6,false))" 添加到多维数据集,同时保持背景平面不变。但是,添加TAARenderPass(以及TAARenderPassBokehPass和其他常见的后处理效果)会清除其后面的所有内容,并且红色平面消失。

我在这里已经研究了类似的问题,并尝试了SAOPassrenderer.setClearColor( 0x000000, 0 )renderer.autoClear = false。这就是现在所有设置的方式:

renderer.autoClearColor = false

有完整的CodePen here

注释 renderer = new THREE.WebGLRenderer( { alpha: true, antialias: true } ); renderer.setPixelRatio( window.devicePixelRatio ); renderer.setSize( window.innerWidth, window.innerHeight ); renderer.setClearColor( 0x000000, 0 ); document.body.appendChild( renderer.domElement ); // EffectComposer const params = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat, stencilBuffer: false }; const renderTarget = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, params ); effectComposer = new THREE.EffectComposer( renderer , renderTarget ); effectComposer.setSize( window.innerWidth, window.innerHeight ); // Render Passes const renderPassBg = new THREE.RenderPass( sceneBg , camera ); const renderPassFg = new THREE.RenderPass( sceneFg , camera ); renderPassFg.clear = false; const taaRenderPass = new THREE.TAARenderPass( sceneFg, camera ); taaRenderPass.clear = false; const copyPass = new THREE.ShaderPass( THREE.CopyShader ); copyPass.renderToScreen = true; effectComposer.addPass( renderPassBg ); effectComposer.addPass( renderPassFg ); // effectComposer.addPass( taaRenderPass ); effectComposer.addPass( copyPass ); 时,一切正常(减去后处理效果)。但是删除注释后,只有白色立方体会呈现。

如何使红色平面渲染到effectComposer.addPass( taaRenderPass )之后?谢谢!

1 个答案:

答案 0 :(得分:0)

您可以尝试在taa通过之前将copyPass插入renderToScreen = false吗?