Skip to content

Commit 9d46847

Browse files
committed
Revert PickDepth
1 parent ea7ce15 commit 9d46847

File tree

3 files changed

+10
-83
lines changed

3 files changed

+10
-83
lines changed

Source/Scene/PickDepth.js

+6-78
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ define([
2828

2929
this._depthTexture = undefined;
3030
this._textureToCopy = undefined;
31-
this._colorTextureMask = undefined;
3231
this._copyDepthCommand = undefined;
33-
this._copyDepthCommandRender = undefined;
34-
this._copyDepthCommandPick = undefined;
3532

3633
this._useLogDepth = undefined;
3734

@@ -115,11 +112,9 @@ define([
115112
}
116113
}
117114

118-
function updateCopyCommands(pickDepth, context, depthTexture, colorTextureMask) {
119-
var fs;
115+
function updateCopyCommands(pickDepth, context, depthTexture) {
120116
if (!defined(pickDepth._copyDepthCommand)) {
121-
// Passthrough depth copy
122-
fs =
117+
var fs =
123118
'uniform sampler2D u_texture;\n' +
124119
'varying vec2 v_textureCoordinates;\n' +
125120
'void main()\n' +
@@ -137,76 +132,17 @@ define([
137132
});
138133
}
139134

140-
if (!defined(pickDepth._copyDepthCommandRender)) {
141-
// If alpha is less than one, use globe depth instead of scene depth. Globe depth will overwrite areas where
142-
// there is translucent geometry or no geometry (like the depth plane).
143-
fs =
144-
'uniform sampler2D u_texture;\n' +
145-
'uniform sampler2D u_colorTextureMask;\n' +
146-
'varying vec2 v_textureCoordinates;\n' +
147-
'void main()\n' +
148-
'{\n' +
149-
' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' +
150-
' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' +
151-
' bool mask = texture2D(u_colorTextureMask, v_textureCoordinates).a < 1.0;\n' +
152-
' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' +
153-
'}\n';
154-
pickDepth._copyDepthCommandRender = context.createViewportQuadCommand(fs, {
155-
renderState : RenderState.fromCache(),
156-
uniformMap : {
157-
u_texture : function() {
158-
return pickDepth._textureToCopy;
159-
},
160-
u_colorTextureMask : function() {
161-
return pickDepth._colorTextureMask;
162-
}
163-
},
164-
owner : pickDepth
165-
});
166-
}
167-
168-
if (!defined(pickDepth._copyDepthCommandPick)) {
169-
// If color is (0,0,0,0), use globe depth instead of scene depth. Globe depth will overwrite areas where
170-
// there is no geometry (like the depth plane).
171-
fs =
172-
'uniform sampler2D u_texture;\n' +
173-
'uniform sampler2D u_colorTextureMask;\n' +
174-
'varying vec2 v_textureCoordinates;\n' +
175-
'void main()\n' +
176-
'{\n' +
177-
' vec4 pickDepth = czm_packDepth(texture2D(u_texture, v_textureCoordinates).r);\n' +
178-
' vec4 globeDepth = texture2D(czm_globeDepthTexture, v_textureCoordinates);\n' +
179-
' bool mask = all(equal(texture2D(u_colorTextureMask, v_textureCoordinates), vec4(0.0)));\n' +
180-
' gl_FragColor = czm_branchFreeTernary(mask, globeDepth, pickDepth);\n' +
181-
'}\n';
182-
pickDepth._copyDepthCommandPick = context.createViewportQuadCommand(fs, {
183-
renderState : RenderState.fromCache(),
184-
uniformMap : {
185-
u_texture : function() {
186-
return pickDepth._textureToCopy;
187-
},
188-
u_colorTextureMask : function() {
189-
return pickDepth._colorTextureMask;
190-
}
191-
},
192-
owner : pickDepth
193-
});
194-
}
195-
196135
pickDepth._textureToCopy = depthTexture;
197-
pickDepth._colorTextureMask = colorTextureMask;
198136
pickDepth._copyDepthCommand.framebuffer = pickDepth._framebuffer;
199-
pickDepth._copyDepthCommandRender.framebuffer = pickDepth._framebuffer;
200-
pickDepth._copyDepthCommandPick.framebuffer = pickDepth._framebuffer;
201137
}
202138

203139
PickDepth.prototype.executeDebugPickDepth = function(context, passState, useLogDepth) {
204140
executeDebugPickDepth(this, context, passState, useLogDepth);
205141
};
206142

207-
PickDepth.prototype.update = function(context, depthTexture, colorTextureMask) {
143+
PickDepth.prototype.update = function(context, depthTexture) {
208144
updateFramebuffers(this, context, depthTexture);
209-
updateCopyCommands(this, context, depthTexture, colorTextureMask);
145+
updateCopyCommands(this, context, depthTexture);
210146
};
211147

212148
var scratchPackedDepth = new Cartesian4();
@@ -226,14 +162,8 @@ define([
226162
return Cartesian4.dot(packedDepth, packedDepthScale);
227163
};
228164

229-
PickDepth.prototype.executeCopyDepth = function(context, passState, copyGlobeDepth, picking) {
230-
if (!copyGlobeDepth) {
231-
this._copyDepthCommand.execute(context, passState);
232-
} else if (picking) {
233-
this._copyDepthCommandPick.execute(context, passState);
234-
} else {
235-
this._copyDepthCommandRender.execute(context, passState);
236-
}
165+
PickDepth.prototype.executeCopyDepth = function(context, passState) {
166+
this._copyDepthCommand.execute(context, passState);
237167
};
238168

239169
PickDepth.prototype.isDestroyed = function() {
@@ -245,8 +175,6 @@ define([
245175
destroyFramebuffers(this);
246176

247177
this._copyDepthCommand.shaderProgram = defined(this._copyDepthCommand.shaderProgram) && this._copyDepthCommand.shaderProgram.destroy();
248-
this._copyDepthCommandRender.shaderProgram = defined(this._copyDepthCommandRender.shaderProgram) && this._copyDepthCommandRender.shaderProgram.destroy();
249-
this._copyDepthCommandPick.shaderProgram = defined(this._copyDepthCommandPick.shaderProgram) && this._copyDepthCommandPick.shaderProgram.destroy();
250178

251179
return destroyObject(this);
252180
};

Source/Scene/Scene.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -2466,10 +2466,9 @@ define([
24662466
if (context.depthTexture && scene.useDepthPicking && (environmentState.useGlobeDepthFramebuffer || renderTranslucentDepthForPick)) {
24672467
// PERFORMANCE_IDEA: Use MRT to avoid the extra copy.
24682468
var depthStencilTexture = renderTranslucentDepthForPick ? passState.framebuffer.depthStencilTexture : globeDepth.framebuffer.depthStencilTexture;
2469-
var colorTexture = passState.framebuffer.getColorTexture(0);
24702469
var pickDepth = getPickDepth(scene, index);
2471-
pickDepth.update(context, depthStencilTexture, colorTexture);
2472-
pickDepth.executeCopyDepth(context, passState, usePrimitiveFramebuffer, picking);
2470+
pickDepth.update(context, depthStencilTexture);
2471+
pickDepth.executeCopyDepth(context, passState);
24732472
}
24742473

24752474
if (picking || !usePostProcessSelected) {

Source/Widgets/Viewer/Viewer.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ Either specify options.terrainProvider instead or set options.baseLayerPicker to
756756
that.selectedEntity = pickEntity(that, e);
757757
}
758758

759-
//cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndSelectObject, ScreenSpaceEventType.LEFT_CLICK);
760-
//cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndTrackObject, ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
759+
cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndSelectObject, ScreenSpaceEventType.LEFT_CLICK);
760+
cesiumWidget.screenSpaceEventHandler.setInputAction(pickAndTrackObject, ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
761761
}
762762

763763
defineProperties(Viewer.prototype, {

0 commit comments

Comments
 (0)