@@ -370,7 +370,7 @@ class Renderer {
370370 const lightsNode = renderList . lightsNode ;
371371
372372 if ( this . opaque === true && opaqueObjects . length > 0 ) this . _renderObjects ( opaqueObjects , camera , sceneRef , lightsNode ) ;
373- if ( this . transparent === true && transparentObjects . length > 0 ) this . _renderObjects ( transparentObjects , camera , sceneRef , lightsNode ) ;
373+ if ( this . transparent === true && transparentObjects . length > 0 ) this . _renderTransparents ( transparentObjects , camera , sceneRef , lightsNode ) ;
374374
375375 // restore render tree
376376
@@ -452,7 +452,7 @@ class Renderer {
452452
453453 const opaqueObjects = renderList . opaque ;
454454
455- if ( opaqueObjects . length > 0 ) this . _renderObjects ( opaqueObjects , camera , sceneRef , lightsNode ) ;
455+ if ( this . opaque === true && opaqueObjects . length > 0 ) this . _renderObjects ( opaqueObjects , camera , sceneRef , lightsNode ) ;
456456
457457 this . _currentRenderBundle = null ;
458458
@@ -728,13 +728,14 @@ class Renderer {
728728 const {
729729 bundles,
730730 lightsNode,
731+ transparentDoublePass : transparentDoublePassObjects ,
731732 transparent : transparentObjects ,
732733 opaque : opaqueObjects
733734 } = renderList ;
734735
735736 if ( bundles . length > 0 ) this . _renderBundles ( bundles , sceneRef , lightsNode ) ;
736737 if ( this . opaque === true && opaqueObjects . length > 0 ) this . _renderObjects ( opaqueObjects , camera , sceneRef , lightsNode ) ;
737- if ( this . transparent === true && transparentObjects . length > 0 ) this . _renderObjects ( transparentObjects , camera , sceneRef , lightsNode ) ;
738+ if ( this . transparent === true && transparentObjects . length > 0 ) this . _renderTransparents ( transparentObjects , transparentDoublePassObjects , camera , sceneRef , lightsNode ) ;
738739
739740 // finish render pass
740741
@@ -1438,7 +1439,47 @@ class Renderer {
14381439
14391440 }
14401441
1441- _renderObjects ( renderList , camera , scene , lightsNode ) {
1442+ _renderTransparents ( renderList , doublePassList , camera , scene , lightsNode ) {
1443+
1444+ if ( doublePassList . length > 0 ) {
1445+
1446+ // render back side
1447+
1448+ for ( const { material } of doublePassList ) {
1449+
1450+ material . side = BackSide ;
1451+
1452+ }
1453+
1454+ this . _renderObjects ( doublePassList , camera , scene , lightsNode , 'backSide' ) ;
1455+
1456+ // render front side
1457+
1458+ for ( const { material } of doublePassList ) {
1459+
1460+ material . side = FrontSide ;
1461+
1462+ }
1463+
1464+ this . _renderObjects ( renderList , camera , scene , lightsNode ) ;
1465+
1466+ // restore
1467+
1468+ for ( const { material } of doublePassList ) {
1469+
1470+ material . side = DoubleSide ;
1471+
1472+ }
1473+
1474+ } else {
1475+
1476+ this . _renderObjects ( renderList , camera , scene , lightsNode ) ;
1477+
1478+ }
1479+
1480+ }
1481+
1482+ _renderObjects ( renderList , camera , scene , lightsNode , passId = null ) {
14421483
14431484 // process renderable objects
14441485
@@ -1472,23 +1513,23 @@ class Renderer {
14721513
14731514 this . backend . updateViewport ( this . _currentRenderContext ) ;
14741515
1475- this . _currentRenderObjectFunction ( object , scene , camera2 , geometry , material , group , lightsNode ) ;
1516+ this . _currentRenderObjectFunction ( object , scene , camera2 , geometry , material , group , lightsNode , passId ) ;
14761517
14771518 }
14781519
14791520 }
14801521
14811522 } else {
14821523
1483- this . _currentRenderObjectFunction ( object , scene , camera , geometry , material , group , lightsNode ) ;
1524+ this . _currentRenderObjectFunction ( object , scene , camera , geometry , material , group , lightsNode , passId ) ;
14841525
14851526 }
14861527
14871528 }
14881529
14891530 }
14901531
1491- renderObject ( object , scene , camera , geometry , material , group , lightsNode ) {
1532+ renderObject ( object , scene , camera , geometry , material , group , lightsNode , passId = null ) {
14921533
14931534 let overridePositionNode ;
14941535 let overrideFragmentNode ;
@@ -1570,13 +1611,13 @@ class Renderer {
15701611 this . _handleObjectFunction ( object , material , scene , camera , lightsNode , group , 'backSide' ) ; // create backSide pass id
15711612
15721613 material . side = FrontSide ;
1573- this . _handleObjectFunction ( object , material , scene , camera , lightsNode , group ) ; // use default pass id
1614+ this . _handleObjectFunction ( object , material , scene , camera , lightsNode , group , passId ) ; // use default pass id
15741615
15751616 material . side = DoubleSide ;
15761617
15771618 } else {
15781619
1579- this . _handleObjectFunction ( object , material , scene , camera , lightsNode , group ) ;
1620+ this . _handleObjectFunction ( object , material , scene , camera , lightsNode , group , passId ) ;
15801621
15811622 }
15821623
0 commit comments