智慧水务管理系统 - 精河县供水工程综合管理平台

SkyAtmosphereFS.glsl 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. in vec3 v_outerPositionWC;
  2. uniform vec3 u_hsbShift;
  3. #ifndef PER_FRAGMENT_ATMOSPHERE
  4. in vec3 v_mieColor;
  5. in vec3 v_rayleighColor;
  6. in float v_opacity;
  7. in float v_translucent;
  8. #endif
  9. void main (void)
  10. {
  11. float lightEnum = u_radiiAndDynamicAtmosphereColor.z;
  12. vec3 lightDirection = czm_getDynamicAtmosphereLightDirection(v_outerPositionWC, lightEnum);
  13. vec3 mieColor;
  14. vec3 rayleighColor;
  15. float opacity;
  16. float translucent;
  17. #ifdef PER_FRAGMENT_ATMOSPHERE
  18. computeAtmosphereScattering(
  19. v_outerPositionWC,
  20. lightDirection,
  21. rayleighColor,
  22. mieColor,
  23. opacity,
  24. translucent
  25. );
  26. #else
  27. mieColor = v_mieColor;
  28. rayleighColor = v_rayleighColor;
  29. opacity = v_opacity;
  30. translucent = v_translucent;
  31. #endif
  32. vec4 color = computeAtmosphereColor(v_outerPositionWC, lightDirection, rayleighColor, mieColor, opacity);
  33. #ifndef HDR
  34. color.rgb = czm_pbrNeutralTonemapping(color.rgb);
  35. color.rgb = czm_inverseGamma(color.rgb);
  36. #endif
  37. #ifdef COLOR_CORRECT
  38. const bool ignoreBlackPixels = true;
  39. color.rgb = czm_applyHSBShift(color.rgb, u_hsbShift, ignoreBlackPixels);
  40. #endif
  41. // For the parts of the sky atmosphere that are not behind a translucent globe,
  42. // we mix in the default opacity so that the sky atmosphere still appears at distance.
  43. // This is needed because the opacity in the sky atmosphere is initially adjusted based
  44. // on the camera height.
  45. if (translucent == 0.0) {
  46. color.a = mix(color.b, 1.0, color.a) * smoothstep(0.0, 1.0, czm_morphTime);
  47. }
  48. out_FragColor = color;
  49. }