fog.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //This file is automatically rebuilt by the Cesium build process.
  2. export default "/**\n\
  3. * Gets the color with fog at a distance from the camera.\n\
  4. *\n\
  5. * @name czm_fog\n\
  6. * @glslFunction\n\
  7. *\n\
  8. * @param {float} distanceToCamera The distance to the camera in meters.\n\
  9. * @param {vec3} color The original color.\n\
  10. * @param {vec3} fogColor The color of the fog.\n\
  11. *\n\
  12. * @returns {vec3} The color adjusted for fog at the distance from the camera.\n\
  13. */\n\
  14. vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor)\n\
  15. {\n\
  16. float scalar = distanceToCamera * czm_fogDensity;\n\
  17. float fog = 1.0 - exp(-(scalar * scalar));\n\
  18. return mix(color, fogColor, fog);\n\
  19. }\n\
  20. \n\
  21. /**\n\
  22. * Gets the color with fog at a distance from the camera.\n\
  23. *\n\
  24. * @name czm_fog\n\
  25. * @glslFunction\n\
  26. *\n\
  27. * @param {float} distanceToCamera The distance to the camera in meters.\n\
  28. * @param {vec3} color The original color.\n\
  29. * @param {vec3} fogColor The color of the fog.\n\
  30. * @param {float} fogModifierConstant A constant to modify the appearance of fog.\n\
  31. *\n\
  32. * @returns {vec3} The color adjusted for fog at the distance from the camera.\n\
  33. */\n\
  34. vec3 czm_fog(float distanceToCamera, vec3 color, vec3 fogColor, float fogModifierConstant)\n\
  35. {\n\
  36. float scalar = distanceToCamera * czm_fogDensity;\n\
  37. float fog = 1.0 - exp(-((fogModifierConstant * scalar + fogModifierConstant) * (scalar * (1.0 + fogModifierConstant))));\n\
  38. return mix(color, fogColor, fog);\n\
  39. }\n\
  40. ";