environment.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*************************************************************************/
  2. /* environment.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifndef ENVIRONMENT_H
  31. #define ENVIRONMENT_H
  32. #include "resource.h"
  33. #include "scene/resources/sky_box.h"
  34. #include "scene/resources/texture.h"
  35. #include "servers/visual_server.h"
  36. class Environment : public Resource {
  37. GDCLASS(Environment, Resource);
  38. public:
  39. enum BGMode {
  40. BG_CLEAR_COLOR,
  41. BG_COLOR,
  42. BG_SKY,
  43. BG_COLOR_SKY,
  44. BG_CANVAS,
  45. BG_KEEP,
  46. BG_MAX
  47. };
  48. enum ToneMapper {
  49. TONE_MAPPER_LINEAR,
  50. TONE_MAPPER_REINHARDT,
  51. TONE_MAPPER_FILMIC,
  52. TONE_MAPPER_ACES
  53. };
  54. enum GlowBlendMode {
  55. GLOW_BLEND_MODE_ADDITIVE,
  56. GLOW_BLEND_MODE_SCREEN,
  57. GLOW_BLEND_MODE_SOFTLIGHT,
  58. GLOW_BLEND_MODE_REPLACE,
  59. };
  60. enum DOFBlurQuality {
  61. DOF_BLUR_QUALITY_LOW,
  62. DOF_BLUR_QUALITY_MEDIUM,
  63. DOF_BLUR_QUALITY_HIGH,
  64. };
  65. enum SSAOBlur {
  66. SSAO_BLUR_DISABLED,
  67. SSAO_BLUR_1x1,
  68. SSAO_BLUR_2x2,
  69. SSAO_BLUR_3x3
  70. };
  71. enum SSAOQuality {
  72. SSAO_QUALITY_LOW,
  73. SSAO_QUALITY_MEDIUM,
  74. SSAO_QUALITY_HIGH
  75. };
  76. private:
  77. RID environment;
  78. BGMode bg_mode;
  79. Ref<Sky> bg_sky;
  80. float bg_sky_custom_fov;
  81. Color bg_color;
  82. float bg_energy;
  83. int bg_canvas_max_layer;
  84. Color ambient_color;
  85. float ambient_energy;
  86. float ambient_sky_contribution;
  87. ToneMapper tone_mapper;
  88. float tonemap_exposure;
  89. float tonemap_white;
  90. bool tonemap_auto_exposure;
  91. float tonemap_auto_exposure_max;
  92. float tonemap_auto_exposure_min;
  93. float tonemap_auto_exposure_speed;
  94. float tonemap_auto_exposure_grey;
  95. bool adjustment_enabled;
  96. float adjustment_contrast;
  97. float adjustment_saturation;
  98. float adjustment_brightness;
  99. Ref<Texture> adjustment_color_correction;
  100. bool ssr_enabled;
  101. int ssr_max_steps;
  102. float ssr_fade_in;
  103. float ssr_fade_out;
  104. float ssr_depth_tolerance;
  105. bool ssr_roughness;
  106. bool ssao_enabled;
  107. float ssao_radius;
  108. float ssao_intensity;
  109. float ssao_radius2;
  110. float ssao_intensity2;
  111. float ssao_bias;
  112. float ssao_direct_light_affect;
  113. Color ssao_color;
  114. SSAOBlur ssao_blur;
  115. float ssao_edge_sharpness;
  116. SSAOQuality ssao_quality;
  117. bool glow_enabled;
  118. int glow_levels;
  119. float glow_intensity;
  120. float glow_strength;
  121. float glow_bloom;
  122. GlowBlendMode glow_blend_mode;
  123. float glow_hdr_bleed_threshold;
  124. float glow_hdr_bleed_scale;
  125. bool glow_bicubic_upscale;
  126. bool dof_blur_far_enabled;
  127. float dof_blur_far_distance;
  128. float dof_blur_far_transition;
  129. float dof_blur_far_amount;
  130. DOFBlurQuality dof_blur_far_quality;
  131. bool dof_blur_near_enabled;
  132. float dof_blur_near_distance;
  133. float dof_blur_near_transition;
  134. float dof_blur_near_amount;
  135. DOFBlurQuality dof_blur_near_quality;
  136. bool fog_enabled;
  137. Color fog_color;
  138. Color fog_sun_color;
  139. float fog_sun_amount;
  140. bool fog_depth_enabled;
  141. float fog_depth_begin;
  142. float fog_depth_curve;
  143. bool fog_transmit_enabled;
  144. float fog_transmit_curve;
  145. bool fog_height_enabled;
  146. float fog_height_min;
  147. float fog_height_max;
  148. float fog_height_curve;
  149. protected:
  150. static void _bind_methods();
  151. virtual void _validate_property(PropertyInfo &property) const;
  152. public:
  153. void set_background(BGMode p_bg);
  154. void set_sky(const Ref<Sky> &p_sky);
  155. void set_sky_custom_fov(float p_scale);
  156. void set_bg_color(const Color &p_color);
  157. void set_bg_energy(float p_energy);
  158. void set_canvas_max_layer(int p_max_layer);
  159. void set_ambient_light_color(const Color &p_color);
  160. void set_ambient_light_energy(float p_energy);
  161. void set_ambient_light_sky_contribution(float p_energy);
  162. BGMode get_background() const;
  163. Ref<Sky> get_sky() const;
  164. float get_sky_custom_fov() const;
  165. Color get_bg_color() const;
  166. float get_bg_energy() const;
  167. int get_canvas_max_layer() const;
  168. Color get_ambient_light_color() const;
  169. float get_ambient_light_energy() const;
  170. float get_ambient_light_sky_contribution() const;
  171. void set_tonemapper(ToneMapper p_tone_mapper);
  172. ToneMapper get_tonemapper() const;
  173. void set_tonemap_exposure(float p_exposure);
  174. float get_tonemap_exposure() const;
  175. void set_tonemap_white(float p_white);
  176. float get_tonemap_white() const;
  177. void set_tonemap_auto_exposure(bool p_enabled);
  178. bool get_tonemap_auto_exposure() const;
  179. void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
  180. float get_tonemap_auto_exposure_max() const;
  181. void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
  182. float get_tonemap_auto_exposure_min() const;
  183. void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
  184. float get_tonemap_auto_exposure_speed() const;
  185. void set_tonemap_auto_exposure_grey(float p_auto_exposure_grey);
  186. float get_tonemap_auto_exposure_grey() const;
  187. void set_adjustment_enable(bool p_enable);
  188. bool is_adjustment_enabled() const;
  189. void set_adjustment_brightness(float p_brightness);
  190. float get_adjustment_brightness() const;
  191. void set_adjustment_contrast(float p_contrast);
  192. float get_adjustment_contrast() const;
  193. void set_adjustment_saturation(float p_saturation);
  194. float get_adjustment_saturation() const;
  195. void set_adjustment_color_correction(const Ref<Texture> &p_ramp);
  196. Ref<Texture> get_adjustment_color_correction() const;
  197. void set_ssr_enabled(bool p_enable);
  198. bool is_ssr_enabled() const;
  199. void set_ssr_max_steps(int p_steps);
  200. int get_ssr_max_steps() const;
  201. void set_ssr_fade_in(float p_fade_in);
  202. float get_ssr_fade_in() const;
  203. void set_ssr_fade_out(float p_fade_out);
  204. float get_ssr_fade_out() const;
  205. void set_ssr_depth_tolerance(float p_depth_tolerance);
  206. float get_ssr_depth_tolerance() const;
  207. void set_ssr_rough(bool p_enable);
  208. bool is_ssr_rough() const;
  209. void set_ssao_enabled(bool p_enable);
  210. bool is_ssao_enabled() const;
  211. void set_ssao_radius(float p_radius);
  212. float get_ssao_radius() const;
  213. void set_ssao_intensity(float p_intensity);
  214. float get_ssao_intensity() const;
  215. void set_ssao_radius2(float p_radius);
  216. float get_ssao_radius2() const;
  217. void set_ssao_intensity2(float p_intensity);
  218. float get_ssao_intensity2() const;
  219. void set_ssao_bias(float p_bias);
  220. float get_ssao_bias() const;
  221. void set_ssao_direct_light_affect(float p_direct_light_affect);
  222. float get_ssao_direct_light_affect() const;
  223. void set_ssao_color(const Color &p_color);
  224. Color get_ssao_color() const;
  225. void set_ssao_blur(SSAOBlur p_blur);
  226. SSAOBlur get_ssao_blur() const;
  227. void set_ssao_quality(SSAOQuality p_quality);
  228. SSAOQuality get_ssao_quality() const;
  229. void set_ssao_edge_sharpness(float p_edge_sharpness);
  230. float get_ssao_edge_sharpness() const;
  231. void set_glow_enabled(bool p_enabled);
  232. bool is_glow_enabled() const;
  233. void set_glow_level(int p_level, bool p_enabled);
  234. bool is_glow_level_enabled(int p_level) const;
  235. void set_glow_intensity(float p_intensity);
  236. float get_glow_intensity() const;
  237. void set_glow_strength(float p_strength);
  238. float get_glow_strength() const;
  239. void set_glow_bloom(float p_threshold);
  240. float get_glow_bloom() const;
  241. void set_glow_blend_mode(GlowBlendMode p_mode);
  242. GlowBlendMode get_glow_blend_mode() const;
  243. void set_glow_hdr_bleed_threshold(float p_threshold);
  244. float get_glow_hdr_bleed_threshold() const;
  245. void set_glow_hdr_bleed_scale(float p_scale);
  246. float get_glow_hdr_bleed_scale() const;
  247. void set_glow_bicubic_upscale(bool p_enable);
  248. bool is_glow_bicubic_upscale_enabled() const;
  249. void set_dof_blur_far_enabled(bool p_enable);
  250. bool is_dof_blur_far_enabled() const;
  251. void set_dof_blur_far_distance(float p_distance);
  252. float get_dof_blur_far_distance() const;
  253. void set_dof_blur_far_transition(float p_distance);
  254. float get_dof_blur_far_transition() const;
  255. void set_dof_blur_far_amount(float p_amount);
  256. float get_dof_blur_far_amount() const;
  257. void set_dof_blur_far_quality(DOFBlurQuality p_quality);
  258. DOFBlurQuality get_dof_blur_far_quality() const;
  259. void set_dof_blur_near_enabled(bool p_enable);
  260. bool is_dof_blur_near_enabled() const;
  261. void set_dof_blur_near_distance(float p_distance);
  262. float get_dof_blur_near_distance() const;
  263. void set_dof_blur_near_transition(float p_distance);
  264. float get_dof_blur_near_transition() const;
  265. void set_dof_blur_near_amount(float p_amount);
  266. float get_dof_blur_near_amount() const;
  267. void set_dof_blur_near_quality(DOFBlurQuality p_quality);
  268. DOFBlurQuality get_dof_blur_near_quality() const;
  269. void set_fog_enabled(bool p_enabled);
  270. bool is_fog_enabled() const;
  271. void set_fog_color(const Color &p_color);
  272. Color get_fog_color() const;
  273. void set_fog_sun_color(const Color &p_color);
  274. Color get_fog_sun_color() const;
  275. void set_fog_sun_amount(float p_amount);
  276. float get_fog_sun_amount() const;
  277. void set_fog_depth_enabled(bool p_enabled);
  278. bool is_fog_depth_enabled() const;
  279. void set_fog_depth_begin(float p_distance);
  280. float get_fog_depth_begin() const;
  281. void set_fog_depth_curve(float p_curve);
  282. float get_fog_depth_curve() const;
  283. void set_fog_transmit_enabled(bool p_enabled);
  284. bool is_fog_transmit_enabled() const;
  285. void set_fog_transmit_curve(float p_curve);
  286. float get_fog_transmit_curve() const;
  287. void set_fog_height_enabled(bool p_enabled);
  288. bool is_fog_height_enabled() const;
  289. void set_fog_height_min(float p_distance);
  290. float get_fog_height_min() const;
  291. void set_fog_height_max(float p_distance);
  292. float get_fog_height_max() const;
  293. void set_fog_height_curve(float p_distance);
  294. float get_fog_height_curve() const;
  295. virtual RID get_rid() const;
  296. Environment();
  297. ~Environment();
  298. };
  299. VARIANT_ENUM_CAST(Environment::BGMode)
  300. VARIANT_ENUM_CAST(Environment::ToneMapper)
  301. VARIANT_ENUM_CAST(Environment::GlowBlendMode)
  302. VARIANT_ENUM_CAST(Environment::DOFBlurQuality)
  303. VARIANT_ENUM_CAST(Environment::SSAOQuality)
  304. VARIANT_ENUM_CAST(Environment::SSAOBlur)
  305. #endif // ENVIRONMENT_H