Sun.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /******************************************************************************
  2. Use 'Sun' to set the main sun object.
  3. Use 'Astros' container to create custom astronomical objects.
  4. /******************************************************************************/
  5. enum SUN_RAYS_MODE : Byte
  6. {
  7. SUN_RAYS_OFF , // disabled
  8. SUN_RAYS_LOW , // enabled with object occlusion detection
  9. SUN_RAYS_HIGH, // enabled with object+clouds occlusion detection
  10. SUN_RAYS_NUM , // number of sun ray modes
  11. };
  12. /******************************************************************************/
  13. struct Astro // Astronomical Object (Star/Planet/Moon)
  14. {
  15. Bool draw; // if use this object in drawing, true/false, default=true
  16. Bool blend ; // if use blending for image, true/false , default=true, if true then 'image' will be applied using alpha blending, if false then 'image' will be added onto the screen
  17. Byte glow ; // glow amount , 0..255 , default=0 , total glow amount is equal to ('image' alpha channel * 'image_color' alpha component * 'glow')
  18. Flt size ; // image size , 0..1 , default=0.15
  19. Vec pos ; // normalized position , position on sky sphere radius=1, default=!Vec(-1,1,-1)
  20. Color image_color; // image color , , default=WHITE
  21. ImagePtr image ; // image , default=null
  22. Vec light_color ; // light color , (0,0,0)..(1,1,1), default=(0,0,0), value of (0,0,0) disables light casting
  23. Flt light_vol , // volumetric amount , 0..Inf , default=0.0
  24. light_vol_exp , // volumetric exponent, 0..Inf , default=1.0
  25. light_vol_steam; // volumetric steam , 0..1 , default=0.5
  26. Astro();
  27. #if EE_PRIVATE
  28. Bool is ()C {return draw && image!=null;}
  29. void light();
  30. void Draw ();
  31. #endif
  32. };
  33. /******************************************************************************/
  34. STRUCT(SunClass , Astro) // Sun objects have default member values: 'glow'=128, 'light_color'=(0.7, 0.7, 0.7)
  35. //{
  36. Flt highlight_front, // amount of highlight applied on atmospheric sky, 0..Inf, default=0.10
  37. highlight_back ; // amount of highlight applied on atmospheric sky, 0..Inf, default=0.07
  38. Vec rays_color ; // rays color , (0,0,0)..(1,1,1), default=(0.05, 0.05, 0.05)
  39. SByte rays_jitter; // rays jitter, -1/false/true , default=-1 , false=always disabled, true=always enabled, -1=auto
  40. SUN_RAYS_MODE rays_mode ; // rays mode , SUN_RAYS_MODE , default=SUN_RAYS_HIGH
  41. SunClass& raysRes (Flt scale); Flt raysRes ()C; // set/get rays resolution (0..1, default=1/4), this determines the size of the buffers used for calculating the Sun Rays effect, 1=full size, 0.5=half size, 0.25=quarter size, .., smaller sizes offer faster performance but worse quality, the change is NOT instant, avoid calling real-time
  42. SunClass& raysMaskRes(Flt scale); Flt raysMaskRes()C; // set/get rays mask resolution (0..1, default=1 ), this determines the size of the buffers used for calculating the Sun Rays Mask effect, 1=full size, 0.5=half size, 0.25=quarter size, .., smaller sizes offer faster performance but worse quality, the change is NOT instant, avoid calling real-time
  43. SunClass();
  44. #if EE_PRIVATE
  45. Bool wantRays ()C;
  46. Bool wantDepth()C {return wantRays();}
  47. void drawRays(Image *coverage, Vec &color);
  48. #endif
  49. #if !EE_PRIVATE
  50. private:
  51. #endif
  52. SUN_RAYS_MODE _actual_rays_mode;
  53. Byte _rays_res, _rays_mask_res;
  54. Vec2 _pos2;
  55. }extern
  56. Sun; // Main Sun
  57. /******************************************************************************/
  58. extern Bool AstrosDraw; // if draw astronomical objects, default=true
  59. extern Memc<Astro> Astros ; // container of astronomical objects
  60. /******************************************************************************/
  61. #if EE_PRIVATE
  62. void AstroPrepare ();
  63. void AstroDraw ();
  64. Bool AstroDrawRays();
  65. #endif
  66. /******************************************************************************/