skyparams.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /*
  2. Minetest
  3. Copyright (C) 2019 Jordach, Jordan Snelling <jordach.snelling@gmail.com>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. struct SkyColor
  18. {
  19. video::SColor day_sky;
  20. video::SColor day_horizon;
  21. video::SColor dawn_sky;
  22. video::SColor dawn_horizon;
  23. video::SColor night_sky;
  24. video::SColor night_horizon;
  25. video::SColor indoors;
  26. };
  27. struct SkyboxParams
  28. {
  29. static constexpr float INVALID_SKYBOX_TILT = -1024.f;
  30. video::SColor bgcolor;
  31. std::string type;
  32. std::vector<std::string> textures;
  33. bool clouds;
  34. SkyColor sky_color;
  35. video::SColor fog_sun_tint;
  36. video::SColor fog_moon_tint;
  37. std::string fog_tint_type;
  38. float body_orbit_tilt { INVALID_SKYBOX_TILT };
  39. s16 fog_distance { -1 };
  40. float fog_start { -1.0f };
  41. video::SColor fog_color; // override, only used if alpha > 0
  42. };
  43. struct SunParams
  44. {
  45. bool visible;
  46. std::string texture;
  47. std::string tonemap;
  48. std::string sunrise;
  49. bool sunrise_visible;
  50. f32 scale;
  51. };
  52. struct MoonParams
  53. {
  54. bool visible;
  55. std::string texture;
  56. std::string tonemap;
  57. f32 scale;
  58. };
  59. struct StarParams
  60. {
  61. bool visible;
  62. u32 count;
  63. video::SColor starcolor;
  64. f32 scale;
  65. f32 day_opacity;
  66. };
  67. struct CloudParams
  68. {
  69. float density;
  70. video::SColor color_bright;
  71. video::SColor color_ambient;
  72. float thickness;
  73. float height;
  74. v2f speed;
  75. };
  76. // Utility class for setting default sky, sun, moon, stars values:
  77. class SkyboxDefaults
  78. {
  79. public:
  80. SkyboxDefaults() = delete;
  81. static const SkyboxParams getSkyDefaults()
  82. {
  83. SkyboxParams sky;
  84. sky.bgcolor = video::SColor(255, 255, 255, 255);
  85. sky.type = "regular";
  86. sky.clouds = true;
  87. sky.sky_color = getSkyColorDefaults();
  88. sky.fog_sun_tint = video::SColor(255, 244, 125, 29);
  89. sky.fog_moon_tint = video::SColorf(0.5, 0.6, 0.8, 1).toSColor();
  90. sky.fog_tint_type = "default";
  91. sky.fog_color = video::SColor(0);
  92. return sky;
  93. }
  94. static const SkyColor getSkyColorDefaults()
  95. {
  96. SkyColor sky;
  97. // Horizon colors
  98. sky.day_horizon = video::SColor(255, 144, 211, 246);
  99. sky.indoors = video::SColor(255, 100, 100, 100);
  100. sky.dawn_horizon = video::SColor(255, 186, 193, 240);
  101. sky.night_horizon = video::SColor(255, 64, 144, 255);
  102. // Sky colors
  103. sky.day_sky = video::SColor(255, 97, 181, 245);
  104. sky.dawn_sky = video::SColor(255, 180, 186, 250);
  105. sky.night_sky = video::SColor(255, 0, 107, 255);
  106. return sky;
  107. }
  108. static const SunParams getSunDefaults()
  109. {
  110. SunParams sun;
  111. sun.visible = true;
  112. sun.sunrise_visible = true;
  113. sun.texture = "sun.png";
  114. sun.tonemap = "sun_tonemap.png";
  115. sun.sunrise = "sunrisebg.png";
  116. sun.scale = 1;
  117. return sun;
  118. }
  119. static const MoonParams getMoonDefaults()
  120. {
  121. MoonParams moon;
  122. moon.visible = true;
  123. moon.texture = "moon.png";
  124. moon.tonemap = "moon_tonemap.png";
  125. moon.scale = 1;
  126. return moon;
  127. }
  128. static const StarParams getStarDefaults()
  129. {
  130. StarParams stars;
  131. stars.visible = true;
  132. stars.count = 1000;
  133. stars.starcolor = video::SColor(105, 235, 235, 255);
  134. stars.scale = 1;
  135. stars.day_opacity = 0;
  136. return stars;
  137. }
  138. static const CloudParams getCloudDefaults()
  139. {
  140. CloudParams clouds;
  141. clouds.density = 0.4f;
  142. clouds.color_bright = video::SColor(229, 240, 240, 255);
  143. clouds.color_ambient = video::SColor(255, 0, 0, 0);
  144. clouds.thickness = 16.0f;
  145. clouds.height = 120;
  146. clouds.speed = v2f(0.0f, -2.0f);
  147. return clouds;
  148. }
  149. };