environment.cpp 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  1. /*************************************************************************/
  2. /* environment.cpp */
  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. #include "environment.h"
  31. #include "core/project_settings.h"
  32. #include "servers/visual_server.h"
  33. #include "texture.h"
  34. RID Environment::get_rid() const {
  35. return environment;
  36. }
  37. void Environment::set_background(BGMode p_bg) {
  38. bg_mode = p_bg;
  39. VS::get_singleton()->environment_set_background(environment, VS::EnvironmentBG(p_bg));
  40. _change_notify();
  41. }
  42. void Environment::set_sky(const Ref<Sky> &p_sky) {
  43. bg_sky = p_sky;
  44. RID sb_rid;
  45. if (bg_sky.is_valid())
  46. sb_rid = bg_sky->get_rid();
  47. VS::get_singleton()->environment_set_sky(environment, sb_rid);
  48. }
  49. void Environment::set_sky_custom_fov(float p_scale) {
  50. bg_sky_custom_fov = p_scale;
  51. VS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale);
  52. }
  53. void Environment::set_sky_orientation(const Basis &p_orientation) {
  54. bg_sky_orientation = p_orientation;
  55. _change_notify("background_sky_rotation");
  56. _change_notify("background_sky_rotation_degrees");
  57. VS::get_singleton()->environment_set_sky_orientation(environment, bg_sky_orientation);
  58. }
  59. void Environment::set_sky_rotation(const Vector3 &p_euler_rad) {
  60. bg_sky_orientation.set_euler(p_euler_rad);
  61. _change_notify("background_sky_orientation");
  62. _change_notify("background_sky_rotation_degrees");
  63. VS::get_singleton()->environment_set_sky_orientation(environment, bg_sky_orientation);
  64. }
  65. void Environment::set_sky_rotation_degrees(const Vector3 &p_euler_deg) {
  66. set_sky_rotation(p_euler_deg * Math_PI / 180.0);
  67. _change_notify("background_sky_rotation");
  68. }
  69. void Environment::set_bg_color(const Color &p_color) {
  70. bg_color = p_color;
  71. VS::get_singleton()->environment_set_bg_color(environment, p_color);
  72. }
  73. void Environment::set_bg_energy(float p_energy) {
  74. bg_energy = p_energy;
  75. VS::get_singleton()->environment_set_bg_energy(environment, p_energy);
  76. }
  77. void Environment::set_canvas_max_layer(int p_max_layer) {
  78. bg_canvas_max_layer = p_max_layer;
  79. VS::get_singleton()->environment_set_canvas_max_layer(environment, p_max_layer);
  80. }
  81. void Environment::set_ambient_light_color(const Color &p_color) {
  82. ambient_color = p_color;
  83. VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_sky_contribution);
  84. }
  85. void Environment::set_ambient_light_energy(float p_energy) {
  86. ambient_energy = p_energy;
  87. VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_sky_contribution);
  88. }
  89. void Environment::set_ambient_light_sky_contribution(float p_energy) {
  90. ambient_sky_contribution = p_energy;
  91. VS::get_singleton()->environment_set_ambient_light(environment, ambient_color, ambient_energy, ambient_sky_contribution);
  92. }
  93. void Environment::set_camera_feed_id(int p_camera_feed_id) {
  94. camera_feed_id = p_camera_feed_id;
  95. VS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id);
  96. };
  97. Environment::BGMode Environment::get_background() const {
  98. return bg_mode;
  99. }
  100. Ref<Sky> Environment::get_sky() const {
  101. return bg_sky;
  102. }
  103. float Environment::get_sky_custom_fov() const {
  104. return bg_sky_custom_fov;
  105. }
  106. Basis Environment::get_sky_orientation() const {
  107. return bg_sky_orientation;
  108. }
  109. Vector3 Environment::get_sky_rotation() const {
  110. // should we cache this? maybe overkill
  111. return bg_sky_orientation.get_euler();
  112. }
  113. Vector3 Environment::get_sky_rotation_degrees() const {
  114. return get_sky_rotation() * 180.0 / Math_PI;
  115. }
  116. Color Environment::get_bg_color() const {
  117. return bg_color;
  118. }
  119. float Environment::get_bg_energy() const {
  120. return bg_energy;
  121. }
  122. int Environment::get_canvas_max_layer() const {
  123. return bg_canvas_max_layer;
  124. }
  125. Color Environment::get_ambient_light_color() const {
  126. return ambient_color;
  127. }
  128. float Environment::get_ambient_light_energy() const {
  129. return ambient_energy;
  130. }
  131. float Environment::get_ambient_light_sky_contribution() const {
  132. return ambient_sky_contribution;
  133. }
  134. int Environment::get_camera_feed_id(void) const {
  135. return camera_feed_id;
  136. }
  137. void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
  138. tone_mapper = p_tone_mapper;
  139. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  140. }
  141. Environment::ToneMapper Environment::get_tonemapper() const {
  142. return tone_mapper;
  143. }
  144. void Environment::set_tonemap_exposure(float p_exposure) {
  145. tonemap_exposure = p_exposure;
  146. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  147. }
  148. float Environment::get_tonemap_exposure() const {
  149. return tonemap_exposure;
  150. }
  151. void Environment::set_tonemap_white(float p_white) {
  152. tonemap_white = p_white;
  153. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  154. }
  155. float Environment::get_tonemap_white() const {
  156. return tonemap_white;
  157. }
  158. void Environment::set_tonemap_auto_exposure(bool p_enabled) {
  159. tonemap_auto_exposure = p_enabled;
  160. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  161. _change_notify();
  162. }
  163. bool Environment::get_tonemap_auto_exposure() const {
  164. return tonemap_auto_exposure;
  165. }
  166. void Environment::set_tonemap_auto_exposure_max(float p_auto_exposure_max) {
  167. tonemap_auto_exposure_max = p_auto_exposure_max;
  168. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  169. }
  170. float Environment::get_tonemap_auto_exposure_max() const {
  171. return tonemap_auto_exposure_max;
  172. }
  173. void Environment::set_tonemap_auto_exposure_min(float p_auto_exposure_min) {
  174. tonemap_auto_exposure_min = p_auto_exposure_min;
  175. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  176. }
  177. float Environment::get_tonemap_auto_exposure_min() const {
  178. return tonemap_auto_exposure_min;
  179. }
  180. void Environment::set_tonemap_auto_exposure_speed(float p_auto_exposure_speed) {
  181. tonemap_auto_exposure_speed = p_auto_exposure_speed;
  182. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  183. }
  184. float Environment::get_tonemap_auto_exposure_speed() const {
  185. return tonemap_auto_exposure_speed;
  186. }
  187. void Environment::set_tonemap_auto_exposure_grey(float p_auto_exposure_grey) {
  188. tonemap_auto_exposure_grey = p_auto_exposure_grey;
  189. VS::get_singleton()->environment_set_tonemap(environment, VS::EnvironmentToneMapper(tone_mapper), tonemap_exposure, tonemap_white, tonemap_auto_exposure, tonemap_auto_exposure_min, tonemap_auto_exposure_max, tonemap_auto_exposure_speed, tonemap_auto_exposure_grey);
  190. }
  191. float Environment::get_tonemap_auto_exposure_grey() const {
  192. return tonemap_auto_exposure_grey;
  193. }
  194. void Environment::set_adjustment_enable(bool p_enable) {
  195. adjustment_enabled = p_enable;
  196. VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
  197. _change_notify();
  198. }
  199. bool Environment::is_adjustment_enabled() const {
  200. return adjustment_enabled;
  201. }
  202. void Environment::set_adjustment_brightness(float p_brightness) {
  203. adjustment_brightness = p_brightness;
  204. VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
  205. }
  206. float Environment::get_adjustment_brightness() const {
  207. return adjustment_brightness;
  208. }
  209. void Environment::set_adjustment_contrast(float p_contrast) {
  210. adjustment_contrast = p_contrast;
  211. VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
  212. }
  213. float Environment::get_adjustment_contrast() const {
  214. return adjustment_contrast;
  215. }
  216. void Environment::set_adjustment_saturation(float p_saturation) {
  217. adjustment_saturation = p_saturation;
  218. VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
  219. }
  220. float Environment::get_adjustment_saturation() const {
  221. return adjustment_saturation;
  222. }
  223. void Environment::set_adjustment_color_correction(const Ref<Texture> &p_ramp) {
  224. adjustment_color_correction = p_ramp;
  225. VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
  226. }
  227. Ref<Texture> Environment::get_adjustment_color_correction() const {
  228. return adjustment_color_correction;
  229. }
  230. void Environment::_validate_property(PropertyInfo &property) const {
  231. if (property.name == "background_sky" || property.name == "background_sky_custom_fov" || property.name == "background_sky_orientation" || property.name == "background_sky_rotation" || property.name == "background_sky_rotation_degrees" || property.name == "ambient_light/sky_contribution") {
  232. if (bg_mode != BG_SKY && bg_mode != BG_COLOR_SKY) {
  233. property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
  234. }
  235. }
  236. if (property.name == "background_color") {
  237. if (bg_mode != BG_COLOR && bg_mode != BG_COLOR_SKY) {
  238. property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
  239. }
  240. }
  241. if (property.name == "background_canvas_max_layer") {
  242. if (bg_mode != BG_CANVAS) {
  243. property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
  244. }
  245. }
  246. if (property.name == "background_camera_feed_id") {
  247. if (bg_mode != BG_CAMERA_FEED) {
  248. property.usage = PROPERTY_USAGE_NOEDITOR;
  249. }
  250. }
  251. static const char *hide_prefixes[] = {
  252. "fog_",
  253. "auto_exposure_",
  254. "ss_reflections_",
  255. "ssao_",
  256. "dof_blur_far_",
  257. "dof_blur_near_",
  258. "glow_",
  259. "adjustment_",
  260. NULL
  261. };
  262. static const char *high_end_prefixes[] = {
  263. "auto_exposure_",
  264. "tonemap_",
  265. "ss_reflections_",
  266. "ssao_",
  267. NULL
  268. };
  269. const char **prefixes = hide_prefixes;
  270. while (*prefixes) {
  271. String prefix = String(*prefixes);
  272. String enabled = prefix + "enabled";
  273. if (property.name.begins_with(prefix) && property.name != enabled && !bool(get(enabled))) {
  274. property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
  275. return;
  276. }
  277. prefixes++;
  278. }
  279. if (VisualServer::get_singleton()->is_low_end()) {
  280. prefixes = high_end_prefixes;
  281. while (*prefixes) {
  282. String prefix = String(*prefixes);
  283. if (property.name.begins_with(prefix)) {
  284. property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
  285. return;
  286. }
  287. prefixes++;
  288. }
  289. }
  290. }
  291. void Environment::set_ssr_enabled(bool p_enable) {
  292. ssr_enabled = p_enable;
  293. VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
  294. _change_notify();
  295. }
  296. bool Environment::is_ssr_enabled() const {
  297. return ssr_enabled;
  298. }
  299. void Environment::set_ssr_max_steps(int p_steps) {
  300. ssr_max_steps = p_steps;
  301. VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
  302. }
  303. int Environment::get_ssr_max_steps() const {
  304. return ssr_max_steps;
  305. }
  306. void Environment::set_ssr_fade_in(float p_fade_in) {
  307. ssr_fade_in = p_fade_in;
  308. VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
  309. }
  310. float Environment::get_ssr_fade_in() const {
  311. return ssr_fade_in;
  312. }
  313. void Environment::set_ssr_fade_out(float p_fade_out) {
  314. ssr_fade_out = p_fade_out;
  315. VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
  316. }
  317. float Environment::get_ssr_fade_out() const {
  318. return ssr_fade_out;
  319. }
  320. void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) {
  321. ssr_depth_tolerance = p_depth_tolerance;
  322. VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
  323. }
  324. float Environment::get_ssr_depth_tolerance() const {
  325. return ssr_depth_tolerance;
  326. }
  327. void Environment::set_ssr_rough(bool p_enable) {
  328. ssr_roughness = p_enable;
  329. VS::get_singleton()->environment_set_ssr(environment, ssr_enabled, ssr_max_steps, ssr_fade_in, ssr_fade_out, ssr_depth_tolerance, ssr_roughness);
  330. }
  331. bool Environment::is_ssr_rough() const {
  332. return ssr_roughness;
  333. }
  334. void Environment::set_ssao_enabled(bool p_enable) {
  335. ssao_enabled = p_enable;
  336. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  337. _change_notify();
  338. }
  339. bool Environment::is_ssao_enabled() const {
  340. return ssao_enabled;
  341. }
  342. void Environment::set_ssao_radius(float p_radius) {
  343. ssao_radius = p_radius;
  344. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  345. }
  346. float Environment::get_ssao_radius() const {
  347. return ssao_radius;
  348. }
  349. void Environment::set_ssao_intensity(float p_intensity) {
  350. ssao_intensity = p_intensity;
  351. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  352. }
  353. float Environment::get_ssao_intensity() const {
  354. return ssao_intensity;
  355. }
  356. void Environment::set_ssao_radius2(float p_radius) {
  357. ssao_radius2 = p_radius;
  358. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  359. }
  360. float Environment::get_ssao_radius2() const {
  361. return ssao_radius2;
  362. }
  363. void Environment::set_ssao_intensity2(float p_intensity) {
  364. ssao_intensity2 = p_intensity;
  365. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  366. }
  367. float Environment::get_ssao_intensity2() const {
  368. return ssao_intensity2;
  369. }
  370. void Environment::set_ssao_bias(float p_bias) {
  371. ssao_bias = p_bias;
  372. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  373. }
  374. float Environment::get_ssao_bias() const {
  375. return ssao_bias;
  376. }
  377. void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) {
  378. ssao_direct_light_affect = p_direct_light_affect;
  379. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  380. }
  381. float Environment::get_ssao_direct_light_affect() const {
  382. return ssao_direct_light_affect;
  383. }
  384. void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) {
  385. ssao_ao_channel_affect = p_ao_channel_affect;
  386. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  387. }
  388. float Environment::get_ssao_ao_channel_affect() const {
  389. return ssao_ao_channel_affect;
  390. }
  391. void Environment::set_ssao_color(const Color &p_color) {
  392. ssao_color = p_color;
  393. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  394. }
  395. Color Environment::get_ssao_color() const {
  396. return ssao_color;
  397. }
  398. void Environment::set_ssao_blur(SSAOBlur p_blur) {
  399. ssao_blur = p_blur;
  400. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  401. }
  402. Environment::SSAOBlur Environment::get_ssao_blur() const {
  403. return ssao_blur;
  404. }
  405. void Environment::set_ssao_quality(SSAOQuality p_quality) {
  406. ssao_quality = p_quality;
  407. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  408. }
  409. Environment::SSAOQuality Environment::get_ssao_quality() const {
  410. return ssao_quality;
  411. }
  412. void Environment::set_ssao_edge_sharpness(float p_edge_sharpness) {
  413. ssao_edge_sharpness = p_edge_sharpness;
  414. VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_ao_channel_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness);
  415. }
  416. float Environment::get_ssao_edge_sharpness() const {
  417. return ssao_edge_sharpness;
  418. }
  419. void Environment::set_glow_enabled(bool p_enabled) {
  420. glow_enabled = p_enabled;
  421. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  422. _change_notify();
  423. }
  424. bool Environment::is_glow_enabled() const {
  425. return glow_enabled;
  426. }
  427. void Environment::set_glow_level(int p_level, bool p_enabled) {
  428. ERR_FAIL_INDEX(p_level, VS::MAX_GLOW_LEVELS);
  429. if (p_enabled)
  430. glow_levels |= (1 << p_level);
  431. else
  432. glow_levels &= ~(1 << p_level);
  433. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  434. }
  435. bool Environment::is_glow_level_enabled(int p_level) const {
  436. ERR_FAIL_INDEX_V(p_level, VS::MAX_GLOW_LEVELS, false);
  437. return glow_levels & (1 << p_level);
  438. }
  439. void Environment::set_glow_intensity(float p_intensity) {
  440. glow_intensity = p_intensity;
  441. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  442. }
  443. float Environment::get_glow_intensity() const {
  444. return glow_intensity;
  445. }
  446. void Environment::set_glow_strength(float p_strength) {
  447. glow_strength = p_strength;
  448. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  449. }
  450. float Environment::get_glow_strength() const {
  451. return glow_strength;
  452. }
  453. void Environment::set_glow_bloom(float p_threshold) {
  454. glow_bloom = p_threshold;
  455. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  456. }
  457. float Environment::get_glow_bloom() const {
  458. return glow_bloom;
  459. }
  460. void Environment::set_glow_blend_mode(GlowBlendMode p_mode) {
  461. glow_blend_mode = p_mode;
  462. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  463. }
  464. Environment::GlowBlendMode Environment::get_glow_blend_mode() const {
  465. return glow_blend_mode;
  466. }
  467. void Environment::set_glow_hdr_bleed_threshold(float p_threshold) {
  468. glow_hdr_bleed_threshold = p_threshold;
  469. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  470. }
  471. float Environment::get_glow_hdr_bleed_threshold() const {
  472. return glow_hdr_bleed_threshold;
  473. }
  474. void Environment::set_glow_hdr_luminance_cap(float p_amount) {
  475. glow_hdr_luminance_cap = p_amount;
  476. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  477. }
  478. float Environment::get_glow_hdr_luminance_cap() const {
  479. return glow_hdr_luminance_cap;
  480. }
  481. void Environment::set_glow_hdr_bleed_scale(float p_scale) {
  482. glow_hdr_bleed_scale = p_scale;
  483. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  484. }
  485. float Environment::get_glow_hdr_bleed_scale() const {
  486. return glow_hdr_bleed_scale;
  487. }
  488. void Environment::set_glow_bicubic_upscale(bool p_enable) {
  489. glow_bicubic_upscale = p_enable;
  490. VS::get_singleton()->environment_set_glow(environment, glow_enabled, glow_levels, glow_intensity, glow_strength, glow_bloom, VS::EnvironmentGlowBlendMode(glow_blend_mode), glow_hdr_bleed_threshold, glow_hdr_bleed_scale, glow_hdr_luminance_cap, glow_bicubic_upscale);
  491. }
  492. bool Environment::is_glow_bicubic_upscale_enabled() const {
  493. return glow_bicubic_upscale;
  494. }
  495. void Environment::set_dof_blur_far_enabled(bool p_enable) {
  496. dof_blur_far_enabled = p_enable;
  497. VS::get_singleton()->environment_set_dof_blur_far(environment, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_far_amount, VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
  498. _change_notify();
  499. }
  500. bool Environment::is_dof_blur_far_enabled() const {
  501. return dof_blur_far_enabled;
  502. }
  503. void Environment::set_dof_blur_far_distance(float p_distance) {
  504. dof_blur_far_distance = p_distance;
  505. VS::get_singleton()->environment_set_dof_blur_far(environment, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_far_amount, VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
  506. }
  507. float Environment::get_dof_blur_far_distance() const {
  508. return dof_blur_far_distance;
  509. }
  510. void Environment::set_dof_blur_far_transition(float p_distance) {
  511. dof_blur_far_transition = p_distance;
  512. VS::get_singleton()->environment_set_dof_blur_far(environment, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_far_amount, VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
  513. }
  514. float Environment::get_dof_blur_far_transition() const {
  515. return dof_blur_far_transition;
  516. }
  517. void Environment::set_dof_blur_far_amount(float p_amount) {
  518. dof_blur_far_amount = p_amount;
  519. VS::get_singleton()->environment_set_dof_blur_far(environment, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_far_amount, VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
  520. }
  521. float Environment::get_dof_blur_far_amount() const {
  522. return dof_blur_far_amount;
  523. }
  524. void Environment::set_dof_blur_far_quality(DOFBlurQuality p_quality) {
  525. dof_blur_far_quality = p_quality;
  526. VS::get_singleton()->environment_set_dof_blur_far(environment, dof_blur_far_enabled, dof_blur_far_distance, dof_blur_far_transition, dof_blur_far_amount, VS::EnvironmentDOFBlurQuality(dof_blur_far_quality));
  527. }
  528. Environment::DOFBlurQuality Environment::get_dof_blur_far_quality() const {
  529. return dof_blur_far_quality;
  530. }
  531. void Environment::set_dof_blur_near_enabled(bool p_enable) {
  532. dof_blur_near_enabled = p_enable;
  533. VS::get_singleton()->environment_set_dof_blur_near(environment, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_near_amount, VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
  534. _change_notify();
  535. }
  536. bool Environment::is_dof_blur_near_enabled() const {
  537. return dof_blur_near_enabled;
  538. }
  539. void Environment::set_dof_blur_near_distance(float p_distance) {
  540. dof_blur_near_distance = p_distance;
  541. VS::get_singleton()->environment_set_dof_blur_near(environment, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_near_amount, VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
  542. }
  543. float Environment::get_dof_blur_near_distance() const {
  544. return dof_blur_near_distance;
  545. }
  546. void Environment::set_dof_blur_near_transition(float p_distance) {
  547. dof_blur_near_transition = p_distance;
  548. VS::get_singleton()->environment_set_dof_blur_near(environment, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_near_amount, VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
  549. }
  550. float Environment::get_dof_blur_near_transition() const {
  551. return dof_blur_near_transition;
  552. }
  553. void Environment::set_dof_blur_near_amount(float p_amount) {
  554. dof_blur_near_amount = p_amount;
  555. VS::get_singleton()->environment_set_dof_blur_near(environment, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_near_amount, VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
  556. }
  557. float Environment::get_dof_blur_near_amount() const {
  558. return dof_blur_near_amount;
  559. }
  560. void Environment::set_dof_blur_near_quality(DOFBlurQuality p_quality) {
  561. dof_blur_near_quality = p_quality;
  562. VS::get_singleton()->environment_set_dof_blur_near(environment, dof_blur_near_enabled, dof_blur_near_distance, dof_blur_near_transition, dof_blur_near_amount, VS::EnvironmentDOFBlurQuality(dof_blur_near_quality));
  563. }
  564. Environment::DOFBlurQuality Environment::get_dof_blur_near_quality() const {
  565. return dof_blur_near_quality;
  566. }
  567. void Environment::set_fog_enabled(bool p_enabled) {
  568. fog_enabled = p_enabled;
  569. VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
  570. _change_notify();
  571. }
  572. bool Environment::is_fog_enabled() const {
  573. return fog_enabled;
  574. }
  575. void Environment::set_fog_color(const Color &p_color) {
  576. fog_color = p_color;
  577. VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
  578. }
  579. Color Environment::get_fog_color() const {
  580. return fog_color;
  581. }
  582. void Environment::set_fog_sun_color(const Color &p_color) {
  583. fog_sun_color = p_color;
  584. VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
  585. }
  586. Color Environment::get_fog_sun_color() const {
  587. return fog_sun_color;
  588. }
  589. void Environment::set_fog_sun_amount(float p_amount) {
  590. fog_sun_amount = p_amount;
  591. VS::get_singleton()->environment_set_fog(environment, fog_enabled, fog_color, fog_sun_color, fog_sun_amount);
  592. }
  593. float Environment::get_fog_sun_amount() const {
  594. return fog_sun_amount;
  595. }
  596. void Environment::set_fog_depth_enabled(bool p_enabled) {
  597. fog_depth_enabled = p_enabled;
  598. VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
  599. }
  600. bool Environment::is_fog_depth_enabled() const {
  601. return fog_depth_enabled;
  602. }
  603. void Environment::set_fog_depth_begin(float p_distance) {
  604. fog_depth_begin = p_distance;
  605. VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
  606. }
  607. float Environment::get_fog_depth_begin() const {
  608. return fog_depth_begin;
  609. }
  610. void Environment::set_fog_depth_end(float p_distance) {
  611. fog_depth_end = p_distance;
  612. VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
  613. }
  614. float Environment::get_fog_depth_end() const {
  615. return fog_depth_end;
  616. }
  617. void Environment::set_fog_depth_curve(float p_curve) {
  618. fog_depth_curve = p_curve;
  619. VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
  620. }
  621. float Environment::get_fog_depth_curve() const {
  622. return fog_depth_curve;
  623. }
  624. void Environment::set_fog_transmit_enabled(bool p_enabled) {
  625. fog_transmit_enabled = p_enabled;
  626. VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
  627. }
  628. bool Environment::is_fog_transmit_enabled() const {
  629. return fog_transmit_enabled;
  630. }
  631. void Environment::set_fog_transmit_curve(float p_curve) {
  632. fog_transmit_curve = p_curve;
  633. VS::get_singleton()->environment_set_fog_depth(environment, fog_depth_enabled, fog_depth_begin, fog_depth_end, fog_depth_curve, fog_transmit_enabled, fog_transmit_curve);
  634. }
  635. float Environment::get_fog_transmit_curve() const {
  636. return fog_transmit_curve;
  637. }
  638. void Environment::set_fog_height_enabled(bool p_enabled) {
  639. fog_height_enabled = p_enabled;
  640. VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
  641. }
  642. bool Environment::is_fog_height_enabled() const {
  643. return fog_height_enabled;
  644. }
  645. void Environment::set_fog_height_min(float p_distance) {
  646. fog_height_min = p_distance;
  647. VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
  648. }
  649. float Environment::get_fog_height_min() const {
  650. return fog_height_min;
  651. }
  652. void Environment::set_fog_height_max(float p_distance) {
  653. fog_height_max = p_distance;
  654. VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
  655. }
  656. float Environment::get_fog_height_max() const {
  657. return fog_height_max;
  658. }
  659. void Environment::set_fog_height_curve(float p_distance) {
  660. fog_height_curve = p_distance;
  661. VS::get_singleton()->environment_set_fog_height(environment, fog_height_enabled, fog_height_min, fog_height_max, fog_height_curve);
  662. }
  663. float Environment::get_fog_height_curve() const {
  664. return fog_height_curve;
  665. }
  666. void Environment::_bind_methods() {
  667. ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background);
  668. ClassDB::bind_method(D_METHOD("set_sky", "sky"), &Environment::set_sky);
  669. ClassDB::bind_method(D_METHOD("set_sky_custom_fov", "scale"), &Environment::set_sky_custom_fov);
  670. ClassDB::bind_method(D_METHOD("set_sky_orientation", "orientation"), &Environment::set_sky_orientation);
  671. ClassDB::bind_method(D_METHOD("set_sky_rotation", "euler_radians"), &Environment::set_sky_rotation);
  672. ClassDB::bind_method(D_METHOD("set_sky_rotation_degrees", "euler_degrees"), &Environment::set_sky_rotation_degrees);
  673. ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &Environment::set_bg_color);
  674. ClassDB::bind_method(D_METHOD("set_bg_energy", "energy"), &Environment::set_bg_energy);
  675. ClassDB::bind_method(D_METHOD("set_canvas_max_layer", "layer"), &Environment::set_canvas_max_layer);
  676. ClassDB::bind_method(D_METHOD("set_ambient_light_color", "color"), &Environment::set_ambient_light_color);
  677. ClassDB::bind_method(D_METHOD("set_ambient_light_energy", "energy"), &Environment::set_ambient_light_energy);
  678. ClassDB::bind_method(D_METHOD("set_ambient_light_sky_contribution", "energy"), &Environment::set_ambient_light_sky_contribution);
  679. ClassDB::bind_method(D_METHOD("set_camera_feed_id", "camera_feed_id"), &Environment::set_camera_feed_id);
  680. ClassDB::bind_method(D_METHOD("get_background"), &Environment::get_background);
  681. ClassDB::bind_method(D_METHOD("get_sky"), &Environment::get_sky);
  682. ClassDB::bind_method(D_METHOD("get_sky_custom_fov"), &Environment::get_sky_custom_fov);
  683. ClassDB::bind_method(D_METHOD("get_sky_orientation"), &Environment::get_sky_orientation);
  684. ClassDB::bind_method(D_METHOD("get_sky_rotation"), &Environment::get_sky_rotation);
  685. ClassDB::bind_method(D_METHOD("get_sky_rotation_degrees"), &Environment::get_sky_rotation_degrees);
  686. ClassDB::bind_method(D_METHOD("get_bg_color"), &Environment::get_bg_color);
  687. ClassDB::bind_method(D_METHOD("get_bg_energy"), &Environment::get_bg_energy);
  688. ClassDB::bind_method(D_METHOD("get_canvas_max_layer"), &Environment::get_canvas_max_layer);
  689. ClassDB::bind_method(D_METHOD("get_ambient_light_color"), &Environment::get_ambient_light_color);
  690. ClassDB::bind_method(D_METHOD("get_ambient_light_energy"), &Environment::get_ambient_light_energy);
  691. ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution);
  692. ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &Environment::get_camera_feed_id);
  693. ADD_GROUP("Background", "background_");
  694. ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Color+Sky,Canvas,Keep,Camera Feed"), "set_background", "get_background");
  695. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "background_sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky");
  696. ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_sky_custom_fov", PROPERTY_HINT_RANGE, "0,180,0.1"), "set_sky_custom_fov", "get_sky_custom_fov");
  697. ADD_PROPERTY(PropertyInfo(Variant::BASIS, "background_sky_orientation"), "set_sky_orientation", "get_sky_orientation");
  698. // Only display rotation in degrees in the inspector (like in Spatial).
  699. // This avoids displaying the same information twice.
  700. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "background_sky_rotation", PROPERTY_HINT_NONE, "", 0), "set_sky_rotation", "get_sky_rotation");
  701. ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "background_sky_rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_sky_rotation_degrees", "get_sky_rotation_degrees");
  702. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color");
  703. ADD_PROPERTY(PropertyInfo(Variant::REAL, "background_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_bg_energy", "get_bg_energy");
  704. ADD_PROPERTY(PropertyInfo(Variant::INT, "background_canvas_max_layer", PROPERTY_HINT_RANGE, "-1000,1000,1"), "set_canvas_max_layer", "get_canvas_max_layer");
  705. ADD_PROPERTY(PropertyInfo(Variant::INT, "background_camera_feed_id", PROPERTY_HINT_RANGE, "1,10,1"), "set_camera_feed_id", "get_camera_feed_id");
  706. ADD_GROUP("Ambient Light", "ambient_light_");
  707. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_light_color"), "set_ambient_light_color", "get_ambient_light_color");
  708. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ambient_light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_light_energy", "get_ambient_light_energy");
  709. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ambient_light_sky_contribution", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ambient_light_sky_contribution", "get_ambient_light_sky_contribution");
  710. ClassDB::bind_method(D_METHOD("set_fog_enabled", "enabled"), &Environment::set_fog_enabled);
  711. ClassDB::bind_method(D_METHOD("is_fog_enabled"), &Environment::is_fog_enabled);
  712. ClassDB::bind_method(D_METHOD("set_fog_color", "color"), &Environment::set_fog_color);
  713. ClassDB::bind_method(D_METHOD("get_fog_color"), &Environment::get_fog_color);
  714. ClassDB::bind_method(D_METHOD("set_fog_sun_color", "color"), &Environment::set_fog_sun_color);
  715. ClassDB::bind_method(D_METHOD("get_fog_sun_color"), &Environment::get_fog_sun_color);
  716. ClassDB::bind_method(D_METHOD("set_fog_sun_amount", "amount"), &Environment::set_fog_sun_amount);
  717. ClassDB::bind_method(D_METHOD("get_fog_sun_amount"), &Environment::get_fog_sun_amount);
  718. ClassDB::bind_method(D_METHOD("set_fog_depth_enabled", "enabled"), &Environment::set_fog_depth_enabled);
  719. ClassDB::bind_method(D_METHOD("is_fog_depth_enabled"), &Environment::is_fog_depth_enabled);
  720. ClassDB::bind_method(D_METHOD("set_fog_depth_begin", "distance"), &Environment::set_fog_depth_begin);
  721. ClassDB::bind_method(D_METHOD("get_fog_depth_begin"), &Environment::get_fog_depth_begin);
  722. ClassDB::bind_method(D_METHOD("set_fog_depth_end", "distance"), &Environment::set_fog_depth_end);
  723. ClassDB::bind_method(D_METHOD("get_fog_depth_end"), &Environment::get_fog_depth_end);
  724. ClassDB::bind_method(D_METHOD("set_fog_depth_curve", "curve"), &Environment::set_fog_depth_curve);
  725. ClassDB::bind_method(D_METHOD("get_fog_depth_curve"), &Environment::get_fog_depth_curve);
  726. ClassDB::bind_method(D_METHOD("set_fog_transmit_enabled", "enabled"), &Environment::set_fog_transmit_enabled);
  727. ClassDB::bind_method(D_METHOD("is_fog_transmit_enabled"), &Environment::is_fog_transmit_enabled);
  728. ClassDB::bind_method(D_METHOD("set_fog_transmit_curve", "curve"), &Environment::set_fog_transmit_curve);
  729. ClassDB::bind_method(D_METHOD("get_fog_transmit_curve"), &Environment::get_fog_transmit_curve);
  730. ClassDB::bind_method(D_METHOD("set_fog_height_enabled", "enabled"), &Environment::set_fog_height_enabled);
  731. ClassDB::bind_method(D_METHOD("is_fog_height_enabled"), &Environment::is_fog_height_enabled);
  732. ClassDB::bind_method(D_METHOD("set_fog_height_min", "height"), &Environment::set_fog_height_min);
  733. ClassDB::bind_method(D_METHOD("get_fog_height_min"), &Environment::get_fog_height_min);
  734. ClassDB::bind_method(D_METHOD("set_fog_height_max", "height"), &Environment::set_fog_height_max);
  735. ClassDB::bind_method(D_METHOD("get_fog_height_max"), &Environment::get_fog_height_max);
  736. ClassDB::bind_method(D_METHOD("set_fog_height_curve", "curve"), &Environment::set_fog_height_curve);
  737. ClassDB::bind_method(D_METHOD("get_fog_height_curve"), &Environment::get_fog_height_curve);
  738. ADD_GROUP("Fog", "fog_");
  739. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_enabled"), "set_fog_enabled", "is_fog_enabled");
  740. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_color"), "set_fog_color", "get_fog_color");
  741. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_sun_color"), "set_fog_sun_color", "get_fog_sun_color");
  742. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_sun_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_fog_sun_amount", "get_fog_sun_amount");
  743. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_depth_enabled"), "set_fog_depth_enabled", "is_fog_depth_enabled");
  744. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_depth_begin", PROPERTY_HINT_RANGE, "0,4000,0.1"), "set_fog_depth_begin", "get_fog_depth_begin");
  745. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_depth_end", PROPERTY_HINT_RANGE, "0,4000,0.1,or_greater"), "set_fog_depth_end", "get_fog_depth_end");
  746. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_depth_curve", PROPERTY_HINT_EXP_EASING), "set_fog_depth_curve", "get_fog_depth_curve");
  747. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_transmit_enabled"), "set_fog_transmit_enabled", "is_fog_transmit_enabled");
  748. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_transmit_curve", PROPERTY_HINT_EXP_EASING), "set_fog_transmit_curve", "get_fog_transmit_curve");
  749. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_height_enabled"), "set_fog_height_enabled", "is_fog_height_enabled");
  750. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_height_min", PROPERTY_HINT_RANGE, "-4000,4000,0.1,or_lesser,or_greater"), "set_fog_height_min", "get_fog_height_min");
  751. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_height_max", PROPERTY_HINT_RANGE, "-4000,4000,0.1,or_lesser,or_greater"), "set_fog_height_max", "get_fog_height_max");
  752. ADD_PROPERTY(PropertyInfo(Variant::REAL, "fog_height_curve", PROPERTY_HINT_EXP_EASING), "set_fog_height_curve", "get_fog_height_curve");
  753. ClassDB::bind_method(D_METHOD("set_tonemapper", "mode"), &Environment::set_tonemapper);
  754. ClassDB::bind_method(D_METHOD("get_tonemapper"), &Environment::get_tonemapper);
  755. ClassDB::bind_method(D_METHOD("set_tonemap_exposure", "exposure"), &Environment::set_tonemap_exposure);
  756. ClassDB::bind_method(D_METHOD("get_tonemap_exposure"), &Environment::get_tonemap_exposure);
  757. ClassDB::bind_method(D_METHOD("set_tonemap_white", "white"), &Environment::set_tonemap_white);
  758. ClassDB::bind_method(D_METHOD("get_tonemap_white"), &Environment::get_tonemap_white);
  759. ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure", "auto_exposure"), &Environment::set_tonemap_auto_exposure);
  760. ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure"), &Environment::get_tonemap_auto_exposure);
  761. ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_max", "exposure_max"), &Environment::set_tonemap_auto_exposure_max);
  762. ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_max"), &Environment::get_tonemap_auto_exposure_max);
  763. ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_min", "exposure_min"), &Environment::set_tonemap_auto_exposure_min);
  764. ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_min"), &Environment::get_tonemap_auto_exposure_min);
  765. ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_speed", "exposure_speed"), &Environment::set_tonemap_auto_exposure_speed);
  766. ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_speed"), &Environment::get_tonemap_auto_exposure_speed);
  767. ClassDB::bind_method(D_METHOD("set_tonemap_auto_exposure_grey", "exposure_grey"), &Environment::set_tonemap_auto_exposure_grey);
  768. ClassDB::bind_method(D_METHOD("get_tonemap_auto_exposure_grey"), &Environment::get_tonemap_auto_exposure_grey);
  769. ADD_GROUP("Tonemap", "tonemap_");
  770. ADD_PROPERTY(PropertyInfo(Variant::INT, "tonemap_mode", PROPERTY_HINT_ENUM, "Linear,Reinhard,Filmic,ACES"), "set_tonemapper", "get_tonemapper");
  771. ADD_PROPERTY(PropertyInfo(Variant::REAL, "tonemap_exposure", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_tonemap_exposure", "get_tonemap_exposure");
  772. ADD_PROPERTY(PropertyInfo(Variant::REAL, "tonemap_white", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_tonemap_white", "get_tonemap_white");
  773. ADD_GROUP("Auto Exposure", "auto_exposure_");
  774. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_exposure_enabled"), "set_tonemap_auto_exposure", "get_tonemap_auto_exposure");
  775. ADD_PROPERTY(PropertyInfo(Variant::REAL, "auto_exposure_scale", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_tonemap_auto_exposure_grey", "get_tonemap_auto_exposure_grey");
  776. ADD_PROPERTY(PropertyInfo(Variant::REAL, "auto_exposure_min_luma", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_tonemap_auto_exposure_min", "get_tonemap_auto_exposure_min");
  777. ADD_PROPERTY(PropertyInfo(Variant::REAL, "auto_exposure_max_luma", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_tonemap_auto_exposure_max", "get_tonemap_auto_exposure_max");
  778. ADD_PROPERTY(PropertyInfo(Variant::REAL, "auto_exposure_speed", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_tonemap_auto_exposure_speed", "get_tonemap_auto_exposure_speed");
  779. ClassDB::bind_method(D_METHOD("set_ssr_enabled", "enabled"), &Environment::set_ssr_enabled);
  780. ClassDB::bind_method(D_METHOD("is_ssr_enabled"), &Environment::is_ssr_enabled);
  781. ClassDB::bind_method(D_METHOD("set_ssr_max_steps", "max_steps"), &Environment::set_ssr_max_steps);
  782. ClassDB::bind_method(D_METHOD("get_ssr_max_steps"), &Environment::get_ssr_max_steps);
  783. ClassDB::bind_method(D_METHOD("set_ssr_fade_in", "fade_in"), &Environment::set_ssr_fade_in);
  784. ClassDB::bind_method(D_METHOD("get_ssr_fade_in"), &Environment::get_ssr_fade_in);
  785. ClassDB::bind_method(D_METHOD("set_ssr_fade_out", "fade_out"), &Environment::set_ssr_fade_out);
  786. ClassDB::bind_method(D_METHOD("get_ssr_fade_out"), &Environment::get_ssr_fade_out);
  787. ClassDB::bind_method(D_METHOD("set_ssr_depth_tolerance", "depth_tolerance"), &Environment::set_ssr_depth_tolerance);
  788. ClassDB::bind_method(D_METHOD("get_ssr_depth_tolerance"), &Environment::get_ssr_depth_tolerance);
  789. ClassDB::bind_method(D_METHOD("set_ssr_rough", "rough"), &Environment::set_ssr_rough);
  790. ClassDB::bind_method(D_METHOD("is_ssr_rough"), &Environment::is_ssr_rough);
  791. ADD_GROUP("SS Reflections", "ss_reflections_");
  792. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ss_reflections_enabled"), "set_ssr_enabled", "is_ssr_enabled");
  793. ADD_PROPERTY(PropertyInfo(Variant::INT, "ss_reflections_max_steps", PROPERTY_HINT_RANGE, "1,512,1"), "set_ssr_max_steps", "get_ssr_max_steps");
  794. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ss_reflections_fade_in", PROPERTY_HINT_EXP_EASING), "set_ssr_fade_in", "get_ssr_fade_in");
  795. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ss_reflections_fade_out", PROPERTY_HINT_EXP_EASING), "set_ssr_fade_out", "get_ssr_fade_out");
  796. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ss_reflections_depth_tolerance", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_ssr_depth_tolerance", "get_ssr_depth_tolerance");
  797. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ss_reflections_roughness"), "set_ssr_rough", "is_ssr_rough");
  798. ClassDB::bind_method(D_METHOD("set_ssao_enabled", "enabled"), &Environment::set_ssao_enabled);
  799. ClassDB::bind_method(D_METHOD("is_ssao_enabled"), &Environment::is_ssao_enabled);
  800. ClassDB::bind_method(D_METHOD("set_ssao_radius", "radius"), &Environment::set_ssao_radius);
  801. ClassDB::bind_method(D_METHOD("get_ssao_radius"), &Environment::get_ssao_radius);
  802. ClassDB::bind_method(D_METHOD("set_ssao_intensity", "intensity"), &Environment::set_ssao_intensity);
  803. ClassDB::bind_method(D_METHOD("get_ssao_intensity"), &Environment::get_ssao_intensity);
  804. ClassDB::bind_method(D_METHOD("set_ssao_radius2", "radius"), &Environment::set_ssao_radius2);
  805. ClassDB::bind_method(D_METHOD("get_ssao_radius2"), &Environment::get_ssao_radius2);
  806. ClassDB::bind_method(D_METHOD("set_ssao_intensity2", "intensity"), &Environment::set_ssao_intensity2);
  807. ClassDB::bind_method(D_METHOD("get_ssao_intensity2"), &Environment::get_ssao_intensity2);
  808. ClassDB::bind_method(D_METHOD("set_ssao_bias", "bias"), &Environment::set_ssao_bias);
  809. ClassDB::bind_method(D_METHOD("get_ssao_bias"), &Environment::get_ssao_bias);
  810. ClassDB::bind_method(D_METHOD("set_ssao_direct_light_affect", "amount"), &Environment::set_ssao_direct_light_affect);
  811. ClassDB::bind_method(D_METHOD("get_ssao_direct_light_affect"), &Environment::get_ssao_direct_light_affect);
  812. ClassDB::bind_method(D_METHOD("set_ssao_ao_channel_affect", "amount"), &Environment::set_ssao_ao_channel_affect);
  813. ClassDB::bind_method(D_METHOD("get_ssao_ao_channel_affect"), &Environment::get_ssao_ao_channel_affect);
  814. ClassDB::bind_method(D_METHOD("set_ssao_color", "color"), &Environment::set_ssao_color);
  815. ClassDB::bind_method(D_METHOD("get_ssao_color"), &Environment::get_ssao_color);
  816. ClassDB::bind_method(D_METHOD("set_ssao_blur", "mode"), &Environment::set_ssao_blur);
  817. ClassDB::bind_method(D_METHOD("get_ssao_blur"), &Environment::get_ssao_blur);
  818. ClassDB::bind_method(D_METHOD("set_ssao_quality", "quality"), &Environment::set_ssao_quality);
  819. ClassDB::bind_method(D_METHOD("get_ssao_quality"), &Environment::get_ssao_quality);
  820. ClassDB::bind_method(D_METHOD("set_ssao_edge_sharpness", "edge_sharpness"), &Environment::set_ssao_edge_sharpness);
  821. ClassDB::bind_method(D_METHOD("get_ssao_edge_sharpness"), &Environment::get_ssao_edge_sharpness);
  822. ADD_GROUP("SSAO", "ssao_");
  823. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssao_enabled"), "set_ssao_enabled", "is_ssao_enabled");
  824. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_radius", PROPERTY_HINT_RANGE, "0.1,128,0.01"), "set_ssao_radius", "get_ssao_radius");
  825. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_intensity", PROPERTY_HINT_RANGE, "0.0,128,0.01"), "set_ssao_intensity", "get_ssao_intensity");
  826. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_radius2", PROPERTY_HINT_RANGE, "0.0,128,0.01"), "set_ssao_radius2", "get_ssao_radius2");
  827. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_intensity2", PROPERTY_HINT_RANGE, "0.0,128,0.01"), "set_ssao_intensity2", "get_ssao_intensity2");
  828. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_bias", PROPERTY_HINT_RANGE, "0.001,8,0.001"), "set_ssao_bias", "get_ssao_bias");
  829. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_light_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_direct_light_affect", "get_ssao_direct_light_affect");
  830. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_ao_channel_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_ao_channel_affect", "get_ssao_ao_channel_affect");
  831. ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ssao_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ssao_color", "get_ssao_color");
  832. ADD_PROPERTY(PropertyInfo(Variant::INT, "ssao_quality", PROPERTY_HINT_ENUM, "Low,Medium,High"), "set_ssao_quality", "get_ssao_quality");
  833. ADD_PROPERTY(PropertyInfo(Variant::INT, "ssao_blur", PROPERTY_HINT_ENUM, "Disabled,1x1,2x2,3x3"), "set_ssao_blur", "get_ssao_blur");
  834. ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_edge_sharpness", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_ssao_edge_sharpness", "get_ssao_edge_sharpness");
  835. ClassDB::bind_method(D_METHOD("set_dof_blur_far_enabled", "enabled"), &Environment::set_dof_blur_far_enabled);
  836. ClassDB::bind_method(D_METHOD("is_dof_blur_far_enabled"), &Environment::is_dof_blur_far_enabled);
  837. ClassDB::bind_method(D_METHOD("set_dof_blur_far_distance", "intensity"), &Environment::set_dof_blur_far_distance);
  838. ClassDB::bind_method(D_METHOD("get_dof_blur_far_distance"), &Environment::get_dof_blur_far_distance);
  839. ClassDB::bind_method(D_METHOD("set_dof_blur_far_transition", "intensity"), &Environment::set_dof_blur_far_transition);
  840. ClassDB::bind_method(D_METHOD("get_dof_blur_far_transition"), &Environment::get_dof_blur_far_transition);
  841. ClassDB::bind_method(D_METHOD("set_dof_blur_far_amount", "intensity"), &Environment::set_dof_blur_far_amount);
  842. ClassDB::bind_method(D_METHOD("get_dof_blur_far_amount"), &Environment::get_dof_blur_far_amount);
  843. ClassDB::bind_method(D_METHOD("set_dof_blur_far_quality", "intensity"), &Environment::set_dof_blur_far_quality);
  844. ClassDB::bind_method(D_METHOD("get_dof_blur_far_quality"), &Environment::get_dof_blur_far_quality);
  845. ClassDB::bind_method(D_METHOD("set_dof_blur_near_enabled", "enabled"), &Environment::set_dof_blur_near_enabled);
  846. ClassDB::bind_method(D_METHOD("is_dof_blur_near_enabled"), &Environment::is_dof_blur_near_enabled);
  847. ClassDB::bind_method(D_METHOD("set_dof_blur_near_distance", "intensity"), &Environment::set_dof_blur_near_distance);
  848. ClassDB::bind_method(D_METHOD("get_dof_blur_near_distance"), &Environment::get_dof_blur_near_distance);
  849. ClassDB::bind_method(D_METHOD("set_dof_blur_near_transition", "intensity"), &Environment::set_dof_blur_near_transition);
  850. ClassDB::bind_method(D_METHOD("get_dof_blur_near_transition"), &Environment::get_dof_blur_near_transition);
  851. ClassDB::bind_method(D_METHOD("set_dof_blur_near_amount", "intensity"), &Environment::set_dof_blur_near_amount);
  852. ClassDB::bind_method(D_METHOD("get_dof_blur_near_amount"), &Environment::get_dof_blur_near_amount);
  853. ClassDB::bind_method(D_METHOD("set_dof_blur_near_quality", "level"), &Environment::set_dof_blur_near_quality);
  854. ClassDB::bind_method(D_METHOD("get_dof_blur_near_quality"), &Environment::get_dof_blur_near_quality);
  855. ADD_GROUP("DOF Far Blur", "dof_blur_far_");
  856. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dof_blur_far_enabled"), "set_dof_blur_far_enabled", "is_dof_blur_far_enabled");
  857. ADD_PROPERTY(PropertyInfo(Variant::REAL, "dof_blur_far_distance", PROPERTY_HINT_EXP_RANGE, "0.01,8192,0.01"), "set_dof_blur_far_distance", "get_dof_blur_far_distance");
  858. ADD_PROPERTY(PropertyInfo(Variant::REAL, "dof_blur_far_transition", PROPERTY_HINT_EXP_RANGE, "0.01,8192,0.01"), "set_dof_blur_far_transition", "get_dof_blur_far_transition");
  859. ADD_PROPERTY(PropertyInfo(Variant::REAL, "dof_blur_far_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_dof_blur_far_amount", "get_dof_blur_far_amount");
  860. ADD_PROPERTY(PropertyInfo(Variant::INT, "dof_blur_far_quality", PROPERTY_HINT_ENUM, "Low,Medium,High"), "set_dof_blur_far_quality", "get_dof_blur_far_quality");
  861. ADD_GROUP("DOF Near Blur", "dof_blur_near_");
  862. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dof_blur_near_enabled"), "set_dof_blur_near_enabled", "is_dof_blur_near_enabled");
  863. ADD_PROPERTY(PropertyInfo(Variant::REAL, "dof_blur_near_distance", PROPERTY_HINT_EXP_RANGE, "0.01,8192,0.01"), "set_dof_blur_near_distance", "get_dof_blur_near_distance");
  864. ADD_PROPERTY(PropertyInfo(Variant::REAL, "dof_blur_near_transition", PROPERTY_HINT_EXP_RANGE, "0.01,8192,0.01"), "set_dof_blur_near_transition", "get_dof_blur_near_transition");
  865. ADD_PROPERTY(PropertyInfo(Variant::REAL, "dof_blur_near_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_dof_blur_near_amount", "get_dof_blur_near_amount");
  866. ADD_PROPERTY(PropertyInfo(Variant::INT, "dof_blur_near_quality", PROPERTY_HINT_ENUM, "Low,Medium,High"), "set_dof_blur_near_quality", "get_dof_blur_near_quality");
  867. ClassDB::bind_method(D_METHOD("set_glow_enabled", "enabled"), &Environment::set_glow_enabled);
  868. ClassDB::bind_method(D_METHOD("is_glow_enabled"), &Environment::is_glow_enabled);
  869. ClassDB::bind_method(D_METHOD("set_glow_level", "idx", "enabled"), &Environment::set_glow_level);
  870. ClassDB::bind_method(D_METHOD("is_glow_level_enabled", "idx"), &Environment::is_glow_level_enabled);
  871. ClassDB::bind_method(D_METHOD("set_glow_intensity", "intensity"), &Environment::set_glow_intensity);
  872. ClassDB::bind_method(D_METHOD("get_glow_intensity"), &Environment::get_glow_intensity);
  873. ClassDB::bind_method(D_METHOD("set_glow_strength", "strength"), &Environment::set_glow_strength);
  874. ClassDB::bind_method(D_METHOD("get_glow_strength"), &Environment::get_glow_strength);
  875. ClassDB::bind_method(D_METHOD("set_glow_bloom", "amount"), &Environment::set_glow_bloom);
  876. ClassDB::bind_method(D_METHOD("get_glow_bloom"), &Environment::get_glow_bloom);
  877. ClassDB::bind_method(D_METHOD("set_glow_blend_mode", "mode"), &Environment::set_glow_blend_mode);
  878. ClassDB::bind_method(D_METHOD("get_glow_blend_mode"), &Environment::get_glow_blend_mode);
  879. ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_threshold", "threshold"), &Environment::set_glow_hdr_bleed_threshold);
  880. ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_threshold"), &Environment::get_glow_hdr_bleed_threshold);
  881. ClassDB::bind_method(D_METHOD("set_glow_hdr_luminance_cap", "amount"), &Environment::set_glow_hdr_luminance_cap);
  882. ClassDB::bind_method(D_METHOD("get_glow_hdr_luminance_cap"), &Environment::get_glow_hdr_luminance_cap);
  883. ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_scale", "scale"), &Environment::set_glow_hdr_bleed_scale);
  884. ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_scale"), &Environment::get_glow_hdr_bleed_scale);
  885. ClassDB::bind_method(D_METHOD("set_glow_bicubic_upscale", "enabled"), &Environment::set_glow_bicubic_upscale);
  886. ClassDB::bind_method(D_METHOD("is_glow_bicubic_upscale_enabled"), &Environment::is_glow_bicubic_upscale_enabled);
  887. ADD_GROUP("Glow", "glow_");
  888. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_enabled"), "set_glow_enabled", "is_glow_enabled");
  889. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/1"), "set_glow_level", "is_glow_level_enabled", 0);
  890. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/2"), "set_glow_level", "is_glow_level_enabled", 1);
  891. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/3"), "set_glow_level", "is_glow_level_enabled", 2);
  892. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/4"), "set_glow_level", "is_glow_level_enabled", 3);
  893. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/5"), "set_glow_level", "is_glow_level_enabled", 4);
  894. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/6"), "set_glow_level", "is_glow_level_enabled", 5);
  895. ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/7"), "set_glow_level", "is_glow_level_enabled", 6);
  896. ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_intensity", PROPERTY_HINT_RANGE, "0.0,8.0,0.01"), "set_glow_intensity", "get_glow_intensity");
  897. ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_strength", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"), "set_glow_strength", "get_glow_strength");
  898. ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_bloom", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_glow_bloom", "get_glow_bloom");
  899. ADD_PROPERTY(PropertyInfo(Variant::INT, "glow_blend_mode", PROPERTY_HINT_ENUM, "Additive,Screen,Softlight,Replace"), "set_glow_blend_mode", "get_glow_blend_mode");
  900. ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_threshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_threshold", "get_glow_hdr_bleed_threshold");
  901. ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_luminance_cap", PROPERTY_HINT_RANGE, "0.0,256.0,0.01"), "set_glow_hdr_luminance_cap", "get_glow_hdr_luminance_cap");
  902. ADD_PROPERTY(PropertyInfo(Variant::REAL, "glow_hdr_scale", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_scale", "get_glow_hdr_bleed_scale");
  903. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_bicubic_upscale"), "set_glow_bicubic_upscale", "is_glow_bicubic_upscale_enabled");
  904. ClassDB::bind_method(D_METHOD("set_adjustment_enable", "enabled"), &Environment::set_adjustment_enable);
  905. ClassDB::bind_method(D_METHOD("is_adjustment_enabled"), &Environment::is_adjustment_enabled);
  906. ClassDB::bind_method(D_METHOD("set_adjustment_brightness", "brightness"), &Environment::set_adjustment_brightness);
  907. ClassDB::bind_method(D_METHOD("get_adjustment_brightness"), &Environment::get_adjustment_brightness);
  908. ClassDB::bind_method(D_METHOD("set_adjustment_contrast", "contrast"), &Environment::set_adjustment_contrast);
  909. ClassDB::bind_method(D_METHOD("get_adjustment_contrast"), &Environment::get_adjustment_contrast);
  910. ClassDB::bind_method(D_METHOD("set_adjustment_saturation", "saturation"), &Environment::set_adjustment_saturation);
  911. ClassDB::bind_method(D_METHOD("get_adjustment_saturation"), &Environment::get_adjustment_saturation);
  912. ClassDB::bind_method(D_METHOD("set_adjustment_color_correction", "color_correction"), &Environment::set_adjustment_color_correction);
  913. ClassDB::bind_method(D_METHOD("get_adjustment_color_correction"), &Environment::get_adjustment_color_correction);
  914. ADD_GROUP("Adjustments", "adjustment_");
  915. ADD_PROPERTY(PropertyInfo(Variant::BOOL, "adjustment_enabled"), "set_adjustment_enable", "is_adjustment_enabled");
  916. ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_brightness", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_brightness", "get_adjustment_brightness");
  917. ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_contrast", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_contrast", "get_adjustment_contrast");
  918. ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation");
  919. ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_adjustment_color_correction", "get_adjustment_color_correction");
  920. BIND_ENUM_CONSTANT(BG_KEEP);
  921. BIND_ENUM_CONSTANT(BG_CLEAR_COLOR);
  922. BIND_ENUM_CONSTANT(BG_COLOR);
  923. BIND_ENUM_CONSTANT(BG_SKY);
  924. BIND_ENUM_CONSTANT(BG_COLOR_SKY);
  925. BIND_ENUM_CONSTANT(BG_CANVAS);
  926. BIND_ENUM_CONSTANT(BG_CAMERA_FEED);
  927. BIND_ENUM_CONSTANT(BG_MAX);
  928. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
  929. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SCREEN);
  930. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
  931. BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_REPLACE);
  932. BIND_ENUM_CONSTANT(TONE_MAPPER_LINEAR);
  933. BIND_ENUM_CONSTANT(TONE_MAPPER_REINHARDT);
  934. BIND_ENUM_CONSTANT(TONE_MAPPER_FILMIC);
  935. BIND_ENUM_CONSTANT(TONE_MAPPER_ACES);
  936. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW);
  937. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM);
  938. BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH);
  939. BIND_ENUM_CONSTANT(SSAO_BLUR_DISABLED);
  940. BIND_ENUM_CONSTANT(SSAO_BLUR_1x1);
  941. BIND_ENUM_CONSTANT(SSAO_BLUR_2x2);
  942. BIND_ENUM_CONSTANT(SSAO_BLUR_3x3);
  943. BIND_ENUM_CONSTANT(SSAO_QUALITY_LOW);
  944. BIND_ENUM_CONSTANT(SSAO_QUALITY_MEDIUM);
  945. BIND_ENUM_CONSTANT(SSAO_QUALITY_HIGH);
  946. }
  947. Environment::Environment() :
  948. bg_mode(BG_CLEAR_COLOR),
  949. tone_mapper(TONE_MAPPER_LINEAR),
  950. ssao_blur(SSAO_BLUR_3x3),
  951. ssao_quality(SSAO_QUALITY_MEDIUM),
  952. glow_blend_mode(GLOW_BLEND_MODE_ADDITIVE),
  953. dof_blur_far_quality(DOF_BLUR_QUALITY_LOW),
  954. dof_blur_near_quality(DOF_BLUR_QUALITY_LOW) {
  955. environment = VS::get_singleton()->environment_create();
  956. bg_mode = BG_CLEAR_COLOR;
  957. bg_sky_custom_fov = 0;
  958. bg_sky_orientation = Basis();
  959. bg_energy = 1.0;
  960. bg_canvas_max_layer = 0;
  961. ambient_energy = 1.0;
  962. //ambient_sky_contribution = 1.0;
  963. set_ambient_light_sky_contribution(1.0);
  964. set_camera_feed_id(1);
  965. tone_mapper = TONE_MAPPER_LINEAR;
  966. tonemap_exposure = 1.0;
  967. tonemap_white = 1.0;
  968. tonemap_auto_exposure = false;
  969. tonemap_auto_exposure_max = 8;
  970. tonemap_auto_exposure_min = 0.05;
  971. tonemap_auto_exposure_speed = 0.5;
  972. tonemap_auto_exposure_grey = 0.4;
  973. set_tonemapper(tone_mapper); //update
  974. adjustment_enabled = false;
  975. adjustment_contrast = 1.0;
  976. adjustment_saturation = 1.0;
  977. adjustment_brightness = 1.0;
  978. set_adjustment_enable(adjustment_enabled); //update
  979. ssr_enabled = false;
  980. ssr_max_steps = 64;
  981. ssr_fade_in = 0.15;
  982. ssr_fade_out = 2.0;
  983. ssr_depth_tolerance = 0.2;
  984. ssr_roughness = true;
  985. ssao_enabled = false;
  986. ssao_radius = 1;
  987. ssao_intensity = 1;
  988. ssao_radius2 = 0;
  989. ssao_intensity2 = 1;
  990. ssao_bias = 0.01;
  991. ssao_direct_light_affect = 0.0;
  992. ssao_ao_channel_affect = 0.0;
  993. ssao_blur = SSAO_BLUR_3x3;
  994. set_ssao_edge_sharpness(4);
  995. set_ssao_quality(SSAO_QUALITY_MEDIUM);
  996. glow_enabled = false;
  997. glow_levels = (1 << 2) | (1 << 4);
  998. glow_intensity = 0.8;
  999. glow_strength = 1.0;
  1000. glow_bloom = 0.0;
  1001. glow_blend_mode = GLOW_BLEND_MODE_SOFTLIGHT;
  1002. glow_hdr_bleed_threshold = 1.0;
  1003. glow_hdr_luminance_cap = 12.0;
  1004. glow_hdr_bleed_scale = 2.0;
  1005. glow_bicubic_upscale = false;
  1006. dof_blur_far_enabled = false;
  1007. dof_blur_far_distance = 10;
  1008. dof_blur_far_transition = 5;
  1009. dof_blur_far_amount = 0.1;
  1010. dof_blur_far_quality = DOF_BLUR_QUALITY_MEDIUM;
  1011. dof_blur_near_enabled = false;
  1012. dof_blur_near_distance = 2;
  1013. dof_blur_near_transition = 1;
  1014. dof_blur_near_amount = 0.1;
  1015. dof_blur_near_quality = DOF_BLUR_QUALITY_MEDIUM;
  1016. fog_enabled = false;
  1017. fog_color = Color(0.5, 0.5, 0.5);
  1018. fog_sun_color = Color(0.8, 0.8, 0.0);
  1019. fog_sun_amount = 0;
  1020. fog_depth_enabled = true;
  1021. fog_depth_begin = 10;
  1022. fog_depth_end = 100;
  1023. fog_depth_curve = 1;
  1024. fog_transmit_enabled = false;
  1025. fog_transmit_curve = 1;
  1026. fog_height_enabled = false;
  1027. fog_height_min = 10;
  1028. fog_height_max = 0;
  1029. fog_height_curve = 1;
  1030. set_fog_color(Color(0.5, 0.6, 0.7));
  1031. set_fog_sun_color(Color(1.0, 0.9, 0.7));
  1032. }
  1033. Environment::~Environment() {
  1034. VS::get_singleton()->free(environment);
  1035. }