From 2eadf8554c56985351b1e59213c6ce3ebaced7e2 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 19 Sep 2019 14:57:09 -0400 Subject: [PATCH 01/14] Rename framebuffer to _framebuffer and add getter --- Source/Scene/GlobeDepth.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index f65cb5974f5..99651646b0a 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -2,6 +2,7 @@ define([ '../Core/BoundingRectangle', '../Core/Color', '../Core/defined', + '../Core/defineProperties', '../Core/destroyObject', '../Core/PixelFormat', '../Renderer/ClearCommand', @@ -24,6 +25,7 @@ define([ BoundingRectangle, Color, defined, + defineProperties, destroyObject, PixelFormat, ClearCommand, @@ -54,7 +56,7 @@ define([ this._tempGlobeDepthTexture = undefined; this._tempCopyDepthTexture = undefined; - this.framebuffer = undefined; + this._framebuffer = undefined; this._copyDepthFramebuffer = undefined; this._tempCopyDepthFramebuffer = undefined; this._updateDepthFramebuffer = undefined; @@ -78,6 +80,14 @@ define([ this._debugGlobeDepthViewportCommand = undefined; } + defineProperties(GlobeDepth.prototype, { + framebuffer : { + get : function() { + return this._framebuffer; + } + } + }); + function executeDebugGlobeDepth(globeDepth, context, passState, useLogDepth) { if (!defined(globeDepth._debugGlobeDepthViewportCommand) || useLogDepth !== globeDepth._useLogDepth) { var fsSource = @@ -120,7 +130,7 @@ define([ } function destroyFramebuffers(globeDepth) { - globeDepth.framebuffer = globeDepth.framebuffer && !globeDepth.framebuffer.isDestroyed() && globeDepth.framebuffer.destroy(); + globeDepth._framebuffer = globeDepth._framebuffer && !globeDepth._framebuffer.isDestroyed() && globeDepth._framebuffer.destroy(); globeDepth._copyDepthFramebuffer = globeDepth._copyDepthFramebuffer && !globeDepth._copyDepthFramebuffer.isDestroyed() && globeDepth._copyDepthFramebuffer.destroy(); } @@ -197,7 +207,7 @@ define([ } function createFramebuffers(globeDepth, context) { - globeDepth.framebuffer = new Framebuffer({ + globeDepth._framebuffer = new Framebuffer({ context : context, colorTextures : [globeDepth._colorTexture], depthStencilTexture : globeDepth._depthStencilTexture, @@ -214,7 +224,7 @@ define([ function updateFramebuffers(globeDepth, context, width, height, hdr) { var colorTexture = globeDepth._colorTexture; var textureChanged = !defined(colorTexture) || colorTexture.width !== width || colorTexture.height !== height || hdr !== globeDepth._useHdr; - if (!defined(globeDepth.framebuffer) || textureChanged) { + if (!defined(globeDepth._framebuffer) || textureChanged) { destroyTextures(globeDepth); destroyFramebuffers(globeDepth); createTextures(globeDepth, context, width, height, hdr); @@ -328,7 +338,7 @@ define([ }); } - globeDepth._clearColorCommand.framebuffer = globeDepth.framebuffer; + globeDepth._clearColorCommand.framebuffer = globeDepth._framebuffer; } GlobeDepth.prototype.executeDebugGlobeDepth = function(context, passState, useLogDepth) { From 0fbebf71c3781a392f0b7e67c9231d292cabc8b9 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Thu, 19 Sep 2019 18:17:04 -0400 Subject: [PATCH 02/14] WIP fix multifrustum artifacts and pickPosition accuracy --- Source/Scene/GlobeDepth.js | 127 +++++++++++++++++++++++++++++++------ Source/Scene/PickDepth.js | 21 ++++-- Source/Scene/Scene.js | 24 ++++++- 3 files changed, 146 insertions(+), 26 deletions(-) diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index 99651646b0a..4e4b233289d 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -18,6 +18,7 @@ define([ '../Shaders/PostProcessStages/DepthViewPacked', '../Shaders/PostProcessStages/PassThrough', '../Shaders/PostProcessStages/PassThroughDepth', + './BlendingState', './StencilConstants', './StencilFunction', './StencilOperation' @@ -41,6 +42,7 @@ define([ DepthViewPacked, PassThrough, PassThroughDepth, + BlendingState, StencilConstants, StencilFunction, StencilOperation) { @@ -50,25 +52,30 @@ define([ * @private */ function GlobeDepth() { - this._colorTexture = undefined; + this._globeColorTexture = undefined; + this._primitiveColorTexture = undefined; this._depthStencilTexture = undefined; this._globeDepthTexture = undefined; this._tempGlobeDepthTexture = undefined; this._tempCopyDepthTexture = undefined; - this._framebuffer = undefined; + this._globeColorFramebuffer = undefined; + this._primitiveColorFramebuffer = undefined; this._copyDepthFramebuffer = undefined; this._tempCopyDepthFramebuffer = undefined; this._updateDepthFramebuffer = undefined; - this._clearColorCommand = undefined; + this._clearGlobeColorCommand = undefined; + this._clearPrimitiveColorCommand = undefined; this._copyColorCommand = undefined; this._copyDepthCommand = undefined; this._tempCopyDepthCommand = undefined; this._updateDepthCommand = undefined; + this._mergeColorCommand = undefined; this._viewport = new BoundingRectangle(); this._rs = undefined; + this._rsBlend = undefined; this._rsUpdate = undefined; this._useScissorTest = false; @@ -83,7 +90,12 @@ define([ defineProperties(GlobeDepth.prototype, { framebuffer : { get : function() { - return this._framebuffer; + return this._globeColorFramebuffer; + } + }, + primitiveFramebuffer : { + get : function() { + return this._primitiveColorFramebuffer; } } }); @@ -124,13 +136,15 @@ define([ } function destroyTextures(globeDepth) { - globeDepth._colorTexture = globeDepth._colorTexture && !globeDepth._colorTexture.isDestroyed() && globeDepth._colorTexture.destroy(); + globeDepth._globeColorTexture = globeDepth._globeColorTexture && !globeDepth._globeColorTexture.isDestroyed() && globeDepth._globeColorTexture.destroy(); + globeDepth._primitiveColorTexture = globeDepth._primitiveColorTexture && !globeDepth._primitiveColorTexture.isDestroyed() && globeDepth._primitiveColorTexture.destroy(); globeDepth._depthStencilTexture = globeDepth._depthStencilTexture && !globeDepth._depthStencilTexture.isDestroyed() && globeDepth._depthStencilTexture.destroy(); globeDepth._globeDepthTexture = globeDepth._globeDepthTexture && !globeDepth._globeDepthTexture.isDestroyed() && globeDepth._globeDepthTexture.destroy(); } function destroyFramebuffers(globeDepth) { - globeDepth._framebuffer = globeDepth._framebuffer && !globeDepth._framebuffer.isDestroyed() && globeDepth._framebuffer.destroy(); + globeDepth._globeColorFramebuffer = globeDepth._globeColorFramebuffer && !globeDepth._globeColorFramebuffer.isDestroyed() && globeDepth._globeColorFramebuffer.destroy(); + globeDepth._primitiveColorFramebuffer = globeDepth._primitiveColorFramebuffer && !globeDepth._primitiveColorFramebuffer.isDestroyed() && globeDepth._primitiveColorFramebuffer.destroy(); globeDepth._copyDepthFramebuffer = globeDepth._copyDepthFramebuffer && !globeDepth._copyDepthFramebuffer.isDestroyed() && globeDepth._copyDepthFramebuffer.destroy(); } @@ -169,7 +183,21 @@ define([ function createTextures(globeDepth, context, width, height, hdr) { var pixelDatatype = hdr ? (context.halfFloatingPointTexture ? PixelDatatype.HALF_FLOAT : PixelDatatype.FLOAT) : PixelDatatype.UNSIGNED_BYTE; - globeDepth._colorTexture = new Texture({ + globeDepth._globeColorTexture = new Texture({ + context : context, + width : width, + height : height, + pixelFormat : PixelFormat.RGBA, + pixelDatatype : pixelDatatype, + sampler : new Sampler({ + wrapS : TextureWrap.CLAMP_TO_EDGE, + wrapT : TextureWrap.CLAMP_TO_EDGE, + minificationFilter : TextureMinificationFilter.NEAREST, + magnificationFilter : TextureMagnificationFilter.NEAREST + }) + }); + + globeDepth._primitiveColorTexture = new Texture({ context : context, width : width, height : height, @@ -207,9 +235,16 @@ define([ } function createFramebuffers(globeDepth, context) { - globeDepth._framebuffer = new Framebuffer({ + globeDepth._globeColorFramebuffer = new Framebuffer({ context : context, - colorTextures : [globeDepth._colorTexture], + colorTextures : [globeDepth._globeColorTexture], + depthStencilTexture : globeDepth._depthStencilTexture, + destroyAttachments : false + }); + + globeDepth._primitiveColorFramebuffer = new Framebuffer({ + context : context, + colorTextures : [globeDepth._primitiveColorTexture], depthStencilTexture : globeDepth._depthStencilTexture, destroyAttachments : false }); @@ -222,9 +257,9 @@ define([ } function updateFramebuffers(globeDepth, context, width, height, hdr) { - var colorTexture = globeDepth._colorTexture; + var colorTexture = globeDepth._globeColorTexture; var textureChanged = !defined(colorTexture) || colorTexture.width !== width || colorTexture.height !== height || hdr !== globeDepth._useHdr; - if (!defined(globeDepth._framebuffer) || textureChanged) { + if (!defined(globeDepth._globeColorFramebuffer) || textureChanged) { destroyTextures(globeDepth); destroyFramebuffers(globeDepth); createTextures(globeDepth, context, width, height, hdr); @@ -253,6 +288,15 @@ define([ rectangle : globeDepth._scissorRectangle } }); + globeDepth._rsBlend = RenderState.fromCache({ + viewport : globeDepth._viewport, + scissorTest : { + enabled : globeDepth._useScissorTest, + rectangle : globeDepth._scissorRectangle + }, + blending: BlendingState.ALPHA_BLEND + }); + // Copy packed depth only if the 3D Tiles bit is set globeDepth._rsUpdate = RenderState.fromCache({ viewport : globeDepth._viewport, @@ -293,7 +337,7 @@ define([ globeDepth._copyColorCommand = context.createViewportQuadCommand(PassThrough, { uniformMap : { colorTexture : function() { - return globeDepth._colorTexture; + return globeDepth._globeColorTexture; } }, owner : globeDepth @@ -330,15 +374,39 @@ define([ globeDepth._updateDepthCommand.framebuffer = globeDepth._updateDepthFramebuffer; globeDepth._updateDepthCommand.renderState = globeDepth._rsUpdate; - if (!defined(globeDepth._clearColorCommand)) { - globeDepth._clearColorCommand = new ClearCommand({ + if (!defined(globeDepth._clearGlobeColorCommand)) { + globeDepth._clearGlobeColorCommand = new ClearCommand({ color : new Color(0.0, 0.0, 0.0, 0.0), stencil : 0.0, owner : globeDepth }); } - globeDepth._clearColorCommand.framebuffer = globeDepth._framebuffer; + globeDepth._clearGlobeColorCommand.framebuffer = globeDepth._globeColorFramebuffer; + + if (!defined(globeDepth._clearPrimitiveColorCommand)) { + globeDepth._clearPrimitiveColorCommand = new ClearCommand({ + color : new Color(0.0, 0.0, 0.0, 0.0), + stencil : 0.0, + owner : globeDepth + }); + } + + globeDepth._clearPrimitiveColorCommand.framebuffer = globeDepth._primitiveColorFramebuffer; + + if (!defined(globeDepth._mergeColorCommand)) { + globeDepth._mergeColorCommand = context.createViewportQuadCommand(PassThrough, { + uniformMap : { + colorTexture : function() { + return globeDepth._primitiveColorTexture; + } + }, + owner : globeDepth + }); + } + + globeDepth._mergeColorCommand.framebuffer = globeDepth._globeColorFramebuffer; + globeDepth._mergeColorCommand.renderState = globeDepth._rsBlend; } GlobeDepth.prototype.executeDebugGlobeDepth = function(context, passState, useLogDepth) { @@ -399,12 +467,22 @@ define([ } }; + GlobeDepth.prototype.executeMergeColor = function(context, passState) { + if (defined(this._mergeColorCommand)) { + this._mergeColorCommand.execute(context, passState); + } + }; + GlobeDepth.prototype.clear = function(context, passState, clearColor) { - var clear = this._clearColorCommand; + var clear = this._clearGlobeColorCommand; if (defined(clear)) { Color.clone(clearColor, clear.color); clear.execute(context, passState); } + clear = this._clearPrimitiveColorCommand; + if (defined(clear)) { + clear.execute(context, passState); + } }; GlobeDepth.prototype.isDestroyed = function() { @@ -424,9 +502,20 @@ define([ this._copyDepthCommand.shaderProgram = this._copyDepthCommand.shaderProgram.destroy(); } - var command = this._debugGlobeDepthViewportCommand; - if (defined(command)) { - command.shaderProgram = command.shaderProgram.destroy(); + if (defined(this._tempCopyDepthCommand)) { + this._tempCopyDepthCommand.shaderProgram = this._tempCopyDepthCommand.shaderProgram.destroy(); + } + + if (defined(this._updateDepthCommand)) { + this._updateDepthCommand.shaderProgram = this._updateDepthCommand.shaderProgram.destroy(); + } + + if (defined(this._mergeColorCommand)) { + this._mergeColorCommand.shaderProgram = this._mergeColorCommand.shaderProgram.destroy(); + } + + if (defined(this._debugGlobeDepthViewportCommand)) { + this._debugGlobeDepthViewportCommand.shaderProgram = this._debugGlobeDepthViewportCommand.shaderProgram.destroy(); } return destroyObject(this); diff --git a/Source/Scene/PickDepth.js b/Source/Scene/PickDepth.js index 6e643747762..566c63b0d26 100644 --- a/Source/Scene/PickDepth.js +++ b/Source/Scene/PickDepth.js @@ -112,20 +112,33 @@ define([ } } - function updateCopyCommands(pickDepth, context, depthTexture) { + function updateCopyCommands(pickDepth, context, depthTexture, colorTextureMask) { if (!defined(pickDepth._copyDepthCommand)) { var fs = 'uniform sampler2D u_texture;\n' + + 'uniform sampler2D u_colorTextureMask;\n' + 'varying vec2 v_textureCoordinates;\n' + 'void main()\n' + '{\n' + - ' gl_FragColor = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + + ' float pickDepth = texture2D(u_texture, v_textureCoordinates).r;\n' + + ' bool noColor = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' + + ' if (noColor)\n' + + ' {\n' + + ' gl_FragColor = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + + ' }\n' + + ' else\n' + + ' {\n' + + ' gl_FragColor = czm_packDepth(pickDepth);\n' + + ' }\n' + '}\n'; pickDepth._copyDepthCommand = context.createViewportQuadCommand(fs, { renderState : RenderState.fromCache(), uniformMap : { u_texture : function() { return pickDepth._textureToCopy; + }, + u_colorTextureMask : function() { + return colorTextureMask; } }, owner : pickDepth @@ -140,9 +153,9 @@ define([ executeDebugPickDepth(this, context, passState, useLogDepth); }; - PickDepth.prototype.update = function(context, depthTexture) { + PickDepth.prototype.update = function(context, depthTexture, colorTextureMask) { updateFramebuffers(this, context, depthTexture); - updateCopyCommands(this, context, depthTexture); + updateCopyCommands(this, context, depthTexture, colorTextureMask); }; var scratchPackedDepth = new Cartesian4(); diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 728c5c985e5..2663ac02809 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2240,6 +2240,7 @@ define([ var clearGlobeDepth = environmentState.clearGlobeDepth; var useDepthPlane = environmentState.useDepthPlane; + var usePrimitiveFramebuffer = clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; var clearDepth = scene._depthClearCommand; var clearStencil = scene._stencilClearCommand; var clearClassificationStencil = scene._classificationStencilClearCommand; @@ -2282,6 +2283,11 @@ define([ passState.framebuffer = globeDepth.framebuffer; } + if (usePrimitiveFramebuffer) { + // TODO comment + passState.framebuffer = globeDepth.framebuffer; + } + clearDepth.execute(context, passState); if (context.stencilBuffer) { @@ -2318,6 +2324,11 @@ define([ } } + if (usePrimitiveFramebuffer) { + // TODO comment + passState.framebuffer = globeDepth.primitiveFramebuffer; + } + if (!environmentState.useInvertClassification || picking) { // Common/fastest path. Draw 3D Tiles and classification normally. @@ -2456,7 +2467,7 @@ define([ // PERFORMANCE_IDEA: Use MRT to avoid the extra copy. var depthStencilTexture = renderTranslucentDepthForPick ? passState.framebuffer.depthStencilTexture : globeDepth.framebuffer.depthStencilTexture; var pickDepth = getPickDepth(scene, index); - pickDepth.update(context, depthStencilTexture); + pickDepth.update(context, depthStencilTexture, passState.framebuffer.getColorTexture(0)); pickDepth.executeCopyDepth(context, passState); } @@ -3106,16 +3117,23 @@ define([ var frameState = scene._frameState; var environmentState = scene._environmentState; var view = scene._view; + var globeDepth = view.globeDepth; var useOIT = environmentState.useOIT; var useGlobeDepthFramebuffer = environmentState.useGlobeDepthFramebuffer; + var usePrimitiveFramebuffer = environmentState.clearGlobeDepth && useGlobeDepthFramebuffer; var usePostProcess = environmentState.usePostProcess; var defaultFramebuffer = environmentState.originalFramebuffer; - var globeFramebuffer = useGlobeDepthFramebuffer ? view.globeDepth.framebuffer : undefined; + var globeFramebuffer = useGlobeDepthFramebuffer ? globeDepth.framebuffer : undefined; var sceneFramebuffer = view.sceneFramebuffer.getFramebuffer(); var idFramebuffer = view.sceneFramebuffer.getIdFramebuffer(); + if (usePrimitiveFramebuffer) { + // TODO comment + globeDepth.executeMergeColor(context, passState); + } + if (useOIT) { passState.framebuffer = usePostProcess ? sceneFramebuffer : defaultFramebuffer; view.oit.execute(context, passState); @@ -3137,7 +3155,7 @@ define([ if (!useOIT && !usePostProcess && useGlobeDepthFramebuffer) { passState.framebuffer = defaultFramebuffer; - view.globeDepth.executeCopyColor(context, passState); + globeDepth.executeCopyColor(context, passState); } var useLogDepth = frameState.useLogDepth; From 1af5cc5870bf879aa2f94393adc1788f0f50215f Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 12:17:45 -0400 Subject: [PATCH 03/14] Depth plane fixes, fixed pick position --- Source/Scene/DepthPlane.js | 12 ++++- Source/Scene/GlobeDepth.js | 65 +++++++++++++----------- Source/Scene/PickDepth.js | 89 +++++++++++++++++++++++++++------ Source/Scene/Scene.js | 23 +++++---- Source/Widgets/Viewer/Viewer.js | 4 +- 5 files changed, 135 insertions(+), 58 deletions(-) diff --git a/Source/Scene/DepthPlane.js b/Source/Scene/DepthPlane.js index ebb85625175..c66d7af8b65 100644 --- a/Source/Scene/DepthPlane.js +++ b/Source/Scene/DepthPlane.js @@ -1,4 +1,5 @@ define([ + '../Core/ApproximateTerrainHeights', '../Core/BoundingSphere', '../Core/Cartesian3', '../Core/ComponentDatatype', @@ -18,6 +19,7 @@ define([ '../Shaders/DepthPlaneVS', './SceneMode' ], function( + ApproximateTerrainHeights, BoundingSphere, Cartesian3, ComponentDatatype, @@ -51,15 +53,23 @@ define([ } var depthQuadScratch = FeatureDetection.supportsTypedArrays() ? new Float32Array(12) : []; + var scratchRadii = new Cartesian3(); var scratchCartesian1 = new Cartesian3(); var scratchCartesian2 = new Cartesian3(); var scratchCartesian3 = new Cartesian3(); var scratchCartesian4 = new Cartesian3(); function computeDepthQuad(ellipsoid, frameState) { - var radii = ellipsoid.radii; + var radii = Cartesian3.clone(ellipsoid.radii, scratchRadii); var p = frameState.camera.positionWC; + // This effectively pushes the depth plane farther from the camera so that the depth plane does not render + // above primitives in the scene. + var radiusOffset = -ApproximateTerrainHeights._defaultMinTerrainHeight; + radii.x -= radiusOffset; + radii.y -= radiusOffset; + radii.z -= radiusOffset; + // Find the corresponding position in the scaled space of the ellipsoid. var q = Cartesian3.multiplyComponents(ellipsoid.oneOverRadii, p, scratchCartesian1); diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index 4e4b233289d..ae2c3639b26 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -83,6 +83,7 @@ define([ this._useLogDepth = undefined; this._useHdr = undefined; + this._clearGlobeDepth = undefined; this._debugGlobeDepthViewportCommand = undefined; } @@ -181,7 +182,7 @@ define([ }); } - function createTextures(globeDepth, context, width, height, hdr) { + function createTextures(globeDepth, context, width, height, hdr, clearGlobeDepth) { var pixelDatatype = hdr ? (context.halfFloatingPointTexture ? PixelDatatype.HALF_FLOAT : PixelDatatype.FLOAT) : PixelDatatype.UNSIGNED_BYTE; globeDepth._globeColorTexture = new Texture({ context : context, @@ -197,20 +198,6 @@ define([ }) }); - globeDepth._primitiveColorTexture = new Texture({ - context : context, - width : width, - height : height, - pixelFormat : PixelFormat.RGBA, - pixelDatatype : pixelDatatype, - sampler : new Sampler({ - wrapS : TextureWrap.CLAMP_TO_EDGE, - wrapT : TextureWrap.CLAMP_TO_EDGE, - minificationFilter : TextureMinificationFilter.NEAREST, - magnificationFilter : TextureMagnificationFilter.NEAREST - }) - }); - globeDepth._depthStencilTexture = new Texture({ context : context, width : width, @@ -232,9 +219,25 @@ define([ magnificationFilter : TextureMagnificationFilter.NEAREST }) }); + + if (clearGlobeDepth) { + globeDepth._primitiveColorTexture = new Texture({ + context : context, + width : width, + height : height, + pixelFormat : PixelFormat.RGBA, + pixelDatatype : pixelDatatype, + sampler : new Sampler({ + wrapS : TextureWrap.CLAMP_TO_EDGE, + wrapT : TextureWrap.CLAMP_TO_EDGE, + minificationFilter : TextureMinificationFilter.NEAREST, + magnificationFilter : TextureMagnificationFilter.NEAREST + }) + }); + } } - function createFramebuffers(globeDepth, context) { + function createFramebuffers(globeDepth, context, clearGlobeDepth) { globeDepth._globeColorFramebuffer = new Framebuffer({ context : context, colorTextures : [globeDepth._globeColorTexture], @@ -242,28 +245,31 @@ define([ destroyAttachments : false }); - globeDepth._primitiveColorFramebuffer = new Framebuffer({ - context : context, - colorTextures : [globeDepth._primitiveColorTexture], - depthStencilTexture : globeDepth._depthStencilTexture, - destroyAttachments : false - }); - globeDepth._copyDepthFramebuffer = new Framebuffer({ context : context, colorTextures : [globeDepth._globeDepthTexture], destroyAttachments : false }); + + if (clearGlobeDepth) { + globeDepth._primitiveColorFramebuffer = new Framebuffer({ + context : context, + colorTextures : [globeDepth._primitiveColorTexture], + depthStencilTexture : globeDepth._depthStencilTexture, + destroyAttachments : false + }); + } } - function updateFramebuffers(globeDepth, context, width, height, hdr) { + function updateFramebuffers(globeDepth, context, width, height, hdr, clearGlobeDepth) { var colorTexture = globeDepth._globeColorTexture; - var textureChanged = !defined(colorTexture) || colorTexture.width !== width || colorTexture.height !== height || hdr !== globeDepth._useHdr; + var textureChanged = !defined(colorTexture) || colorTexture.width !== width || colorTexture.height !== height || + hdr !== globeDepth._useHdr || clearGlobeDepth !== globeDepth._clearGlobeDepth; if (!defined(globeDepth._globeColorFramebuffer) || textureChanged) { destroyTextures(globeDepth); destroyFramebuffers(globeDepth); - createTextures(globeDepth, context, width, height, hdr); - createFramebuffers(globeDepth, context); + createTextures(globeDepth, context, width, height, hdr, clearGlobeDepth); + createFramebuffers(globeDepth, context, clearGlobeDepth); } } @@ -413,15 +419,16 @@ define([ executeDebugGlobeDepth(this, context, passState, useLogDepth); }; - GlobeDepth.prototype.update = function(context, passState, viewport, hdr) { + GlobeDepth.prototype.update = function(context, passState, viewport, hdr, clearGlobeDepth) { var width = viewport.width; var height = viewport.height; - updateFramebuffers(this, context, width, height, hdr); + updateFramebuffers(this, context, width, height, hdr, clearGlobeDepth); updateCopyCommands(this, context, width, height, passState); context.uniformState.globeDepthTexture = undefined; this._useHdr = hdr; + this._clearGlobeDepth = clearGlobeDepth; }; GlobeDepth.prototype.executeCopyDepth = function(context, passState) { diff --git a/Source/Scene/PickDepth.js b/Source/Scene/PickDepth.js index 566c63b0d26..bc1cb627a52 100644 --- a/Source/Scene/PickDepth.js +++ b/Source/Scene/PickDepth.js @@ -28,7 +28,10 @@ define([ this._depthTexture = undefined; this._textureToCopy = undefined; + this._colorTextureMask = undefined; this._copyDepthCommand = undefined; + this._copyDepthCommandRender = undefined; + this._copyDepthCommandPick = undefined; this._useLogDepth = undefined; @@ -113,32 +116,77 @@ define([ } function updateCopyCommands(pickDepth, context, depthTexture, colorTextureMask) { + var fs; if (!defined(pickDepth._copyDepthCommand)) { - var fs = + // Passthrough depth copy + fs = 'uniform sampler2D u_texture;\n' + - 'uniform sampler2D u_colorTextureMask;\n' + 'varying vec2 v_textureCoordinates;\n' + 'void main()\n' + '{\n' + - ' float pickDepth = texture2D(u_texture, v_textureCoordinates).r;\n' + - ' bool noColor = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' + - ' if (noColor)\n' + - ' {\n' + - ' gl_FragColor = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + - ' }\n' + - ' else\n' + - ' {\n' + - ' gl_FragColor = czm_packDepth(pickDepth);\n' + - ' }\n' + + ' gl_FragColor = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + '}\n'; pickDepth._copyDepthCommand = context.createViewportQuadCommand(fs, { + renderState : RenderState.fromCache(), + uniformMap : { + u_texture : function() { + return pickDepth._textureToCopy; + } + }, + owner : pickDepth + }); + } + + if (!defined(pickDepth._copyDepthCommandRender)) { + // If alpha is less than one, use globe depth instead of scene depth. Globe depth will overwrite areas where + // there is translucent geometry or no geometry (like the depth plane). + fs = + 'uniform sampler2D u_texture;\n' + + 'uniform sampler2D u_colorTextureMask;\n' + + 'varying vec2 v_textureCoordinates;\n' + + 'void main()\n' + + '{\n' + + ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + + ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + + ' bool mask = texture2D(u_colorTextureMask, v_textureCoordinates).a < 1.0;\n' + + ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + + '}\n'; + pickDepth._copyDepthCommandRender = context.createViewportQuadCommand(fs, { + renderState : RenderState.fromCache(), + uniformMap : { + u_texture : function() { + return pickDepth._textureToCopy; + }, + u_colorTextureMask : function() { + return pickDepth._colorTextureMask; + } + }, + owner : pickDepth + }); + } + + if (!defined(pickDepth._copyDepthCommandPick)) { + // If color is (0,0,0,0), use globe depth instead of scene depth. Globe depth will overwrite areas where + // there is no geometry (like the depth plane). + fs = + 'uniform sampler2D u_texture;\n' + + 'uniform sampler2D u_colorTextureMask;\n' + + 'varying vec2 v_textureCoordinates;\n' + + 'void main()\n' + + '{\n' + + ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + + ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + + ' bool mask = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' + + ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + + '}\n'; + pickDepth._copyDepthCommandPick = context.createViewportQuadCommand(fs, { renderState : RenderState.fromCache(), uniformMap : { u_texture : function() { return pickDepth._textureToCopy; }, u_colorTextureMask : function() { - return colorTextureMask; + return pickDepth._colorTextureMask; } }, owner : pickDepth @@ -146,7 +194,10 @@ define([ } pickDepth._textureToCopy = depthTexture; + pickDepth._colorTextureMask = colorTextureMask; pickDepth._copyDepthCommand.framebuffer = pickDepth._framebuffer; + pickDepth._copyDepthCommandRender.framebuffer = pickDepth._framebuffer; + pickDepth._copyDepthCommandPick.framebuffer = pickDepth._framebuffer; } PickDepth.prototype.executeDebugPickDepth = function(context, passState, useLogDepth) { @@ -175,8 +226,14 @@ define([ return Cartesian4.dot(packedDepth, packedDepthScale); }; - PickDepth.prototype.executeCopyDepth = function(context, passState) { - this._copyDepthCommand.execute(context, passState); + PickDepth.prototype.executeCopyDepth = function(context, passState, copyGlobeDepth, picking) { + if (!copyGlobeDepth) { + this._copyDepthCommand.execute(context, passState); + } else if (picking) { + this._copyDepthCommandPick.execute(context, passState); + } else { + this._copyDepthCommandRender.execute(context, passState); + } }; PickDepth.prototype.isDestroyed = function() { @@ -188,6 +245,8 @@ define([ destroyFramebuffers(this); this._copyDepthCommand.shaderProgram = defined(this._copyDepthCommand.shaderProgram) && this._copyDepthCommand.shaderProgram.destroy(); + this._copyDepthCommandRender.shaderProgram = defined(this._copyDepthCommandRender.shaderProgram) && this._copyDepthCommandRender.shaderProgram.destroy(); + this._copyDepthCommandPick.shaderProgram = defined(this._copyDepthCommandPick.shaderProgram) && this._copyDepthCommandPick.shaderProgram.destroy(); return destroyObject(this); }; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 2663ac02809..0f4566f60c0 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2275,19 +2275,19 @@ define([ var globeDepth = scene.debugShowGlobeDepth ? getDebugGlobeDepth(scene, index) : view.globeDepth; + if (usePrimitiveFramebuffer) { + // Render to globe framebuffer in GLOBE pass + passState.framebuffer = globeDepth.framebuffer; + } + var fb; if (scene.debugShowGlobeDepth && defined(globeDepth) && environmentState.useGlobeDepthFramebuffer) { - globeDepth.update(context, passState, view.viewport); + globeDepth.update(context, passState, view.viewport, scene._hdr, clearGlobeDepth); globeDepth.clear(context, passState, scene._clearColorCommand.color); fb = passState.framebuffer; passState.framebuffer = globeDepth.framebuffer; } - if (usePrimitiveFramebuffer) { - // TODO comment - passState.framebuffer = globeDepth.framebuffer; - } - clearDepth.execute(context, passState); if (context.stencilBuffer) { @@ -2325,7 +2325,7 @@ define([ } if (usePrimitiveFramebuffer) { - // TODO comment + // Render to primitive framebuffer in all other passes passState.framebuffer = globeDepth.primitiveFramebuffer; } @@ -2466,9 +2466,10 @@ define([ if (context.depthTexture && scene.useDepthPicking && (environmentState.useGlobeDepthFramebuffer || renderTranslucentDepthForPick)) { // PERFORMANCE_IDEA: Use MRT to avoid the extra copy. var depthStencilTexture = renderTranslucentDepthForPick ? passState.framebuffer.depthStencilTexture : globeDepth.framebuffer.depthStencilTexture; + var colorTexture = passState.framebuffer.getColorTexture(0); var pickDepth = getPickDepth(scene, index); - pickDepth.update(context, depthStencilTexture, passState.framebuffer.getColorTexture(0)); - pickDepth.executeCopyDepth(context, passState); + pickDepth.update(context, depthStencilTexture, colorTexture); + pickDepth.executeCopyDepth(context, passState, usePrimitiveFramebuffer, picking); } if (picking || !usePostProcessSelected) { @@ -3047,7 +3048,7 @@ define([ // Globe depth is copied for the pick pass to support picking batched geometries in GroundPrimitives. var useGlobeDepthFramebuffer = environmentState.useGlobeDepthFramebuffer = defined(view.globeDepth); if (useGlobeDepthFramebuffer) { - view.globeDepth.update(context, passState, view.viewport, scene._hdr); + view.globeDepth.update(context, passState, view.viewport, scene._hdr, environmentState.clearGlobeDepth); view.globeDepth.clear(context, passState, clearColor); } @@ -3130,7 +3131,7 @@ define([ var idFramebuffer = view.sceneFramebuffer.getIdFramebuffer(); if (usePrimitiveFramebuffer) { - // TODO comment + // Merge primitive framebuffer into globe framebuffer globeDepth.executeMergeColor(context, passState); } diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 70995948182..5ad4aab9101 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -756,8 +756,8 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to that.selectedEntity = pickEntity(that, e); } - cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndSelectObject, ScreenSpaceEventType.LEFT_CLICK); - cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndTrackObject, ScreenSpaceEventType.LEFT_DOUBLE_CLICK); + //cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndSelectObject, ScreenSpaceEventType.LEFT_CLICK); + //cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndTrackObject, ScreenSpaceEventType.LEFT_DOUBLE_CLICK); } defineProperties(Viewer.prototype, { From c421d3efacb916a323cb78193e5ed9f6ccb395eb Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 14:02:21 -0400 Subject: [PATCH 04/14] Only use new approach if there's more than one frustum --- Source/Scene/Scene.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 0f4566f60c0..acd4c5bc2f8 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2238,9 +2238,12 @@ define([ executeTranslucentCommands = executeTranslucentCommandsFrontToBack; } + var frustumCommandsList = view.frustumCommandsList; + var numFrustums = frustumCommandsList.length; + var clearGlobeDepth = environmentState.clearGlobeDepth; var useDepthPlane = environmentState.useDepthPlane; - var usePrimitiveFramebuffer = clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; + var usePrimitiveFramebuffer = (numFrustums > 1) && clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; var clearDepth = scene._depthClearCommand; var clearStencil = scene._stencilClearCommand; var clearClassificationStencil = scene._classificationStencilClearCommand; @@ -2251,9 +2254,6 @@ define([ // Execute commands in each frustum in back to front order var j; - var frustumCommandsList = view.frustumCommandsList; - var numFrustums = frustumCommandsList.length; - for (var i = 0; i < numFrustums; ++i) { var index = numFrustums - i - 1; var frustumCommands = frustumCommandsList[index]; @@ -3119,10 +3119,11 @@ define([ var environmentState = scene._environmentState; var view = scene._view; var globeDepth = view.globeDepth; + var numFrustums = view.frustumCommandsList.length; var useOIT = environmentState.useOIT; var useGlobeDepthFramebuffer = environmentState.useGlobeDepthFramebuffer; - var usePrimitiveFramebuffer = environmentState.clearGlobeDepth && useGlobeDepthFramebuffer; + var usePrimitiveFramebuffer = (numFrustums > 1) && environmentState.clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; var usePostProcess = environmentState.usePostProcess; var defaultFramebuffer = environmentState.originalFramebuffer; From ea7ce15b38c6d1ea87972e772aa26ed86ec41dce Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 15:30:03 -0400 Subject: [PATCH 05/14] Revert depth plane changes --- Source/Scene/DepthPlane.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Source/Scene/DepthPlane.js b/Source/Scene/DepthPlane.js index c66d7af8b65..ebb85625175 100644 --- a/Source/Scene/DepthPlane.js +++ b/Source/Scene/DepthPlane.js @@ -1,5 +1,4 @@ define([ - '../Core/ApproximateTerrainHeights', '../Core/BoundingSphere', '../Core/Cartesian3', '../Core/ComponentDatatype', @@ -19,7 +18,6 @@ define([ '../Shaders/DepthPlaneVS', './SceneMode' ], function( - ApproximateTerrainHeights, BoundingSphere, Cartesian3, ComponentDatatype, @@ -53,23 +51,15 @@ define([ } var depthQuadScratch = FeatureDetection.supportsTypedArrays() ? new Float32Array(12) : []; - var scratchRadii = new Cartesian3(); var scratchCartesian1 = new Cartesian3(); var scratchCartesian2 = new Cartesian3(); var scratchCartesian3 = new Cartesian3(); var scratchCartesian4 = new Cartesian3(); function computeDepthQuad(ellipsoid, frameState) { - var radii = Cartesian3.clone(ellipsoid.radii, scratchRadii); + var radii = ellipsoid.radii; var p = frameState.camera.positionWC; - // This effectively pushes the depth plane farther from the camera so that the depth plane does not render - // above primitives in the scene. - var radiusOffset = -ApproximateTerrainHeights._defaultMinTerrainHeight; - radii.x -= radiusOffset; - radii.y -= radiusOffset; - radii.z -= radiusOffset; - // Find the corresponding position in the scaled space of the ellipsoid. var q = Cartesian3.multiplyComponents(ellipsoid.oneOverRadii, p, scratchCartesian1); From 9d46847ae9f264c3c906c3addfe6fe4081a2ce6e Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 15:31:34 -0400 Subject: [PATCH 06/14] Revert PickDepth --- Source/Scene/PickDepth.js | 84 +++------------------------------ Source/Scene/Scene.js | 5 +- Source/Widgets/Viewer/Viewer.js | 4 +- 3 files changed, 10 insertions(+), 83 deletions(-) diff --git a/Source/Scene/PickDepth.js b/Source/Scene/PickDepth.js index bc1cb627a52..6e643747762 100644 --- a/Source/Scene/PickDepth.js +++ b/Source/Scene/PickDepth.js @@ -28,10 +28,7 @@ define([ this._depthTexture = undefined; this._textureToCopy = undefined; - this._colorTextureMask = undefined; this._copyDepthCommand = undefined; - this._copyDepthCommandRender = undefined; - this._copyDepthCommandPick = undefined; this._useLogDepth = undefined; @@ -115,11 +112,9 @@ define([ } } - function updateCopyCommands(pickDepth, context, depthTexture, colorTextureMask) { - var fs; + function updateCopyCommands(pickDepth, context, depthTexture) { if (!defined(pickDepth._copyDepthCommand)) { - // Passthrough depth copy - fs = + var fs = 'uniform sampler2D u_texture;\n' + 'varying vec2 v_textureCoordinates;\n' + 'void main()\n' + @@ -137,76 +132,17 @@ define([ }); } - if (!defined(pickDepth._copyDepthCommandRender)) { - // If alpha is less than one, use globe depth instead of scene depth. Globe depth will overwrite areas where - // there is translucent geometry or no geometry (like the depth plane). - fs = - 'uniform sampler2D u_texture;\n' + - 'uniform sampler2D u_colorTextureMask;\n' + - 'varying vec2 v_textureCoordinates;\n' + - 'void main()\n' + - '{\n' + - ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + - ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + - ' bool mask = texture2D(u_colorTextureMask, v_textureCoordinates).a < 1.0;\n' + - ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + - '}\n'; - pickDepth._copyDepthCommandRender = context.createViewportQuadCommand(fs, { - renderState : RenderState.fromCache(), - uniformMap : { - u_texture : function() { - return pickDepth._textureToCopy; - }, - u_colorTextureMask : function() { - return pickDepth._colorTextureMask; - } - }, - owner : pickDepth - }); - } - - if (!defined(pickDepth._copyDepthCommandPick)) { - // If color is (0,0,0,0), use globe depth instead of scene depth. Globe depth will overwrite areas where - // there is no geometry (like the depth plane). - fs = - 'uniform sampler2D u_texture;\n' + - 'uniform sampler2D u_colorTextureMask;\n' + - 'varying vec2 v_textureCoordinates;\n' + - 'void main()\n' + - '{\n' + - ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + - ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + - ' bool mask = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' + - ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + - '}\n'; - pickDepth._copyDepthCommandPick = context.createViewportQuadCommand(fs, { - renderState : RenderState.fromCache(), - uniformMap : { - u_texture : function() { - return pickDepth._textureToCopy; - }, - u_colorTextureMask : function() { - return pickDepth._colorTextureMask; - } - }, - owner : pickDepth - }); - } - pickDepth._textureToCopy = depthTexture; - pickDepth._colorTextureMask = colorTextureMask; pickDepth._copyDepthCommand.framebuffer = pickDepth._framebuffer; - pickDepth._copyDepthCommandRender.framebuffer = pickDepth._framebuffer; - pickDepth._copyDepthCommandPick.framebuffer = pickDepth._framebuffer; } PickDepth.prototype.executeDebugPickDepth = function(context, passState, useLogDepth) { executeDebugPickDepth(this, context, passState, useLogDepth); }; - PickDepth.prototype.update = function(context, depthTexture, colorTextureMask) { + PickDepth.prototype.update = function(context, depthTexture) { updateFramebuffers(this, context, depthTexture); - updateCopyCommands(this, context, depthTexture, colorTextureMask); + updateCopyCommands(this, context, depthTexture); }; var scratchPackedDepth = new Cartesian4(); @@ -226,14 +162,8 @@ define([ return Cartesian4.dot(packedDepth, packedDepthScale); }; - PickDepth.prototype.executeCopyDepth = function(context, passState, copyGlobeDepth, picking) { - if (!copyGlobeDepth) { - this._copyDepthCommand.execute(context, passState); - } else if (picking) { - this._copyDepthCommandPick.execute(context, passState); - } else { - this._copyDepthCommandRender.execute(context, passState); - } + PickDepth.prototype.executeCopyDepth = function(context, passState) { + this._copyDepthCommand.execute(context, passState); }; PickDepth.prototype.isDestroyed = function() { @@ -245,8 +175,6 @@ define([ destroyFramebuffers(this); this._copyDepthCommand.shaderProgram = defined(this._copyDepthCommand.shaderProgram) && this._copyDepthCommand.shaderProgram.destroy(); - this._copyDepthCommandRender.shaderProgram = defined(this._copyDepthCommandRender.shaderProgram) && this._copyDepthCommandRender.shaderProgram.destroy(); - this._copyDepthCommandPick.shaderProgram = defined(this._copyDepthCommandPick.shaderProgram) && this._copyDepthCommandPick.shaderProgram.destroy(); return destroyObject(this); }; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index acd4c5bc2f8..7f662a87de4 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2466,10 +2466,9 @@ define([ if (context.depthTexture && scene.useDepthPicking && (environmentState.useGlobeDepthFramebuffer || renderTranslucentDepthForPick)) { // PERFORMANCE_IDEA: Use MRT to avoid the extra copy. var depthStencilTexture = renderTranslucentDepthForPick ? passState.framebuffer.depthStencilTexture : globeDepth.framebuffer.depthStencilTexture; - var colorTexture = passState.framebuffer.getColorTexture(0); var pickDepth = getPickDepth(scene, index); - pickDepth.update(context, depthStencilTexture, colorTexture); - pickDepth.executeCopyDepth(context, passState, usePrimitiveFramebuffer, picking); + pickDepth.update(context, depthStencilTexture); + pickDepth.executeCopyDepth(context, passState); } if (picking || !usePostProcessSelected) { diff --git a/Source/Widgets/Viewer/Viewer.js b/Source/Widgets/Viewer/Viewer.js index 5ad4aab9101..70995948182 100644 --- a/Source/Widgets/Viewer/Viewer.js +++ b/Source/Widgets/Viewer/Viewer.js @@ -756,8 +756,8 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to that.selectedEntity = pickEntity(that, e); } - //cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndSelectObject, ScreenSpaceEventType.LEFT_CLICK); - //cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndTrackObject, ScreenSpaceEventType.LEFT_DOUBLE_CLICK); + cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndSelectObject, ScreenSpaceEventType.LEFT_CLICK); + cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndTrackObject, ScreenSpaceEventType.LEFT_DOUBLE_CLICK); } defineProperties(Viewer.prototype, { From a5f9457fdf61c716f212848b5402f380d96255ec Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 15:39:19 -0400 Subject: [PATCH 07/14] Revert "Revert PickDepth" This reverts commit 9d46847ae9f264c3c906c3addfe6fe4081a2ce6e. --- Source/Scene/PickDepth.js | 84 ++++++++++++++++++++++++++++++++++++--- Source/Scene/Scene.js | 5 ++- 2 files changed, 81 insertions(+), 8 deletions(-) diff --git a/Source/Scene/PickDepth.js b/Source/Scene/PickDepth.js index 6e643747762..bc1cb627a52 100644 --- a/Source/Scene/PickDepth.js +++ b/Source/Scene/PickDepth.js @@ -28,7 +28,10 @@ define([ this._depthTexture = undefined; this._textureToCopy = undefined; + this._colorTextureMask = undefined; this._copyDepthCommand = undefined; + this._copyDepthCommandRender = undefined; + this._copyDepthCommandPick = undefined; this._useLogDepth = undefined; @@ -112,9 +115,11 @@ define([ } } - function updateCopyCommands(pickDepth, context, depthTexture) { + function updateCopyCommands(pickDepth, context, depthTexture, colorTextureMask) { + var fs; if (!defined(pickDepth._copyDepthCommand)) { - var fs = + // Passthrough depth copy + fs = 'uniform sampler2D u_texture;\n' + 'varying vec2 v_textureCoordinates;\n' + 'void main()\n' + @@ -132,17 +137,76 @@ define([ }); } + if (!defined(pickDepth._copyDepthCommandRender)) { + // If alpha is less than one, use globe depth instead of scene depth. Globe depth will overwrite areas where + // there is translucent geometry or no geometry (like the depth plane). + fs = + 'uniform sampler2D u_texture;\n' + + 'uniform sampler2D u_colorTextureMask;\n' + + 'varying vec2 v_textureCoordinates;\n' + + 'void main()\n' + + '{\n' + + ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + + ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + + ' bool mask = texture2D(u_colorTextureMask, v_textureCoordinates).a < 1.0;\n' + + ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + + '}\n'; + pickDepth._copyDepthCommandRender = context.createViewportQuadCommand(fs, { + renderState : RenderState.fromCache(), + uniformMap : { + u_texture : function() { + return pickDepth._textureToCopy; + }, + u_colorTextureMask : function() { + return pickDepth._colorTextureMask; + } + }, + owner : pickDepth + }); + } + + if (!defined(pickDepth._copyDepthCommandPick)) { + // If color is (0,0,0,0), use globe depth instead of scene depth. Globe depth will overwrite areas where + // there is no geometry (like the depth plane). + fs = + 'uniform sampler2D u_texture;\n' + + 'uniform sampler2D u_colorTextureMask;\n' + + 'varying vec2 v_textureCoordinates;\n' + + 'void main()\n' + + '{\n' + + ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + + ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + + ' bool mask = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' + + ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + + '}\n'; + pickDepth._copyDepthCommandPick = context.createViewportQuadCommand(fs, { + renderState : RenderState.fromCache(), + uniformMap : { + u_texture : function() { + return pickDepth._textureToCopy; + }, + u_colorTextureMask : function() { + return pickDepth._colorTextureMask; + } + }, + owner : pickDepth + }); + } + pickDepth._textureToCopy = depthTexture; + pickDepth._colorTextureMask = colorTextureMask; pickDepth._copyDepthCommand.framebuffer = pickDepth._framebuffer; + pickDepth._copyDepthCommandRender.framebuffer = pickDepth._framebuffer; + pickDepth._copyDepthCommandPick.framebuffer = pickDepth._framebuffer; } PickDepth.prototype.executeDebugPickDepth = function(context, passState, useLogDepth) { executeDebugPickDepth(this, context, passState, useLogDepth); }; - PickDepth.prototype.update = function(context, depthTexture) { + PickDepth.prototype.update = function(context, depthTexture, colorTextureMask) { updateFramebuffers(this, context, depthTexture); - updateCopyCommands(this, context, depthTexture); + updateCopyCommands(this, context, depthTexture, colorTextureMask); }; var scratchPackedDepth = new Cartesian4(); @@ -162,8 +226,14 @@ define([ return Cartesian4.dot(packedDepth, packedDepthScale); }; - PickDepth.prototype.executeCopyDepth = function(context, passState) { - this._copyDepthCommand.execute(context, passState); + PickDepth.prototype.executeCopyDepth = function(context, passState, copyGlobeDepth, picking) { + if (!copyGlobeDepth) { + this._copyDepthCommand.execute(context, passState); + } else if (picking) { + this._copyDepthCommandPick.execute(context, passState); + } else { + this._copyDepthCommandRender.execute(context, passState); + } }; PickDepth.prototype.isDestroyed = function() { @@ -175,6 +245,8 @@ define([ destroyFramebuffers(this); this._copyDepthCommand.shaderProgram = defined(this._copyDepthCommand.shaderProgram) && this._copyDepthCommand.shaderProgram.destroy(); + this._copyDepthCommandRender.shaderProgram = defined(this._copyDepthCommandRender.shaderProgram) && this._copyDepthCommandRender.shaderProgram.destroy(); + this._copyDepthCommandPick.shaderProgram = defined(this._copyDepthCommandPick.shaderProgram) && this._copyDepthCommandPick.shaderProgram.destroy(); return destroyObject(this); }; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index 7f662a87de4..acd4c5bc2f8 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2466,9 +2466,10 @@ define([ if (context.depthTexture && scene.useDepthPicking && (environmentState.useGlobeDepthFramebuffer || renderTranslucentDepthForPick)) { // PERFORMANCE_IDEA: Use MRT to avoid the extra copy. var depthStencilTexture = renderTranslucentDepthForPick ? passState.framebuffer.depthStencilTexture : globeDepth.framebuffer.depthStencilTexture; + var colorTexture = passState.framebuffer.getColorTexture(0); var pickDepth = getPickDepth(scene, index); - pickDepth.update(context, depthStencilTexture); - pickDepth.executeCopyDepth(context, passState); + pickDepth.update(context, depthStencilTexture, colorTexture); + pickDepth.executeCopyDepth(context, passState, usePrimitiveFramebuffer, picking); } if (picking || !usePostProcessSelected) { From 13c018aa5ef06edde5f920babfa6eff69899c91a Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Fri, 20 Sep 2019 15:55:50 -0400 Subject: [PATCH 08/14] Update CHANGES --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a660b73f7f9..f2064a3a91b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -24,7 +24,7 @@ Change Log * Fixed per-feature post processing from sometimes selecting the wrong feature. [#7929](https://github.com/AnalyticalGraphicsInc/cesium/pull/7929) * Fixed labels not showing for individual entities in data sources when clustering is enabled. [#6087](https://github.com/AnalyticalGraphicsInc/cesium/issues/6087) * Fixed a crash for 3D Tiles that have zero volume. [#7945](https://github.com/AnalyticalGraphicsInc/cesium/pull/7945) - +* Fixed seam artifacts when log depth is disabled, `scene.globe.depthTestAgainstTerrain` is false, and primitives are under the globe. [#8205](https://github.com/AnalyticalGraphicsInc/cesium/pull/8205) ### 1.61 - 2019-09-03 From 2ce72b5b3f3a139e0c95deb05a95c32b29869874 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 23 Sep 2019 17:21:21 -0400 Subject: [PATCH 09/14] Revert "Revert "Revert PickDepth"" This reverts commit a5f9457fdf61c716f212848b5402f380d96255ec. --- Source/Scene/PickDepth.js | 84 +++------------------------------------ Source/Scene/Scene.js | 5 +-- 2 files changed, 8 insertions(+), 81 deletions(-) diff --git a/Source/Scene/PickDepth.js b/Source/Scene/PickDepth.js index bc1cb627a52..6e643747762 100644 --- a/Source/Scene/PickDepth.js +++ b/Source/Scene/PickDepth.js @@ -28,10 +28,7 @@ define([ this._depthTexture = undefined; this._textureToCopy = undefined; - this._colorTextureMask = undefined; this._copyDepthCommand = undefined; - this._copyDepthCommandRender = undefined; - this._copyDepthCommandPick = undefined; this._useLogDepth = undefined; @@ -115,11 +112,9 @@ define([ } } - function updateCopyCommands(pickDepth, context, depthTexture, colorTextureMask) { - var fs; + function updateCopyCommands(pickDepth, context, depthTexture) { if (!defined(pickDepth._copyDepthCommand)) { - // Passthrough depth copy - fs = + var fs = 'uniform sampler2D u_texture;\n' + 'varying vec2 v_textureCoordinates;\n' + 'void main()\n' + @@ -137,76 +132,17 @@ define([ }); } - if (!defined(pickDepth._copyDepthCommandRender)) { - // If alpha is less than one, use globe depth instead of scene depth. Globe depth will overwrite areas where - // there is translucent geometry or no geometry (like the depth plane). - fs = - 'uniform sampler2D u_texture;\n' + - 'uniform sampler2D u_colorTextureMask;\n' + - 'varying vec2 v_textureCoordinates;\n' + - 'void main()\n' + - '{\n' + - ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + - ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + - ' bool mask = texture2D(u_colorTextureMask, v_textureCoordinates).a < 1.0;\n' + - ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + - '}\n'; - pickDepth._copyDepthCommandRender = context.createViewportQuadCommand(fs, { - renderState : RenderState.fromCache(), - uniformMap : { - u_texture : function() { - return pickDepth._textureToCopy; - }, - u_colorTextureMask : function() { - return pickDepth._colorTextureMask; - } - }, - owner : pickDepth - }); - } - - if (!defined(pickDepth._copyDepthCommandPick)) { - // If color is (0,0,0,0), use globe depth instead of scene depth. Globe depth will overwrite areas where - // there is no geometry (like the depth plane). - fs = - 'uniform sampler2D u_texture;\n' + - 'uniform sampler2D u_colorTextureMask;\n' + - 'varying vec2 v_textureCoordinates;\n' + - 'void main()\n' + - '{\n' + - ' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' + - ' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' + - ' bool mask = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' + - ' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' + - '}\n'; - pickDepth._copyDepthCommandPick = context.createViewportQuadCommand(fs, { - renderState : RenderState.fromCache(), - uniformMap : { - u_texture : function() { - return pickDepth._textureToCopy; - }, - u_colorTextureMask : function() { - return pickDepth._colorTextureMask; - } - }, - owner : pickDepth - }); - } - pickDepth._textureToCopy = depthTexture; - pickDepth._colorTextureMask = colorTextureMask; pickDepth._copyDepthCommand.framebuffer = pickDepth._framebuffer; - pickDepth._copyDepthCommandRender.framebuffer = pickDepth._framebuffer; - pickDepth._copyDepthCommandPick.framebuffer = pickDepth._framebuffer; } PickDepth.prototype.executeDebugPickDepth = function(context, passState, useLogDepth) { executeDebugPickDepth(this, context, passState, useLogDepth); }; - PickDepth.prototype.update = function(context, depthTexture, colorTextureMask) { + PickDepth.prototype.update = function(context, depthTexture) { updateFramebuffers(this, context, depthTexture); - updateCopyCommands(this, context, depthTexture, colorTextureMask); + updateCopyCommands(this, context, depthTexture); }; var scratchPackedDepth = new Cartesian4(); @@ -226,14 +162,8 @@ define([ return Cartesian4.dot(packedDepth, packedDepthScale); }; - PickDepth.prototype.executeCopyDepth = function(context, passState, copyGlobeDepth, picking) { - if (!copyGlobeDepth) { - this._copyDepthCommand.execute(context, passState); - } else if (picking) { - this._copyDepthCommandPick.execute(context, passState); - } else { - this._copyDepthCommandRender.execute(context, passState); - } + PickDepth.prototype.executeCopyDepth = function(context, passState) { + this._copyDepthCommand.execute(context, passState); }; PickDepth.prototype.isDestroyed = function() { @@ -245,8 +175,6 @@ define([ destroyFramebuffers(this); this._copyDepthCommand.shaderProgram = defined(this._copyDepthCommand.shaderProgram) && this._copyDepthCommand.shaderProgram.destroy(); - this._copyDepthCommandRender.shaderProgram = defined(this._copyDepthCommandRender.shaderProgram) && this._copyDepthCommandRender.shaderProgram.destroy(); - this._copyDepthCommandPick.shaderProgram = defined(this._copyDepthCommandPick.shaderProgram) && this._copyDepthCommandPick.shaderProgram.destroy(); return destroyObject(this); }; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index e4fc2dd23f2..a4d767fa789 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2466,10 +2466,9 @@ define([ if (context.depthTexture && scene.useDepthPicking && (environmentState.useGlobeDepthFramebuffer || renderTranslucentDepthForPick)) { // PERFORMANCE_IDEA: Use MRT to avoid the extra copy. var depthStencilTexture = renderTranslucentDepthForPick ? passState.framebuffer.depthStencilTexture : globeDepth.framebuffer.depthStencilTexture; - var colorTexture = passState.framebuffer.getColorTexture(0); var pickDepth = getPickDepth(scene, index); - pickDepth.update(context, depthStencilTexture, colorTexture); - pickDepth.executeCopyDepth(context, passState, usePrimitiveFramebuffer, picking); + pickDepth.update(context, depthStencilTexture); + pickDepth.executeCopyDepth(context, passState); } if (picking || !usePostProcessSelected) { From 6a3fb5431fc43f8cc7422e8b4408245f3cf6c4ea Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Mon, 23 Sep 2019 19:19:54 -0400 Subject: [PATCH 10/14] Fix cardboard example --- Source/Scene/Scene.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index a4d767fa789..980d7aeb889 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -2471,6 +2471,11 @@ define([ pickDepth.executeCopyDepth(context, passState); } + if (usePrimitiveFramebuffer) { + // Reset framebuffer + passState.framebuffer = globeDepth.framebuffer; + } + if (picking || !usePostProcessSelected) { continue; } From 698814d8a992b3e80b3be1b726cbdc87ae1d4b59 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 24 Sep 2019 12:33:35 -0400 Subject: [PATCH 11/14] Only clear if primitive framebuffer exists --- Source/Scene/GlobeDepth.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index ae2c3639b26..b304e3273fc 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -487,7 +487,7 @@ define([ clear.execute(context, passState); } clear = this._clearPrimitiveColorCommand; - if (defined(clear)) { + if (defined(clear) && defined(this._primitiveColorFramebuffer)) { clear.execute(context, passState); } }; From ed4804900ae1f12da9973060d36c8229a71f8e5b Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 2 Oct 2019 09:19:37 -0400 Subject: [PATCH 12/14] Update CHANGES [skip ci] --- CHANGES.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 086160d5f17..a9fde2c2f7a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,12 @@ Change Log ========== +### 1.63 - 2019-11-01 + +##### Fixes :wrench: + +* Fixed seam artifacts when log depth is disabled, `scene.globe.depthTestAgainstTerrain` is false, and primitives are under the globe. [#8205](https://github.com/AnalyticalGraphicsInc/cesium/pull/8205) + ### 1.62 - 2019-10-01 ##### Deprecated :hourglass_flowing_sand: @@ -26,10 +32,6 @@ Change Log * Fixed 3D tiles style coloring when multiple tilesets are in the scene [#8051](https://github.com/AnalyticalGraphicsInc/cesium/pull/8051) * 3D Tiles geometric error now correctly scales with transform. [#8182](https://github.com/AnalyticalGraphicsInc/cesium/pull/8182) * Fixed per-feature post processing from sometimes selecting the wrong feature. [#7929](https://github.com/AnalyticalGraphicsInc/cesium/pull/7929) -* Fixed labels not showing for individual entities in data sources when clustering is enabled. [#6087](https://github.com/AnalyticalGraphicsInc/cesium/issues/6087) -* Fixed a crash for 3D Tiles that have zero volume. [#7945](https://github.com/AnalyticalGraphicsInc/cesium/pull/7945) -* Fixed seam artifacts when log depth is disabled, `scene.globe.depthTestAgainstTerrain` is false, and primitives are under the globe. [#8205](https://github.com/AnalyticalGraphicsInc/cesium/pull/8205) -* Spread out KMl loading across multiple frames to prevent freezing. [#8195](https://github.com/AnalyticalGraphicsInc/cesium/pull/8195) * Fixed a bug where dynamic polylines did not use the given arcType. [#8191](https://github.com/AnalyticalGraphicsInc/cesium/issues/8191) * Fixed atmosphere brightness when High Dynamic Range is disabled. [#8149](https://github.com/AnalyticalGraphicsInc/cesium/issues/8149) * Fixed brightness levels for procedural Image Based Lighting. [#7803](https://github.com/AnalyticalGraphicsInc/cesium/issues/7803) From 263b3a317f0e30c446275f93b8be347fec52112f Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Wed, 2 Oct 2019 09:25:16 -0400 Subject: [PATCH 13/14] Reuse usePrimitiveFramebuffer --- Source/Scene/Scene.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index cbf78012014..dafbdd1bd30 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -698,6 +698,7 @@ define([ originalFramebuffer : undefined, useGlobeDepthFramebuffer : false, + usePrimitiveFramebuffer : false, useOIT : false, useInvertClassification : false, usePostProcess : false, @@ -2261,7 +2262,7 @@ define([ var clearGlobeDepth = environmentState.clearGlobeDepth; var useDepthPlane = environmentState.useDepthPlane; - var usePrimitiveFramebuffer = (numFrustums > 1) && clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; + var usePrimitiveFramebuffer = environmentState.usePrimitiveFramebuffer = (numFrustums > 1) && clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; var clearDepth = scene._depthClearCommand; var clearStencil = scene._stencilClearCommand; var clearClassificationStencil = scene._classificationStencilClearCommand; @@ -3152,11 +3153,9 @@ define([ var environmentState = this._environmentState; var view = this._view; var globeDepth = view.globeDepth; - var numFrustums = view.frustumCommandsList.length; var useOIT = environmentState.useOIT; var useGlobeDepthFramebuffer = environmentState.useGlobeDepthFramebuffer; - var usePrimitiveFramebuffer = (numFrustums > 1) && environmentState.clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; var usePostProcess = environmentState.usePostProcess; var defaultFramebuffer = environmentState.originalFramebuffer; @@ -3164,7 +3163,7 @@ define([ var sceneFramebuffer = view.sceneFramebuffer.getFramebuffer(); var idFramebuffer = view.sceneFramebuffer.getIdFramebuffer(); - if (usePrimitiveFramebuffer) { + if (environmentState.usePrimitiveFramebuffer) { // Merge primitive framebuffer into globe framebuffer globeDepth.executeMergeColor(context, passState); } From 42700b4a499ff745b2d5bc83914edb68dd376e77 Mon Sep 17 00:00:00 2001 From: Sean Lilley Date: Tue, 15 Oct 2019 17:18:11 -0400 Subject: [PATCH 14/14] Updates from review --- Source/Scene/GlobeDepth.js | 2 ++ Source/Scene/Scene.js | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index bcc356d8651..7d30cfd48cb 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -1,6 +1,7 @@ import BoundingRectangle from '../Core/BoundingRectangle.js'; import Color from '../Core/Color.js'; import defined from '../Core/defined.js'; +import defineProperties from '../Core/defineProperties.js'; import destroyObject from '../Core/destroyObject.js'; import PixelFormat from '../Core/PixelFormat.js'; import ClearCommand from '../Renderer/ClearCommand.js'; @@ -15,6 +16,7 @@ import TextureMinificationFilter from '../Renderer/TextureMinificationFilter.js' import TextureWrap from '../Renderer/TextureWrap.js'; import PassThrough from '../Shaders/PostProcessStages/PassThrough.js'; import PassThroughDepth from '../Shaders/PostProcessStages/PassThroughDepth.js'; +import BlendingState from './BlendingState.js'; import StencilConstants from './StencilConstants.js'; import StencilFunction from './StencilFunction.js'; import StencilOperation from './StencilOperation.js'; diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index b31a52dfc80..bbdd42739e2 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -619,7 +619,7 @@ import View from './View.js'; originalFramebuffer : undefined, useGlobeDepthFramebuffer : false, - usePrimitiveFramebuffer : false, + separatePrimitiveFramebuffer : false, useOIT : false, useInvertClassification : false, usePostProcess : false, @@ -2198,7 +2198,7 @@ import View from './View.js'; var clearGlobeDepth = environmentState.clearGlobeDepth; var useDepthPlane = environmentState.useDepthPlane; - var usePrimitiveFramebuffer = environmentState.usePrimitiveFramebuffer = (numFrustums > 1) && clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; + var separatePrimitiveFramebuffer = environmentState.separatePrimitiveFramebuffer = (numFrustums > 1) && clearGlobeDepth && environmentState.useGlobeDepthFramebuffer; var clearDepth = scene._depthClearCommand; var clearStencil = scene._stencilClearCommand; var clearClassificationStencil = scene._classificationStencilClearCommand; @@ -2230,7 +2230,7 @@ import View from './View.js'; var globeDepth = scene.debugShowGlobeDepth ? getDebugGlobeDepth(scene, index) : view.globeDepth; - if (usePrimitiveFramebuffer) { + if (separatePrimitiveFramebuffer) { // Render to globe framebuffer in GLOBE pass passState.framebuffer = globeDepth.framebuffer; } @@ -2279,7 +2279,7 @@ import View from './View.js'; } } - if (usePrimitiveFramebuffer) { + if (separatePrimitiveFramebuffer) { // Render to primitive framebuffer in all other passes passState.framebuffer = globeDepth.primitiveFramebuffer; } @@ -2426,7 +2426,7 @@ import View from './View.js'; pickDepth.executeCopyDepth(context, passState); } - if (usePrimitiveFramebuffer) { + if (separatePrimitiveFramebuffer) { // Reset framebuffer passState.framebuffer = globeDepth.framebuffer; } @@ -3099,7 +3099,7 @@ import View from './View.js'; var sceneFramebuffer = view.sceneFramebuffer.getFramebuffer(); var idFramebuffer = view.sceneFramebuffer.getIdFramebuffer(); - if (environmentState.usePrimitiveFramebuffer) { + if (environmentState.separatePrimitiveFramebuffer) { // Merge primitive framebuffer into globe framebuffer globeDepth.executeMergeColor(context, passState); }