1/2pi.
+ *
+ * @alias czm_oneOverTwoPi
+ * @glslConstant
+ *
+ * @see CesiumMath.ONE_OVER_TWO_PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_oneOverTwoPi = ...;
+ *
+ * // Example
+ * float pi = 2.0 * czm_oneOverTwoPi;
+ */
+const float czm_oneOverTwoPi = 0.15915494309189535;
+`;var ekt=y(C(),1),CR=`/**
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE}
+ *
+ * @name czm_passCesium3DTile
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCesium3DTile = 4.0;
+`;var nkt=y(C(),1),xR=`/**
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION}
+ *
+ * @name czm_passCesium3DTileClassification
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCesium3DTileClassification = 5.0;
+`;var okt=y(C(),1),IR=`/**
+ * The automatic GLSL constant for {@link Pass#CESIUM_3D_TILE_CLASSIFICATION_IGNORE_SHOW}
+ *
+ * @name czm_passCesium3DTileClassificationIgnoreShow
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCesium3DTileClassificationIgnoreShow = 6.0;
+`;var skt=y(C(),1),_R=`/**
+ * The automatic GLSL constant for {@link Pass#CLASSIFICATION}
+ *
+ * @name czm_passClassification
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passClassification = 7.0;
+`;var ckt=y(C(),1),ER=`/**
+ * The automatic GLSL constant for {@link Pass#COMPUTE}
+ *
+ * @name czm_passCompute
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passCompute = 1.0;
+`;var dkt=y(C(),1),TR=`/**
+ * The automatic GLSL constant for {@link Pass#ENVIRONMENT}
+ *
+ * @name czm_passEnvironment
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passEnvironment = 0.0;
+`;var mkt=y(C(),1),SR=`/**
+ * The automatic GLSL constant for {@link Pass#GAUSSIAN_SPLATS}
+ *
+ * @name czm_passGaussianSplats
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passGaussianSplats = 10.0;
+`;var fkt=y(C(),1),LR=`/**
+ * The automatic GLSL constant for {@link Pass#GLOBE}
+ *
+ * @name czm_passGlobe
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passGlobe = 2.0;
+`;var Akt=y(C(),1),RR=`/**
+ * The automatic GLSL constant for {@link Pass#OPAQUE}
+ *
+ * @name czm_passOpaque
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passOpaque = 7.0;
+`;var bkt=y(C(),1),VR=`/**
+ * The automatic GLSL constant for {@link Pass#OVERLAY}
+ *
+ * @name czm_passOverlay
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passOverlay = 11.0;
+`;var Ckt=y(C(),1),GR=`/**
+ * The automatic GLSL constant for {@link Pass#TERRAIN_CLASSIFICATION}
+ *
+ * @name czm_passTerrainClassification
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passTerrainClassification = 3.0;
+`;var Ikt=y(C(),1),ZR=`/**
+ * The automatic GLSL constant for {@link Pass#TRANSLUCENT}
+ *
+ * @name czm_passTranslucent
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passTranslucent = 8.0;
+`;var Ekt=y(C(),1),BR=`/**
+ * The automatic GLSL constant for {@link Pass#VOXELS}
+ *
+ * @name czm_passVoxels
+ * @glslConstant
+ *
+ * @see czm_pass
+ */
+const float czm_passVoxels = 9.0;
+`;var Skt=y(C(),1),wR=`/**
+ * A built-in GLSL floating-point constant for Math.PI.
+ *
+ * @alias czm_pi
+ * @glslConstant
+ *
+ * @see CesiumMath.PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_pi = ...;
+ *
+ * // Example
+ * float twoPi = 2.0 * czm_pi;
+ */
+const float czm_pi = 3.141592653589793;
+`;var Rkt=y(C(),1),XR=`/**
+ * A built-in GLSL floating-point constant for pi/4.
+ *
+ * @alias czm_piOverFour
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_FOUR
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverFour = ...;
+ *
+ * // Example
+ * float pi = 4.0 * czm_piOverFour;
+ */
+const float czm_piOverFour = 0.7853981633974483;
+`;var Gkt=y(C(),1),WR=`/**
+ * A built-in GLSL floating-point constant for pi/6.
+ *
+ * @alias czm_piOverSix
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_SIX
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverSix = ...;
+ *
+ * // Example
+ * float pi = 6.0 * czm_piOverSix;
+ */
+const float czm_piOverSix = 0.5235987755982988;
+`;var Bkt=y(C(),1),FR=`/**
+ * A built-in GLSL floating-point constant for pi/3.
+ *
+ * @alias czm_piOverThree
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_THREE
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverThree = ...;
+ *
+ * // Example
+ * float pi = 3.0 * czm_piOverThree;
+ */
+const float czm_piOverThree = 1.0471975511965976;
+`;var Xkt=y(C(),1),PR=`/**
+ * A built-in GLSL floating-point constant for pi/2.
+ *
+ * @alias czm_piOverTwo
+ * @glslConstant
+ *
+ * @see CesiumMath.PI_OVER_TWO
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_piOverTwo = ...;
+ *
+ * // Example
+ * float pi = 2.0 * czm_piOverTwo;
+ */
+const float czm_piOverTwo = 1.5707963267948966;
+`;var Fkt=y(C(),1),MR=`/**
+ * A built-in GLSL floating-point constant for converting degrees to radians.
+ *
+ * @alias czm_radiansPerDegree
+ * @glslConstant
+ *
+ * @see CesiumMath.RADIANS_PER_DEGREE
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_radiansPerDegree = ...;
+ *
+ * // Example
+ * float rad = czm_radiansPerDegree * deg;
+ */
+const float czm_radiansPerDegree = 0.017453292519943295;
+`;var Mkt=y(C(),1),vR=`/**
+ * The constant identifier for the 2D {@link SceneMode}
+ *
+ * @name czm_sceneMode2D
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneModeColumbusView
+ * @see czm_sceneMode3D
+ * @see czm_sceneModeMorphing
+ */
+const float czm_sceneMode2D = 2.0;
+`;var Nkt=y(C(),1),NR=`/**
+ * The constant identifier for the 3D {@link SceneMode}
+ *
+ * @name czm_sceneMode3D
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneMode2D
+ * @see czm_sceneModeColumbusView
+ * @see czm_sceneModeMorphing
+ */
+const float czm_sceneMode3D = 3.0;
+`;var Qkt=y(C(),1),DR=`/**
+ * The constant identifier for the Columbus View {@link SceneMode}
+ *
+ * @name czm_sceneModeColumbusView
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneMode2D
+ * @see czm_sceneMode3D
+ * @see czm_sceneModeMorphing
+ */
+const float czm_sceneModeColumbusView = 1.0;
+`;var kkt=y(C(),1),QR=`/**
+ * The constant identifier for the Morphing {@link SceneMode}
+ *
+ * @name czm_sceneModeMorphing
+ * @glslConstant
+ * @see czm_sceneMode
+ * @see czm_sceneMode2D
+ * @see czm_sceneModeColumbusView
+ * @see czm_sceneMode3D
+ */
+const float czm_sceneModeMorphing = 0.0;
+`;var Okt=y(C(),1),UR=`/**
+ * A built-in GLSL floating-point constant for one solar radius.
+ *
+ * @alias czm_solarRadius
+ * @glslConstant
+ *
+ * @see CesiumMath.SOLAR_RADIUS
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_solarRadius = ...;
+ */
+const float czm_solarRadius = 695500000.0;
+`;var zkt=y(C(),1),kR=`/**
+ * A built-in GLSL floating-point constant for 3pi/2.
+ *
+ * @alias czm_threePiOver2
+ * @glslConstant
+ *
+ * @see CesiumMath.THREE_PI_OVER_TWO
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_threePiOver2 = ...;
+ *
+ * // Example
+ * float pi = (2.0 / 3.0) * czm_threePiOver2;
+ */
+const float czm_threePiOver2 = 4.71238898038469;
+`;var Jkt=y(C(),1),YR=`/**
+ * A built-in GLSL floating-point constant for 2pi.
+ *
+ * @alias czm_twoPi
+ * @glslConstant
+ *
+ * @see CesiumMath.TWO_PI
+ *
+ * @example
+ * // GLSL declaration
+ * const float czm_twoPi = ...;
+ *
+ * // Example
+ * float pi = czm_twoPi / 2.0;
+ */
+const float czm_twoPi = 6.283185307179586;
+`;var qkt=y(C(),1),OR=`/**
+ * The maximum latitude, in radians, both North and South, supported by a Web Mercator
+ * (EPSG:3857) projection. Technically, the Mercator projection is defined
+ * for any latitude up to (but not including) 90 degrees, but it makes sense
+ * to cut it off sooner because it grows exponentially with increasing latitude.
+ * The logic behind this particular cutoff value, which is the one used by
+ * Google Maps, Bing Maps, and Esri, is that it makes the projection
+ * square. That is, the rectangle is equal in the X and Y directions.
+ *
+ * The constant value is computed as follows:
+ * czm_pi * 0.5 - (2.0 * atan(exp(-czm_pi)))
+ *
+ * @name czm_webMercatorMaxLatitude
+ * @glslConstant
+ */
+const float czm_webMercatorMaxLatitude = 1.4844222297453324;
+`;var eYt=y(C(),1),HR=`/**
+ * @name czm_depthRangeStruct
+ * @glslStruct
+ */
+struct czm_depthRangeStruct
+{
+ float near;
+ float far;
+};
+`;var nYt=y(C(),1),zR=`/**
+ * Holds material information that can be used for lighting. Returned by all czm_getMaterial functions.
+ *
+ * @name czm_material
+ * @glslStruct
+ *
+ * @property {vec3} diffuse Incoming light that scatters evenly in all directions.
+ * @property {float} specular Intensity of incoming light reflecting in a single direction.
+ * @property {float} shininess The sharpness of the specular reflection. Higher values create a smaller, more focused specular highlight.
+ * @property {vec3} normal Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal.
+ * @property {vec3} emission Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light.
+ * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque.
+ */
+struct czm_material
+{
+ vec3 diffuse;
+ float specular;
+ float shininess;
+ vec3 normal;
+ vec3 emission;
+ float alpha;
+};
+`;var oYt=y(C(),1),KR=`/**
+ * Used as input to every material's czm_getMaterial function.
+ *
+ * @name czm_materialInput
+ * @glslStruct
+ *
+ * @property {float} s 1D texture coordinates.
+ * @property {vec2} st 2D texture coordinates.
+ * @property {vec3} str 3D texture coordinates.
+ * @property {vec3} normalEC Unperturbed surface normal in eye coordinates.
+ * @property {mat3} tangentToEyeMatrix Matrix for converting a tangent space normal to eye space.
+ * @property {vec3} positionToEyeEC Vector from the fragment to the eye in eye coordinates. The magnitude is the distance in meters from the fragment to the eye.
+ * @property {float} height The height of the terrain in meters above or below the ellipsoid. Only available for globe materials.
+ * @property {float} slope The slope of the terrain in radians. 0 is flat; pi/2 is vertical. Only available for globe materials.
+ * @property {float} aspect The aspect of the terrain in radians. 0 is East, pi/2 is North, pi is West, 3pi/2 is South. Only available for globe materials.
+* @property {float} waterMask The value of the water mask. 0 is land, 1 is water. Only available for globe materials.
+ */
+struct czm_materialInput
+{
+ float s;
+ vec2 st;
+ vec3 str;
+ vec3 normalEC;
+ mat3 tangentToEyeMatrix;
+ vec3 positionToEyeEC;
+ float height;
+ float slope;
+ float aspect;
+ float waterMask;
+};
+`;var sYt=y(C(),1),JR=`/**
+ * Struct for representing a material for a {@link Model}. The model
+ * rendering pipeline will pass this struct between material, custom shaders,
+ * and lighting stages. This is not to be confused with {@link czm_material}
+ * which is used by the older Fabric materials system, although they are similar.
+ * + * All color values (diffuse, specular, emissive) are in linear color space. + *
+ * + * @name czm_modelMaterial + * @glslStruct + * + * @property {vec4} baseColor The base color of the material. + * @property {vec3} diffuse Incoming light that scatters evenly in all directions. + * @property {float} alpha Alpha of this material. 0.0 is completely transparent; 1.0 is completely opaque. + * @property {vec3} specular Color of reflected light at normal incidence in PBR materials. This is sometimes referred to as f0 in the literature. + * @property {float} roughness A number from 0.0 to 1.0 representing how rough the surface is. Values near 0.0 produce glossy surfaces, while values near 1.0 produce rough surfaces. + * @property {vec3} normalEC Surface's normal in eye coordinates. It is used for effects such as normal mapping. The default is the surface's unmodified normal. + * @property {float} occlusion Ambient occlusion recieved at this point on the material. 1.0 means fully lit, 0.0 means fully occluded. + * @property {vec3} emissive Light emitted by the material equally in all directions. The default is vec3(0.0), which emits no light. + */ +struct czm_modelMaterial { + vec4 baseColor; + vec3 diffuse; + float alpha; + vec3 specular; + float roughness; + vec3 normalEC; + float occlusion; + vec3 emissive; +#ifdef USE_SPECULAR + float specularWeight; +#endif +#ifdef USE_ANISOTROPY + vec3 anisotropicT; + vec3 anisotropicB; + float anisotropyStrength; +#endif +#ifdef USE_CLEARCOAT + float clearcoatFactor; + float clearcoatRoughness; + vec3 clearcoatNormal; + // Add clearcoatF0 when KHR_materials_ior is implemented +#endif +}; +`;var cYt=y(C(),1),jR=`/** + * Struct for representing the output of a custom vertex shader. + * + * @name czm_modelVertexOutput + * @glslStruct + * + * @see {@link CustomShader} + * @see {@link Model} + * + * @property {vec3} positionMC The position of the vertex in model coordinates + * @property {float} pointSize A custom value for gl_PointSize. This is only used for point primitives. + */ +struct czm_modelVertexOutput { + vec3 positionMC; + float pointSize; +}; +`;var dYt=y(C(),1),qR=`/** + * DOC_TBA + * + * @name czm_ray + * @glslStruct + */ +struct czm_ray +{ + vec3 origin; + vec3 direction; +}; +`;var mYt=y(C(),1),$R=`/** + * DOC_TBA + * + * @name czm_raySegment + * @glslStruct + */ +struct czm_raySegment +{ + float start; + float stop; +}; + +/** + * DOC_TBA + * + * @name czm_emptyRaySegment + * @glslConstant + */ +const czm_raySegment czm_emptyRaySegment = czm_raySegment(-czm_infinity, -czm_infinity); + +/** + * DOC_TBA + * + * @name czm_fullRaySegment + * @glslConstant + */ +const czm_raySegment czm_fullRaySegment = czm_raySegment(0.0, czm_infinity); +`;var fYt=y(C(),1),eV=`struct czm_shadowParameters +{ +#ifdef USE_CUBE_MAP_SHADOW + vec3 texCoords; +#else + vec2 texCoords; +#endif + + float depthBias; + float depth; + float nDotL; + vec2 texelStepSize; + float normalShadingSmooth; + float darkness; +}; +`;var AYt=y(C(),1),tV=`/** + * Converts an HSB color (hue, saturation, brightness) to RGB + * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl} + * + * @name czm_HSBToRGB + * @glslFunction + * + * @param {vec3} hsb The color in HSB. + * + * @returns {vec3} The color in RGB. + * + * @example + * vec3 hsb = czm_RGBToHSB(rgb); + * hsb.z *= 0.1; + * rgb = czm_HSBToRGB(hsb); + */ + +const vec4 K_HSB2RGB = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); + +vec3 czm_HSBToRGB(vec3 hsb) +{ + vec3 p = abs(fract(hsb.xxx + K_HSB2RGB.xyz) * 6.0 - K_HSB2RGB.www); + return hsb.z * mix(K_HSB2RGB.xxx, clamp(p - K_HSB2RGB.xxx, 0.0, 1.0), hsb.y); +} +`;var bYt=y(C(),1),nV=`/** + * Converts an HSL color (hue, saturation, lightness) to RGB + * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html} + * + * @name czm_HSLToRGB + * @glslFunction + * + * @param {vec3} rgb The color in HSL. + * + * @returns {vec3} The color in RGB. + * + * @example + * vec3 hsl = czm_RGBToHSL(rgb); + * hsl.z *= 0.1; + * rgb = czm_HSLToRGB(hsl); + */ + +vec3 hueToRGB(float hue) +{ + float r = abs(hue * 6.0 - 3.0) - 1.0; + float g = 2.0 - abs(hue * 6.0 - 2.0); + float b = 2.0 - abs(hue * 6.0 - 4.0); + return clamp(vec3(r, g, b), 0.0, 1.0); +} + +vec3 czm_HSLToRGB(vec3 hsl) +{ + vec3 rgb = hueToRGB(hsl.x); + float c = (1.0 - abs(2.0 * hsl.z - 1.0)) * hsl.y; + return (rgb - 0.5) * c + hsl.z; +} +`;var CYt=y(C(),1),iV=`/** + * Converts an RGB color to HSB (hue, saturation, brightness) + * HSB <-> RGB conversion with minimal branching: {@link http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl} + * + * @name czm_RGBToHSB + * @glslFunction + * + * @param {vec3} rgb The color in RGB. + * + * @returns {vec3} The color in HSB. + * + * @example + * vec3 hsb = czm_RGBToHSB(rgb); + * hsb.z *= 0.1; + * rgb = czm_HSBToRGB(hsb); + */ + +const vec4 K_RGB2HSB = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); + +vec3 czm_RGBToHSB(vec3 rgb) +{ + vec4 p = mix(vec4(rgb.bg, K_RGB2HSB.wz), vec4(rgb.gb, K_RGB2HSB.xy), step(rgb.b, rgb.g)); + vec4 q = mix(vec4(p.xyw, rgb.r), vec4(rgb.r, p.yzx), step(p.x, rgb.r)); + + float d = q.x - min(q.w, q.y); + return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + czm_epsilon7)), d / (q.x + czm_epsilon7), q.x); +} +`;var IYt=y(C(),1),oV=`/** + * Converts an RGB color to HSL (hue, saturation, lightness) + * HSL <-> RGB conversion: {@link http://www.chilliant.com/rgb2hsv.html} + * + * @name czm_RGBToHSL + * @glslFunction + * + * @param {vec3} rgb The color in RGB. + * + * @returns {vec3} The color in HSL. + * + * @example + * vec3 hsl = czm_RGBToHSL(rgb); + * hsl.z *= 0.1; + * rgb = czm_HSLToRGB(hsl); + */ + +vec3 RGBtoHCV(vec3 rgb) +{ + // Based on work by Sam Hocevar and Emil Persson + vec4 p = (rgb.g < rgb.b) ? vec4(rgb.bg, -1.0, 2.0 / 3.0) : vec4(rgb.gb, 0.0, -1.0 / 3.0); + vec4 q = (rgb.r < p.x) ? vec4(p.xyw, rgb.r) : vec4(rgb.r, p.yzx); + float c = q.x - min(q.w, q.y); + float h = abs((q.w - q.y) / (6.0 * c + czm_epsilon7) + q.z); + return vec3(h, c, q.x); +} + +vec3 czm_RGBToHSL(vec3 rgb) +{ + vec3 hcv = RGBtoHCV(rgb); + float l = hcv.z - hcv.y * 0.5; + float s = hcv.y / (1.0 - abs(l * 2.0 - 1.0) + czm_epsilon7); + return vec3(hcv.x, s, l); +} +`;var EYt=y(C(),1),rV=`/** + * Converts an RGB color to CIE Yxy. + *The conversion is described in + * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform} + *
+ * + * @name czm_RGBToXYZ + * @glslFunction + * + * @param {vec3} rgb The color in RGB. + * + * @returns {vec3} The color in CIE Yxy. + * + * @example + * vec3 xyz = czm_RGBToXYZ(rgb); + * xyz.x = max(xyz.x - luminanceThreshold, 0.0); + * rgb = czm_XYZToRGB(xyz); + */ +vec3 czm_RGBToXYZ(vec3 rgb) +{ + const mat3 RGB2XYZ = mat3(0.4124, 0.2126, 0.0193, + 0.3576, 0.7152, 0.1192, + 0.1805, 0.0722, 0.9505); + vec3 xyz = RGB2XYZ * rgb; + vec3 Yxy; + Yxy.r = xyz.g; + float temp = dot(vec3(1.0), xyz); + Yxy.gb = xyz.rg / temp; + return Yxy; +} +`;var SYt=y(C(),1),sV=`/** + * Converts a CIE Yxy color to RGB. + *The conversion is described in + * {@link http://content.gpwiki.org/index.php/D3DBook:High-Dynamic_Range_Rendering#Luminance_Transform|Luminance Transform} + *
+ * + * @name czm_XYZToRGB + * @glslFunction + * + * @param {vec3} Yxy The color in CIE Yxy. + * + * @returns {vec3} The color in RGB. + * + * @example + * vec3 xyz = czm_RGBToXYZ(rgb); + * xyz.x = max(xyz.x - luminanceThreshold, 0.0); + * rgb = czm_XYZToRGB(xyz); + */ +vec3 czm_XYZToRGB(vec3 Yxy) +{ + const mat3 XYZ2RGB = mat3( 3.2405, -0.9693, 0.0556, + -1.5371, 1.8760, -0.2040, + -0.4985, 0.0416, 1.0572); + vec3 xyz; + xyz.r = Yxy.r * Yxy.g / Yxy.b; + xyz.g = Yxy.r; + xyz.b = Yxy.r * (1.0 - Yxy.g - Yxy.b) / Yxy.b; + + return XYZ2RGB * xyz; +} +`;var RYt=y(C(),1),aV=`// See: +// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ + +vec3 czm_acesTonemapping(vec3 color) { + float g = 0.985; + float a = 0.065; + float b = 0.0001; + float c = 0.433; + float d = 0.238; + + color = (color * (color + a) - b) / (color * (g * color + c) + d); + + color = clamp(color, 0.0, 1.0); + + return color; +} +`;var GYt=y(C(),1),cV=`/** + * @private + */ +float czm_alphaWeight(float a) +{ + float z = (gl_FragCoord.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2]; + + // See Weighted Blended Order-Independent Transparency for examples of different weighting functions: + // http://jcgt.org/published/0002/02/09/ + return pow(a + 0.01, 4.0) + max(1e-2, min(3.0 * 1e3, 0.003 / (1e-5 + pow(abs(z) / 200.0, 4.0)))); +} +`;var BYt=y(C(),1),lV=`/** + * Procedural anti-aliasing by blurring two colors that meet at a sharp edge. + * + * @name czm_antialias + * @glslFunction + * + * @param {vec4} color1 The color on one side of the edge. + * @param {vec4} color2 The color on the other side of the edge. + * @param {vec4} currentcolor The current color, eithercolor1 or color2.
+ * @param {float} dist The distance to the edge in texture coordinates.
+ * @param {float} [fuzzFactor=0.1] Controls the blurriness between the two colors.
+ * @returns {vec4} The anti-aliased color.
+ *
+ * @example
+ * // GLSL declarations
+ * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor);
+ * vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist);
+ *
+ * // get the color for a material that has a sharp edge at the line y = 0.5 in texture space
+ * float dist = abs(textureCoordinates.t - 0.5);
+ * vec4 currentColor = mix(bottomColor, topColor, step(0.5, textureCoordinates.t));
+ * vec4 color = czm_antialias(bottomColor, topColor, currentColor, dist, 0.1);
+ */
+vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist, float fuzzFactor)
+{
+ float val1 = clamp(dist / fuzzFactor, 0.0, 1.0);
+ float val2 = clamp((dist - 0.5) / fuzzFactor, 0.0, 1.0);
+ val1 = val1 * (1.0 - val2);
+ val1 = val1 * val1 * (3.0 - (2.0 * val1));
+ val1 = pow(val1, 0.5); //makes the transition nicer
+
+ vec4 midColor = (color1 + color2) * 0.5;
+ return mix(midColor, currentColor, val1);
+}
+
+vec4 czm_antialias(vec4 color1, vec4 color2, vec4 currentColor, float dist)
+{
+ return czm_antialias(color1, color2, currentColor, dist, 0.1);
+}
+`;var XYt=y(C(),1),dV=`/**
+ * Apply a HSB color shift to an RGB color.
+ *
+ * @param {vec3} rgb The color in RGB space.
+ * @param {vec3} hsbShift The amount to shift each component. The xyz components correspond to hue, saturation, and brightness. Shifting the hue by +/- 1.0 corresponds to shifting the hue by a full cycle. Saturation and brightness are clamped between 0 and 1 after the adjustment
+ * @param {bool} ignoreBlackPixels If true, black pixels will be unchanged. This is necessary in some shaders such as atmosphere-related effects.
+ *
+ * @return {vec3} The RGB color after shifting in HSB space and clamping saturation and brightness to a valid range.
+ */
+vec3 czm_applyHSBShift(vec3 rgb, vec3 hsbShift, bool ignoreBlackPixels) {
+ // Convert rgb color to hsb
+ vec3 hsb = czm_RGBToHSB(rgb);
+
+ // Perform hsb shift
+ // Hue cycles around so no clamp is needed.
+ hsb.x += hsbShift.x; // hue
+ hsb.y = clamp(hsb.y + hsbShift.y, 0.0, 1.0); // saturation
+
+ // brightness
+ //
+ // Some shaders such as atmosphere-related effects need to leave black
+ // pixels unchanged
+ if (ignoreBlackPixels) {
+ hsb.z = hsb.z > czm_epsilon7 ? hsb.z + hsbShift.z : 0.0;
+ } else {
+ hsb.z = hsb.z + hsbShift.z;
+ }
+ hsb.z = clamp(hsb.z, 0.0, 1.0);
+
+ // Convert shifted hsb back to rgb
+ return czm_HSBToRGB(hsb);
+}
+`;var FYt=y(C(),1),uV=`/**
+ * Approximately computes spherical coordinates given a normal.
+ * Uses approximate inverse trigonometry for speed and consistency,
+ * since inverse trigonometry can differ from vendor-to-vendor and when compared with the CPU.
+ *
+ * @name czm_approximateSphericalCoordinates
+ * @glslFunction
+ *
+ * @param {vec3} normal arbitrary-length normal.
+ *
+ * @returns {vec2} Approximate latitude and longitude spherical coordinates.
+ */
+vec2 czm_approximateSphericalCoordinates(vec3 normal) {
+ // Project into plane with vertical for latitude
+ float latitudeApproximation = czm_fastApproximateAtan(sqrt(normal.x * normal.x + normal.y * normal.y), normal.z);
+ float longitudeApproximation = czm_fastApproximateAtan(normal.x, normal.y);
+ return vec2(latitudeApproximation, longitudeApproximation);
+}
+`;var MYt=y(C(),1),mV=`/**
+ * Compute a rational approximation to tanh(x)
+ *
+ * @param {float} x A real number input
+ * @returns {float} An approximation for tanh(x)
+*/
+float czm_approximateTanh(float x) {
+ float x2 = x * x;
+ return max(-1.0, min(1.0, x * (27.0 + x2) / (27.0 + 9.0 * x2)));
+}
+`;var NYt=y(C(),1),hV=`/**
+ * Determines if the fragment is back facing
+ *
+ * @name czm_backFacing
+ * @glslFunction
+ *
+ * @returns {bool} true if the fragment is back facing; otherwise, false.
+ */
+bool czm_backFacing()
+{
+ // !gl_FrontFacing doesn't work as expected on Mac/Intel so use the more verbose form instead. See https://github.com/CesiumGS/cesium/pull/8494.
+ return gl_FrontFacing == false;
+}
+`;var QYt=y(C(),1),fV=`/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a float expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {float} a Value to return if the comparison is true.
+ * @param {float} b Value to return if the comparison is false.
+ *
+ * @returns {float} equivalent of comparison ? a : b
+ */
+float czm_branchFreeTernary(bool comparison, float a, float b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+
+/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a vec2 expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {vec2} a Value to return if the comparison is true.
+ * @param {vec2} b Value to return if the comparison is false.
+ *
+ * @returns {vec2} equivalent of comparison ? a : b
+ */
+vec2 czm_branchFreeTernary(bool comparison, vec2 a, vec2 b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+
+/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a vec3 expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {vec3} a Value to return if the comparison is true.
+ * @param {vec3} b Value to return if the comparison is false.
+ *
+ * @returns {vec3} equivalent of comparison ? a : b
+ */
+vec3 czm_branchFreeTernary(bool comparison, vec3 a, vec3 b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+
+/**
+ * Branchless ternary operator to be used when it's inexpensive to explicitly
+ * evaluate both possibilities for a vec4 expression.
+ *
+ * @name czm_branchFreeTernary
+ * @glslFunction
+ *
+ * @param {bool} comparison A comparison statement
+ * @param {vec3} a Value to return if the comparison is true.
+ * @param {vec3} b Value to return if the comparison is false.
+ *
+ * @returns {vec3} equivalent of comparison ? a : b
+ */
+vec4 czm_branchFreeTernary(bool comparison, vec4 a, vec4 b) {
+ float useA = float(comparison);
+ return a * useA + b * (1.0 - useA);
+}
+`;var kYt=y(C(),1),pV=`
+vec4 czm_cascadeColor(vec4 weights)
+{
+ return vec4(1.0, 0.0, 0.0, 1.0) * weights.x +
+ vec4(0.0, 1.0, 0.0, 1.0) * weights.y +
+ vec4(0.0, 0.0, 1.0, 1.0) * weights.z +
+ vec4(1.0, 0.0, 1.0, 1.0) * weights.w;
+}
+`;var OYt=y(C(),1),AV=`
+uniform vec4 shadowMap_cascadeDistances;
+
+float czm_cascadeDistance(vec4 weights)
+{
+ return dot(shadowMap_cascadeDistances, weights);
+}
+`;var zYt=y(C(),1),gV=`
+uniform mat4 shadowMap_cascadeMatrices[4];
+
+mat4 czm_cascadeMatrix(vec4 weights)
+{
+ return shadowMap_cascadeMatrices[0] * weights.x +
+ shadowMap_cascadeMatrices[1] * weights.y +
+ shadowMap_cascadeMatrices[2] * weights.z +
+ shadowMap_cascadeMatrices[3] * weights.w;
+}
+`;var JYt=y(C(),1),bV=`
+uniform vec4 shadowMap_cascadeSplits[2];
+
+vec4 czm_cascadeWeights(float depthEye)
+{
+ // One component is set to 1.0 and all others set to 0.0.
+ vec4 near = step(shadowMap_cascadeSplits[0], vec4(depthEye));
+ vec4 far = step(depthEye, shadowMap_cascadeSplits[1]);
+ return near * far;
+}
+`;var qYt=y(C(),1),yV=`float getSignedDistance(vec2 uv, highp sampler2D clippingDistance) {
+ float signedDistance = texture(clippingDistance, uv).r;
+ return (signedDistance - 0.5) * 2.0;
+}
+
+void czm_clipPolygons(highp sampler2D clippingDistance, int extentsLength, vec2 clippingPosition, int regionIndex) {
+ // Position is completely outside of polygons bounds
+ vec2 rectUv = clippingPosition;
+ if (regionIndex < 0 || rectUv.x <= 0.0 || rectUv.y <= 0.0 || rectUv.x >= 1.0 || rectUv.y >= 1.0) {
+ #ifdef CLIPPING_INVERSE
+ discard;
+ #endif
+ return;
+ }
+
+ vec2 clippingDistanceTextureDimensions = vec2(textureSize(clippingDistance, 0));
+ vec2 sampleOffset = max(1.0 / clippingDistanceTextureDimensions, vec2(0.005));
+ float dimension = float(extentsLength);
+ if (extentsLength > 2) {
+ dimension = ceil(log2(float(extentsLength)));
+ }
+
+ vec2 textureOffset = vec2(mod(float(regionIndex), dimension), floor(float(regionIndex) / dimension)) / dimension;
+ vec2 uv = textureOffset + rectUv / dimension;
+
+ float signedDistance = getSignedDistance(uv, clippingDistance);
+
+ #ifdef CLIPPING_INVERSE
+ if (signedDistance > 0.0) {
+ discard;
+ }
+ #else
+ if (signedDistance < 0.0) {
+ discard;
+ }
+ #endif
+}
+`;var e3t=y(C(),1),CV=`/**
+ * DOC_TBA
+ *
+ * @name czm_columbusViewMorph
+ * @glslFunction
+ */
+vec4 czm_columbusViewMorph(vec4 position2D, vec4 position3D, float time)
+{
+ // Just linear for now.
+ vec3 p = mix(position2D.xyz, position3D.xyz, time);
+ return vec4(p, 1.0);
+}
+`;var n3t=y(C(),1),xV=`/**
+ * Compute the atmosphere color, applying Rayleigh and Mie scattering. This
+ * builtin uses automatic uniforms so the atmophere settings are synced with the
+ * state of the Scene, even in other contexts like Model.
+ *
+ * @name czm_computeAtmosphereColor
+ * @glslFunction
+ *
+ * @param {vec3} positionWC Position of the fragment in world coords (low precision)
+ * @param {vec3} lightDirection Light direction from the sun or other light source.
+ * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
+ * @param {vec3} mieColor The Mie scattering color computed by a scattering function
+ * @param {float} opacity The opacity computed by a scattering function.
+ */
+vec4 czm_computeAtmosphereColor(
+ vec3 positionWC,
+ vec3 lightDirection,
+ vec3 rayleighColor,
+ vec3 mieColor,
+ float opacity
+) {
+ // Setup the primary ray: from the camera position to the vertex position.
+ vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
+ vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
+
+ float cosAngle = dot(cameraToPositionWCDirection, lightDirection);
+ float cosAngleSq = cosAngle * cosAngle;
+
+ float G = czm_atmosphereMieAnisotropy;
+ float GSq = G * G;
+
+ // The Rayleigh phase function.
+ float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
+ // The Mie phase function.
+ float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));
+
+ // The final color is generated by combining the effects of the Rayleigh and Mie scattering.
+ vec3 rayleigh = rayleighPhase * rayleighColor;
+ vec3 mie = miePhase * mieColor;
+
+ vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
+
+ return vec4(color, opacity);
+}
+
+/**
+ * Compute the atmosphere color, applying Rayleigh and Mie scattering. This
+ * builtin uses automatic uniforms so the atmophere settings are synced with the
+ * state of the Scene, even in other contexts like Model.
+ *
+ * @name czm_computeAtmosphereColor
+ * @glslFunction
+ *
+ * @param {czm_ray} primaryRay Ray from the origin to sky fragment to in world coords (low precision)
+ * @param {vec3} lightDirection Light direction from the sun or other light source.
+ * @param {vec3} rayleighColor The Rayleigh scattering color computed by a scattering function
+ * @param {vec3} mieColor The Mie scattering color computed by a scattering function
+ * @param {float} opacity The opacity computed by a scattering function.
+ */
+vec4 czm_computeAtmosphereColor(
+ czm_ray primaryRay,
+ vec3 lightDirection,
+ vec3 rayleighColor,
+ vec3 mieColor,
+ float opacity
+) {
+ vec3 direction = normalize(primaryRay.direction);
+
+ float cosAngle = dot(direction, lightDirection);
+ float cosAngleSq = cosAngle * cosAngle;
+
+ float G = czm_atmosphereMieAnisotropy;
+ float GSq = G * G;
+
+ // The Rayleigh phase function.
+ float rayleighPhase = 3.0 / (50.2654824574) * (1.0 + cosAngleSq);
+ // The Mie phase function.
+ float miePhase = 3.0 / (25.1327412287) * ((1.0 - GSq) * (cosAngleSq + 1.0)) / (pow(1.0 + GSq - 2.0 * cosAngle * G, 1.5) * (2.0 + GSq));
+
+ // The final color is generated by combining the effects of the Rayleigh and Mie scattering.
+ vec3 rayleigh = rayleighPhase * rayleighColor;
+ vec3 mie = miePhase * mieColor;
+
+ vec3 color = (rayleigh + mie) * czm_atmosphereLightIntensity;
+
+ return vec4(color, opacity);
+}
+
+`;var o3t=y(C(),1),IV=`/**
+ * Compute atmosphere scattering for the ground atmosphere and fog. This method
+ * uses automatic uniforms so it is always synced with the scene settings.
+ *
+ * @name czm_computeGroundAtmosphereScattering
+ * @glslfunction
+ *
+ * @param {vec3} positionWC The position of the fragment in world coordinates.
+ * @param {vec3} lightDirection The direction of the light to calculate the scattering from.
+ * @param {vec3} rayleighColor The variable the Rayleigh scattering will be written to.
+ * @param {vec3} mieColor The variable the Mie scattering will be written to.
+ * @param {float} opacity The variable the transmittance will be written to.
+ */
+void czm_computeGroundAtmosphereScattering(vec3 positionWC, vec3 lightDirection, out vec3 rayleighColor, out vec3 mieColor, out float opacity) {
+ vec3 cameraToPositionWC = positionWC - czm_viewerPositionWC;
+ vec3 cameraToPositionWCDirection = normalize(cameraToPositionWC);
+ czm_ray primaryRay = czm_ray(czm_viewerPositionWC, cameraToPositionWCDirection);
+
+ float atmosphereInnerRadius = length(positionWC);
+
+ czm_computeScattering(
+ primaryRay,
+ length(cameraToPositionWC),
+ lightDirection,
+ atmosphereInnerRadius,
+ rayleighColor,
+ mieColor,
+ opacity
+ );
+}
+`;var s3t=y(C(),1),_V=`/**
+ * Returns a position in model coordinates relative to eye taking into
+ * account the current scene mode: 3D, 2D, or Columbus view.
+ *
+ * This uses standard position attributes, position3DHigh,
+ * position3DLow, position2DHigh, and position2DLow,
+ * and should be used when writing a vertex shader for an {@link Appearance}.
+ *
positionMC, in eye coordinates.
+ *
+ * @returns {mat3} A 3x3 rotation matrix that transforms vectors from the east-north-up coordinate system to eye coordinates.
+ *
+ * @example
+ * // Transform a vector defined in the east-north-up coordinate
+ * // system, (0, 0, 1) which is the surface normal, to eye
+ * // coordinates.
+ * mat3 m = czm_eastNorthUpToEyeCoordinates(positionMC, normalEC);
+ * vec3 normalEC = m * vec3(0.0, 0.0, 1.0);
+ */
+mat3 czm_eastNorthUpToEyeCoordinates(vec3 positionMC, vec3 normalEC)
+{
+ vec3 tangentMC = normalize(vec3(-positionMC.y, positionMC.x, 0.0)); // normalized surface tangent in model coordinates
+ vec3 tangentEC = normalize(czm_normal3D * tangentMC); // normalized surface tangent in eye coordinates
+ vec3 bitangentEC = normalize(cross(normalEC, tangentEC)); // normalized surface bitangent in eye coordinates
+
+ return mat3(
+ tangentEC.x, tangentEC.y, tangentEC.z,
+ bitangentEC.x, bitangentEC.y, bitangentEC.z,
+ normalEC.x, normalEC.y, normalEC.z);
+}
+`;var b3t=y(C(),1),VV=`/**
+ * DOC_TBA
+ *
+ * @name czm_ellipsoidContainsPoint
+ * @glslFunction
+ *
+ */
+bool czm_ellipsoidContainsPoint(vec3 ellipsoid_inverseRadii, vec3 point)
+{
+ vec3 scaled = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(point, 1.0)).xyz;
+ return (dot(scaled, scaled) <= 1.0);
+}
+`;var C3t=y(C(),1),GV=`/**
+ * Approximate uv coordinates based on the ellipsoid normal.
+ *
+ * @name czm_ellipsoidTextureCoordinates
+ * @glslFunction
+ */
+vec2 czm_ellipsoidTextureCoordinates(vec3 normal)
+{
+ return vec2(atan(normal.y, normal.x) * czm_oneOverTwoPi + 0.5, asin(normal.z) * czm_oneOverPi + 0.5);
+}
+`;var I3t=y(C(),1),ZV=`/**
+ * Compares left and right componentwise. Returns true
+ * if they are within epsilon and false otherwise. The inputs
+ * left and right can be floats, vec2s,
+ * vec3s, or vec4s.
+ *
+ * @name czm_equalsEpsilon
+ * @glslFunction
+ *
+ * @param {} left The first vector.
+ * @param {} right The second vector.
+ * @param {float} epsilon The epsilon to use for equality testing.
+ * @returns {bool} true if the components are within epsilon and false otherwise.
+ *
+ * @example
+ * // GLSL declarations
+ * bool czm_equalsEpsilon(float left, float right, float epsilon);
+ * bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon);
+ * bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon);
+ * bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon);
+ */
+bool czm_equalsEpsilon(vec4 left, vec4 right, float epsilon) {
+ return all(lessThanEqual(abs(left - right), vec4(epsilon)));
+}
+
+bool czm_equalsEpsilon(vec3 left, vec3 right, float epsilon) {
+ return all(lessThanEqual(abs(left - right), vec3(epsilon)));
+}
+
+bool czm_equalsEpsilon(vec2 left, vec2 right, float epsilon) {
+ return all(lessThanEqual(abs(left - right), vec2(epsilon)));
+}
+
+bool czm_equalsEpsilon(float left, float right, float epsilon) {
+ return (abs(left - right) <= epsilon);
+}
+`;var E3t=y(C(),1),BV=`/**
+ * DOC_TBA
+ *
+ * @name czm_eyeOffset
+ * @glslFunction
+ *
+ * @param {vec4} positionEC DOC_TBA.
+ * @param {vec3} eyeOffset DOC_TBA.
+ *
+ * @returns {vec4} DOC_TBA.
+ */
+vec4 czm_eyeOffset(vec4 positionEC, vec3 eyeOffset)
+{
+ // This equation is approximate in x and y.
+ vec4 p = positionEC;
+ vec4 zEyeOffset = normalize(p) * eyeOffset.z;
+ p.xy += eyeOffset.xy + zEyeOffset.xy;
+ p.z += zEyeOffset.z;
+ return p;
+}
+`;var S3t=y(C(),1),wV=`/**
+ * Transforms a position from eye to window coordinates. The transformation
+ * from eye to clip coordinates is done using {@link czm_projection}.
+ * The transform from normalized device coordinates to window coordinates is
+ * done using {@link czm_viewportTransformation}, which assumes a depth range
+ * of near = 0 and far = 1.
+ * true if the time interval is empty; otherwise, false.
+ *
+ * @example
+ * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
+ * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
+ * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
+ */
+bool czm_isEmpty(czm_raySegment interval)
+{
+ return (interval.stop < 0.0);
+}
+`;var q3t=y(C(),1),OV=`/**
+ * Determines if a time interval is empty.
+ *
+ * @name czm_isFull
+ * @glslFunction
+ *
+ * @param {czm_raySegment} interval The interval to test.
+ *
+ * @returns {bool} true if the time interval is empty; otherwise, false.
+ *
+ * @example
+ * bool b0 = czm_isEmpty(czm_emptyRaySegment); // true
+ * bool b1 = czm_isEmpty(czm_raySegment(0.0, 1.0)); // false
+ * bool b2 = czm_isEmpty(czm_raySegment(1.0, 1.0)); // false, contains 1.0.
+ */
+bool czm_isFull(czm_raySegment interval)
+{
+ return (interval.start == 0.0 && interval.stop == czm_infinity);
+}
+`;var eOt=y(C(),1),HV=`/**
+ * Computes the fraction of a Web Wercator rectangle at which a given geodetic latitude is located.
+ *
+ * @name czm_latitudeToWebMercatorFraction
+ * @glslFunction
+ *
+ * @param {float} latitude The geodetic latitude, in radians.
+ * @param {float} southMercatorY The Web Mercator coordinate of the southern boundary of the rectangle.
+ * @param {float} oneOverMercatorHeight The total height of the rectangle in Web Mercator coordinates.
+ *
+ * @returns {float} The fraction of the rectangle at which the latitude occurs. If the latitude is the southern
+ * boundary of the rectangle, the return value will be zero. If it is the northern boundary, the return
+ * value will be 1.0. Latitudes in between are mapped according to the Web Mercator projection.
+ */
+float czm_latitudeToWebMercatorFraction(float latitude, float southMercatorY, float oneOverMercatorHeight)
+{
+ float sinLatitude = sin(latitude);
+ float mercatorY = 0.5 * log((1.0 + sinLatitude) / (1.0 - sinLatitude));
+
+ return (mercatorY - southMercatorY) * oneOverMercatorHeight;
+}
+`;var nOt=y(C(),1),zV=`/**
+ * Computes distance from an point in 2D to a line in 2D.
+ *
+ * @name czm_lineDistance
+ * @glslFunction
+ *
+ * param {vec2} point1 A point along the line.
+ * param {vec2} point2 A point along the line.
+ * param {vec2} point A point that may or may not be on the line.
+ * returns {float} The distance from the point to the line.
+ */
+float czm_lineDistance(vec2 point1, vec2 point2, vec2 point) {
+ return abs((point2.y - point1.y) * point.x - (point2.x - point1.x) * point.y + point2.x * point1.y - point2.y * point1.x) / distance(point2, point1);
+}
+`;var oOt=y(C(),1),KV=`/**
+ * Converts a linear RGB color to an sRGB color.
+ *
+ * @param {vec3|vec4} linearIn The color in linear color space.
+ * @returns {vec3|vec4} The color in sRGB color space. The vector type matches the input.
+ */
+vec3 czm_linearToSrgb(vec3 linearIn)
+{
+ return pow(linearIn, vec3(1.0/2.2));
+}
+
+vec4 czm_linearToSrgb(vec4 linearIn)
+{
+ vec3 srgbOut = pow(linearIn.rgb, vec3(1.0/2.2));
+ return vec4(srgbOut, linearIn.a);
+}
+`;var sOt=y(C(),1),JV=`/**
+ * Computes the luminance of a color.
+ *
+ * @name czm_luminance
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color.
+ *
+ * @returns {float} The luminance.
+ *
+ * @example
+ * float light = czm_luminance(vec3(0.0)); // 0.0
+ * float dark = czm_luminance(vec3(1.0)); // ~1.0
+ */
+float czm_luminance(vec3 rgb)
+{
+ // Algorithm from Chapter 10 of Graphics Shaders.
+ const vec3 W = vec3(0.2125, 0.7154, 0.0721);
+ return dot(rgb, W);
+}
+`;var cOt=y(C(),1),jV=`/**
+ * Find the maximum component of a vector.
+ *
+ * @name czm_maximumComponent
+ * @glslFunction
+ *
+ * @param {vec2|vec3|vec4} v The input vector.
+ * @returns {float} The value of the largest component.
+ */
+float czm_maximumComponent(vec2 v)
+{
+ return max(v.x, v.y);
+}
+float czm_maximumComponent(vec3 v)
+{
+ return max(max(v.x, v.y), v.z);
+}
+float czm_maximumComponent(vec4 v)
+{
+ return max(max(max(v.x, v.y), v.z), v.w);
+}
+`;var dOt=y(C(),1),qV=`/**
+ * Computes the size of a pixel in meters at a distance from the eye.
+ * + * Use this version when passing in a custom pixel ratio. For example, passing in 1.0 will return meters per native device pixel. + *
+ * @name czm_metersPerPixel + * @glslFunction + * + * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates. + * @param {float} pixelRatio The scaling factor from pixel space to coordinate space + * + * @returns {float} The meters per pixel at positionEC. + */ +float czm_metersPerPixel(vec4 positionEC, float pixelRatio) +{ + float width = czm_viewport.z; + float height = czm_viewport.w; + float pixelWidth; + float pixelHeight; + + float top = czm_frustumPlanes.x; + float bottom = czm_frustumPlanes.y; + float left = czm_frustumPlanes.z; + float right = czm_frustumPlanes.w; + + if (czm_sceneMode == czm_sceneMode2D || czm_orthographicIn3D == 1.0) + { + float frustumWidth = right - left; + float frustumHeight = top - bottom; + pixelWidth = frustumWidth / width; + pixelHeight = frustumHeight / height; + } + else + { + float distanceToPixel = -positionEC.z; + float inverseNear = 1.0 / czm_currentFrustum.x; + float tanTheta = top * inverseNear; + pixelHeight = 2.0 * distanceToPixel * tanTheta / height; + tanTheta = right * inverseNear; + pixelWidth = 2.0 * distanceToPixel * tanTheta / width; + } + + return max(pixelWidth, pixelHeight) * pixelRatio; +} + +/** + * Computes the size of a pixel in meters at a distance from the eye. + *+ * Use this version when scaling by pixel ratio. + *
+ * @name czm_metersPerPixel + * @glslFunction + * + * @param {vec3} positionEC The position to get the meters per pixel in eye coordinates. + * + * @returns {float} The meters per pixel at positionEC. + */ +float czm_metersPerPixel(vec4 positionEC) +{ + return czm_metersPerPixel(positionEC, czm_pixelRatio); +} +`;var mOt=y(C(),1),$V=`/** + * Transforms a position from model to window coordinates. The transformation + * from model to clip coordinates is done using {@link czm_modelViewProjection}. + * The transform from normalized device coordinates to window coordinates is + * done using {@link czm_viewportTransformation}, which assumes a depth range + * ofnear = 0 and far = 1.
+ * + * This function only handles the lighting calculations. Metallic/roughness + * and specular/glossy must be handled separately. See {@MaterialStageFS} + *
+ * + * @name czm_pbrLighting + * @glslFunction + * + * @param {vec3} viewDirectionEC Unit vector pointing from the fragment to the eye position + * @param {vec3} normalEC The surface normal in eye coordinates + * @param {vec3} lightDirectionEC Unit vector pointing to the light source in eye coordinates. + * @param {czm_modelMaterial} The material properties. + * @return {vec3} The computed HDR color + */ +vec3 czm_pbrLighting(vec3 viewDirectionEC, vec3 normalEC, vec3 lightDirectionEC, czm_modelMaterial material) +{ + vec3 halfwayDirectionEC = normalize(viewDirectionEC + lightDirectionEC); + float VdotH = clamp(dot(viewDirectionEC, halfwayDirectionEC), 0.0, 1.0); + float NdotL = clamp(dot(normalEC, lightDirectionEC), 0.001, 1.0); + + vec3 f0 = material.specular; + float reflectance = czm_maximumComponent(f0); + // Typical dielectrics will have reflectance 0.04, so f90 will be 1.0. + // In this case, at grazing angle, all incident energy is reflected. + vec3 f90 = vec3(clamp(reflectance * 25.0, 0.0, 1.0)); + vec3 F = fresnelSchlick2(f0, f90, VdotH); + + #if defined(USE_SPECULAR) + F *= material.specularWeight; + #endif + + float alphaRoughness = material.roughness * material.roughness; + #ifdef USE_ANISOTROPY + mat3 tbn = mat3(material.anisotropicT, material.anisotropicB, normalEC); + vec3 lightDirection = lightDirectionEC * tbn; + vec3 viewDirection = viewDirectionEC * tbn; + vec3 halfwayDirection = halfwayDirectionEC * tbn; + float anisotropyStrength = material.anisotropyStrength; + float tangentialRoughness = mix(alphaRoughness, 1.0, anisotropyStrength * anisotropyStrength); + float bitangentRoughness = clamp(alphaRoughness, 0.001, 1.0); + float G = smithVisibilityGGX_anisotropic(bitangentRoughness, tangentialRoughness, lightDirection, viewDirection); + float D = GGX_anisotropic(bitangentRoughness, tangentialRoughness, halfwayDirection); + vec3 specularContribution = F * G * D; + #else + float specularStrength = computeDirectSpecularStrength(normalEC, lightDirectionEC, viewDirectionEC, halfwayDirectionEC, alphaRoughness); + vec3 specularContribution = F * specularStrength; + #endif + + vec3 diffuseColor = material.diffuse; + // F here represents the specular contribution + vec3 diffuseContribution = (1.0 - F) * lambertianDiffuse(diffuseColor); + + // Lo = (diffuse + specular) * Li * NdotL + return (diffuseContribution + specularContribution) * NdotL; +} +`;var EOt=y(C(),1),rG=`// KhronosGroup https://github.com/KhronosGroup/ToneMapping/tree/main/PBR_Neutral + +// Input color is non-negative and resides in the Linear Rec. 709 color space. +// Output color is also Linear Rec. 709, but in the [0, 1] range. + +vec3 czm_pbrNeutralTonemapping(vec3 color) { + const float startCompression = 0.8 - 0.04; + const float desaturation = 0.15; + + float x = min(color.r, min(color.g, color.b)); + float offset = czm_branchFreeTernary(x < 0.08, x - 6.25 * x * x, 0.04); + color -= offset; + + float peak = max(color.r, max(color.g, color.b)); + if (peak < startCompression) return color; + + const float d = 1.0 - startCompression; + float newPeak = 1.0 - d * d / (peak + d - startCompression); + color *= newPeak / peak; + + float g = 1.0 - 1.0 / (desaturation * (peak - newPeak) + 1.0); + return mix(color, newPeak * vec3(1.0, 1.0, 1.0), g); +} +`;var SOt=y(C(),1),sG=`float czm_private_getLambertDiffuseOfMaterial(vec3 lightDirectionEC, czm_material material) +{ + return czm_getLambertDiffuse(lightDirectionEC, material.normal); +} + +float czm_private_getSpecularOfMaterial(vec3 lightDirectionEC, vec3 toEyeEC, czm_material material) +{ + return czm_getSpecular(lightDirectionEC, toEyeEC, material.normal, material.shininess); +} + +/** + * Computes a color using the Phong lighting model. + * + * @name czm_phong + * @glslFunction + * + * @param {vec3} toEye A normalized vector from the fragment to the eye in eye coordinates. + * @param {czm_material} material The fragment's material. + * + * @returns {vec4} The computed color. + * + * @example + * vec3 positionToEyeEC = // ... + * czm_material material = // ... + * vec3 lightDirectionEC = // ... + * out_FragColor = czm_phong(normalize(positionToEyeEC), material, lightDirectionEC); + * + * @see czm_getMaterial + */ +vec4 czm_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC) +{ + // Diffuse from directional light sources at eye (for top-down) + float diffuse = czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 0.0, 1.0), material); + if (czm_sceneMode == czm_sceneMode3D) { + // (and horizon views in 3D) + diffuse += czm_private_getLambertDiffuseOfMaterial(vec3(0.0, 1.0, 0.0), material); + } + + float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material); + + // Temporary workaround for adding ambient. + vec3 materialDiffuse = material.diffuse * 0.5; + + vec3 ambient = materialDiffuse; + vec3 color = ambient + material.emission; + color += materialDiffuse * diffuse * czm_lightColor; + color += material.specular * specular * czm_lightColor; + + return vec4(color, material.alpha); +} + +vec4 czm_private_phong(vec3 toEye, czm_material material, vec3 lightDirectionEC) +{ + float diffuse = czm_private_getLambertDiffuseOfMaterial(lightDirectionEC, material); + float specular = czm_private_getSpecularOfMaterial(lightDirectionEC, toEye, material); + + vec3 ambient = vec3(0.0); + vec3 color = ambient + material.emission; + color += material.diffuse * diffuse * czm_lightColor; + color += material.specular * specular * czm_lightColor; + + return vec4(color, material.alpha); +} +`;var ROt=y(C(),1),aG=`/** + * Computes distance from a point to a plane. + * + * @name czm_planeDistance + * @glslFunction + * + * param {vec4} plane A Plane in Hessian Normal Form. See Plane.js + * param {vec3} point A point in the same space as the plane. + * returns {float} The distance from the point to the plane. + */ +float czm_planeDistance(vec4 plane, vec3 point) { + return (dot(plane.xyz, point) + plane.w); +} + +/** + * Computes distance from a point to a plane. + * + * @name czm_planeDistance + * @glslFunction + * + * param {vec3} planeNormal Normal for a plane in Hessian Normal Form. See Plane.js + * param {float} planeDistance Distance for a plane in Hessian Normal form. See Plane.js + * param {vec3} point A point in the same space as the plane. + * returns {float} The distance from the point to the plane. + */ +float czm_planeDistance(vec3 planeNormal, float planeDistance, vec3 point) { + return (dot(planeNormal, point) + planeDistance); +} +`;var GOt=y(C(),1),cG=`/** + * Computes the point along a ray at the given time.time can be positive, negative, or zero.
+ *
+ * @name czm_pointAlongRay
+ * @glslFunction
+ *
+ * @param {czm_ray} ray The ray to compute the point along.
+ * @param {float} time The time along the ray.
+ *
+ * @returns {vec3} The point along the ray at the given time.
+ *
+ * @example
+ * czm_ray ray = czm_ray(vec3(0.0), vec3(1.0, 0.0, 0.0)); // origin, direction
+ * vec3 v = czm_pointAlongRay(ray, 2.0); // (2.0, 0.0, 0.0)
+ */
+vec3 czm_pointAlongRay(czm_ray ray, float time)
+{
+ return ray.origin + (time * ray.direction);
+}
+`;var BOt=y(C(),1),lG=`/**
+ * DOC_TBA
+ *
+ * @name czm_rayEllipsoidIntersectionInterval
+ * @glslFunction
+ */
+czm_raySegment czm_rayEllipsoidIntersectionInterval(czm_ray ray, vec3 ellipsoid_center, vec3 ellipsoid_inverseRadii)
+{
+ // ray and ellipsoid center in eye coordinates. radii in model coordinates.
+ vec3 q = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.origin, 1.0)).xyz;
+ vec3 w = ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ray.direction, 0.0)).xyz;
+
+ q = q - ellipsoid_inverseRadii * (czm_inverseModelView * vec4(ellipsoid_center, 1.0)).xyz;
+
+ float q2 = dot(q, q);
+ float qw = dot(q, w);
+
+ if (q2 > 1.0) // Outside ellipsoid.
+ {
+ if (qw >= 0.0) // Looking outward or tangent (0 intersections).
+ {
+ return czm_emptyRaySegment;
+ }
+ else // qw < 0.0.
+ {
+ float qw2 = qw * qw;
+ float difference = q2 - 1.0; // Positively valued.
+ float w2 = dot(w, w);
+ float product = w2 * difference;
+
+ if (qw2 < product) // Imaginary roots (0 intersections).
+ {
+ return czm_emptyRaySegment;
+ }
+ else if (qw2 > product) // Distinct roots (2 intersections).
+ {
+ float discriminant = qw * qw - product;
+ float temp = -qw + sqrt(discriminant); // Avoid cancellation.
+ float root0 = temp / w2;
+ float root1 = difference / temp;
+ if (root0 < root1)
+ {
+ czm_raySegment i = czm_raySegment(root0, root1);
+ return i;
+ }
+ else
+ {
+ czm_raySegment i = czm_raySegment(root1, root0);
+ return i;
+ }
+ }
+ else // qw2 == product. Repeated roots (2 intersections).
+ {
+ float root = sqrt(difference / w2);
+ czm_raySegment i = czm_raySegment(root, root);
+ return i;
+ }
+ }
+ }
+ else if (q2 < 1.0) // Inside ellipsoid (2 intersections).
+ {
+ float difference = q2 - 1.0; // Negatively valued.
+ float w2 = dot(w, w);
+ float product = w2 * difference; // Negatively valued.
+ float discriminant = qw * qw - product;
+ float temp = -qw + sqrt(discriminant); // Positively valued.
+ czm_raySegment i = czm_raySegment(0.0, temp / w2);
+ return i;
+ }
+ else // q2 == 1.0. On ellipsoid.
+ {
+ if (qw < 0.0) // Looking inward.
+ {
+ float w2 = dot(w, w);
+ czm_raySegment i = czm_raySegment(0.0, -qw / w2);
+ return i;
+ }
+ else // qw >= 0.0. Looking outward or tangent.
+ {
+ return czm_emptyRaySegment;
+ }
+ }
+}
+`;var XOt=y(C(),1),dG=`/**
+ * Compute the intersection interval of a ray with a sphere.
+ *
+ * @name czm_raySphereIntersectionInterval
+ * @glslFunction
+ *
+ * @param {czm_ray} ray The ray.
+ * @param {vec3} center The center of the sphere.
+ * @param {float} radius The radius of the sphere.
+ * @return {czm_raySegment} The intersection interval of the ray with the sphere.
+ */
+czm_raySegment czm_raySphereIntersectionInterval(czm_ray ray, vec3 center, float radius)
+{
+ vec3 o = ray.origin;
+ vec3 d = ray.direction;
+
+ vec3 oc = o - center;
+
+ float a = dot(d, d);
+ float b = 2.0 * dot(d, oc);
+ float c = dot(oc, oc) - (radius * radius);
+
+ float det = (b * b) - (4.0 * a * c);
+
+ if (det < 0.0) {
+ return czm_emptyRaySegment;
+ }
+
+ float sqrtDet = sqrt(det);
+
+ float t0 = (-b - sqrtDet) / (2.0 * a);
+ float t1 = (-b + sqrtDet) / (2.0 * a);
+
+ czm_raySegment result = czm_raySegment(t0, t1);
+ return result;
+}
+`;var FOt=y(C(),1),uG=`float czm_readDepth(sampler2D depthTexture, vec2 texCoords)
+{
+ return czm_reverseLogDepth(texture(depthTexture, texCoords).r);
+}
+`;var MOt=y(C(),1),mG=`/**
+ * Reads a value previously transformed with {@link czm_writeNonPerspective}
+ * by dividing it by \`w\`, the value used in the perspective divide.
+ * This function is intended to be called in a fragment shader to access a
+ * \`varying\` that should not be subject to perspective interpolation.
+ * For example, screen-space texture coordinates. The value should have been
+ * previously written in the vertex shader with a call to
+ * {@link czm_writeNonPerspective}.
+ *
+ * @name czm_readNonPerspective
+ * @glslFunction
+ *
+ * @param {float|vec2|vec3|vec4} value The non-perspective value to be read.
+ * @param {float} oneOverW One over the perspective divide value, \`w\`. Usually this is simply \`gl_FragCoord.w\`.
+ * @returns {float|vec2|vec3|vec4} The usable value.
+ */
+float czm_readNonPerspective(float value, float oneOverW) {
+ return value * oneOverW;
+}
+
+vec2 czm_readNonPerspective(vec2 value, float oneOverW) {
+ return value * oneOverW;
+}
+
+vec3 czm_readNonPerspective(vec3 value, float oneOverW) {
+ return value * oneOverW;
+}
+
+vec4 czm_readNonPerspective(vec4 value, float oneOverW) {
+ return value * oneOverW;
+}
+`;var NOt=y(C(),1),hG=`float czm_reverseLogDepth(float logZ)
+{
+#ifdef LOG_DEPTH
+ float near = czm_currentFrustum.x;
+ float far = czm_currentFrustum.y;
+ float log2Depth = logZ * czm_log2FarDepthFromNearPlusOne;
+ float depthFromNear = exp2(log2Depth) - 1.0;
+ return far * (1.0 - near / (depthFromNear + near)) / (far - near);
+#endif
+ return logZ;
+}
+`;var QOt=y(C(),1),fG=`/**
+ * Round a floating point value. This function exists because round() doesn't
+ * exist in GLSL 1.00.
+ *
+ * @param {float|vec2|vec3|vec4} value The value to round
+ * @param {float|vec2|vec3|vec3} The rounded value. The type matches the input.
+ */
+float czm_round(float value) {
+ return floor(value + 0.5);
+}
+
+vec2 czm_round(vec2 value) {
+ return floor(value + 0.5);
+}
+
+vec3 czm_round(vec3 value) {
+ return floor(value + 0.5);
+}
+
+vec4 czm_round(vec4 value) {
+ return floor(value + 0.5);
+}
+`;var kOt=y(C(),1),pG=`/**
+ * Adjusts the saturation of a color.
+ *
+ * @name czm_saturation
+ * @glslFunction
+ *
+ * @param {vec3} rgb The color.
+ * @param {float} adjustment The amount to adjust the saturation of the color.
+ *
+ * @returns {float} The color with the saturation adjusted.
+ *
+ * @example
+ * vec3 greyScale = czm_saturation(color, 0.0);
+ * vec3 doubleSaturation = czm_saturation(color, 2.0);
+ */
+vec3 czm_saturation(vec3 rgb, float adjustment)
+{
+ // Algorithm from Chapter 16 of OpenGL Shading Language
+ const vec3 W = vec3(0.2125, 0.7154, 0.0721);
+ vec3 intensity = vec3(dot(rgb, W));
+ return mix(intensity, rgb, adjustment);
+}
+`;var OOt=y(C(),1),AG=`
+float czm_sampleShadowMap(highp samplerCube shadowMap, vec3 d)
+{
+ return czm_unpackDepth(czm_textureCube(shadowMap, d));
+}
+
+float czm_sampleShadowMap(highp sampler2D shadowMap, vec2 uv)
+{
+#ifdef USE_SHADOW_DEPTH_TEXTURE
+ return texture(shadowMap, uv).r;
+#else
+ return czm_unpackDepth(texture(shadowMap, uv));
+#endif
+}
+
+float czm_shadowDepthCompare(samplerCube shadowMap, vec3 uv, float depth)
+{
+ return step(depth, czm_sampleShadowMap(shadowMap, uv));
+}
+
+float czm_shadowDepthCompare(sampler2D shadowMap, vec2 uv, float depth)
+{
+ return step(depth, czm_sampleShadowMap(shadowMap, uv));
+}
+`;var zOt=y(C(),1),gG=`
+float czm_private_shadowVisibility(float visibility, float nDotL, float normalShadingSmooth, float darkness)
+{
+#ifdef USE_NORMAL_SHADING
+#ifdef USE_NORMAL_SHADING_SMOOTH
+ float strength = clamp(nDotL / normalShadingSmooth, 0.0, 1.0);
+#else
+ float strength = step(0.0, nDotL);
+#endif
+ visibility *= strength;
+#endif
+
+ visibility = max(visibility, darkness);
+ return visibility;
+}
+
+#ifdef USE_CUBE_MAP_SHADOW
+float czm_shadowVisibility(samplerCube shadowMap, czm_shadowParameters shadowParameters)
+{
+ float depthBias = shadowParameters.depthBias;
+ float depth = shadowParameters.depth;
+ float nDotL = shadowParameters.nDotL;
+ float normalShadingSmooth = shadowParameters.normalShadingSmooth;
+ float darkness = shadowParameters.darkness;
+ vec3 uvw = shadowParameters.texCoords;
+
+ depth -= depthBias;
+ float visibility = czm_shadowDepthCompare(shadowMap, uvw, depth);
+ return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
+}
+#else
+float czm_shadowVisibility(sampler2D shadowMap, czm_shadowParameters shadowParameters)
+{
+ float depthBias = shadowParameters.depthBias;
+ float depth = shadowParameters.depth;
+ float nDotL = shadowParameters.nDotL;
+ float normalShadingSmooth = shadowParameters.normalShadingSmooth;
+ float darkness = shadowParameters.darkness;
+ vec2 uv = shadowParameters.texCoords;
+
+ depth -= depthBias;
+#ifdef USE_SOFT_SHADOWS
+ vec2 texelStepSize = shadowParameters.texelStepSize;
+ float radius = 1.0;
+ float dx0 = -texelStepSize.x * radius;
+ float dy0 = -texelStepSize.y * radius;
+ float dx1 = texelStepSize.x * radius;
+ float dy1 = texelStepSize.y * radius;
+ float visibility = (
+ czm_shadowDepthCompare(shadowMap, uv, depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy0), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy0), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy0), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, 0.0), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, 0.0), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(dx0, dy1), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(0.0, dy1), depth) +
+ czm_shadowDepthCompare(shadowMap, uv + vec2(dx1, dy1), depth)
+ ) * (1.0 / 9.0);
+#else
+ float visibility = czm_shadowDepthCompare(shadowMap, uv, depth);
+#endif
+
+ return czm_private_shadowVisibility(visibility, nDotL, normalShadingSmooth, darkness);
+}
+#endif
+`;var JOt=y(C(),1),bG=`/**
+ * Returns 1.0 if the given value is positive or zero, and -1.0 if it is negative. This is similar to the GLSL
+ * built-in function sign except that returns 1.0 instead of 0.0 when the input value is 0.0.
+ *
+ * @name czm_signNotZero
+ * @glslFunction
+ *
+ * @param {} value The value for which to determine the sign.
+ * @returns {} 1.0 if the value is positive or zero, -1.0 if the value is negative.
+ */
+float czm_signNotZero(float value)
+{
+ return value >= 0.0 ? 1.0 : -1.0;
+}
+
+vec2 czm_signNotZero(vec2 value)
+{
+ return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));
+}
+
+vec3 czm_signNotZero(vec3 value)
+{
+ return vec3(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z));
+}
+
+vec4 czm_signNotZero(vec4 value)
+{
+ return vec4(czm_signNotZero(value.x), czm_signNotZero(value.y), czm_signNotZero(value.z), czm_signNotZero(value.w));
+}
+`;var qOt=y(C(),1),yG=`/**
+ * Computes a color from the third order spherical harmonic coefficients and a normalized direction vector.
+ * + * The order of the coefficients is [L00, L1_1, L10, L11, L2_2, L2_1, L20, L21, L22]. + *
+ * + * @name czm_sphericalHarmonics + * @glslFunction + * + * @param {vec3} normal The normalized direction. + * @param {vec3[9]} coefficients The third order spherical harmonic coefficients. + * @returns {vec3} The color at the direction. + * + * @see https://graphics.stanford.edu/papers/envmap/envmap.pdf + */ +vec3 czm_sphericalHarmonics(vec3 normal, vec3 coefficients[9]) +{ + vec3 L00 = coefficients[0]; + vec3 L1_1 = coefficients[1]; + vec3 L10 = coefficients[2]; + vec3 L11 = coefficients[3]; + vec3 L2_2 = coefficients[4]; + vec3 L2_1 = coefficients[5]; + vec3 L20 = coefficients[6]; + vec3 L21 = coefficients[7]; + vec3 L22 = coefficients[8]; + + float x = normal.x; + float y = normal.y; + float z = normal.z; + + vec3 L = + L00 + + L1_1 * y + + L10 * z + + L11 * x + + L2_2 * (y * x) + + L2_1 * (y * z) + + L20 * (3.0 * z * z - 1.0) + + L21 * (z * x) + + L22 * (x * x - y * y); + + return max(L, vec3(0.0)); +} +`;var eHt=y(C(),1),CG=`/** + * Converts an sRGB color to a linear RGB color. + * + * @param {vec3|vec4} srgbIn The color in sRGB space + * @returns {vec3|vec4} The color in linear color space. The vector type matches the input. + */ +vec3 czm_srgbToLinear(vec3 srgbIn) +{ + return pow(srgbIn, vec3(2.2)); +} + +vec4 czm_srgbToLinear(vec4 srgbIn) +{ + vec3 linearOut = pow(srgbIn.rgb, vec3(2.2)); + return vec4(linearOut, srgbIn.a); +} +`;var nHt=y(C(),1),xG=`/** + * Creates a matrix that transforms vectors from tangent space to eye space. + * + * @name czm_tangentToEyeSpaceMatrix + * @glslFunction + * + * @param {vec3} normalEC The normal vector in eye coordinates. + * @param {vec3} tangentEC The tangent vector in eye coordinates. + * @param {vec3} bitangentEC The bitangent vector in eye coordinates. + * + * @returns {mat3} The matrix that transforms from tangent space to eye space. + * + * @example + * mat3 tangentToEye = czm_tangentToEyeSpaceMatrix(normalEC, tangentEC, bitangentEC); + * vec3 normal = tangentToEye * texture(normalMap, st).xyz; + */ +mat3 czm_tangentToEyeSpaceMatrix(vec3 normalEC, vec3 tangentEC, vec3 bitangentEC) +{ + vec3 normal = normalize(normalEC); + vec3 tangent = normalize(tangentEC); + vec3 bitangent = normalize(bitangentEC); + return mat3(tangent.x , tangent.y , tangent.z, + bitangent.x, bitangent.y, bitangent.z, + normal.x , normal.y , normal.z); +} +`;var oHt=y(C(),1),IG=`/** + * A wrapper around the texture (WebGL2) / textureCube (WebGL1) + * function to allow for WebGL 1 support. + * + * @name czm_textureCube + * @glslFunction + * + * @param {samplerCube} sampler The sampler. + * @param {vec3} p The coordinate at which to sample the texture. + */ +vec4 czm_textureCube(samplerCube sampler, vec3 p) { +#if __VERSION__ == 300 + return texture(sampler, p); +#else + return textureCube(sampler, p); +#endif +} + +/** + * A wrapper around the textureLod (WebGL2) / textureCube (WebGL1) + * function to allow for WebGL 1 support in fragment shaders. + * + * @name czm_textureCubeLod + * @glslFunction + * + * @param {samplerCube} sampler The sampler. + * @param {vec3} p The coordinate at which to sample the texture. + * @param {float} lod The mipmap level from which to sample. + */ +vec4 czm_textureCube(samplerCube sampler, vec3 p, float lod) { +#if __VERSION__ == 300 + return textureLod(sampler, p, lod); +#elif defined(GL_EXT_shader_texture_lod) + return textureCubeLodEXT(sampler, p, lod); +#endif +}`;var sHt=y(C(),1),_G=`/** + * Transforms a plane. + * + * @name czm_transformPlane + * @glslFunction + * + * @param {vec4} plane The plane in Hessian Normal Form. + * @param {mat4} transform The inverse-transpose of a transformation matrix. + */ +vec4 czm_transformPlane(vec4 plane, mat4 transform) { + vec4 transformedPlane = transform * plane; + // Convert the transformed plane to Hessian Normal Form + float normalMagnitude = length(transformedPlane.xyz); + return transformedPlane / normalMagnitude; +} +`;var cHt=y(C(),1),EG=`/** + * Translates a position (or anyvec3) that was encoded with {@link EncodedCartesian3},
+ * and then provided to the shader as separate high and low bits to
+ * be relative to the eye. As shown in the example, the position can then be transformed in eye
+ * or clip coordinates using {@link czm_modelViewRelativeToEye} or {@link czm_modelViewProjectionRelativeToEye},
+ * respectively.
+ * + * This technique, called GPU RTE, eliminates jittering artifacts when using large coordinates as + * described in {@link http://help.agi.com/AGIComponents/html/BlogPrecisionsPrecisions.htm|Precisions, Precisions}. + *
+ * + * @name czm_translateRelativeToEye + * @glslFunction + * + * @param {vec3} high The position's high bits. + * @param {vec3} low The position's low bits. + * @returns {vec3} The position translated to be relative to the camera's position. + * + * @example + * in vec3 positionHigh; + * in vec3 positionLow; + * + * void main() + * { + * vec4 p = czm_translateRelativeToEye(positionHigh, positionLow); + * gl_Position = czm_modelViewProjectionRelativeToEye * p; + * } + * + * @see czm_modelViewRelativeToEye + * @see czm_modelViewProjectionRelativeToEye + * @see czm_computePosition + * @see EncodedCartesian3 + */ +vec4 czm_translateRelativeToEye(vec3 high, vec3 low) +{ + vec3 highDifference = high - czm_encodedCameraPositionMCHigh; + // This check handles the case when NaN values have gotten into \`highDifference\`. + // Such a thing could happen on devices running iOS. + if (length(highDifference) == 0.0) { + highDifference = vec3(0); + } + vec3 lowDifference = low - czm_encodedCameraPositionMCLow; + + return vec4(highDifference + lowDifference, 1.0); +} +`;var dHt=y(C(),1),TG=`/** + * @private + */ +vec4 czm_translucentPhong(vec3 toEye, czm_material material, vec3 lightDirectionEC) +{ + // Diffuse from directional light sources at eye (for top-down and horizon views) + float diffuse = czm_getLambertDiffuse(vec3(0.0, 0.0, 1.0), material.normal); + + if (czm_sceneMode == czm_sceneMode3D) { + // (and horizon views in 3D) + diffuse += czm_getLambertDiffuse(vec3(0.0, 1.0, 0.0), material.normal); + } + + diffuse = clamp(diffuse, 0.0, 1.0); + + float specular = czm_getSpecular(lightDirectionEC, toEye, material.normal, material.shininess); + + // Temporary workaround for adding ambient. + vec3 materialDiffuse = material.diffuse * 0.5; + + vec3 ambient = materialDiffuse; + vec3 color = ambient + material.emission; + color += materialDiffuse * diffuse * czm_lightColor; + color += material.specular * specular * czm_lightColor; + + return vec4(color, material.alpha); +} +`;var mHt=y(C(),1),SG=`/** + * Returns the transpose of the matrix. The inputmatrix can be
+ * a mat2, mat3, or mat4.
+ *
+ * @name czm_transpose
+ * @glslFunction
+ *
+ * @param {} matrix The matrix to transpose.
+ *
+ * @returns {} The transposed matrix.
+ *
+ * @example
+ * // GLSL declarations
+ * mat2 czm_transpose(mat2 matrix);
+ * mat3 czm_transpose(mat3 matrix);
+ * mat4 czm_transpose(mat4 matrix);
+ *
+ * // Transpose a 3x3 rotation matrix to find its inverse.
+ * mat3 eastNorthUpToEye = czm_eastNorthUpToEyeCoordinates(
+ * positionMC, normalEC);
+ * mat3 eyeToEastNorthUp = czm_transpose(eastNorthUpToEye);
+ */
+mat2 czm_transpose(mat2 matrix)
+{
+ return mat2(
+ matrix[0][0], matrix[1][0],
+ matrix[0][1], matrix[1][1]);
+}
+
+mat3 czm_transpose(mat3 matrix)
+{
+ return mat3(
+ matrix[0][0], matrix[1][0], matrix[2][0],
+ matrix[0][1], matrix[1][1], matrix[2][1],
+ matrix[0][2], matrix[1][2], matrix[2][2]);
+}
+
+mat4 czm_transpose(mat4 matrix)
+{
+ return mat4(
+ matrix[0][0], matrix[1][0], matrix[2][0], matrix[3][0],
+ matrix[0][1], matrix[1][1], matrix[2][1], matrix[3][1],
+ matrix[0][2], matrix[1][2], matrix[2][2], matrix[3][2],
+ matrix[0][3], matrix[1][3], matrix[2][3], matrix[3][3]);
+}
+`;var fHt=y(C(),1),LG=`vec2 getLookupUv(vec2 dimensions, int i) {
+ int pixY = i / int(dimensions.x);
+ int pixX = i - (pixY * int(dimensions.x));
+ float pixelWidth = 1.0 / dimensions.x;
+ float pixelHeight = 1.0 / dimensions.y;
+ float u = (float(pixX) + 0.5) * pixelWidth; // sample from center of pixel
+ float v = (float(pixY) + 0.5) * pixelHeight;
+ return vec2(u, v);
+}
+
+vec4 czm_unpackClippingExtents(highp sampler2D extentsTexture, int index) {
+ vec2 textureDimensions = vec2(textureSize(extentsTexture, 0));
+ return texture(extentsTexture, getLookupUv(textureDimensions, index));
+}`;var AHt=y(C(),1),RG=`/**
+ * Unpacks a vec4 depth value to a float in [0, 1) range.
+ *
+ * @name czm_unpackDepth
+ * @glslFunction
+ *
+ * @param {vec4} packedDepth The packed depth.
+ *
+ * @returns {float} The floating-point depth in [0, 1) range.
+ */
+float czm_unpackDepth(vec4 packedDepth)
+{
+ // See Aras Pranckevi\u010Dius' post Encoding Floats to RGBA
+ // http://aras-p.info/blog/2009/07/30/encoding-floats-to-rgba-the-final/
+ return dot(packedDepth, vec4(1.0, 1.0 / 255.0, 1.0 / 65025.0, 1.0 / 16581375.0));
+}
+`;var bHt=y(C(),1),VG=`/**
+ * Unpack an IEEE 754 single-precision float that is packed as a little-endian unsigned normalized vec4.
+ *
+ * @name czm_unpackFloat
+ * @glslFunction
+ *
+ * @param {vec4} packedFloat The packed float.
+ *
+ * @returns {float} The floating-point depth in arbitrary range.
+ */
+float czm_unpackFloat(vec4 packedFloat)
+{
+ // Convert to [0.0, 255.0] and round to integer
+ packedFloat = floor(packedFloat * 255.0 + 0.5);
+ float sign = 1.0 - step(128.0, packedFloat[3]) * 2.0;
+ float exponent = 2.0 * mod(packedFloat[3], 128.0) + step(128.0, packedFloat[2]) - 127.0;
+ if (exponent == -127.0)
+ {
+ return 0.0;
+ }
+ float mantissa = mod(packedFloat[2], 128.0) * 65536.0 + packedFloat[1] * 256.0 + packedFloat[0] + float(0x800000);
+ float result = sign * exp2(exponent - 23.0) * mantissa;
+ return result;
+}
+`;var CHt=y(C(),1),GG=`/**
+ * Unpack unsigned integers of 1-4 bytes. in WebGL 1, there is no uint type,
+ * so the return value is an int.
+ * + * There are also precision limitations in WebGL 1. highp int is still limited + * to 24 bits. Above the value of 2^24 = 16777216, precision loss may occur. + *
+ * + * @param {float|vec2|vec3|vec4} packed The packed value. For vectors, the components are listed in little-endian order. + * + * @return {int} The unpacked value. + */ + int czm_unpackUint(float packedValue) { + float rounded = czm_round(packedValue * 255.0); + return int(rounded); + } + + int czm_unpackUint(vec2 packedValue) { + vec2 rounded = czm_round(packedValue * 255.0); + return int(dot(rounded, vec2(1.0, 256.0))); + } + + int czm_unpackUint(vec3 packedValue) { + vec3 rounded = czm_round(packedValue * 255.0); + return int(dot(rounded, vec3(1.0, 256.0, 65536.0))); + } + + int czm_unpackUint(vec4 packedValue) { + vec4 rounded = czm_round(packedValue * 255.0); + return int(dot(rounded, vec4(1.0, 256.0, 65536.0, 16777216.0))); + } +`;var IHt=y(C(),1),ZG=`/** + * Transform metadata values following the EXT_structural_metadata spec + * by multiplying by scale and adding the offset. Operations are always + * performed component-wise, even for matrices. + * + * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} offset The offset to add + * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} scale The scale factor to multiply + * @param {float|vec2|vec3|vec4|mat2|mat3|mat4} value The original value. + * + * @return {float|vec2|vec3|vec4|mat2|mat3|mat4} The transformed value of the same scalar/vector/matrix type as the input. + */ +float czm_valueTransform(float offset, float scale, float value) { + return scale * value + offset; +} + +vec2 czm_valueTransform(vec2 offset, vec2 scale, vec2 value) { + return scale * value + offset; +} + +vec3 czm_valueTransform(vec3 offset, vec3 scale, vec3 value) { + return scale * value + offset; +} + +vec4 czm_valueTransform(vec4 offset, vec4 scale, vec4 value) { + return scale * value + offset; +} + +mat2 czm_valueTransform(mat2 offset, mat2 scale, mat2 value) { + return matrixCompMult(scale, value) + offset; +} + +mat3 czm_valueTransform(mat3 offset, mat3 scale, mat3 value) { + return matrixCompMult(scale, value) + offset; +} + +mat4 czm_valueTransform(mat4 offset, mat4 scale, mat4 value) { + return matrixCompMult(scale, value) + offset; +} +`;var EHt=y(C(),1),BG=`#ifdef LOG_DEPTH +// 1.0 at the near plane, increasing linearly from there. +out float v_depthFromNearPlusOne; +#ifdef SHADOW_MAP +out vec3 v_logPositionEC; +#endif +#endif + +vec4 czm_updatePositionDepth(vec4 coords) { +#if defined(LOG_DEPTH) + +#ifdef SHADOW_MAP + vec3 logPositionEC = (czm_inverseProjection * coords).xyz; + v_logPositionEC = logPositionEC; +#endif + + // With the very high far/near ratios used with the logarithmic depth + // buffer, floating point rounding errors can cause linear depth values + // to end up on the wrong side of the far plane, even for vertices that + // are really nowhere near it. Since we always write a correct logarithmic + // depth value in the fragment shader anyway, we just need to make sure + // such errors don't cause the primitive to be clipped entirely before + // we even get to the fragment shader. + coords.z = clamp(coords.z / coords.w, -1.0, 1.0) * coords.w; +#endif + + return coords; +} + +/** + * Writes the logarithmic depth to gl_Position using the already computed gl_Position. + * + * @name czm_vertexLogDepth + * @glslFunction + */ +void czm_vertexLogDepth() +{ +#ifdef LOG_DEPTH + v_depthFromNearPlusOne = (gl_Position.w - czm_currentFrustum.x) + 1.0; + gl_Position = czm_updatePositionDepth(gl_Position); +#endif +} + +/** + * Writes the logarithmic depth to gl_Position using the provided clip coordinates. + *+ * An example use case for this function would be moving the vertex in window coordinates + * before converting back to clip coordinates. Use the original vertex clip coordinates. + *
+ * @name czm_vertexLogDepth + * @glslFunction + * + * @param {vec4} clipCoords The vertex in clip coordinates. + * + * @example + * czm_vertexLogDepth(czm_projection * vec4(positionEyeCoordinates, 1.0)); + */ +void czm_vertexLogDepth(vec4 clipCoords) +{ +#ifdef LOG_DEPTH + v_depthFromNearPlusOne = (clipCoords.w - czm_currentFrustum.x) + 1.0; + czm_updatePositionDepth(clipCoords); +#endif +} +`;var SHt=y(C(),1),wG=`vec4 czm_screenToEyeCoordinates(vec4 screenCoordinate) +{ + // Reconstruct NDC coordinates + float x = 2.0 * screenCoordinate.x - 1.0; + float y = 2.0 * screenCoordinate.y - 1.0; + float z = (screenCoordinate.z - czm_viewportTransformation[3][2]) / czm_viewportTransformation[2][2]; + vec4 q = vec4(x, y, z, 1.0); + + // Reverse the perspective division to obtain clip coordinates. + q /= screenCoordinate.w; + + // Reverse the projection transformation to obtain eye coordinates. + if (!(czm_inverseProjection == mat4(0.0))) // IE and Edge sometimes do something weird with != between mat4s + { + q = czm_inverseProjection * q; + } + else + { + float top = czm_frustumPlanes.x; + float bottom = czm_frustumPlanes.y; + float left = czm_frustumPlanes.z; + float right = czm_frustumPlanes.w; + + float near = czm_currentFrustum.x; + float far = czm_currentFrustum.y; + + q.x = (q.x * (right - left) + left + right) * 0.5; + q.y = (q.y * (top - bottom) + bottom + top) * 0.5; + q.z = (q.z * (near - far) - near - far) * 0.5; + q.w = 1.0; + } + + return q; +} + +/** + * Transforms a position from window to eye coordinates. + * The transform from window to normalized device coordinates is done using components + * of (@link czm_viewport} and {@link czm_viewportTransformation} instead of calculating + * the inverse ofczm_viewportTransformation. The transformation from
+ * normalized device coordinates to clip coordinates is done using fragmentCoordinate.w,
+ * which is expected to be the scalar used in the perspective divide. The transformation
+ * from clip to eye coordinates is done using {@link czm_inverseProjection}.
+ *
+ * @name czm_windowToEyeCoordinates
+ * @glslFunction
+ *
+ * @param {vec4} fragmentCoordinate The position in window coordinates to transform.
+ *
+ * @returns {vec4} The transformed position in eye coordinates.
+ *
+ * @see czm_modelToWindowCoordinates
+ * @see czm_eyeToWindowCoordinates
+ * @see czm_inverseProjection
+ * @see czm_viewport
+ * @see czm_viewportTransformation
+ *
+ * @example
+ * vec4 positionEC = czm_windowToEyeCoordinates(gl_FragCoord);
+ */
+vec4 czm_windowToEyeCoordinates(vec4 fragmentCoordinate)
+{
+ vec2 screenCoordXY = (fragmentCoordinate.xy - czm_viewport.xy) / czm_viewport.zw;
+ return czm_screenToEyeCoordinates(vec4(screenCoordXY, fragmentCoordinate.zw));
+}
+
+vec4 czm_screenToEyeCoordinates(vec2 screenCoordinateXY, float depthOrLogDepth)
+{
+ // See reverseLogDepth.glsl. This is separate to re-use the pow.
+#if defined(LOG_DEPTH) || defined(LOG_DEPTH_READ_ONLY)
+ float near = czm_currentFrustum.x;
+ float far = czm_currentFrustum.y;
+ float log2Depth = depthOrLogDepth * czm_log2FarDepthFromNearPlusOne;
+ float depthFromNear = exp2(log2Depth) - 1.0;
+ float depthFromCamera = depthFromNear + near;
+ vec4 screenCoord = vec4(screenCoordinateXY, far * (1.0 - near / depthFromCamera) / (far - near), 1.0);
+ vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);
+ eyeCoordinate.w = 1.0 / depthFromCamera; // Better precision
+#else
+ vec4 screenCoord = vec4(screenCoordinateXY, depthOrLogDepth, 1.0);
+ vec4 eyeCoordinate = czm_screenToEyeCoordinates(screenCoord);
+#endif
+ return eyeCoordinate;
+}
+
+/**
+ * Transforms a position given as window x/y and a depth or a log depth from window to eye coordinates.
+ * This function produces more accurate results for window positions with log depth than
+ * conventionally unpacking the log depth using czm_reverseLogDepth and using the standard version
+ * of czm_windowToEyeCoordinates.
+ *
+ * @name czm_windowToEyeCoordinates
+ * @glslFunction
+ *
+ * @param {vec2} fragmentCoordinateXY The XY position in window coordinates to transform.
+ * @param {float} depthOrLogDepth A depth or log depth for the fragment.
+ *
+ * @see czm_modelToWindowCoordinates
+ * @see czm_eyeToWindowCoordinates
+ * @see czm_inverseProjection
+ * @see czm_viewport
+ * @see czm_viewportTransformation
+ *
+ * @returns {vec4} The transformed position in eye coordinates.
+ */
+vec4 czm_windowToEyeCoordinates(vec2 fragmentCoordinateXY, float depthOrLogDepth)
+{
+ vec2 screenCoordXY = (fragmentCoordinateXY.xy - czm_viewport.xy) / czm_viewport.zw;
+ return czm_screenToEyeCoordinates(screenCoordXY, depthOrLogDepth);
+}
+`;var RHt=y(C(),1),XG=`// emulated noperspective
+#if !defined(LOG_DEPTH)
+in float v_WindowZ;
+#endif
+
+/**
+ * Emulates GL_DEPTH_CLAMP. Clamps a fragment to the near and far plane
+ * by writing the fragment's depth. See czm_depthClamp for more details.
+ *
+ * @name czm_writeDepthClamp
+ * @glslFunction
+ *
+ * @example
+ * out_FragColor = color;
+ * czm_writeDepthClamp();
+ *
+ * @see czm_depthClamp
+ */
+void czm_writeDepthClamp()
+{
+#if (!defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth)))
+ gl_FragDepth = clamp(v_WindowZ * gl_FragCoord.w, 0.0, 1.0);
+#endif
+}
+`;var GHt=y(C(),1),WG=`#ifdef LOG_DEPTH
+in float v_depthFromNearPlusOne;
+
+#ifdef POLYGON_OFFSET
+uniform vec2 u_polygonOffset;
+#endif
+
+#endif
+
+/**
+ * Writes the fragment depth to the logarithmic depth buffer.
+ * + * Use this when the vertex shader does not call {@link czm_vertexLogDepth}, for example, when + * ray-casting geometry using a full screen quad. + *
+ * @name czm_writeLogDepth + * @glslFunction + * + * @param {float} depth The depth coordinate, where 1.0 is on the near plane and + * depth increases in eye-space units from there + * + * @example + * czm_writeLogDepth((czm_projection * v_positionEyeCoordinates).w + 1.0); + */ +void czm_writeLogDepth(float depth) +{ +#if (defined(LOG_DEPTH) && (__VERSION__ == 300 || defined(GL_EXT_frag_depth))) + // Discard the vertex if it's not between the near and far planes. + // We allow a bit of epsilon on the near plane comparison because a 1.0 + // from the vertex shader (indicating the vertex should be _on_ the near + // plane) will not necessarily come here as exactly 1.0. + if (depth <= 0.9999999 || depth > czm_farDepthFromNearPlusOne) { + discard; + } + +#ifdef POLYGON_OFFSET + // Polygon offset: m * factor + r * units + float factor = u_polygonOffset[0]; + float units = u_polygonOffset[1]; + +#if (__VERSION__ == 300 || defined(GL_OES_standard_derivatives)) + // This factor doesn't work in IE 10 + if (factor != 0.0) { + // m = sqrt(dZdX^2 + dZdY^2); + float x = dFdx(depth); + float y = dFdy(depth); + float m = sqrt(x * x + y * y); + + // Apply the factor before computing the log depth. + depth += m * factor; + } +#endif + +#endif + + gl_FragDepth = log2(depth) * czm_oneOverLog2FarDepthFromNearPlusOne; + +#ifdef POLYGON_OFFSET + // Apply the units after the log depth. + gl_FragDepth += czm_epsilon7 * units; +#endif + +#endif +} + +/** + * Writes the fragment depth to the logarithmic depth buffer. + *+ * Use this when the vertex shader calls {@link czm_vertexLogDepth}. + *
+ * + * @name czm_writeLogDepth + * @glslFunction + */ +void czm_writeLogDepth() { +#ifdef LOG_DEPTH + czm_writeLogDepth(v_depthFromNearPlusOne); +#endif +} +`;var BHt=y(C(),1),FG=`/** + * Transforms a value for non-perspective interpolation by multiplying + * it by w, the value used in the perspective divide. This function is + * intended to be called in a vertex shader to compute the value of a + * \`varying\` that should not be subject to perspective interpolation. + * For example, screen-space texture coordinates. The fragment shader + * must call {@link czm_readNonPerspective} to retrieve the final + * non-perspective value. + * + * @name czm_writeNonPerspective + * @glslFunction + * + * @param {float|vec2|vec3|vec4} value The value to be interpolated without accounting for perspective. + * @param {float} w The perspective divide value. Usually this is the computed \`gl_Position.w\`. + * @returns {float|vec2|vec3|vec4} The transformed value, intended to be stored in a \`varying\` and read in the + * fragment shader with {@link czm_readNonPerspective}. + */ +float czm_writeNonPerspective(float value, float w) { + return value * w; +} + +vec2 czm_writeNonPerspective(vec2 value, float w) { + return value * w; +} + +vec3 czm_writeNonPerspective(vec3 value, float w) { + return value * w; +} + +vec4 czm_writeNonPerspective(vec4 value, float w) { + return value * w; +} +`;var iC={czm_degreesPerRadian:cR,czm_depthRange:lR,czm_epsilon1:dR,czm_epsilon2:uR,czm_epsilon3:mR,czm_epsilon4:hR,czm_epsilon5:fR,czm_epsilon6:pR,czm_epsilon7:AR,czm_infinity:gR,czm_oneOverPi:bR,czm_oneOverTwoPi:yR,czm_passCesium3DTile:CR,czm_passCesium3DTileClassification:xR,czm_passCesium3DTileClassificationIgnoreShow:IR,czm_passClassification:_R,czm_passCompute:ER,czm_passEnvironment:TR,czm_passGaussianSplats:SR,czm_passGlobe:LR,czm_passOpaque:RR,czm_passOverlay:VR,czm_passTerrainClassification:GR,czm_passTranslucent:ZR,czm_passVoxels:BR,czm_pi:wR,czm_piOverFour:XR,czm_piOverSix:WR,czm_piOverThree:FR,czm_piOverTwo:PR,czm_radiansPerDegree:MR,czm_sceneMode2D:vR,czm_sceneMode3D:NR,czm_sceneModeColumbusView:DR,czm_sceneModeMorphing:QR,czm_solarRadius:UR,czm_threePiOver2:kR,czm_twoPi:YR,czm_webMercatorMaxLatitude:OR,czm_depthRangeStruct:HR,czm_material:zR,czm_materialInput:KR,czm_modelMaterial:JR,czm_modelVertexOutput:jR,czm_ray:qR,czm_raySegment:$R,czm_shadowParameters:eV,czm_HSBToRGB:tV,czm_HSLToRGB:nV,czm_RGBToHSB:iV,czm_RGBToHSL:oV,czm_RGBToXYZ:rV,czm_XYZToRGB:sV,czm_acesTonemapping:aV,czm_alphaWeight:cV,czm_antialias:lV,czm_applyHSBShift:dV,czm_approximateSphericalCoordinates:uV,czm_approximateTanh:mV,czm_backFacing:hV,czm_branchFreeTernary:fV,czm_cascadeColor:pV,czm_cascadeDistance:AV,czm_cascadeMatrix:gV,czm_cascadeWeights:bV,czm_clipPolygons:yV,czm_columbusViewMorph:CV,czm_computeAtmosphereColor:xV,czm_computeGroundAtmosphereScattering:IV,czm_computePosition:_V,czm_computeScattering:EV,czm_cosineAndSine:TV,czm_decompressTextureCoordinates:SV,czm_depthClamp:LV,czm_eastNorthUpToEyeCoordinates:RV,czm_ellipsoidContainsPoint:VV,czm_ellipsoidTextureCoordinates:GV,czm_equalsEpsilon:ZV,czm_eyeOffset:BV,czm_eyeToWindowCoordinates:wV,czm_fastApproximateAtan:XV,czm_fog:WV,czm_gammaCorrect:FV,czm_geodeticSurfaceNormal:PV,czm_getDefaultMaterial:MV,czm_getDynamicAtmosphereLightDirection:vV,czm_getLambertDiffuse:NV,czm_getSpecular:DV,czm_getWaterNoise:QV,czm_hue:UV,czm_inverseGamma:kV,czm_isEmpty:YV,czm_isFull:OV,czm_latitudeToWebMercatorFraction:HV,czm_lineDistance:zV,czm_linearToSrgb:KV,czm_luminance:JV,czm_maximumComponent:jV,czm_metersPerPixel:qV,czm_modelToWindowCoordinates:$V,czm_multiplyWithColorBalance:eG,czm_nearFarScalar:tG,czm_octDecode:nG,czm_packDepth:iG,czm_pbrLighting:oG,czm_pbrNeutralTonemapping:rG,czm_phong:sG,czm_planeDistance:aG,czm_pointAlongRay:cG,czm_rayEllipsoidIntersectionInterval:lG,czm_raySphereIntersectionInterval:dG,czm_readDepth:uG,czm_readNonPerspective:mG,czm_reverseLogDepth:hG,czm_round:fG,czm_saturation:pG,czm_shadowDepthCompare:AG,czm_shadowVisibility:gG,czm_signNotZero:bG,czm_sphericalHarmonics:yG,czm_srgbToLinear:CG,czm_tangentToEyeSpaceMatrix:xG,czm_textureCube:IG,czm_transformPlane:_G,czm_translateRelativeToEye:EG,czm_translucentPhong:TG,czm_transpose:SG,czm_unpackClippingExtents:LG,czm_unpackDepth:RG,czm_unpackFloat:VG,czm_unpackUint:GG,czm_valueTransform:ZG,czm_vertexLogDepth:BG,czm_windowToEyeCoordinates:wG,czm_writeDepthClamp:XG,czm_writeLogDepth:WG,czm_writeNonPerspective:FG};var uJt=y(C(),1);function KBe(e,t){let n=e;return n=n.replaceAll("version 300 es",""),n=n.replaceAll(/(texture\()/g,"texture2D("),t?(n=n.replaceAll(/\n\s*(in)\s+(vec\d|mat\d|float)/g,` +varying $2`),/out_FragData_(\d+)/.test(n)&&(n=`#extension GL_EXT_draw_buffers : enable +${n}`,n=n.replaceAll(/layout\s+\(location\s*=\s*\d+\)\s*out\s+vec4\s+out_FragData_\d+;/g,""),n=n.replaceAll(/out_FragData_(\d+)/g,"gl_FragData[$1]")),n=n.replaceAll(/layout\s+\(location\s*=\s*0\)\s*out\s+vec4\s+out_FragColor;/g,""),n=n.replaceAll(/out_FragColor/g,"gl_FragColor"),n=n.replaceAll(/out_FragColor\[(\d+)\]/g,"gl_FragColor[$1]"),/gl_FragDepth/.test(n)&&(n=`#extension GL_EXT_frag_depth : enable +${n}`,n=n.replaceAll(/gl_FragDepth/g,"gl_FragDepthEXT")),n=`#ifdef GL_EXT_shader_texture_lod +#extension GL_EXT_shader_texture_lod : enable +#endif +${n}`,n=`#ifdef GL_OES_standard_derivatives +#extension GL_OES_standard_derivatives : enable +#endif +${n}`):(n=n.replaceAll(/(in)\s+(vec\d|mat\d|float)/g,"attribute $2"),n=n.replaceAll(/(out)\s+(vec\d|mat\d|float)\s+([\w]+);/g,"varying $2 $3;")),n=`#version 100 +${n}`,n}var PG=KBe;function $ie(e){return e=e.replace(/\/\/.*/g,""),e.replace(/\/\*\*[\s\S]*?\*\//gm,function(t){let n=t.match(/\n/gm).length,i="";for(let o=0;o0?(s="",e&&(s+=`uniform bool tile_translucentCommand;
+`),s+=`uniform sampler2D tile_batchTexture;
+out vec4 tile_featureColor;
+out vec2 tile_featureSt;
+void main()
+{
+ vec2 st = computeSt(${t});
+ vec4 featureProperties = texture(tile_batchTexture, st);
+ tile_color(featureProperties);
+ float show = ceil(featureProperties.a);
+ gl_Position *= show;
+`,e&&(s+=` bool isStyleTranslucent = (featureProperties.a != 1.0);
+ if (czm_pass == czm_passTranslucent)
+ {
+ if (!isStyleTranslucent && !tile_translucentCommand)
+ {
+ gl_Position *= 0.0;
+ }
+ }
+ else
+ {
+ if (isStyleTranslucent)
+ {
+ gl_Position *= 0.0;
+ }
+ }
+`),s+=` tile_featureColor = featureProperties;
+ tile_featureSt = st;
+}`):s=`out vec2 tile_featureSt;
+void main()
+{
+ tile_color(vec4(1.0));
+ tile_featureSt = computeSt(${t});
+}`,`${r}
+${SFe(i)}${s}`}};function ese(e,t){return e=Oe.replaceMain(e,"tile_main"),t?`${e}uniform float tile_colorBlend;
+void tile_color(vec4 tile_featureColor)
+{
+ tile_main();
+ tile_featureColor = czm_gammaCorrect(tile_featureColor);
+ out_FragColor.a *= tile_featureColor.a;
+ float highlight = ceil(tile_colorBlend);
+ out_FragColor.rgb *= mix(tile_featureColor.rgb, vec3(1.0), highlight);
+}
+`:`${e}void tile_color(vec4 tile_featureColor)
+{
+ tile_main();
+}
+`}function LFe(e,t){let n=`texture(${t}`,i=0,o=e.indexOf(n,i),r;for(;o>-1;){let s=0;for(let d=o;d