@@ -8,15 +8,13 @@ import SceneMode from "./SceneMode.js";
88function GlobeSurfaceShader (
99 numberOfDayTextures ,
1010 flags ,
11- flags2 ,
1211 material ,
1312 shaderProgram ,
1413 clippingShaderState ,
15- clippingPolygonShaderState
14+ clippingPolygonShaderState ,
1615) {
1716 this . numberOfDayTextures = numberOfDayTextures ;
1817 this . flags = flags ;
19- this . flags2 = flags2 ;
2018 this . material = material ;
2119 this . shaderProgram = shaderProgram ;
2220 this . clippingShaderState = clippingShaderState ;
@@ -168,40 +166,40 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
168166 // Flags beyond bit 31 use arithmetic to avoid silent wrap-around
169167 // (x << 32 === x << 0 in JavaScript).
170168 const flags =
171- sceneMode |
172- ( applyBrightness << 2 ) |
173- ( applyContrast << 3 ) |
174- ( applyHue << 4 ) |
175- ( applySaturation << 5 ) |
176- ( applyGamma << 6 ) |
177- ( applyAlpha << 7 ) |
178- ( hasWaterMask << 8 ) |
179- ( showReflectiveOcean << 9 ) |
180- ( showOceanWaves << 10 ) |
181- ( enableLighting << 11 ) |
182- ( dynamicAtmosphereLighting << 12 ) |
183- ( dynamicAtmosphereLightingFromSun << 13 ) |
184- ( showGroundAtmosphere << 14 ) |
185- ( perFragmentGroundAtmosphere << 15 ) |
186- ( hasVertexNormals << 16 ) |
187- ( useWebMercatorProjection << 17 ) |
188- ( enableFog << 18 ) |
189- ( quantization << 19 ) |
190- ( applySplit << 20 ) |
191- ( enableClippingPlanes << 21 ) |
192- ( enableClippingPolygons << 22 ) |
193- ( cartographicLimitRectangleFlag << 23 ) |
194- ( imageryCutoutFlag << 24 ) |
195- ( colorCorrect << 25 ) |
196- ( highlightFillTile << 26 ) |
197- ( colorToAlpha << 27 ) |
198- ( hasGeodeticSurfaceNormals << 28 ) |
199- ( hasExaggeration << 29 ) |
200- ( showUndergroundColor << 30 ) |
201- ( translucent << 31 ) ;
202-
203- // More bit flags that don't fit in the first `flag`
204- const flags2 = applyDayNightAlpha | ( splitTerrain << 2 ) ;
169+ ( ( sceneMode |
170+ ( applyBrightness << 2 ) |
171+ ( applyContrast << 3 ) |
172+ ( applyHue << 4 ) |
173+ ( applySaturation << 5 ) |
174+ ( applyGamma << 6 ) |
175+ ( applyAlpha << 7 ) |
176+ ( hasWaterMask << 8 ) |
177+ ( showReflectiveOcean << 9 ) |
178+ ( showOceanWaves << 10 ) |
179+ ( enableLighting << 11 ) |
180+ ( dynamicAtmosphereLighting << 12 ) |
181+ ( dynamicAtmosphereLightingFromSun << 13 ) |
182+ ( showGroundAtmosphere << 14 ) |
183+ ( perFragmentGroundAtmosphere << 15 ) |
184+ ( hasVertexNormals << 16 ) |
185+ ( useWebMercatorProjection << 17 ) |
186+ ( enableFog << 18 ) |
187+ ( quantization << 19 ) |
188+ ( applySplit << 20 ) |
189+ ( enableClippingPlanes << 21 ) |
190+ ( enableClippingPolygons << 22 ) |
191+ ( cartographicLimitRectangleFlag << 23 ) |
192+ ( imageryCutoutFlag << 24 ) |
193+ ( colorCorrect << 25 ) |
194+ ( highlightFillTile << 26 ) |
195+ ( colorToAlpha << 27 ) |
196+ ( hasGeodeticSurfaceNormals << 28 ) |
197+ ( hasExaggeration << 29 ) |
198+ ( showUndergroundColor << 30 ) |
199+ ( translucent << 31 ) ) >>>
200+ 0 ) +
201+ ( applyDayNightAlpha ? 0x100000000 : 0 ) +
202+ ( splitTerrain ? 0x1000000000 : 0 ) ;
205203
206204 let currentClippingShaderState = 0 ;
207205 if ( defined ( clippingPlanes ) && clippingPlanes . length > 0 ) {
@@ -222,7 +220,6 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
222220 defined ( surfaceShader ) &&
223221 surfaceShader . numberOfDayTextures === numberOfDayTextures &&
224222 surfaceShader . flags === flags &&
225- surfaceShader . flags2 === flags2 &&
226223 surfaceShader . material === this . material &&
227224 surfaceShader . clippingShaderState === currentClippingShaderState &&
228225 surfaceShader . clippingPolygonShaderState ===
@@ -237,12 +234,7 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
237234 shadersByFlags = this . _shadersByTexturesFlags [ numberOfDayTextures ] = [ ] ;
238235 }
239236
240- let shadersByFlags2 = shadersByFlags [ flags ] ;
241- if ( ! defined ( shadersByFlags2 ) ) {
242- shadersByFlags2 = shadersByFlags [ flags2 ] = [ ] ;
243- }
244-
245- surfaceShader = shadersByFlags2 [ flags2 ] ;
237+ surfaceShader = shadersByFlags [ flags ] ;
246238 if (
247239 ! defined ( surfaceShader ) ||
248240 surfaceShader . material !== this . material ||
@@ -257,7 +249,7 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
257249 // Need to go before GlobeFS
258250 if ( currentClippingShaderState !== 0 ) {
259251 fs . sources . unshift (
260- getClippingFunction ( clippingPlanes , frameState . context )
252+ getClippingFunction ( clippingPlanes , frameState . context ) ,
261253 ) ;
262254 }
263255
@@ -271,7 +263,7 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
271263 fs . defines . push (
272264 `TEXTURE_UNITS ${ numberOfDayTextures } ` ,
273265 cartographicLimitRectangleDefine ,
274- imageryCutoutDefine
266+ imageryCutoutDefine ,
275267 ) ;
276268
277269 if ( applyBrightness ) {
@@ -369,10 +361,10 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
369361 }
370362
371363 fs . defines . push (
372- `CLIPPING_POLYGON_REGIONS_LENGTH ${ clippingPolygons . extentsCount } `
364+ `CLIPPING_POLYGON_REGIONS_LENGTH ${ clippingPolygons . extentsCount } ` ,
373365 ) ;
374366 vs . defines . push (
375- `CLIPPING_POLYGON_REGIONS_LENGTH ${ clippingPolygons . extentsCount } `
367+ `CLIPPING_POLYGON_REGIONS_LENGTH ${ clippingPolygons . extentsCount } ` ,
376368 ) ;
377369 }
378370
@@ -461,25 +453,22 @@ GlobeSurfaceShaderSet.prototype.getShaderProgram = function (options) {
461453 attributeLocations : terrainEncoding . getAttributeLocations ( ) ,
462454 } ) ;
463455
464- surfaceShader = new GlobeSurfaceShader (
456+ surfaceShader = shadersByFlags [ flags ] = new GlobeSurfaceShader (
465457 numberOfDayTextures ,
466458 flags ,
467- flags2 ,
468459 this . material ,
469460 shader ,
470461 currentClippingShaderState ,
471- currentClippingPolygonsShaderState
462+ currentClippingPolygonsShaderState ,
472463 ) ;
473-
474- shadersByFlags2 [ flags2 ] = surfaceShader ;
475464 }
476465
477466 surfaceTile . surfaceShader = surfaceShader ;
478467 return surfaceShader . shaderProgram ;
479468} ;
480469
481470GlobeSurfaceShaderSet . prototype . destroy = function ( ) {
482- let flags , flags2 ;
471+ let flags ;
483472 let shader ;
484473
485474 const shadersByTexturesFlags = this . _shadersByTexturesFlags ;
@@ -492,14 +481,9 @@ GlobeSurfaceShaderSet.prototype.destroy = function () {
492481
493482 for ( flags in shadersByFlags ) {
494483 if ( shadersByFlags . hasOwnProperty ( flags ) ) {
495- const shadersByFlags2 = shadersByFlags [ flags ] ;
496- for ( flags2 in shadersByFlags2 ) {
497- if ( shadersByFlags2 . hasOwnProperty ( flags2 ) ) {
498- shader = shadersByFlags2 [ flags2 ] ;
499- if ( defined ( shader ) ) {
500- shader . shaderProgram . destroy ( ) ;
501- }
502- }
484+ shader = shadersByFlags [ flags ] ;
485+ if ( defined ( shader ) ) {
486+ shader . shaderProgram . destroy ( ) ;
503487 }
504488 }
505489 }
0 commit comments