SkyAtmosphereFS.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "in vec3 v_outerPositionWC;\n\
  3. \n\
  4. uniform vec3 u_hsbShift;\n\
  5. \n\
  6. #ifndef PER_FRAGMENT_ATMOSPHERE\n\
  7. in vec3 v_mieColor;\n\
  8. in vec3 v_rayleighColor;\n\
  9. in float v_opacity;\n\
  10. in float v_translucent;\n\
  11. #endif\n\
  12. \n\
  13. void main (void)\n\
  14. {\n\
  15. vec3 lightDirection = getLightDirection(v_outerPositionWC);\n\
  16. \n\
  17. vec3 mieColor;\n\
  18. vec3 rayleighColor;\n\
  19. float opacity;\n\
  20. float translucent;\n\
  21. \n\
  22. #ifdef PER_FRAGMENT_ATMOSPHERE\n\
  23. computeAtmosphereScattering(\n\
  24. v_outerPositionWC,\n\
  25. lightDirection,\n\
  26. rayleighColor,\n\
  27. mieColor,\n\
  28. opacity,\n\
  29. translucent\n\
  30. );\n\
  31. #else\n\
  32. mieColor = v_mieColor;\n\
  33. rayleighColor = v_rayleighColor;\n\
  34. opacity = v_opacity;\n\
  35. translucent = v_translucent;\n\
  36. #endif\n\
  37. \n\
  38. vec4 color = computeAtmosphereColor(v_outerPositionWC, lightDirection, rayleighColor, mieColor, opacity);\n\
  39. \n\
  40. #ifndef HDR\n\
  41. color.rgb = czm_acesTonemapping(color.rgb);\n\
  42. color.rgb = czm_inverseGamma(color.rgb);\n\
  43. #endif\n\
  44. \n\
  45. #ifdef COLOR_CORRECT\n\
  46. // Convert rgb color to hsb\n\
  47. vec3 hsb = czm_RGBToHSB(color.rgb);\n\
  48. // Perform hsb shift\n\
  49. hsb.x += u_hsbShift.x; // hue\n\
  50. hsb.y = clamp(hsb.y + u_hsbShift.y, 0.0, 1.0); // saturation\n\
  51. hsb.z = hsb.z > czm_epsilon7 ? hsb.z + u_hsbShift.z : 0.0; // brightness\n\
  52. // Convert shifted hsb back to rgb\n\
  53. color.rgb = czm_HSBToRGB(hsb);\n\
  54. #endif\n\
  55. \n\
  56. // For the parts of the sky atmosphere that are not behind a translucent globe,\n\
  57. // we mix in the default opacity so that the sky atmosphere still appears at distance.\n\
  58. // This is needed because the opacity in the sky atmosphere is initially adjusted based\n\
  59. // on the camera height.\n\
  60. if (translucent == 0.0) {\n\
  61. color.a = mix(color.b, 1.0, color.a) * smoothstep(0.0, 1.0, czm_morphTime);\n\
  62. }\n\
  63. \n\
  64. out_FragColor = color;\n\
  65. }\n\
  66. ";