@@ -426,20 +426,33 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
426426 } ;
427427
428428 // Renders myself
429+ publicAPI . renderForPass = ( renderEncoder , depthOnly = false ) => {
430+ model . depthOnlyPass = depthOnly ;
431+ publicAPI . prepareToDraw ( renderEncoder ) ;
432+ model . renderEncoder . registerDrawCallback ( model . pipeline , publicAPI . draw ) ;
433+ model . depthOnlyPass = false ;
434+ } ;
435+
429436 publicAPI . translucentPass = ( prepass ) => {
430437 if ( prepass ) {
431- publicAPI . prepareToDraw ( model . WebGPURenderer . getRenderEncoder ( ) ) ;
432- model . renderEncoder . registerDrawCallback ( model . pipeline , publicAPI . draw ) ;
438+ publicAPI . renderForPass ( model . WebGPURenderer . getRenderEncoder ( ) ) ;
433439 }
434440 } ;
435441
436442 publicAPI . opaquePass = ( prepass ) => {
437443 if ( prepass ) {
438- publicAPI . prepareToDraw ( model . WebGPURenderer . getRenderEncoder ( ) ) ;
439- model . renderEncoder . registerDrawCallback ( model . pipeline , publicAPI . draw ) ;
444+ publicAPI . renderForPass ( model . WebGPURenderer . getRenderEncoder ( ) ) ;
440445 }
441446 } ;
442447
448+ publicAPI . zBufferPass = ( prepass ) => {
449+ if ( prepass ) {
450+ publicAPI . renderForPass ( model . WebGPURenderer . getRenderEncoder ( ) , true ) ;
451+ }
452+ } ;
453+
454+ publicAPI . opaqueZBufferPass = ( prepass ) => publicAPI . zBufferPass ( prepass ) ;
455+
443456 publicAPI . updateUBO = ( ) => {
444457 const actor = model . WebGPUActor . getRenderable ( ) ;
445458 const ppty = actor . getProperty ( ) ;
@@ -621,6 +634,18 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
621634 primitive : {
622635 cullMode : publicAPI . getCullMode ( ) ,
623636 } ,
637+ ...( model . depthOnlyPass
638+ ? {
639+ fragment : {
640+ targets : [
641+ {
642+ format : 'rgba16float' ,
643+ writeMask : 0 ,
644+ } ,
645+ ] ,
646+ } ,
647+ }
648+ : { } ) ,
624649 } ) ;
625650
626651 publicAPI . getCoincidentParameters = ( ) => {
@@ -1545,6 +1570,9 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
15451570 let pipelineHash = `pd${ model . useRendererMatrix ? 'r' : '' } ${
15461571 model . forceZValue ? 'z' : ''
15471572 } `;
1573+ if ( model . depthOnlyPass ) {
1574+ pipelineHash += 'd' ;
1575+ }
15481576
15491577 if (
15501578 model . primitiveType === PrimitiveTypes . TriangleEdges ||
@@ -1622,6 +1650,7 @@ function vtkWebGPUCellArrayMapper(publicAPI, model) {
16221650// ----------------------------------------------------------------------------
16231651
16241652const DEFAULT_VALUES = {
1653+ depthOnlyPass : false ,
16251654 is2D : false ,
16261655 cellArray : null ,
16271656 currentInput : null ,
0 commit comments