@@ -46,14 +46,14 @@ define([
46
46
47
47
/**
48
48
* Eye dome lighting. Does not support points with per-point translucency, but does allow translucent styling against the globe.
49
- * Requires support for EXT_frag_depth, OES_texture_float, and WEBGL_draw_buffers extensions in WebGL 1.0.
49
+ * Requires support for EXT_frag_depth and WEBGL_draw_buffers extensions in WebGL 1.0.
50
50
*
51
51
* @private
52
52
*/
53
53
function PointCloudEyeDomeLighting ( ) {
54
54
this . _framebuffer = undefined ;
55
- this . _colorTexture = undefined ; // color gbuffer
56
- this . _ecAndLogDepthTexture = undefined ; // depth gbuffer
55
+ this . _colorGBuffer = undefined ; // color gbuffer
56
+ this . _depthGBuffer = undefined ; // depth gbuffer
57
57
this . _depthTexture = undefined ; // needed to write depth so camera based on depth works
58
58
this . _drawCommand = undefined ;
59
59
this . _clearCommand = undefined ;
@@ -77,14 +77,14 @@ define([
77
77
return ;
78
78
}
79
79
80
- processor . _colorTexture . destroy ( ) ;
81
- processor . _ecAndLogDepthTexture . destroy ( ) ;
80
+ processor . _colorGBuffer . destroy ( ) ;
81
+ processor . _depthGBuffer . destroy ( ) ;
82
82
processor . _depthTexture . destroy ( ) ;
83
83
framebuffer . destroy ( ) ;
84
84
85
85
processor . _framebuffer = undefined ;
86
- processor . _colorTexture = undefined ;
87
- processor . _ecAndLogDepthTexture = undefined ;
86
+ processor . _colorGBuffer = undefined ;
87
+ processor . _depthGBuffer = undefined ;
88
88
processor . _depthTexture = undefined ;
89
89
processor . _drawCommand = undefined ;
90
90
processor . _clearCommand = undefined ;
@@ -94,22 +94,21 @@ define([
94
94
var screenWidth = context . drawingBufferWidth ;
95
95
var screenHeight = context . drawingBufferHeight ;
96
96
97
- var colorTexture = new Texture ( {
97
+ var colorGBuffer = new Texture ( {
98
98
context : context ,
99
99
width : screenWidth ,
100
100
height : screenHeight ,
101
101
pixelFormat : PixelFormat . RGBA ,
102
- // Firefox as of 57.02 throws FRAMEBUFFER_UNSUPPORTED 0x8CDD if this doesn't match what's in ecTexture
103
- pixelDatatype : FeatureDetection . isFirefox ( ) ? PixelDatatype . FLOAT : PixelDatatype . UNSIGNED_BYTE ,
102
+ pixelDatatype : PixelDatatype . UNSIGNED_BYTE ,
104
103
sampler : createSampler ( )
105
104
} ) ;
106
105
107
- var ecTexture = new Texture ( {
106
+ var depthGBuffer = new Texture ( {
108
107
context : context ,
109
108
width : screenWidth ,
110
109
height : screenHeight ,
111
110
pixelFormat : PixelFormat . RGBA ,
112
- pixelDatatype : PixelDatatype . FLOAT ,
111
+ pixelDatatype : PixelDatatype . UNSIGNED_BYTE ,
113
112
sampler : createSampler ( )
114
113
} ) ;
115
114
@@ -125,14 +124,14 @@ define([
125
124
processor . _framebuffer = new Framebuffer ( {
126
125
context : context ,
127
126
colorTextures : [
128
- colorTexture ,
129
- ecTexture
127
+ colorGBuffer ,
128
+ depthGBuffer
130
129
] ,
131
130
depthTexture : depthTexture ,
132
131
destroyAttachments : false
133
132
} ) ;
134
- processor . _colorTexture = colorTexture ;
135
- processor . _ecAndLogDepthTexture = ecTexture ;
133
+ processor . _colorGBuffer = colorGBuffer ;
134
+ processor . _depthGBuffer = depthGBuffer ;
136
135
processor . _depthTexture = depthTexture ;
137
136
}
138
137
@@ -142,11 +141,11 @@ define([
142
141
var blendFS = PointCloudEyeDomeLightingShader ;
143
142
144
143
var blendUniformMap = {
145
- u_pointCloud_colorTexture : function ( ) {
146
- return processor . _colorTexture ;
144
+ u_pointCloud_colorGBuffer : function ( ) {
145
+ return processor . _colorGBuffer ;
147
146
} ,
148
- u_pointCloud_ecAndLogDepthTexture : function ( ) {
149
- return processor . _ecAndLogDepthTexture ;
147
+ u_pointCloud_depthGBuffer : function ( ) {
148
+ return processor . _depthGBuffer ;
150
149
} ,
151
150
u_distancesAndEdlStrength : function ( ) {
152
151
distancesAndEdlStrengthScratch . x = processor . _radius / context . drawingBufferWidth ;
@@ -184,13 +183,13 @@ define([
184
183
function createResources ( processor , context ) {
185
184
var screenWidth = context . drawingBufferWidth ;
186
185
var screenHeight = context . drawingBufferHeight ;
187
- var colorTexture = processor . _colorTexture ;
186
+ var colorGBuffer = processor . _colorGBuffer ;
188
187
var nowDirty = false ;
189
- var resized = defined ( colorTexture ) &&
190
- ( ( colorTexture . width !== screenWidth ) ||
191
- ( colorTexture . height !== screenHeight ) ) ;
188
+ var resized = defined ( colorGBuffer ) &&
189
+ ( ( colorGBuffer . width !== screenWidth ) ||
190
+ ( colorGBuffer . height !== screenHeight ) ) ;
192
191
193
- if ( ! defined ( colorTexture ) || resized ) {
192
+ if ( ! defined ( colorGBuffer ) || resized ) {
194
193
destroyFramebuffer ( processor ) ;
195
194
createFramebuffer ( processor , context ) ;
196
195
createCommands ( processor , context ) ;
@@ -200,7 +199,7 @@ define([
200
199
}
201
200
202
201
function isSupported ( context ) {
203
- return context . floatingPointTexture && context . drawBuffers && context . fragmentDepth ;
202
+ return context . drawBuffers && context . fragmentDepth ;
204
203
}
205
204
206
205
PointCloudEyeDomeLighting . isSupported = isSupported ;
@@ -210,39 +209,24 @@ define([
210
209
if ( ! defined ( shader ) ) {
211
210
var attributeLocations = shaderProgram . _attributeLocations ;
212
211
213
- var vs = shaderProgram . vertexShaderSource . clone ( ) ;
214
212
var fs = shaderProgram . fragmentShaderSource . clone ( ) ;
215
213
216
- vs . sources = vs . sources . map ( function ( source ) {
217
- source = ShaderSource . replaceMain ( source , 'czm_point_cloud_post_process_main' ) ;
218
- return source ;
219
- } ) ;
220
-
221
214
fs . sources = fs . sources . map ( function ( source ) {
222
215
source = ShaderSource . replaceMain ( source , 'czm_point_cloud_post_process_main' ) ;
223
216
source = source . replace ( / g l _ F r a g C o l o r / g, 'gl_FragData[0]' ) ;
224
217
return source ;
225
218
} ) ;
226
219
227
- vs . sources . push (
228
- 'varying vec3 v_positionEC; \n' +
229
- 'void main() \n' +
230
- '{ \n' +
231
- ' czm_point_cloud_post_process_main(); \n' +
232
- ' v_positionEC = (czm_inverseProjection * gl_Position).xyz; \n' +
233
- '}' ) ;
234
220
fs . sources . unshift ( '#extension GL_EXT_draw_buffers : enable \n' ) ;
235
221
fs . sources . push (
236
- 'varying vec3 v_positionEC; \n' +
237
222
'void main() \n' +
238
223
'{ \n' +
239
224
' czm_point_cloud_post_process_main(); \n' +
240
- // Write log base 2 depth to alpha for EDL
241
- ' gl_FragData[1] = vec4(v_positionEC, log2(-v_positionEC.z)); \n' +
225
+ ' gl_FragData[1] = czm_packDepth(gl_FragCoord.z); \n' +
242
226
'}' ) ;
243
227
244
228
shader = context . shaderCache . createDerivedShaderProgram ( shaderProgram , 'EC' , {
245
- vertexShaderSource : vs ,
229
+ vertexShaderSource : shaderProgram . vertexShaderSource ,
246
230
fragmentShaderSource : fs ,
247
231
attributeLocations : attributeLocations
248
232
} ) ;
0 commit comments