GlobeFS.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "uniform vec4 u_initialColor;\n\
  3. #if TEXTURE_UNITS > 0\n\
  4. uniform sampler2D u_dayTextures[TEXTURE_UNITS];\n\
  5. uniform vec4 u_dayTextureTranslationAndScale[TEXTURE_UNITS];\n\
  6. uniform bool u_dayTextureUseWebMercatorT[TEXTURE_UNITS];\n\
  7. #ifdef APPLY_ALPHA\n\
  8. uniform float u_dayTextureAlpha[TEXTURE_UNITS];\n\
  9. #endif\n\
  10. #ifdef APPLY_SPLIT\n\
  11. uniform float u_dayTextureSplit[TEXTURE_UNITS];\n\
  12. #endif\n\
  13. #ifdef APPLY_BRIGHTNESS\n\
  14. uniform float u_dayTextureBrightness[TEXTURE_UNITS];\n\
  15. #endif\n\
  16. #ifdef APPLY_CONTRAST\n\
  17. uniform float u_dayTextureContrast[TEXTURE_UNITS];\n\
  18. #endif\n\
  19. #ifdef APPLY_HUE\n\
  20. uniform float u_dayTextureHue[TEXTURE_UNITS];\n\
  21. #endif\n\
  22. #ifdef APPLY_SATURATION\n\
  23. uniform float u_dayTextureSaturation[TEXTURE_UNITS];\n\
  24. #endif\n\
  25. #ifdef APPLY_GAMMA\n\
  26. uniform float u_dayTextureOneOverGamma[TEXTURE_UNITS];\n\
  27. #endif\n\
  28. #ifdef APPLY_IMAGERY_CUTOUT\n\
  29. uniform vec4 u_dayTextureCutoutRectangles[TEXTURE_UNITS];\n\
  30. #endif\n\
  31. #ifdef APPLY_COLOR_TO_ALPHA\n\
  32. uniform vec4 u_colorsToAlpha[TEXTURE_UNITS];\n\
  33. #endif\n\
  34. uniform vec4 u_dayTextureTexCoordsRectangle[TEXTURE_UNITS];\n\
  35. #endif\n\
  36. #ifdef SHOW_REFLECTIVE_OCEAN\n\
  37. uniform sampler2D u_waterMask;\n\
  38. uniform vec4 u_waterMaskTranslationAndScale;\n\
  39. uniform float u_zoomedOutOceanSpecularIntensity;\n\
  40. #endif\n\
  41. #ifdef SHOW_OCEAN_WAVES\n\
  42. uniform sampler2D u_oceanNormalMap;\n\
  43. #endif\n\
  44. #if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)\n\
  45. uniform vec2 u_lightingFadeDistance;\n\
  46. #endif\n\
  47. #ifdef TILE_LIMIT_RECTANGLE\n\
  48. uniform vec4 u_cartographicLimitRectangle;\n\
  49. #endif\n\
  50. #ifdef GROUND_ATMOSPHERE\n\
  51. uniform vec2 u_nightFadeDistance;\n\
  52. #endif\n\
  53. #ifdef ENABLE_CLIPPING_PLANES\n\
  54. uniform sampler2D u_clippingPlanes;\n\
  55. uniform mat4 u_clippingPlanesMatrix;\n\
  56. uniform vec4 u_clippingPlanesEdgeStyle;\n\
  57. #endif\n\
  58. #if defined(FOG) && (defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING)) || defined(GROUND_ATMOSPHERE)\n\
  59. uniform float u_minimumBrightness;\n\
  60. #endif\n\
  61. #ifdef COLOR_CORRECT\n\
  62. uniform vec3 u_hsbShift;\n\
  63. #endif\n\
  64. #ifdef HIGHLIGHT_FILL_TILE\n\
  65. uniform vec4 u_fillHighlightColor;\n\
  66. #endif\n\
  67. varying vec3 v_positionMC;\n\
  68. varying vec3 v_positionEC;\n\
  69. varying vec3 v_textureCoordinates;\n\
  70. varying vec3 v_normalMC;\n\
  71. varying vec3 v_normalEC;\n\
  72. #ifdef APPLY_MATERIAL\n\
  73. varying float v_height;\n\
  74. varying float v_slope;\n\
  75. varying float v_aspect;\n\
  76. #endif\n\
  77. #if defined(FOG) || defined(GROUND_ATMOSPHERE)\n\
  78. varying float v_distance;\n\
  79. varying vec3 v_fogRayleighColor;\n\
  80. varying vec3 v_fogMieColor;\n\
  81. #endif\n\
  82. #ifdef GROUND_ATMOSPHERE\n\
  83. varying vec3 v_rayleighColor;\n\
  84. varying vec3 v_mieColor;\n\
  85. #endif\n\
  86. vec4 sampleAndBlend(\n\
  87. vec4 previousColor,\n\
  88. sampler2D textureToSample,\n\
  89. vec2 tileTextureCoordinates,\n\
  90. vec4 textureCoordinateRectangle,\n\
  91. vec4 textureCoordinateTranslationAndScale,\n\
  92. float textureAlpha,\n\
  93. float textureBrightness,\n\
  94. float textureContrast,\n\
  95. float textureHue,\n\
  96. float textureSaturation,\n\
  97. float textureOneOverGamma,\n\
  98. float split,\n\
  99. vec4 colorToAlpha)\n\
  100. {\n\
  101. vec2 alphaMultiplier = step(textureCoordinateRectangle.st, tileTextureCoordinates);\n\
  102. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;\n\
  103. alphaMultiplier = step(vec2(0.0), textureCoordinateRectangle.pq - tileTextureCoordinates);\n\
  104. textureAlpha = textureAlpha * alphaMultiplier.x * alphaMultiplier.y;\n\
  105. vec2 translation = textureCoordinateTranslationAndScale.xy;\n\
  106. vec2 scale = textureCoordinateTranslationAndScale.zw;\n\
  107. vec2 textureCoordinates = tileTextureCoordinates * scale + translation;\n\
  108. vec4 value = texture2D(textureToSample, textureCoordinates);\n\
  109. vec3 color = value.rgb;\n\
  110. float alpha = value.a;\n\
  111. #ifdef APPLY_COLOR_TO_ALPHA\n\
  112. vec3 colorDiff = abs(color.rgb - colorToAlpha.rgb);\n\
  113. colorDiff.r = max(max(colorDiff.r, colorDiff.g), colorDiff.b);\n\
  114. alpha = czm_branchFreeTernary(colorDiff.r < colorToAlpha.a, 0.0, alpha);\n\
  115. #endif\n\
  116. #if !defined(APPLY_GAMMA)\n\
  117. vec4 tempColor = czm_gammaCorrect(vec4(color, alpha));\n\
  118. color = tempColor.rgb;\n\
  119. alpha = tempColor.a;\n\
  120. #else\n\
  121. color = pow(color, vec3(textureOneOverGamma));\n\
  122. #endif\n\
  123. #ifdef APPLY_SPLIT\n\
  124. float splitPosition = czm_imagerySplitPosition;\n\
  125. if (split < 0.0 && gl_FragCoord.x > splitPosition) {\n\
  126. alpha = 0.0;\n\
  127. }\n\
  128. else if (split > 0.0 && gl_FragCoord.x < splitPosition) {\n\
  129. alpha = 0.0;\n\
  130. }\n\
  131. #endif\n\
  132. #ifdef APPLY_BRIGHTNESS\n\
  133. color = mix(vec3(0.0), color, textureBrightness);\n\
  134. #endif\n\
  135. #ifdef APPLY_CONTRAST\n\
  136. color = mix(vec3(0.5), color, textureContrast);\n\
  137. #endif\n\
  138. #ifdef APPLY_HUE\n\
  139. color = czm_hue(color, textureHue);\n\
  140. #endif\n\
  141. #ifdef APPLY_SATURATION\n\
  142. color = czm_saturation(color, textureSaturation);\n\
  143. #endif\n\
  144. float sourceAlpha = alpha * textureAlpha;\n\
  145. float outAlpha = mix(previousColor.a, 1.0, sourceAlpha);\n\
  146. outAlpha += sign(outAlpha) - 1.0;\n\
  147. vec3 outColor = mix(previousColor.rgb * previousColor.a, color, sourceAlpha) / outAlpha;\n\
  148. return vec4(outColor, max(outAlpha, 0.0));\n\
  149. }\n\
  150. vec3 colorCorrect(vec3 rgb) {\n\
  151. #ifdef COLOR_CORRECT\n\
  152. vec3 hsb = czm_RGBToHSB(rgb);\n\
  153. hsb.x += u_hsbShift.x;\n\
  154. hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0);\n\
  155. hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0;\n\
  156. rgb = czm_HSBToRGB(hsb);\n\
  157. #endif\n\
  158. return rgb;\n\
  159. }\n\
  160. vec4 computeDayColor(vec4 initialColor, vec3 textureCoordinates);\n\
  161. vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float specularMapValue, float fade);\n\
  162. void main()\n\
  163. {\n\
  164. #ifdef TILE_LIMIT_RECTANGLE\n\
  165. if (v_textureCoordinates.x < u_cartographicLimitRectangle.x || u_cartographicLimitRectangle.z < v_textureCoordinates.x ||\n\
  166. v_textureCoordinates.y < u_cartographicLimitRectangle.y || u_cartographicLimitRectangle.w < v_textureCoordinates.y)\n\
  167. {\n\
  168. discard;\n\
  169. }\n\
  170. #endif\n\
  171. #ifdef ENABLE_CLIPPING_PLANES\n\
  172. float clipDistance = clip(gl_FragCoord, u_clippingPlanes, u_clippingPlanesMatrix);\n\
  173. #endif\n\
  174. vec4 color = computeDayColor(u_initialColor, clamp(v_textureCoordinates, 0.0, 1.0));\n\
  175. #ifdef SHOW_TILE_BOUNDARIES\n\
  176. if (v_textureCoordinates.x < (1.0/256.0) || v_textureCoordinates.x > (255.0/256.0) ||\n\
  177. v_textureCoordinates.y < (1.0/256.0) || v_textureCoordinates.y > (255.0/256.0))\n\
  178. {\n\
  179. color = vec4(1.0, 0.0, 0.0, 1.0);\n\
  180. }\n\
  181. #endif\n\
  182. #if defined(SHOW_REFLECTIVE_OCEAN) || defined(ENABLE_DAYNIGHT_SHADING) || defined(HDR)\n\
  183. vec3 normalMC = czm_geodeticSurfaceNormal(v_positionMC, vec3(0.0), vec3(1.0));\n\
  184. vec3 normalEC = czm_normal3D * normalMC;\n\
  185. #endif\n\
  186. #if defined(ENABLE_DAYNIGHT_SHADING) || defined(GROUND_ATMOSPHERE)\n\
  187. float cameraDist;\n\
  188. if (czm_sceneMode == czm_sceneMode2D)\n\
  189. {\n\
  190. cameraDist = max(czm_frustumPlanes.x - czm_frustumPlanes.y, czm_frustumPlanes.w - czm_frustumPlanes.z) * 0.5;\n\
  191. }\n\
  192. else if (czm_sceneMode == czm_sceneModeColumbusView)\n\
  193. {\n\
  194. cameraDist = -czm_view[3].z;\n\
  195. }\n\
  196. else\n\
  197. {\n\
  198. cameraDist = length(czm_view[3]);\n\
  199. }\n\
  200. float fadeOutDist = u_lightingFadeDistance.x;\n\
  201. float fadeInDist = u_lightingFadeDistance.y;\n\
  202. if (czm_sceneMode != czm_sceneMode3D) {\n\
  203. vec3 radii = czm_ellipsoidRadii;\n\
  204. float maxRadii = max(radii.x, max(radii.y, radii.z));\n\
  205. fadeOutDist -= maxRadii;\n\
  206. fadeInDist -= maxRadii;\n\
  207. }\n\
  208. float fade = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.0, 1.0);\n\
  209. #else\n\
  210. float fade = 0.0;\n\
  211. #endif\n\
  212. #ifdef SHOW_REFLECTIVE_OCEAN\n\
  213. vec2 waterMaskTranslation = u_waterMaskTranslationAndScale.xy;\n\
  214. vec2 waterMaskScale = u_waterMaskTranslationAndScale.zw;\n\
  215. vec2 waterMaskTextureCoordinates = v_textureCoordinates.xy * waterMaskScale + waterMaskTranslation;\n\
  216. waterMaskTextureCoordinates.y = 1.0 - waterMaskTextureCoordinates.y;\n\
  217. float mask = texture2D(u_waterMask, waterMaskTextureCoordinates).r;\n\
  218. if (mask > 0.0)\n\
  219. {\n\
  220. mat3 enuToEye = czm_eastNorthUpToEyeCoordinates(v_positionMC, normalEC);\n\
  221. vec2 ellipsoidTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC);\n\
  222. vec2 ellipsoidFlippedTextureCoordinates = czm_ellipsoidWgs84TextureCoordinates(normalMC.zyx);\n\
  223. vec2 textureCoordinates = mix(ellipsoidTextureCoordinates, ellipsoidFlippedTextureCoordinates, czm_morphTime * smoothstep(0.9, 0.95, normalMC.z));\n\
  224. color = computeWaterColor(v_positionEC, textureCoordinates, enuToEye, color, mask, fade);\n\
  225. }\n\
  226. #endif\n\
  227. #ifdef APPLY_MATERIAL\n\
  228. czm_materialInput materialInput;\n\
  229. materialInput.st = v_textureCoordinates.st;\n\
  230. materialInput.normalEC = normalize(v_normalEC);\n\
  231. materialInput.slope = v_slope;\n\
  232. materialInput.height = v_height;\n\
  233. materialInput.aspect = v_aspect;\n\
  234. czm_material material = czm_getMaterial(materialInput);\n\
  235. color.xyz = mix(color.xyz, material.diffuse, material.alpha);\n\
  236. #endif\n\
  237. #ifdef ENABLE_VERTEX_LIGHTING\n\
  238. float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_sunDirectionEC, normalize(v_normalEC)) * 0.9 + 0.3, 0.0, 1.0);\n\
  239. vec4 finalColor = vec4(color.rgb * diffuseIntensity, color.a);\n\
  240. #elif defined(ENABLE_DAYNIGHT_SHADING)\n\
  241. float diffuseIntensity = clamp(czm_getLambertDiffuse(czm_sunDirectionEC, normalEC) * 5.0 + 0.3, 0.0, 1.0);\n\
  242. diffuseIntensity = mix(1.0, diffuseIntensity, fade);\n\
  243. vec4 finalColor = vec4(color.rgb * diffuseIntensity, color.a);\n\
  244. #else\n\
  245. vec4 finalColor = color;\n\
  246. #endif\n\
  247. #ifdef ENABLE_CLIPPING_PLANES\n\
  248. vec4 clippingPlanesEdgeColor = vec4(1.0);\n\
  249. clippingPlanesEdgeColor.rgb = u_clippingPlanesEdgeStyle.rgb;\n\
  250. float clippingPlanesEdgeWidth = u_clippingPlanesEdgeStyle.a;\n\
  251. if (clipDistance < clippingPlanesEdgeWidth)\n\
  252. {\n\
  253. finalColor = clippingPlanesEdgeColor;\n\
  254. }\n\
  255. #endif\n\
  256. #ifdef HIGHLIGHT_FILL_TILE\n\
  257. finalColor = vec4(mix(finalColor.rgb, u_fillHighlightColor.rgb, u_fillHighlightColor.a), finalColor.a);\n\
  258. #endif\n\
  259. #if defined(FOG) || defined(GROUND_ATMOSPHERE)\n\
  260. vec3 fogColor = colorCorrect(v_fogMieColor) + finalColor.rgb * colorCorrect(v_fogRayleighColor);\n\
  261. #ifndef HDR\n\
  262. const float fExposure = 2.0;\n\
  263. fogColor = vec3(1.0) - exp(-fExposure * fogColor);\n\
  264. #endif\n\
  265. #endif\n\
  266. #ifdef FOG\n\
  267. #if defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING)\n\
  268. float darken = clamp(dot(normalize(czm_viewerPositionWC), normalize(czm_sunPositionWC)), u_minimumBrightness, 1.0);\n\
  269. fogColor *= darken;\n\
  270. #endif\n\
  271. #ifdef HDR\n\
  272. const float modifier = 0.15;\n\
  273. finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor, modifier), finalColor.a);\n\
  274. #else\n\
  275. finalColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor), finalColor.a);\n\
  276. #endif\n\
  277. #endif\n\
  278. #ifdef GROUND_ATMOSPHERE\n\
  279. if (czm_sceneMode != czm_sceneMode3D)\n\
  280. {\n\
  281. gl_FragColor = finalColor;\n\
  282. return;\n\
  283. }\n\
  284. #if defined(PER_FRAGMENT_GROUND_ATMOSPHERE) && (defined(ENABLE_DAYNIGHT_SHADING) || defined(ENABLE_VERTEX_LIGHTING))\n\
  285. float mpp = czm_metersPerPixel(vec4(0.0, 0.0, -czm_currentFrustum.x, 1.0), 1.0);\n\
  286. vec2 xy = gl_FragCoord.xy / czm_viewport.zw * 2.0 - vec2(1.0);\n\
  287. xy *= czm_viewport.zw * mpp * 0.5;\n\
  288. vec3 direction = normalize(vec3(xy, -czm_currentFrustum.x));\n\
  289. czm_ray ray = czm_ray(vec3(0.0), direction);\n\
  290. vec3 ellipsoid_center = czm_view[3].xyz;\n\
  291. czm_raySegment intersection = czm_rayEllipsoidIntersectionInterval(ray, ellipsoid_center, czm_ellipsoidInverseRadii);\n\
  292. vec3 ellipsoidPosition = czm_pointAlongRay(ray, intersection.start);\n\
  293. ellipsoidPosition = (czm_inverseView * vec4(ellipsoidPosition, 1.0)).xyz;\n\
  294. AtmosphereColor atmosColor = computeGroundAtmosphereFromSpace(ellipsoidPosition, true);\n\
  295. vec3 groundAtmosphereColor = colorCorrect(atmosColor.mie) + finalColor.rgb * colorCorrect(atmosColor.rayleigh);\n\
  296. #ifndef HDR\n\
  297. groundAtmosphereColor = vec3(1.0) - exp(-fExposure * groundAtmosphereColor);\n\
  298. #endif\n\
  299. fadeInDist = u_nightFadeDistance.x;\n\
  300. fadeOutDist = u_nightFadeDistance.y;\n\
  301. float sunlitAtmosphereIntensity = clamp((cameraDist - fadeOutDist) / (fadeInDist - fadeOutDist), 0.0, 1.0);\n\
  302. #ifdef HDR\n\
  303. sunlitAtmosphereIntensity = max(sunlitAtmosphereIntensity * sunlitAtmosphereIntensity, 0.03);\n\
  304. #endif\n\
  305. groundAtmosphereColor = mix(groundAtmosphereColor, fogColor, sunlitAtmosphereIntensity);\n\
  306. #else\n\
  307. vec3 groundAtmosphereColor = fogColor;\n\
  308. #endif\n\
  309. #ifdef HDR\n\
  310. groundAtmosphereColor = czm_saturation(groundAtmosphereColor, 1.6);\n\
  311. #endif\n\
  312. finalColor = vec4(mix(finalColor.rgb, groundAtmosphereColor, fade), finalColor.a);\n\
  313. #endif\n\
  314. gl_FragColor = finalColor;\n\
  315. }\n\
  316. #ifdef SHOW_REFLECTIVE_OCEAN\n\
  317. float waveFade(float edge0, float edge1, float x)\n\
  318. {\n\
  319. float y = clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\
  320. return pow(1.0 - y, 5.0);\n\
  321. }\n\
  322. float linearFade(float edge0, float edge1, float x)\n\
  323. {\n\
  324. return clamp((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n\
  325. }\n\
  326. const float oceanFrequencyLowAltitude = 825000.0;\n\
  327. const float oceanAnimationSpeedLowAltitude = 0.004;\n\
  328. const float oceanOneOverAmplitudeLowAltitude = 1.0 / 2.0;\n\
  329. const float oceanSpecularIntensity = 0.5;\n\
  330. const float oceanFrequencyHighAltitude = 125000.0;\n\
  331. const float oceanAnimationSpeedHighAltitude = 0.008;\n\
  332. const float oceanOneOverAmplitudeHighAltitude = 1.0 / 2.0;\n\
  333. vec4 computeWaterColor(vec3 positionEyeCoordinates, vec2 textureCoordinates, mat3 enuToEye, vec4 imageryColor, float maskValue, float fade)\n\
  334. {\n\
  335. vec3 positionToEyeEC = -positionEyeCoordinates;\n\
  336. float positionToEyeECLength = length(positionToEyeEC);\n\
  337. vec3 normalizedpositionToEyeEC = normalize(normalize(positionToEyeEC));\n\
  338. float waveIntensity = waveFade(70000.0, 1000000.0, positionToEyeECLength);\n\
  339. #ifdef SHOW_OCEAN_WAVES\n\
  340. float time = czm_frameNumber * oceanAnimationSpeedHighAltitude;\n\
  341. vec4 noise = czm_getWaterNoise(u_oceanNormalMap, textureCoordinates * oceanFrequencyHighAltitude, time, 0.0);\n\
  342. vec3 normalTangentSpaceHighAltitude = vec3(noise.xy, noise.z * oceanOneOverAmplitudeHighAltitude);\n\
  343. time = czm_frameNumber * oceanAnimationSpeedLowAltitude;\n\
  344. noise = czm_getWaterNoise(u_oceanNormalMap, textureCoordinates * oceanFrequencyLowAltitude, time, 0.0);\n\
  345. vec3 normalTangentSpaceLowAltitude = vec3(noise.xy, noise.z * oceanOneOverAmplitudeLowAltitude);\n\
  346. float highAltitudeFade = linearFade(0.0, 60000.0, positionToEyeECLength);\n\
  347. float lowAltitudeFade = 1.0 - linearFade(20000.0, 60000.0, positionToEyeECLength);\n\
  348. vec3 normalTangentSpace =\n\
  349. (highAltitudeFade * normalTangentSpaceHighAltitude) +\n\
  350. (lowAltitudeFade * normalTangentSpaceLowAltitude);\n\
  351. normalTangentSpace = normalize(normalTangentSpace);\n\
  352. normalTangentSpace.xy *= waveIntensity;\n\
  353. normalTangentSpace = normalize(normalTangentSpace);\n\
  354. #else\n\
  355. vec3 normalTangentSpace = vec3(0.0, 0.0, 1.0);\n\
  356. #endif\n\
  357. vec3 normalEC = enuToEye * normalTangentSpace;\n\
  358. const vec3 waveHighlightColor = vec3(0.3, 0.45, 0.6);\n\
  359. float diffuseIntensity = czm_getLambertDiffuse(czm_sunDirectionEC, normalEC) * maskValue;\n\
  360. vec3 diffuseHighlight = waveHighlightColor * diffuseIntensity * (1.0 - fade);\n\
  361. #ifdef SHOW_OCEAN_WAVES\n\
  362. float tsPerturbationRatio = normalTangentSpace.z;\n\
  363. vec3 nonDiffuseHighlight = mix(waveHighlightColor * 5.0 * (1.0 - tsPerturbationRatio), vec3(0.0), diffuseIntensity);\n\
  364. #else\n\
  365. vec3 nonDiffuseHighlight = vec3(0.0);\n\
  366. #endif\n\
  367. float specularIntensity = czm_getSpecular(czm_sunDirectionEC, normalizedpositionToEyeEC, normalEC, 10.0) + 0.25 * czm_getSpecular(czm_moonDirectionEC, normalizedpositionToEyeEC, normalEC, 10.0);\n\
  368. float surfaceReflectance = mix(0.0, mix(u_zoomedOutOceanSpecularIntensity, oceanSpecularIntensity, waveIntensity), maskValue);\n\
  369. float specular = specularIntensity * surfaceReflectance;\n\
  370. #ifdef HDR\n\
  371. specular *= 1.4;\n\
  372. float e = 0.2;\n\
  373. float d = 3.3;\n\
  374. float c = 1.7;\n\
  375. vec3 color = imageryColor.rgb + (c * (vec3(e) + imageryColor.rgb * d) * (diffuseHighlight + nonDiffuseHighlight + specular));\n\
  376. #else\n\
  377. vec3 color = imageryColor.rgb + diffuseHighlight + nonDiffuseHighlight + specular;\n\
  378. #endif\n\
  379. return vec4(color, imageryColor.a);\n\
  380. }\n\
  381. #endif // #ifdef SHOW_REFLECTIVE_OCEAN\n\
  382. ";