|
|
@@ -1744,7 +1744,6 @@ const ColorManagement = {
|
|
|
|
|
|
};
|
|
|
|
|
|
-
|
|
|
function SRGBToLinear( c ) {
|
|
|
|
|
|
return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
|
|
|
@@ -16013,13 +16012,6 @@ function WebGLCapabilities( gl, extensions, parameters, utils ) {
|
|
|
const logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;
|
|
|
const reverseDepthBuffer = parameters.reverseDepthBuffer === true && extensions.has( 'EXT_clip_control' );
|
|
|
|
|
|
- if ( reverseDepthBuffer === true ) {
|
|
|
-
|
|
|
- const ext = extensions.get( 'EXT_clip_control' );
|
|
|
- ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
const maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );
|
|
|
const maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );
|
|
|
const maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );
|
|
|
@@ -20614,7 +20606,6 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
const programs = [];
|
|
|
|
|
|
const logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;
|
|
|
- const reverseDepthBuffer = capabilities.reverseDepthBuffer;
|
|
|
const SUPPORTS_VERTEX_TEXTURES = capabilities.vertexTextures;
|
|
|
|
|
|
let precision = capabilities.precision;
|
|
|
@@ -20709,6 +20700,7 @@ function WebGLPrograms( renderer, cubemaps, cubeuvmaps, extensions, capabilities
|
|
|
}
|
|
|
|
|
|
const currentRenderTarget = renderer.getRenderTarget();
|
|
|
+ const reverseDepthBuffer = renderer.state.buffers.depth.getReversed();
|
|
|
|
|
|
const IS_INSTANCEDMESH = object.isInstancedMesh === true;
|
|
|
const IS_BATCHEDMESH = object.isBatchedMesh === true;
|
|
|
@@ -22740,7 +22732,7 @@ const reversedFuncs = {
|
|
|
[ GreaterEqualDepth ]: LessEqualDepth,
|
|
|
};
|
|
|
|
|
|
-function WebGLState( gl ) {
|
|
|
+function WebGLState( gl, extensions ) {
|
|
|
|
|
|
function ColorBuffer() {
|
|
|
|
|
|
@@ -22814,10 +22806,36 @@ function WebGLState( gl ) {
|
|
|
|
|
|
setReversed: function ( value ) {
|
|
|
|
|
|
+ if ( reversed !== value ) {
|
|
|
+
|
|
|
+ const ext = extensions.get( 'EXT_clip_control' );
|
|
|
+
|
|
|
+ if ( reversed ) {
|
|
|
+
|
|
|
+ ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.ZERO_TO_ONE_EXT );
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ ext.clipControlEXT( ext.LOWER_LEFT_EXT, ext.NEGATIVE_ONE_TO_ONE_EXT );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const oldDepth = currentDepthClear;
|
|
|
+ currentDepthClear = null;
|
|
|
+ this.setClear( oldDepth );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
reversed = value;
|
|
|
|
|
|
},
|
|
|
|
|
|
+ getReversed: function () {
|
|
|
+
|
|
|
+ return reversed;
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
setTest: function ( depthTest ) {
|
|
|
|
|
|
if ( depthTest ) {
|
|
|
@@ -22913,6 +22931,12 @@ function WebGLState( gl ) {
|
|
|
|
|
|
if ( currentDepthClear !== depth ) {
|
|
|
|
|
|
+ if ( reversed ) {
|
|
|
+
|
|
|
+ depth = 1 - depth;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
gl.clearDepth( depth );
|
|
|
currentDepthClear = depth;
|
|
|
|
|
|
@@ -22927,6 +22951,7 @@ function WebGLState( gl ) {
|
|
|
currentDepthMask = null;
|
|
|
currentDepthFunc = null;
|
|
|
currentDepthClear = null;
|
|
|
+ reversed = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -23897,6 +23922,9 @@ function WebGLState( gl ) {
|
|
|
|
|
|
gl.depthMask( true );
|
|
|
gl.depthFunc( gl.LESS );
|
|
|
+
|
|
|
+ depthBuffer.setReversed( false );
|
|
|
+
|
|
|
gl.clearDepth( 1 );
|
|
|
|
|
|
gl.stencilMask( 0xffffffff );
|
|
|
@@ -28896,6 +28924,7 @@ class WebGLRenderer {
|
|
|
preserveDrawingBuffer = false,
|
|
|
powerPreference = 'default',
|
|
|
failIfMajorPerformanceCaveat = false,
|
|
|
+ reverseDepthBuffer = false,
|
|
|
} = parameters;
|
|
|
|
|
|
this.isWebGLRenderer = true;
|
|
|
@@ -29114,9 +29143,13 @@ class WebGLRenderer {
|
|
|
|
|
|
capabilities = new WebGLCapabilities( _gl, extensions, parameters, utils );
|
|
|
|
|
|
- state = new WebGLState( _gl );
|
|
|
+ state = new WebGLState( _gl, extensions );
|
|
|
+
|
|
|
+ if ( capabilities.reverseDepthBuffer && reverseDepthBuffer ) {
|
|
|
|
|
|
- if ( capabilities.reverseDepthBuffer ) state.buffers.depth.setReversed( true );
|
|
|
+ state.buffers.depth.setReversed( true );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
info = new WebGLInfo( _gl );
|
|
|
properties = new WebGLProperties();
|
|
|
@@ -29420,7 +29453,6 @@ class WebGLRenderer {
|
|
|
if ( depth ) {
|
|
|
|
|
|
bits |= _gl.DEPTH_BUFFER_BIT;
|
|
|
- _gl.clearDepth( this.capabilities.reverseDepthBuffer ? 0 : 1 );
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -30804,7 +30836,9 @@ class WebGLRenderer {
|
|
|
|
|
|
// common camera uniforms
|
|
|
|
|
|
- if ( capabilities.reverseDepthBuffer ) {
|
|
|
+ const reverseDepthBuffer = state.buffers.depth.getReversed();
|
|
|
+
|
|
|
+ if ( reverseDepthBuffer ) {
|
|
|
|
|
|
_currentProjectionMatrix.copy( camera.projectionMatrix );
|
|
|
|