Environment.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /******************************************************************************
  2. 'Environment' holds information about graphics options like:
  3. ambient, bloom, clouds, fog, sky, sun.
  4. /******************************************************************************/
  5. struct Environment
  6. {
  7. struct Ambient
  8. {
  9. Bool on ; // if enabled , true/false , default=true
  10. Vec color , // ambient color, (0,0,0) .. (1,1,1), default=(0.4, 0.4, 0.4)
  11. night_shade_color; // night shade color, (0,0,0) .. (1,1,1), default=(0.0, 0.0, 0.0)
  12. // set / get
  13. void set ()C; // apply these settings to graphics
  14. void get () ; // get current graphics settings and store them in self
  15. void reset() ; // reset to default values
  16. // io
  17. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  18. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  19. Ambient() {reset();}
  20. };
  21. struct Bloom
  22. {
  23. Bool on , // if enabled , true/false, default=true
  24. half , // half/quarter , true/false, default=true, this specifies whether bloom should be calculated using half of quarter sized render targets (half is more precise but slower, quarter is more blurred)
  25. saturate, // saturation , true/false, default=true
  26. maximum ; // maximum filter , true/false, default=false
  27. Byte blurs ; // number of blurs, 0..4 , default=1
  28. Flt original, // original color , 0..Inf , default=1.0
  29. scale , // bloom scale , 0..Inf , default=0.5
  30. cut ; // bloom cutoff , 0..Inf , default=0.3
  31. // set / get
  32. void set ()C; // apply these settings to graphics
  33. void get () ; // get current graphics settings and store them in self
  34. void reset() ; // reset to default values
  35. // io
  36. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  37. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  38. Bloom() {reset();}
  39. };
  40. struct Clouds
  41. {
  42. struct Layer // Cloud Layer
  43. {
  44. Flt scale ; // texture scale , 0..Inf , default={0.35, 0.41, 0.50, 0.62}
  45. Vec2 velocity; // texture velocity, -Inf..Inf , default={0.010, 0.008, 0.006, 0.004}
  46. Vec4 color ; // texture color , (0,0,0,0)..(1,1,1,1), default=(1,1,1,1)
  47. ImagePtr image ; // texture , default=null
  48. };
  49. Bool on ; // if enabled, true/false, default=true
  50. Flt vertical_scale , // vertical texture scaling , 1..2 , default=1.05, setting this value higher than 1 helps covering the empty gap between flat ground and the clouds
  51. ray_mask_contrast; // sun rays masking contrast, 1..Inf , default=4 , this is used when "Sun.rays_mode==SUN_RAYS_HIGH"
  52. Layer layers[4] ; // layer array
  53. // set / get
  54. void set ()C; // apply these settings to graphics
  55. void get () ; // get current graphics settings and store them in self
  56. void reset() ; // reset to default values
  57. // io
  58. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  59. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  60. Clouds() {reset();}
  61. };
  62. struct Fog
  63. {
  64. Bool on , // if enabled , true/false , default=false
  65. affect_sky; // if fog affects sky, true/false , default=false
  66. Flt density ; // fog density , 0..1 , default=0.02
  67. Vec color ; // fog color , (0,0,0)..(1,1,1), default=(0.5, 0.5, 0.5)
  68. // set / get
  69. void set ()C; // apply these settings to graphics
  70. void get () ; // get current graphics settings and store them in self
  71. void reset() ; // reset to default values
  72. // io
  73. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  74. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  75. Fog() {reset();}
  76. };
  77. struct Sky
  78. {
  79. Bool on ; // if enabled , true/false, default=true
  80. Flt frac; // sky fraction, 0..1 , default=0.8, (1 is the fastest), fraction of the Viewport range where the sky starts
  81. Flt atmospheric_density_exponent , // atmospheric density exponent, 0..1 , default=1.0, (1 is the fastest)
  82. atmospheric_horizon_exponent ; // atmospheric horizon exponent, 0..Inf , default=3.5, (this affects at what height the horizon color will be selected instead of the sky color)
  83. Vec4 atmospheric_horizon_color , // atmospheric horizon color , (0,0,0,0)..(1,1,1,1) , default=(0.32, 0.46, 0.58, 1.0) here alpha specifies opacity to combine with star map when used
  84. atmospheric_sky_color ; // atmospheric sky color , (0,0,0,0)..(1,1,1,1) , default=(0.16, 0.36, 0.54, 0.9) here alpha specifies opacity to combine with star map when used
  85. ImagePtr atmospheric_stars ; // atmospheric star map , image must be in IMAGE_CUBE format, default=null
  86. Matrix3 atmospheric_stars_orientation; // atmospheric star orientation, must be normalized , default=MatrixIdentity3
  87. ImagePtr skybox; // skybox image, default=null, when specified then it will be used instead of atmospheric sky
  88. // set / get
  89. void set ()C; // apply these settings to graphics
  90. void get () ; // get current graphics settings and store them in self
  91. void reset() ; // reset to default values
  92. // io
  93. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  94. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  95. Sky() {reset();}
  96. };
  97. struct Sun
  98. {
  99. Bool on , // if enabled , true/false , default=true
  100. 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
  101. Byte glow ; // glow amount , 0..255 , default=128 , total glow amount is equal to ('image' alpha channel * 'image_color' alpha component * 'glow')
  102. Flt size , // image size , 0..1 , default=0.15
  103. highlight_front, // highlight on atmospheric sky, 0..Inf , default=0.10
  104. highlight_back ; // highlight on atmospheric sky, 0..Inf , default=0.07
  105. Vec pos , // position on sky sphere , its length must be equal 1, default=!Vec(-1, 1, -1)
  106. light_color , // light color , (0,0,0)..(1,1,1) , default=(0.7, 0.7, 0.7), value of (0, 0, 0) disables light casting
  107. rays_color ; // rays color , (0,0,0)..(1,1,1) , default=(0.05, 0.05, 0.05)
  108. Vec4 image_color ; // image color , (0,0,0,0)..(1,1,1,1) , default=(1, 1, 1, 1)
  109. ImagePtr image ; // image , default=null
  110. // set / get
  111. void set ()C; // apply these settings to graphics
  112. void get () ; // get current graphics settings and store them in self
  113. void reset() ; // reset to default values
  114. // io
  115. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  116. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  117. Sun() {reset();}
  118. };
  119. Ambient ambient;
  120. Bloom bloom ;
  121. Clouds clouds ;
  122. Fog fog ;
  123. Sky sky ;
  124. Sun sun ;
  125. // set / get
  126. void set ()C; // apply these settings to graphics (this will call 'set' on all members of this class)
  127. void get () ; // get current graphics settings and store them in self (this will call 'get' on all members of this class)
  128. void reset() ; // reset to default values (this will call 'reset' on all members of this class)
  129. // io
  130. Bool save(File &f, CChar *path=null)C; // save to file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  131. Bool load(File &f, CChar *path=null) ; // load from file, 'path'=path at which resource is located (this is needed so that the sub-resources can be accessed with relative path), false on fail
  132. Bool save(C Str &name)C; // save to file, false on fail
  133. Bool load(C Str &name) ; // load from file, false on fail
  134. };
  135. /******************************************************************************/
  136. DECLARE_CACHE(Environment, Environments, EnvironmentPtr); // 'Environments' cache storing 'Environment' objects which can be accessed by 'EnvironmentPtr' pointer
  137. /******************************************************************************/