EffectComposer 第二遍“覆盖"第一关 [英] EffectComposer second pass "overwrites" first pass
问题描述
我想在背景上渲染纹理,在前景中渲染 3dscene.我使用 effectcomposer 来做到这一点.
i want to render a texture on the background and the 3dscene in the foreground. i used the effectcomposer to do this.
我的第一遍(背景)似乎被第二遍(场景)覆盖"了,结果只有场景被绘制成黑色背景.看起来第二遍的背景没有绘制透明或透明度丢失.
how ever my first pass (the background) seems to be "overwritten" with the 2nd pass (the scene) the result only the scene gets drawn with a black background. it looks like the background of the second pass isnt drawn transparent or the transparancy is lost.
http://jsfiddle.net/mdwzx1f8/8/
var renderTex = new THREE.TexturePass(myTex);
var renderScene = new THREE.RenderPass(scene, camera);
composer.addPass(renderTex);
composer.addPass(renderScene);
var effectCopy = new THREE.ShaderPass(THREE.CopyShader);
effectCopy.renderToScreen = true;
composer.addPass(effectCopy);
我希望有人可以快速浏览一下并指出正确的方向
i hope someone can take a quick look at it and point me in the right direction
提前致谢
更新:
07/07/2015
我尝试使用 renderer.clear(false, true, false); 清除 zbuffer;
I tried clearing the zbuffer with renderer.clear(false, true, false);
找到了一篇关于遮罩的帖子,我看过但没有添加到
据我所知,threejs
https://github.com/mrdoob/three.js/issues/2448
Found a post on masking which i looked at but it wasnt added to
threejs as far as i can tell
https://github.com/mrdoob/three.js/issues/2448
08/07/2015
- 发现另一个有趣的页面 https://github.com/mrdoob/three.js/问题/5979 不确定这是否相关
- 如果您评论第 53 行,则更新了小提琴,您将看到第一遍,如果场景背景绘制为透明,则应该可见
推荐答案
threejs irc 频道中的 Bobafett 帮我解决了,他发现了我的问题,结果我打电话给:renderer.autoClear = false;
而是 onrenderer.autoClearColor = false;
Bobafett in the threejs irc channel helped me out and he found my issue, it turns out that i called:
renderer.autoClear = false;
instead onrenderer.autoClearColor = false;
这是修改后的工作小提琴:http://jsfiddle.net/mdwzx1f8/9/
Here is the modified and working fiddle: http://jsfiddle.net/mdwzx1f8/9/
感谢所有帮助我寻找解决方案的人
I would like to thank all who have helped me in the search for the solution
这篇关于EffectComposer 第二遍“覆盖"第一关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!