未验证 提交 79735437 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #17136 from gkjohnson/fix-mask-pass

MaskPass: Add stencil state locking in MaskPass effect
......@@ -55,6 +55,7 @@ THREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE );
state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff );
state.buffers.stencil.setClear( clearValue );
state.buffers.stencil.setLocked( true );
// draw into the stencil buffer
......@@ -73,8 +74,10 @@ THREE.MaskPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ),
// only render where stencil is set to 1
state.buffers.stencil.setLocked( false );
state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );
state.buffers.stencil.setLocked( true );
}
......@@ -95,6 +98,7 @@ Object.assign( THREE.ClearMaskPass.prototype, {
render: function ( renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
renderer.state.buffers.stencil.setLocked( false );
renderer.state.buffers.stencil.setTest( false );
}
......
......@@ -58,6 +58,7 @@ MaskPass.prototype = Object.assign( Object.create( Pass.prototype ), {
state.buffers.stencil.setOp( context.REPLACE, context.REPLACE, context.REPLACE );
state.buffers.stencil.setFunc( context.ALWAYS, writeValue, 0xffffffff );
state.buffers.stencil.setClear( clearValue );
state.buffers.stencil.setLocked( true );
// draw into the stencil buffer
......@@ -76,8 +77,10 @@ MaskPass.prototype = Object.assign( Object.create( Pass.prototype ), {
// only render where stencil is set to 1
state.buffers.stencil.setLocked( false );
state.buffers.stencil.setFunc( context.EQUAL, 1, 0xffffffff ); // draw if == 1
state.buffers.stencil.setOp( context.KEEP, context.KEEP, context.KEEP );
state.buffers.stencil.setLocked( true );
}
......@@ -98,6 +101,7 @@ Object.assign( ClearMaskPass.prototype, {
render: function ( renderer /*, writeBuffer, readBuffer, deltaTime, maskActive */ ) {
renderer.state.buffers.stencil.setLocked( false );
renderer.state.buffers.stencil.setTest( false );
}
......
......@@ -215,13 +215,17 @@ function WebGLState( gl, extensions, utils, capabilities ) {
setTest: function ( stencilTest ) {
if ( stencilTest ) {
if ( ! locked ) {
enable( gl.STENCIL_TEST );
if ( stencilTest ) {
} else {
enable( gl.STENCIL_TEST );
} else {
disable( gl.STENCIL_TEST );
disable( gl.STENCIL_TEST );
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册