environment.h 12 KB

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