@@ -28,10 +28,7 @@ define([
28
28
29
29
this . _depthTexture = undefined ;
30
30
this . _textureToCopy = undefined ;
31
- this . _colorTextureMask = undefined ;
32
31
this . _copyDepthCommand = undefined ;
33
- this . _copyDepthCommandRender = undefined ;
34
- this . _copyDepthCommandPick = undefined ;
35
32
36
33
this . _useLogDepth = undefined ;
37
34
@@ -115,11 +112,9 @@ define([
115
112
}
116
113
}
117
114
118
- function updateCopyCommands ( pickDepth , context , depthTexture , colorTextureMask ) {
119
- var fs ;
115
+ function updateCopyCommands ( pickDepth , context , depthTexture ) {
120
116
if ( ! defined ( pickDepth . _copyDepthCommand ) ) {
121
- // Passthrough depth copy
122
- fs =
117
+ var fs =
123
118
'uniform sampler2D u_texture;\n' +
124
119
'varying vec2 v_textureCoordinates;\n' +
125
120
'void main()\n' +
@@ -137,76 +132,17 @@ define([
137
132
} ) ;
138
133
}
139
134
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
-
196
135
pickDepth . _textureToCopy = depthTexture ;
197
- pickDepth . _colorTextureMask = colorTextureMask ;
198
136
pickDepth . _copyDepthCommand . framebuffer = pickDepth . _framebuffer ;
199
- pickDepth . _copyDepthCommandRender . framebuffer = pickDepth . _framebuffer ;
200
- pickDepth . _copyDepthCommandPick . framebuffer = pickDepth . _framebuffer ;
201
137
}
202
138
203
139
PickDepth . prototype . executeDebugPickDepth = function ( context , passState , useLogDepth ) {
204
140
executeDebugPickDepth ( this , context , passState , useLogDepth ) ;
205
141
} ;
206
142
207
- PickDepth . prototype . update = function ( context , depthTexture , colorTextureMask ) {
143
+ PickDepth . prototype . update = function ( context , depthTexture ) {
208
144
updateFramebuffers ( this , context , depthTexture ) ;
209
- updateCopyCommands ( this , context , depthTexture , colorTextureMask ) ;
145
+ updateCopyCommands ( this , context , depthTexture ) ;
210
146
} ;
211
147
212
148
var scratchPackedDepth = new Cartesian4 ( ) ;
@@ -226,14 +162,8 @@ define([
226
162
return Cartesian4 . dot ( packedDepth , packedDepthScale ) ;
227
163
} ;
228
164
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 ) ;
237
167
} ;
238
168
239
169
PickDepth . prototype . isDestroyed = function ( ) {
@@ -245,8 +175,6 @@ define([
245
175
destroyFramebuffers ( this ) ;
246
176
247
177
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 ( ) ;
250
178
251
179
return destroyObject ( this ) ;
252
180
} ;
0 commit comments