environment.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. /*************************************************************************/
  2. /* environment.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 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 "core/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. Basis bg_sky_orientation;
  82. Color bg_color;
  83. float bg_energy;
  84. int bg_canvas_max_layer;
  85. Color ambient_color;
  86. float ambient_energy;
  87. float ambient_sky_contribution;
  88. ToneMapper tone_mapper;
  89. float tonemap_exposure;
  90. float tonemap_white;
  91. bool tonemap_auto_exposure;
  92. float tonemap_auto_exposure_max;
  93. float tonemap_auto_exposure_min;
  94. float tonemap_auto_exposure_speed;
  95. float tonemap_auto_exposure_grey;
  96. bool adjustment_enabled;
  97. float adjustment_contrast;
  98. float adjustment_saturation;
  99. float adjustment_brightness;
  100. Ref<Texture> adjustment_color_correction;
  101. bool ssr_enabled;
  102. int ssr_max_steps;
  103. float ssr_fade_in;
  104. float ssr_fade_out;
  105. float ssr_depth_tolerance;
  106. bool ssr_roughness;
  107. bool ssao_enabled;
  108. float ssao_radius;
  109. float ssao_intensity;
  110. float ssao_radius2;
  111. float ssao_intensity2;
  112. float ssao_bias;
  113. float ssao_direct_light_affect;
  114. float ssao_ao_channel_affect;
  115. Color ssao_color;
  116. SSAOBlur ssao_blur;
  117. float ssao_edge_sharpness;
  118. SSAOQuality ssao_quality;
  119. bool glow_enabled;
  120. int glow_levels;
  121. float glow_intensity;
  122. float glow_strength;
  123. float glow_bloom;
  124. GlowBlendMode glow_blend_mode;
  125. float glow_hdr_bleed_threshold;
  126. float glow_hdr_bleed_scale;
  127. float glow_hdr_luminance_cap;
  128. bool glow_bicubic_upscale;
  129. bool dof_blur_far_enabled;
  130. float dof_blur_far_distance;
  131. float dof_blur_far_transition;
  132. float dof_blur_far_amount;
  133. DOFBlurQuality dof_blur_far_quality;
  134. bool dof_blur_near_enabled;
  135. float dof_blur_near_distance;
  136. float dof_blur_near_transition;
  137. float dof_blur_near_amount;
  138. DOFBlurQuality dof_blur_near_quality;
  139. bool fog_enabled;
  140. Color fog_color;
  141. Color fog_sun_color;
  142. float fog_sun_amount;
  143. bool fog_depth_enabled;
  144. float fog_depth_begin;
  145. float fog_depth_end;
  146. float fog_depth_curve;
  147. bool fog_transmit_enabled;
  148. float fog_transmit_curve;
  149. bool fog_height_enabled;
  150. float fog_height_min;
  151. float fog_height_max;
  152. float fog_height_curve;
  153. protected:
  154. static void _bind_methods();
  155. virtual void _validate_property(PropertyInfo &property) const;
  156. public:
  157. void set_background(BGMode p_bg);
  158. void set_sky(const Ref<Sky> &p_sky);
  159. void set_sky_custom_fov(float p_scale);
  160. void set_sky_orientation(const Basis &p_orientation);
  161. void set_sky_rotation(const Vector3 &p_euler_rad);
  162. void set_sky_rotation_degrees(const Vector3 &p_euler_deg);
  163. void set_bg_color(const Color &p_color);
  164. void set_bg_energy(float p_energy);
  165. void set_canvas_max_layer(int p_max_layer);
  166. void set_ambient_light_color(const Color &p_color);
  167. void set_ambient_light_energy(float p_energy);
  168. void set_ambient_light_sky_contribution(float p_energy);
  169. BGMode get_background() const;
  170. Ref<Sky> get_sky() const;
  171. float get_sky_custom_fov() const;
  172. Basis get_sky_orientation() const;
  173. Vector3 get_sky_rotation() const;
  174. Vector3 get_sky_rotation_degrees() const;
  175. Color get_bg_color() const;
  176. float get_bg_energy() const;
  177. int get_canvas_max_layer() const;
  178. Color get_ambient_light_color() const;
  179. float get_ambient_light_energy() const;
  180. float get_ambient_light_sky_contribution() const;
  181. void set_tonemapper(ToneMapper p_tone_mapper);
  182. ToneMapper get_tonemapper() const;
  183. void set_tonemap_exposure(float p_exposure);
  184. float get_tonemap_exposure() const;
  185. void set_tonemap_white(float p_white);
  186. float get_tonemap_white() const;
  187. void set_tonemap_auto_exposure(bool p_enabled);
  188. bool get_tonemap_auto_exposure() const;
  189. void set_tonemap_auto_exposure_max(float p_auto_exposure_max);
  190. float get_tonemap_auto_exposure_max() const;
  191. void set_tonemap_auto_exposure_min(float p_auto_exposure_min);
  192. float get_tonemap_auto_exposure_min() const;
  193. void set_tonemap_auto_exposure_speed(float p_auto_exposure_speed);
  194. float get_tonemap_auto_exposure_speed() const;
  195. void set_tonemap_auto_exposure_grey(float p_auto_exposure_grey);
  196. float get_tonemap_auto_exposure_grey() const;
  197. void set_adjustment_enable(bool p_enable);
  198. bool is_adjustment_enabled() const;
  199. void set_adjustment_brightness(float p_brightness);
  200. float get_adjustment_brightness() const;
  201. void set_adjustment_contrast(float p_contrast);
  202. float get_adjustment_contrast() const;
  203. void set_adjustment_saturation(float p_saturation);
  204. float get_adjustment_saturation() const;
  205. void set_adjustment_color_correction(const Ref<Texture> &p_ramp);
  206. Ref<Texture> get_adjustment_color_correction() const;
  207. void set_ssr_enabled(bool p_enable);
  208. bool is_ssr_enabled() const;
  209. void set_ssr_max_steps(int p_steps);
  210. int get_ssr_max_steps() const;
  211. void set_ssr_fade_in(float p_fade_in);
  212. float get_ssr_fade_in() const;
  213. void set_ssr_fade_out(float p_fade_out);
  214. float get_ssr_fade_out() const;
  215. void set_ssr_depth_tolerance(float p_depth_tolerance);
  216. float get_ssr_depth_tolerance() const;
  217. void set_ssr_rough(bool p_enable);
  218. bool is_ssr_rough() const;
  219. void set_ssao_enabled(bool p_enable);
  220. bool is_ssao_enabled() const;
  221. void set_ssao_radius(float p_radius);
  222. float get_ssao_radius() const;
  223. void set_ssao_intensity(float p_intensity);
  224. float get_ssao_intensity() const;
  225. void set_ssao_radius2(float p_radius);
  226. float get_ssao_radius2() const;
  227. void set_ssao_intensity2(float p_intensity);
  228. float get_ssao_intensity2() const;
  229. void set_ssao_bias(float p_bias);
  230. float get_ssao_bias() const;
  231. void set_ssao_direct_light_affect(float p_direct_light_affect);
  232. float get_ssao_direct_light_affect() const;
  233. void set_ssao_ao_channel_affect(float p_ao_channel_affect);
  234. float get_ssao_ao_channel_affect() const;
  235. void set_ssao_color(const Color &p_color);
  236. Color get_ssao_color() const;
  237. void set_ssao_blur(SSAOBlur p_blur);
  238. SSAOBlur get_ssao_blur() const;
  239. void set_ssao_quality(SSAOQuality p_quality);
  240. SSAOQuality get_ssao_quality() const;
  241. void set_ssao_edge_sharpness(float p_edge_sharpness);
  242. float get_ssao_edge_sharpness() const;
  243. void set_glow_enabled(bool p_enabled);
  244. bool is_glow_enabled() const;
  245. void set_glow_level(int p_level, bool p_enabled);
  246. bool is_glow_level_enabled(int p_level) const;
  247. void set_glow_intensity(float p_intensity);
  248. float get_glow_intensity() const;
  249. void set_glow_strength(float p_strength);
  250. float get_glow_strength() const;
  251. void set_glow_bloom(float p_threshold);
  252. float get_glow_bloom() const;
  253. void set_glow_blend_mode(GlowBlendMode p_mode);
  254. GlowBlendMode get_glow_blend_mode() const;
  255. void set_glow_hdr_bleed_threshold(float p_threshold);
  256. float get_glow_hdr_bleed_threshold() const;
  257. void set_glow_hdr_luminance_cap(float p_amount);
  258. float get_glow_hdr_luminance_cap() const;
  259. void set_glow_hdr_bleed_scale(float p_scale);
  260. float get_glow_hdr_bleed_scale() const;
  261. void set_glow_bicubic_upscale(bool p_enable);
  262. bool is_glow_bicubic_upscale_enabled() const;
  263. void set_dof_blur_far_enabled(bool p_enable);
  264. bool is_dof_blur_far_enabled() const;
  265. void set_dof_blur_far_distance(float p_distance);
  266. float get_dof_blur_far_distance() const;
  267. void set_dof_blur_far_transition(float p_distance);
  268. float get_dof_blur_far_transition() const;
  269. void set_dof_blur_far_amount(float p_amount);
  270. float get_dof_blur_far_amount() const;
  271. void set_dof_blur_far_quality(DOFBlurQuality p_quality);
  272. DOFBlurQuality get_dof_blur_far_quality() const;
  273. void set_dof_blur_near_enabled(bool p_enable);
  274. bool is_dof_blur_near_enabled() const;
  275. void set_dof_blur_near_distance(float p_distance);
  276. float get_dof_blur_near_distance() const;
  277. void set_dof_blur_near_transition(float p_distance);
  278. float get_dof_blur_near_transition() const;
  279. void set_dof_blur_near_amount(float p_amount);
  280. float get_dof_blur_near_amount() const;
  281. void set_dof_blur_near_quality(DOFBlurQuality p_quality);
  282. DOFBlurQuality get_dof_blur_near_quality() const;
  283. void set_fog_enabled(bool p_enabled);
  284. bool is_fog_enabled() const;
  285. void set_fog_color(const Color &p_color);
  286. Color get_fog_color() const;
  287. void set_fog_sun_color(const Color &p_color);
  288. Color get_fog_sun_color() const;
  289. void set_fog_sun_amount(float p_amount);
  290. float get_fog_sun_amount() const;
  291. void set_fog_depth_enabled(bool p_enabled);
  292. bool is_fog_depth_enabled() const;
  293. void set_fog_depth_begin(float p_distance);
  294. float get_fog_depth_begin() const;
  295. void set_fog_depth_end(float p_distance);
  296. float get_fog_depth_end() const;
  297. void set_fog_depth_curve(float p_curve);
  298. float get_fog_depth_curve() const;
  299. void set_fog_transmit_enabled(bool p_enabled);
  300. bool is_fog_transmit_enabled() const;
  301. void set_fog_transmit_curve(float p_curve);
  302. float get_fog_transmit_curve() const;
  303. void set_fog_height_enabled(bool p_enabled);
  304. bool is_fog_height_enabled() const;
  305. void set_fog_height_min(float p_distance);
  306. float get_fog_height_min() const;
  307. void set_fog_height_max(float p_distance);
  308. float get_fog_height_max() const;
  309. void set_fog_height_curve(float p_distance);
  310. float get_fog_height_curve() const;
  311. virtual RID get_rid() const;
  312. Environment();
  313. ~Environment();
  314. };
  315. VARIANT_ENUM_CAST(Environment::BGMode)
  316. VARIANT_ENUM_CAST(Environment::ToneMapper)
  317. VARIANT_ENUM_CAST(Environment::GlowBlendMode)
  318. VARIANT_ENUM_CAST(Environment::DOFBlurQuality)
  319. VARIANT_ENUM_CAST(Environment::SSAOQuality)
  320. VARIANT_ENUM_CAST(Environment::SSAOBlur)
  321. #endif // ENVIRONMENT_H