@@ -15,7 +15,7 @@ import {
15
15
CLEARFLAG_COLOR , CLEARFLAG_DEPTH , CLEARFLAG_STENCIL ,
16
16
CULLFACE_BACK , CULLFACE_FRONT , CULLFACE_FRONTANDBACK , CULLFACE_NONE ,
17
17
FILTER_LINEAR , FILTER_NEAREST ,
18
- FUNC_ALWAYS , FUNC_LESS ,
18
+ FUNC_ALWAYS , FUNC_LESS , FUNC_LESSEQUAL ,
19
19
PIXELFORMAT_DEPTH , PIXELFORMAT_R8_G8_B8_A8 , PIXELFORMAT_RGBA16F , PIXELFORMAT_RGBA32F ,
20
20
PRIMITIVE_TRIANGLES ,
21
21
SEMANTIC_ATTR , SEMANTIC_POSITION ,
@@ -1813,7 +1813,16 @@ Object.assign(ForwardRenderer.prototype, {
1813
1813
}
1814
1814
device . setColorWrite ( material . redWrite , material . greenWrite , material . blueWrite , material . alphaWrite ) ;
1815
1815
device . setDepthWrite ( material . depthWrite ) ;
1816
- device . setDepthTest ( material . depthTest ) ;
1816
+
1817
+ // this fixes the case where the user wishes to turn off depth testing but wants to write depth
1818
+ if ( material . depthWrite && ! material . depthTest ) {
1819
+ device . setDepthFunc ( FUNC_ALWAYS ) ;
1820
+ device . setDepthTest ( true ) ;
1821
+ } else {
1822
+ device . setDepthFunc ( FUNC_LESSEQUAL ) ;
1823
+ device . setDepthTest ( material . depthTest ) ;
1824
+ }
1825
+
1817
1826
device . setAlphaToCoverage ( material . alphaToCoverage ) ;
1818
1827
1819
1828
if ( material . depthBias || material . slopeDepthBias ) {
0 commit comments