environment.cpp 63 KB

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