How to write to zbuffer only with three.js

老子叫甜甜 提交于 2019-12-24 13:45:03

问题


I'm trying to use thee.js to only update the zbuffer (I'm using preserveDrawingBuffer to create a trace effect). However I can't find any way to only write to the zbuffer with the standard materials, so far I've tried:

  • setting the material's visible to false, which stops the object rendering.
  • setting the material's opacity to 0.0, which means nothing gets rendered.

Is there a 'standard' way of doing this, or do I need to use a custom fragment shader?


回答1:


You can render to the depth buffer only using the following pattern.

renderer.context.colorMask( false, false, false, false ); // don't update color buffer
renderer.render( scene1, camera ); // first scene

renderer.context.colorMask( true, true, true, true );
renderer.render( scene2, camera ); // second scene

three.js r.71



来源:https://stackoverflow.com/questions/31515966/how-to-write-to-zbuffer-only-with-three-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!