问题
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