1/**************************************************************************/
2/* environment.cpp */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
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
31#include "environment.h"
32
33#include "core/config/project_settings.h"
34#include "scene/resources/gradient_texture.h"
35#include "servers/rendering_server.h"
36
37RID Environment::get_rid() const {
38 return environment;
39}
40
41// Background
42
43void Environment::set_background(BGMode p_bg) {
44 bg_mode = p_bg;
45 RS::get_singleton()->environment_set_background(environment, RS::EnvironmentBG(p_bg));
46 notify_property_list_changed();
47 if (bg_mode != BG_SKY) {
48 set_fog_aerial_perspective(0.0);
49 }
50}
51
52Environment::BGMode Environment::get_background() const {
53 return bg_mode;
54}
55
56void Environment::set_sky(const Ref<Sky> &p_sky) {
57 bg_sky = p_sky;
58 RID sb_rid;
59 if (bg_sky.is_valid()) {
60 sb_rid = bg_sky->get_rid();
61 }
62 RS::get_singleton()->environment_set_sky(environment, sb_rid);
63}
64
65Ref<Sky> Environment::get_sky() const {
66 return bg_sky;
67}
68
69void Environment::set_sky_custom_fov(float p_scale) {
70 bg_sky_custom_fov = p_scale;
71 RS::get_singleton()->environment_set_sky_custom_fov(environment, p_scale);
72}
73
74float Environment::get_sky_custom_fov() const {
75 return bg_sky_custom_fov;
76}
77
78void Environment::set_sky_rotation(const Vector3 &p_rotation) {
79 bg_sky_rotation = p_rotation;
80 RS::get_singleton()->environment_set_sky_orientation(environment, Basis::from_euler(p_rotation));
81}
82
83Vector3 Environment::get_sky_rotation() const {
84 return bg_sky_rotation;
85}
86
87void Environment::set_bg_color(const Color &p_color) {
88 bg_color = p_color;
89 RS::get_singleton()->environment_set_bg_color(environment, p_color);
90}
91
92Color Environment::get_bg_color() const {
93 return bg_color;
94}
95
96void Environment::set_bg_energy_multiplier(float p_multiplier) {
97 bg_energy_multiplier = p_multiplier;
98 _update_bg_energy();
99}
100
101float Environment::get_bg_energy_multiplier() const {
102 return bg_energy_multiplier;
103}
104
105void Environment::set_bg_intensity(float p_exposure_value) {
106 bg_intensity = p_exposure_value;
107 _update_bg_energy();
108}
109
110float Environment::get_bg_intensity() const {
111 return bg_intensity;
112}
113
114void Environment::_update_bg_energy() {
115 if (GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
116 RS::get_singleton()->environment_set_bg_energy(environment, bg_energy_multiplier, bg_intensity);
117 } else {
118 RS::get_singleton()->environment_set_bg_energy(environment, bg_energy_multiplier, 1.0);
119 }
120}
121
122void Environment::set_canvas_max_layer(int p_max_layer) {
123 bg_canvas_max_layer = p_max_layer;
124 RS::get_singleton()->environment_set_canvas_max_layer(environment, p_max_layer);
125}
126
127int Environment::get_canvas_max_layer() const {
128 return bg_canvas_max_layer;
129}
130
131void Environment::set_camera_feed_id(int p_id) {
132 bg_camera_feed_id = p_id;
133// FIXME: Disabled during Vulkan refactoring, should be ported.
134#if 0
135 RS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id);
136#endif
137}
138
139int Environment::get_camera_feed_id() const {
140 return bg_camera_feed_id;
141}
142
143// Ambient light
144
145void Environment::set_ambient_light_color(const Color &p_color) {
146 ambient_color = p_color;
147 _update_ambient_light();
148}
149
150Color Environment::get_ambient_light_color() const {
151 return ambient_color;
152}
153
154void Environment::set_ambient_source(AmbientSource p_source) {
155 ambient_source = p_source;
156 _update_ambient_light();
157 notify_property_list_changed();
158}
159
160Environment::AmbientSource Environment::get_ambient_source() const {
161 return ambient_source;
162}
163
164void Environment::set_ambient_light_energy(float p_energy) {
165 ambient_energy = p_energy;
166 _update_ambient_light();
167}
168
169float Environment::get_ambient_light_energy() const {
170 return ambient_energy;
171}
172
173void Environment::set_ambient_light_sky_contribution(float p_ratio) {
174 // Sky contribution values outside the [0.0; 1.0] range don't make sense and
175 // can result in negative colors.
176 ambient_sky_contribution = CLAMP(p_ratio, 0.0, 1.0);
177 _update_ambient_light();
178}
179
180float Environment::get_ambient_light_sky_contribution() const {
181 return ambient_sky_contribution;
182}
183
184void Environment::set_reflection_source(ReflectionSource p_source) {
185 reflection_source = p_source;
186 _update_ambient_light();
187 notify_property_list_changed();
188}
189
190Environment::ReflectionSource Environment::get_reflection_source() const {
191 return reflection_source;
192}
193
194void Environment::_update_ambient_light() {
195 RS::get_singleton()->environment_set_ambient_light(
196 environment,
197 ambient_color,
198 RS::EnvironmentAmbientSource(ambient_source),
199 ambient_energy,
200 ambient_sky_contribution, RS::EnvironmentReflectionSource(reflection_source));
201}
202
203// Tonemap
204
205void Environment::set_tonemapper(ToneMapper p_tone_mapper) {
206 tone_mapper = p_tone_mapper;
207 _update_tonemap();
208 notify_property_list_changed();
209}
210
211Environment::ToneMapper Environment::get_tonemapper() const {
212 return tone_mapper;
213}
214
215void Environment::set_tonemap_exposure(float p_exposure) {
216 tonemap_exposure = p_exposure;
217 _update_tonemap();
218}
219
220float Environment::get_tonemap_exposure() const {
221 return tonemap_exposure;
222}
223
224void Environment::set_tonemap_white(float p_white) {
225 tonemap_white = p_white;
226 _update_tonemap();
227}
228
229float Environment::get_tonemap_white() const {
230 return tonemap_white;
231}
232
233void Environment::_update_tonemap() {
234 RS::get_singleton()->environment_set_tonemap(
235 environment,
236 RS::EnvironmentToneMapper(tone_mapper),
237 tonemap_exposure,
238 tonemap_white);
239}
240
241// SSR
242
243void Environment::set_ssr_enabled(bool p_enabled) {
244 ssr_enabled = p_enabled;
245 _update_ssr();
246 notify_property_list_changed();
247}
248
249bool Environment::is_ssr_enabled() const {
250 return ssr_enabled;
251}
252
253void Environment::set_ssr_max_steps(int p_steps) {
254 ssr_max_steps = p_steps;
255 _update_ssr();
256}
257
258int Environment::get_ssr_max_steps() const {
259 return ssr_max_steps;
260}
261
262void Environment::set_ssr_fade_in(float p_fade_in) {
263 ssr_fade_in = MAX(p_fade_in, 0.0f);
264 _update_ssr();
265}
266
267float Environment::get_ssr_fade_in() const {
268 return ssr_fade_in;
269}
270
271void Environment::set_ssr_fade_out(float p_fade_out) {
272 ssr_fade_out = MAX(p_fade_out, 0.0f);
273 _update_ssr();
274}
275
276float Environment::get_ssr_fade_out() const {
277 return ssr_fade_out;
278}
279
280void Environment::set_ssr_depth_tolerance(float p_depth_tolerance) {
281 ssr_depth_tolerance = p_depth_tolerance;
282 _update_ssr();
283}
284
285float Environment::get_ssr_depth_tolerance() const {
286 return ssr_depth_tolerance;
287}
288
289void Environment::_update_ssr() {
290 RS::get_singleton()->environment_set_ssr(
291 environment,
292 ssr_enabled,
293 ssr_max_steps,
294 ssr_fade_in,
295 ssr_fade_out,
296 ssr_depth_tolerance);
297}
298
299// SSAO
300
301void Environment::set_ssao_enabled(bool p_enabled) {
302 ssao_enabled = p_enabled;
303 _update_ssao();
304 notify_property_list_changed();
305}
306
307bool Environment::is_ssao_enabled() const {
308 return ssao_enabled;
309}
310
311void Environment::set_ssao_radius(float p_radius) {
312 ssao_radius = p_radius;
313 _update_ssao();
314}
315
316float Environment::get_ssao_radius() const {
317 return ssao_radius;
318}
319
320void Environment::set_ssao_intensity(float p_intensity) {
321 ssao_intensity = p_intensity;
322 _update_ssao();
323}
324
325float Environment::get_ssao_intensity() const {
326 return ssao_intensity;
327}
328
329void Environment::set_ssao_power(float p_power) {
330 ssao_power = p_power;
331 _update_ssao();
332}
333
334float Environment::get_ssao_power() const {
335 return ssao_power;
336}
337
338void Environment::set_ssao_detail(float p_detail) {
339 ssao_detail = p_detail;
340 _update_ssao();
341}
342
343float Environment::get_ssao_detail() const {
344 return ssao_detail;
345}
346
347void Environment::set_ssao_horizon(float p_horizon) {
348 ssao_horizon = p_horizon;
349 _update_ssao();
350}
351
352float Environment::get_ssao_horizon() const {
353 return ssao_horizon;
354}
355
356void Environment::set_ssao_sharpness(float p_sharpness) {
357 ssao_sharpness = p_sharpness;
358 _update_ssao();
359}
360
361float Environment::get_ssao_sharpness() const {
362 return ssao_sharpness;
363}
364
365void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) {
366 ssao_direct_light_affect = p_direct_light_affect;
367 _update_ssao();
368}
369
370float Environment::get_ssao_direct_light_affect() const {
371 return ssao_direct_light_affect;
372}
373
374void Environment::set_ssao_ao_channel_affect(float p_ao_channel_affect) {
375 ssao_ao_channel_affect = p_ao_channel_affect;
376 _update_ssao();
377}
378
379float Environment::get_ssao_ao_channel_affect() const {
380 return ssao_ao_channel_affect;
381}
382
383void Environment::_update_ssao() {
384 RS::get_singleton()->environment_set_ssao(
385 environment,
386 ssao_enabled,
387 ssao_radius,
388 ssao_intensity,
389 ssao_power,
390 ssao_detail,
391 ssao_horizon,
392 ssao_sharpness,
393 ssao_direct_light_affect,
394 ssao_ao_channel_affect);
395}
396
397// SSIL
398
399void Environment::set_ssil_enabled(bool p_enabled) {
400 ssil_enabled = p_enabled;
401 _update_ssil();
402 notify_property_list_changed();
403}
404
405bool Environment::is_ssil_enabled() const {
406 return ssil_enabled;
407}
408
409void Environment::set_ssil_radius(float p_radius) {
410 ssil_radius = p_radius;
411 _update_ssil();
412}
413
414float Environment::get_ssil_radius() const {
415 return ssil_radius;
416}
417
418void Environment::set_ssil_intensity(float p_intensity) {
419 ssil_intensity = p_intensity;
420 _update_ssil();
421}
422
423float Environment::get_ssil_intensity() const {
424 return ssil_intensity;
425}
426
427void Environment::set_ssil_sharpness(float p_sharpness) {
428 ssil_sharpness = p_sharpness;
429 _update_ssil();
430}
431
432float Environment::get_ssil_sharpness() const {
433 return ssil_sharpness;
434}
435
436void Environment::set_ssil_normal_rejection(float p_normal_rejection) {
437 ssil_normal_rejection = p_normal_rejection;
438 _update_ssil();
439}
440
441float Environment::get_ssil_normal_rejection() const {
442 return ssil_normal_rejection;
443}
444
445void Environment::_update_ssil() {
446 RS::get_singleton()->environment_set_ssil(
447 environment,
448 ssil_enabled,
449 ssil_radius,
450 ssil_intensity,
451 ssil_sharpness,
452 ssil_normal_rejection);
453}
454
455// SDFGI
456
457void Environment::set_sdfgi_enabled(bool p_enabled) {
458 sdfgi_enabled = p_enabled;
459 _update_sdfgi();
460 notify_property_list_changed();
461}
462
463bool Environment::is_sdfgi_enabled() const {
464 return sdfgi_enabled;
465}
466
467void Environment::set_sdfgi_cascades(int p_cascades) {
468 ERR_FAIL_COND_MSG(p_cascades < 1 || p_cascades > 8, "Invalid number of SDFGI cascades (must be between 1 and 8).");
469 sdfgi_cascades = p_cascades;
470 _update_sdfgi();
471}
472
473int Environment::get_sdfgi_cascades() const {
474 return sdfgi_cascades;
475}
476
477void Environment::set_sdfgi_min_cell_size(float p_size) {
478 sdfgi_min_cell_size = p_size;
479 _update_sdfgi();
480}
481
482float Environment::get_sdfgi_min_cell_size() const {
483 return sdfgi_min_cell_size;
484}
485
486void Environment::set_sdfgi_max_distance(float p_distance) {
487 p_distance /= 64.0;
488 for (int i = 0; i < sdfgi_cascades; i++) {
489 p_distance *= 0.5; //halve for each cascade
490 }
491 sdfgi_min_cell_size = p_distance;
492 _update_sdfgi();
493}
494
495float Environment::get_sdfgi_max_distance() const {
496 float md = sdfgi_min_cell_size;
497 md *= 64.0;
498 for (int i = 0; i < sdfgi_cascades; i++) {
499 md *= 2.0;
500 }
501 return md;
502}
503
504void Environment::set_sdfgi_cascade0_distance(float p_distance) {
505 sdfgi_min_cell_size = p_distance / 64.0;
506 _update_sdfgi();
507}
508
509float Environment::get_sdfgi_cascade0_distance() const {
510 return sdfgi_min_cell_size * 64.0;
511}
512
513void Environment::set_sdfgi_y_scale(SDFGIYScale p_y_scale) {
514 sdfgi_y_scale = p_y_scale;
515 _update_sdfgi();
516}
517
518Environment::SDFGIYScale Environment::get_sdfgi_y_scale() const {
519 return sdfgi_y_scale;
520}
521
522void Environment::set_sdfgi_use_occlusion(bool p_enabled) {
523 sdfgi_use_occlusion = p_enabled;
524 _update_sdfgi();
525}
526
527bool Environment::is_sdfgi_using_occlusion() const {
528 return sdfgi_use_occlusion;
529}
530
531void Environment::set_sdfgi_bounce_feedback(float p_amount) {
532 sdfgi_bounce_feedback = p_amount;
533 _update_sdfgi();
534}
535float Environment::get_sdfgi_bounce_feedback() const {
536 return sdfgi_bounce_feedback;
537}
538
539void Environment::set_sdfgi_read_sky_light(bool p_enabled) {
540 sdfgi_read_sky_light = p_enabled;
541 _update_sdfgi();
542}
543
544bool Environment::is_sdfgi_reading_sky_light() const {
545 return sdfgi_read_sky_light;
546}
547
548void Environment::set_sdfgi_energy(float p_energy) {
549 sdfgi_energy = p_energy;
550 _update_sdfgi();
551}
552
553float Environment::get_sdfgi_energy() const {
554 return sdfgi_energy;
555}
556
557void Environment::set_sdfgi_normal_bias(float p_bias) {
558 sdfgi_normal_bias = p_bias;
559 _update_sdfgi();
560}
561
562float Environment::get_sdfgi_normal_bias() const {
563 return sdfgi_normal_bias;
564}
565
566void Environment::set_sdfgi_probe_bias(float p_bias) {
567 sdfgi_probe_bias = p_bias;
568 _update_sdfgi();
569}
570
571float Environment::get_sdfgi_probe_bias() const {
572 return sdfgi_probe_bias;
573}
574
575void Environment::_update_sdfgi() {
576 RS::get_singleton()->environment_set_sdfgi(
577 environment,
578 sdfgi_enabled,
579 sdfgi_cascades,
580 sdfgi_min_cell_size,
581 RS::EnvironmentSDFGIYScale(sdfgi_y_scale),
582 sdfgi_use_occlusion,
583 sdfgi_bounce_feedback,
584 sdfgi_read_sky_light,
585 sdfgi_energy,
586 sdfgi_normal_bias,
587 sdfgi_probe_bias);
588}
589
590// Glow
591
592void Environment::set_glow_enabled(bool p_enabled) {
593 glow_enabled = p_enabled;
594 _update_glow();
595 notify_property_list_changed();
596}
597
598bool Environment::is_glow_enabled() const {
599 return glow_enabled;
600}
601
602void Environment::set_glow_level(int p_level, float p_intensity) {
603 ERR_FAIL_INDEX(p_level, RS::MAX_GLOW_LEVELS);
604
605 glow_levels.write[p_level] = p_intensity;
606
607 _update_glow();
608}
609
610float Environment::get_glow_level(int p_level) const {
611 ERR_FAIL_INDEX_V(p_level, RS::MAX_GLOW_LEVELS, 0.0);
612
613 return glow_levels[p_level];
614}
615
616void Environment::set_glow_normalized(bool p_normalized) {
617 glow_normalize_levels = p_normalized;
618
619 _update_glow();
620}
621
622bool Environment::is_glow_normalized() const {
623 return glow_normalize_levels;
624}
625
626void Environment::set_glow_intensity(float p_intensity) {
627 glow_intensity = p_intensity;
628 _update_glow();
629}
630
631float Environment::get_glow_intensity() const {
632 return glow_intensity;
633}
634
635void Environment::set_glow_strength(float p_strength) {
636 glow_strength = p_strength;
637 _update_glow();
638}
639
640float Environment::get_glow_strength() const {
641 return glow_strength;
642}
643
644void Environment::set_glow_mix(float p_mix) {
645 glow_mix = p_mix;
646 _update_glow();
647}
648
649float Environment::get_glow_mix() const {
650 return glow_mix;
651}
652
653void Environment::set_glow_bloom(float p_threshold) {
654 glow_bloom = p_threshold;
655 _update_glow();
656}
657
658float Environment::get_glow_bloom() const {
659 return glow_bloom;
660}
661
662void Environment::set_glow_blend_mode(GlowBlendMode p_mode) {
663 glow_blend_mode = p_mode;
664 _update_glow();
665 notify_property_list_changed();
666}
667
668Environment::GlowBlendMode Environment::get_glow_blend_mode() const {
669 return glow_blend_mode;
670}
671
672void Environment::set_glow_hdr_bleed_threshold(float p_threshold) {
673 glow_hdr_bleed_threshold = p_threshold;
674 _update_glow();
675}
676
677float Environment::get_glow_hdr_bleed_threshold() const {
678 return glow_hdr_bleed_threshold;
679}
680
681void Environment::set_glow_hdr_bleed_scale(float p_scale) {
682 glow_hdr_bleed_scale = p_scale;
683 _update_glow();
684}
685
686float Environment::get_glow_hdr_bleed_scale() const {
687 return glow_hdr_bleed_scale;
688}
689
690void Environment::set_glow_hdr_luminance_cap(float p_amount) {
691 glow_hdr_luminance_cap = p_amount;
692 _update_glow();
693}
694
695float Environment::get_glow_hdr_luminance_cap() const {
696 return glow_hdr_luminance_cap;
697}
698
699void Environment::set_glow_map_strength(float p_strength) {
700 glow_map_strength = p_strength;
701 _update_glow();
702}
703
704float Environment::get_glow_map_strength() const {
705 return glow_map_strength;
706}
707
708void Environment::set_glow_map(Ref<Texture> p_glow_map) {
709 glow_map = p_glow_map;
710 _update_glow();
711}
712
713Ref<Texture> Environment::get_glow_map() const {
714 return glow_map;
715}
716
717void Environment::_update_glow() {
718 Vector<float> normalized_levels;
719 if (glow_normalize_levels) {
720 normalized_levels.resize(7);
721 float size = 0.0;
722 for (int i = 0; i < glow_levels.size(); i++) {
723 size += glow_levels[i];
724 }
725 for (int i = 0; i < glow_levels.size(); i++) {
726 normalized_levels.write[i] = glow_levels[i] / size;
727 }
728 } else {
729 normalized_levels = glow_levels;
730 }
731
732 float _glow_map_strength = 0.0f;
733 RID glow_map_rid;
734 if (glow_map.is_valid()) {
735 glow_map_rid = glow_map->get_rid();
736 _glow_map_strength = glow_map_strength;
737 } else {
738 glow_map_rid = RID();
739 }
740
741 RS::get_singleton()->environment_set_glow(
742 environment,
743 glow_enabled,
744 normalized_levels,
745 glow_intensity,
746 glow_strength,
747 glow_mix,
748 glow_bloom,
749 RS::EnvironmentGlowBlendMode(glow_blend_mode),
750 glow_hdr_bleed_threshold,
751 glow_hdr_bleed_scale,
752 glow_hdr_luminance_cap,
753 _glow_map_strength,
754 glow_map_rid);
755}
756
757// Fog
758
759void Environment::set_fog_enabled(bool p_enabled) {
760 fog_enabled = p_enabled;
761 _update_fog();
762 notify_property_list_changed();
763}
764
765bool Environment::is_fog_enabled() const {
766 return fog_enabled;
767}
768
769void Environment::set_fog_light_color(const Color &p_light_color) {
770 fog_light_color = p_light_color;
771 _update_fog();
772}
773Color Environment::get_fog_light_color() const {
774 return fog_light_color;
775}
776void Environment::set_fog_light_energy(float p_amount) {
777 fog_light_energy = p_amount;
778 _update_fog();
779}
780float Environment::get_fog_light_energy() const {
781 return fog_light_energy;
782}
783void Environment::set_fog_sun_scatter(float p_amount) {
784 fog_sun_scatter = p_amount;
785 _update_fog();
786}
787float Environment::get_fog_sun_scatter() const {
788 return fog_sun_scatter;
789}
790void Environment::set_fog_density(float p_amount) {
791 fog_density = p_amount;
792 _update_fog();
793}
794float Environment::get_fog_density() const {
795 return fog_density;
796}
797void Environment::set_fog_height(float p_amount) {
798 fog_height = p_amount;
799 _update_fog();
800}
801float Environment::get_fog_height() const {
802 return fog_height;
803}
804void Environment::set_fog_height_density(float p_amount) {
805 fog_height_density = p_amount;
806 _update_fog();
807}
808float Environment::get_fog_height_density() const {
809 return fog_height_density;
810}
811
812void Environment::set_fog_aerial_perspective(float p_aerial_perspective) {
813 fog_aerial_perspective = p_aerial_perspective;
814 _update_fog();
815}
816float Environment::get_fog_aerial_perspective() const {
817 return fog_aerial_perspective;
818}
819
820void Environment::set_fog_sky_affect(float p_sky_affect) {
821 fog_sky_affect = p_sky_affect;
822 _update_fog();
823}
824
825float Environment::get_fog_sky_affect() const {
826 return fog_sky_affect;
827}
828
829void Environment::_update_fog() {
830 RS::get_singleton()->environment_set_fog(
831 environment,
832 fog_enabled,
833 fog_light_color,
834 fog_light_energy,
835 fog_sun_scatter,
836 fog_density,
837 fog_height,
838 fog_height_density,
839 fog_aerial_perspective,
840 fog_sky_affect);
841}
842
843// Volumetric Fog
844
845void Environment::_update_volumetric_fog() {
846 RS::get_singleton()->environment_set_volumetric_fog(
847 environment,
848 volumetric_fog_enabled,
849 volumetric_fog_density,
850 volumetric_fog_albedo,
851 volumetric_fog_emission,
852 volumetric_fog_emission_energy,
853 volumetric_fog_anisotropy,
854 volumetric_fog_length,
855 volumetric_fog_detail_spread,
856 volumetric_fog_gi_inject,
857 volumetric_fog_temporal_reproject,
858 volumetric_fog_temporal_reproject_amount,
859 volumetric_fog_ambient_inject,
860 volumetric_fog_sky_affect);
861}
862
863void Environment::set_volumetric_fog_enabled(bool p_enable) {
864 volumetric_fog_enabled = p_enable;
865 _update_volumetric_fog();
866 notify_property_list_changed();
867}
868
869bool Environment::is_volumetric_fog_enabled() const {
870 return volumetric_fog_enabled;
871}
872void Environment::set_volumetric_fog_density(float p_density) {
873 volumetric_fog_density = p_density;
874 _update_volumetric_fog();
875}
876float Environment::get_volumetric_fog_density() const {
877 return volumetric_fog_density;
878}
879void Environment::set_volumetric_fog_albedo(Color p_color) {
880 volumetric_fog_albedo = p_color;
881 _update_volumetric_fog();
882}
883Color Environment::get_volumetric_fog_albedo() const {
884 return volumetric_fog_albedo;
885}
886void Environment::set_volumetric_fog_emission(Color p_color) {
887 volumetric_fog_emission = p_color;
888 _update_volumetric_fog();
889}
890Color Environment::get_volumetric_fog_emission() const {
891 return volumetric_fog_emission;
892}
893void Environment::set_volumetric_fog_emission_energy(float p_begin) {
894 volumetric_fog_emission_energy = p_begin;
895 _update_volumetric_fog();
896}
897float Environment::get_volumetric_fog_emission_energy() const {
898 return volumetric_fog_emission_energy;
899}
900void Environment::set_volumetric_fog_anisotropy(float p_anisotropy) {
901 volumetric_fog_anisotropy = p_anisotropy;
902 _update_volumetric_fog();
903}
904float Environment::get_volumetric_fog_anisotropy() const {
905 return volumetric_fog_anisotropy;
906}
907void Environment::set_volumetric_fog_length(float p_length) {
908 volumetric_fog_length = p_length;
909 _update_volumetric_fog();
910}
911float Environment::get_volumetric_fog_length() const {
912 return volumetric_fog_length;
913}
914void Environment::set_volumetric_fog_detail_spread(float p_detail_spread) {
915 p_detail_spread = CLAMP(p_detail_spread, 0.5, 6.0);
916 volumetric_fog_detail_spread = p_detail_spread;
917 _update_volumetric_fog();
918}
919float Environment::get_volumetric_fog_detail_spread() const {
920 return volumetric_fog_detail_spread;
921}
922
923void Environment::set_volumetric_fog_gi_inject(float p_gi_inject) {
924 volumetric_fog_gi_inject = p_gi_inject;
925 _update_volumetric_fog();
926}
927float Environment::get_volumetric_fog_gi_inject() const {
928 return volumetric_fog_gi_inject;
929}
930void Environment::set_volumetric_fog_ambient_inject(float p_ambient_inject) {
931 volumetric_fog_ambient_inject = p_ambient_inject;
932 _update_volumetric_fog();
933}
934float Environment::get_volumetric_fog_ambient_inject() const {
935 return volumetric_fog_ambient_inject;
936}
937
938void Environment::set_volumetric_fog_sky_affect(float p_sky_affect) {
939 volumetric_fog_sky_affect = p_sky_affect;
940 _update_volumetric_fog();
941}
942
943float Environment::get_volumetric_fog_sky_affect() const {
944 return volumetric_fog_sky_affect;
945}
946
947void Environment::set_volumetric_fog_temporal_reprojection_enabled(bool p_enable) {
948 volumetric_fog_temporal_reproject = p_enable;
949 _update_volumetric_fog();
950}
951bool Environment::is_volumetric_fog_temporal_reprojection_enabled() const {
952 return volumetric_fog_temporal_reproject;
953}
954void Environment::set_volumetric_fog_temporal_reprojection_amount(float p_amount) {
955 volumetric_fog_temporal_reproject_amount = p_amount;
956 _update_volumetric_fog();
957}
958
959float Environment::get_volumetric_fog_temporal_reprojection_amount() const {
960 return volumetric_fog_temporal_reproject_amount;
961}
962
963// Adjustment
964
965void Environment::set_adjustment_enabled(bool p_enabled) {
966 adjustment_enabled = p_enabled;
967 _update_adjustment();
968 notify_property_list_changed();
969}
970
971bool Environment::is_adjustment_enabled() const {
972 return adjustment_enabled;
973}
974
975void Environment::set_adjustment_brightness(float p_brightness) {
976 adjustment_brightness = p_brightness;
977 _update_adjustment();
978}
979
980float Environment::get_adjustment_brightness() const {
981 return adjustment_brightness;
982}
983
984void Environment::set_adjustment_contrast(float p_contrast) {
985 adjustment_contrast = p_contrast;
986 _update_adjustment();
987}
988
989float Environment::get_adjustment_contrast() const {
990 return adjustment_contrast;
991}
992
993void Environment::set_adjustment_saturation(float p_saturation) {
994 adjustment_saturation = p_saturation;
995 _update_adjustment();
996}
997
998float Environment::get_adjustment_saturation() const {
999 return adjustment_saturation;
1000}
1001
1002void Environment::set_adjustment_color_correction(Ref<Texture> p_color_correction) {
1003 adjustment_color_correction = p_color_correction;
1004 Ref<GradientTexture1D> grad_tex = p_color_correction;
1005 if (grad_tex.is_valid()) {
1006 grad_tex->connect_changed(callable_mp(this, &Environment::_update_adjustment));
1007 }
1008 Ref<Texture2D> adjustment_texture_2d = adjustment_color_correction;
1009 if (adjustment_texture_2d.is_valid()) {
1010 use_1d_color_correction = true;
1011 } else {
1012 use_1d_color_correction = false;
1013 }
1014 _update_adjustment();
1015}
1016
1017Ref<Texture> Environment::get_adjustment_color_correction() const {
1018 return adjustment_color_correction;
1019}
1020
1021void Environment::_update_adjustment() {
1022 RID color_correction = adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID();
1023
1024 RS::get_singleton()->environment_set_adjustment(
1025 environment,
1026 adjustment_enabled,
1027 adjustment_brightness,
1028 adjustment_contrast,
1029 adjustment_saturation,
1030 use_1d_color_correction,
1031 color_correction);
1032}
1033
1034// Private methods, constructor and destructor
1035
1036void Environment::_validate_property(PropertyInfo &p_property) const {
1037 if (p_property.name == "sky" || p_property.name == "sky_custom_fov" || p_property.name == "sky_rotation" || p_property.name == "ambient_light_sky_contribution") {
1038 if (bg_mode != BG_SKY && ambient_source != AMBIENT_SOURCE_SKY && reflection_source != REFLECTION_SOURCE_SKY) {
1039 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1040 }
1041 }
1042
1043 if (p_property.name == "ambient_light_color" || p_property.name == "ambient_light_energy") {
1044 if (ambient_source == AMBIENT_SOURCE_DISABLED) {
1045 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1046 }
1047 }
1048
1049 if (p_property.name == "ambient_light_sky_contribution") {
1050 if (ambient_source == AMBIENT_SOURCE_DISABLED || ambient_source == AMBIENT_SOURCE_COLOR) {
1051 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1052 }
1053 }
1054
1055 if (p_property.name == "fog_aerial_perspective") {
1056 if (bg_mode != BG_SKY) {
1057 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1058 }
1059 }
1060
1061 if (p_property.name == "tonemap_white" && tone_mapper == TONE_MAPPER_LINEAR) {
1062 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1063 }
1064
1065 if (p_property.name == "glow_intensity" && glow_blend_mode == GLOW_BLEND_MODE_MIX) {
1066 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1067 }
1068
1069 if (p_property.name == "glow_mix" && glow_blend_mode != GLOW_BLEND_MODE_MIX) {
1070 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1071 }
1072
1073 if (p_property.name == "background_color") {
1074 if (bg_mode != BG_COLOR && ambient_source != AMBIENT_SOURCE_COLOR) {
1075 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1076 }
1077 }
1078
1079 if (p_property.name == "background_canvas_max_layer") {
1080 if (bg_mode != BG_CANVAS) {
1081 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1082 }
1083 }
1084
1085 if (p_property.name == "background_camera_feed_id") {
1086 if (bg_mode != BG_CAMERA_FEED) {
1087 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1088 }
1089 }
1090
1091 if (p_property.name == "background_intensity" && !GLOBAL_GET("rendering/lights_and_shadows/use_physical_light_units")) {
1092 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1093 }
1094
1095 static const char *hide_prefixes[] = {
1096 "fog_",
1097 "volumetric_fog_",
1098 "ssr_",
1099 "ssao_",
1100 "ssil_",
1101 "sdfgi_",
1102 "glow_",
1103 "adjustment_",
1104 nullptr
1105
1106 };
1107
1108 const char **prefixes = hide_prefixes;
1109 while (*prefixes) {
1110 String prefix = String(*prefixes);
1111
1112 String enabled = prefix + "enabled";
1113 if (p_property.name.begins_with(prefix) && p_property.name != enabled && !bool(get(enabled))) {
1114 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
1115 return;
1116 }
1117
1118 prefixes++;
1119 }
1120}
1121
1122#ifndef DISABLE_DEPRECATED
1123// Kept for compatibility from 3.x to 4.0.
1124bool Environment::_set(const StringName &p_name, const Variant &p_value) {
1125 if (p_name == "background_sky") {
1126 set_sky(p_value);
1127 return true;
1128 } else if (p_name == "background_sky_custom_fov") {
1129 set_sky_custom_fov(p_value);
1130 return true;
1131 } else if (p_name == "background_sky_orientation") {
1132 Vector3 euler = p_value.operator Basis().get_euler();
1133 set_sky_rotation(euler);
1134 return true;
1135 } else {
1136 return false;
1137 }
1138}
1139#endif
1140
1141void Environment::_bind_methods() {
1142 // Background
1143
1144 ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background);
1145 ClassDB::bind_method(D_METHOD("get_background"), &Environment::get_background);
1146 ClassDB::bind_method(D_METHOD("set_sky", "sky"), &Environment::set_sky);
1147 ClassDB::bind_method(D_METHOD("get_sky"), &Environment::get_sky);
1148 ClassDB::bind_method(D_METHOD("set_sky_custom_fov", "scale"), &Environment::set_sky_custom_fov);
1149 ClassDB::bind_method(D_METHOD("get_sky_custom_fov"), &Environment::get_sky_custom_fov);
1150 ClassDB::bind_method(D_METHOD("set_sky_rotation", "euler_radians"), &Environment::set_sky_rotation);
1151 ClassDB::bind_method(D_METHOD("get_sky_rotation"), &Environment::get_sky_rotation);
1152 ClassDB::bind_method(D_METHOD("set_bg_color", "color"), &Environment::set_bg_color);
1153 ClassDB::bind_method(D_METHOD("get_bg_color"), &Environment::get_bg_color);
1154 ClassDB::bind_method(D_METHOD("set_bg_energy_multiplier", "energy"), &Environment::set_bg_energy_multiplier);
1155 ClassDB::bind_method(D_METHOD("get_bg_energy_multiplier"), &Environment::get_bg_energy_multiplier);
1156 ClassDB::bind_method(D_METHOD("set_bg_intensity", "energy"), &Environment::set_bg_intensity);
1157 ClassDB::bind_method(D_METHOD("get_bg_intensity"), &Environment::get_bg_intensity);
1158 ClassDB::bind_method(D_METHOD("set_canvas_max_layer", "layer"), &Environment::set_canvas_max_layer);
1159 ClassDB::bind_method(D_METHOD("get_canvas_max_layer"), &Environment::get_canvas_max_layer);
1160 ClassDB::bind_method(D_METHOD("set_camera_feed_id", "id"), &Environment::set_camera_feed_id);
1161 ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &Environment::get_camera_feed_id);
1162
1163 ADD_GROUP("Background", "background_");
1164 ADD_PROPERTY(PropertyInfo(Variant::INT, "background_mode", PROPERTY_HINT_ENUM, "Clear Color,Custom Color,Sky,Canvas,Keep,Camera Feed"), "set_background", "get_background");
1165 ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_bg_color", "get_bg_color");
1166 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "background_energy_multiplier", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_bg_energy_multiplier", "get_bg_energy_multiplier");
1167 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "background_intensity", PROPERTY_HINT_RANGE, "0,100000,0.01,suffix:nt"), "set_bg_intensity", "get_bg_intensity");
1168
1169 ADD_PROPERTY(PropertyInfo(Variant::INT, "background_canvas_max_layer", PROPERTY_HINT_RANGE, "-1000,1000,1"), "set_canvas_max_layer", "get_canvas_max_layer");
1170 ADD_PROPERTY(PropertyInfo(Variant::INT, "background_camera_feed_id", PROPERTY_HINT_RANGE, "1,10,1"), "set_camera_feed_id", "get_camera_feed_id");
1171
1172 ADD_GROUP("Sky", "sky_");
1173 ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "sky", PROPERTY_HINT_RESOURCE_TYPE, "Sky"), "set_sky", "get_sky");
1174 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sky_custom_fov", PROPERTY_HINT_RANGE, "0,180,0.1,degrees"), "set_sky_custom_fov", "get_sky_custom_fov");
1175 ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "sky_rotation", PROPERTY_HINT_RANGE, "-360,360,0.1,or_less,or_greater,radians"), "set_sky_rotation", "get_sky_rotation");
1176
1177 // Ambient light
1178
1179 ClassDB::bind_method(D_METHOD("set_ambient_light_color", "color"), &Environment::set_ambient_light_color);
1180 ClassDB::bind_method(D_METHOD("get_ambient_light_color"), &Environment::get_ambient_light_color);
1181 ClassDB::bind_method(D_METHOD("set_ambient_source", "source"), &Environment::set_ambient_source);
1182 ClassDB::bind_method(D_METHOD("get_ambient_source"), &Environment::get_ambient_source);
1183 ClassDB::bind_method(D_METHOD("set_ambient_light_energy", "energy"), &Environment::set_ambient_light_energy);
1184 ClassDB::bind_method(D_METHOD("get_ambient_light_energy"), &Environment::get_ambient_light_energy);
1185 ClassDB::bind_method(D_METHOD("set_ambient_light_sky_contribution", "ratio"), &Environment::set_ambient_light_sky_contribution);
1186 ClassDB::bind_method(D_METHOD("get_ambient_light_sky_contribution"), &Environment::get_ambient_light_sky_contribution);
1187 ClassDB::bind_method(D_METHOD("set_reflection_source", "source"), &Environment::set_reflection_source);
1188 ClassDB::bind_method(D_METHOD("get_reflection_source"), &Environment::get_reflection_source);
1189
1190 ADD_GROUP("Ambient Light", "ambient_light_");
1191 ADD_PROPERTY(PropertyInfo(Variant::INT, "ambient_light_source", PROPERTY_HINT_ENUM, "Background,Disabled,Color,Sky"), "set_ambient_source", "get_ambient_source");
1192 ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_light_color"), "set_ambient_light_color", "get_ambient_light_color");
1193 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_light_sky_contribution", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ambient_light_sky_contribution", "get_ambient_light_sky_contribution");
1194 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_light_energy", "get_ambient_light_energy");
1195
1196 ADD_GROUP("Reflected Light", "reflected_light_");
1197 ADD_PROPERTY(PropertyInfo(Variant::INT, "reflected_light_source", PROPERTY_HINT_ENUM, "Background,Disabled,Sky"), "set_reflection_source", "get_reflection_source");
1198
1199 // Tonemap
1200
1201 ClassDB::bind_method(D_METHOD("set_tonemapper", "mode"), &Environment::set_tonemapper);
1202 ClassDB::bind_method(D_METHOD("get_tonemapper"), &Environment::get_tonemapper);
1203 ClassDB::bind_method(D_METHOD("set_tonemap_exposure", "exposure"), &Environment::set_tonemap_exposure);
1204 ClassDB::bind_method(D_METHOD("get_tonemap_exposure"), &Environment::get_tonemap_exposure);
1205 ClassDB::bind_method(D_METHOD("set_tonemap_white", "white"), &Environment::set_tonemap_white);
1206 ClassDB::bind_method(D_METHOD("get_tonemap_white"), &Environment::get_tonemap_white);
1207
1208 ADD_GROUP("Tonemap", "tonemap_");
1209 ADD_PROPERTY(PropertyInfo(Variant::INT, "tonemap_mode", PROPERTY_HINT_ENUM, "Linear,Reinhard,Filmic,ACES"), "set_tonemapper", "get_tonemapper");
1210 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tonemap_exposure", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_tonemap_exposure", "get_tonemap_exposure");
1211 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "tonemap_white", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_tonemap_white", "get_tonemap_white");
1212
1213 // SSR
1214
1215 ClassDB::bind_method(D_METHOD("set_ssr_enabled", "enabled"), &Environment::set_ssr_enabled);
1216 ClassDB::bind_method(D_METHOD("is_ssr_enabled"), &Environment::is_ssr_enabled);
1217 ClassDB::bind_method(D_METHOD("set_ssr_max_steps", "max_steps"), &Environment::set_ssr_max_steps);
1218 ClassDB::bind_method(D_METHOD("get_ssr_max_steps"), &Environment::get_ssr_max_steps);
1219 ClassDB::bind_method(D_METHOD("set_ssr_fade_in", "fade_in"), &Environment::set_ssr_fade_in);
1220 ClassDB::bind_method(D_METHOD("get_ssr_fade_in"), &Environment::get_ssr_fade_in);
1221 ClassDB::bind_method(D_METHOD("set_ssr_fade_out", "fade_out"), &Environment::set_ssr_fade_out);
1222 ClassDB::bind_method(D_METHOD("get_ssr_fade_out"), &Environment::get_ssr_fade_out);
1223 ClassDB::bind_method(D_METHOD("set_ssr_depth_tolerance", "depth_tolerance"), &Environment::set_ssr_depth_tolerance);
1224 ClassDB::bind_method(D_METHOD("get_ssr_depth_tolerance"), &Environment::get_ssr_depth_tolerance);
1225
1226 ADD_GROUP("SSR", "ssr_");
1227 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssr_enabled"), "set_ssr_enabled", "is_ssr_enabled");
1228 ADD_PROPERTY(PropertyInfo(Variant::INT, "ssr_max_steps", PROPERTY_HINT_RANGE, "1,512,1"), "set_ssr_max_steps", "get_ssr_max_steps");
1229 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssr_fade_in", PROPERTY_HINT_EXP_EASING, "positive_only"), "set_ssr_fade_in", "get_ssr_fade_in");
1230 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssr_fade_out", PROPERTY_HINT_EXP_EASING, "positive_only"), "set_ssr_fade_out", "get_ssr_fade_out");
1231 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssr_depth_tolerance", PROPERTY_HINT_RANGE, "0.01,128,0.1"), "set_ssr_depth_tolerance", "get_ssr_depth_tolerance");
1232
1233 // SSAO
1234 ClassDB::bind_method(D_METHOD("set_ssao_enabled", "enabled"), &Environment::set_ssao_enabled);
1235 ClassDB::bind_method(D_METHOD("is_ssao_enabled"), &Environment::is_ssao_enabled);
1236 ClassDB::bind_method(D_METHOD("set_ssao_radius", "radius"), &Environment::set_ssao_radius);
1237 ClassDB::bind_method(D_METHOD("get_ssao_radius"), &Environment::get_ssao_radius);
1238 ClassDB::bind_method(D_METHOD("set_ssao_intensity", "intensity"), &Environment::set_ssao_intensity);
1239 ClassDB::bind_method(D_METHOD("get_ssao_intensity"), &Environment::get_ssao_intensity);
1240 ClassDB::bind_method(D_METHOD("set_ssao_power", "power"), &Environment::set_ssao_power);
1241 ClassDB::bind_method(D_METHOD("get_ssao_power"), &Environment::get_ssao_power);
1242 ClassDB::bind_method(D_METHOD("set_ssao_detail", "detail"), &Environment::set_ssao_detail);
1243 ClassDB::bind_method(D_METHOD("get_ssao_detail"), &Environment::get_ssao_detail);
1244 ClassDB::bind_method(D_METHOD("set_ssao_horizon", "horizon"), &Environment::set_ssao_horizon);
1245 ClassDB::bind_method(D_METHOD("get_ssao_horizon"), &Environment::get_ssao_horizon);
1246 ClassDB::bind_method(D_METHOD("set_ssao_sharpness", "sharpness"), &Environment::set_ssao_sharpness);
1247 ClassDB::bind_method(D_METHOD("get_ssao_sharpness"), &Environment::get_ssao_sharpness);
1248 ClassDB::bind_method(D_METHOD("set_ssao_direct_light_affect", "amount"), &Environment::set_ssao_direct_light_affect);
1249 ClassDB::bind_method(D_METHOD("get_ssao_direct_light_affect"), &Environment::get_ssao_direct_light_affect);
1250 ClassDB::bind_method(D_METHOD("set_ssao_ao_channel_affect", "amount"), &Environment::set_ssao_ao_channel_affect);
1251 ClassDB::bind_method(D_METHOD("get_ssao_ao_channel_affect"), &Environment::get_ssao_ao_channel_affect);
1252
1253 ADD_GROUP("SSAO", "ssao_");
1254 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssao_enabled"), "set_ssao_enabled", "is_ssao_enabled");
1255 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_radius", PROPERTY_HINT_RANGE, "0.01,16,0.01,or_greater"), "set_ssao_radius", "get_ssao_radius");
1256 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_intensity", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_ssao_intensity", "get_ssao_intensity");
1257 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_power", PROPERTY_HINT_EXP_EASING, "positive_only"), "set_ssao_power", "get_ssao_power");
1258 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_detail", PROPERTY_HINT_RANGE, "0,5,0.01"), "set_ssao_detail", "get_ssao_detail");
1259 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_horizon", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ssao_horizon", "get_ssao_horizon");
1260 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_sharpness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ssao_sharpness", "get_ssao_sharpness");
1261 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_light_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_direct_light_affect", "get_ssao_direct_light_affect");
1262 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_ao_channel_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_ao_channel_affect", "get_ssao_ao_channel_affect");
1263
1264 // SSIL
1265 ClassDB::bind_method(D_METHOD("set_ssil_enabled", "enabled"), &Environment::set_ssil_enabled);
1266 ClassDB::bind_method(D_METHOD("is_ssil_enabled"), &Environment::is_ssil_enabled);
1267 ClassDB::bind_method(D_METHOD("set_ssil_radius", "radius"), &Environment::set_ssil_radius);
1268 ClassDB::bind_method(D_METHOD("get_ssil_radius"), &Environment::get_ssil_radius);
1269 ClassDB::bind_method(D_METHOD("set_ssil_intensity", "intensity"), &Environment::set_ssil_intensity);
1270 ClassDB::bind_method(D_METHOD("get_ssil_intensity"), &Environment::get_ssil_intensity);
1271 ClassDB::bind_method(D_METHOD("set_ssil_sharpness", "sharpness"), &Environment::set_ssil_sharpness);
1272 ClassDB::bind_method(D_METHOD("get_ssil_sharpness"), &Environment::get_ssil_sharpness);
1273 ClassDB::bind_method(D_METHOD("set_ssil_normal_rejection", "normal_rejection"), &Environment::set_ssil_normal_rejection);
1274 ClassDB::bind_method(D_METHOD("get_ssil_normal_rejection"), &Environment::get_ssil_normal_rejection);
1275
1276 ADD_GROUP("SSIL", "ssil_");
1277 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssil_enabled"), "set_ssil_enabled", "is_ssil_enabled");
1278 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssil_radius", PROPERTY_HINT_RANGE, "0.01,16,0.01,or_greater,suffix:m"), "set_ssil_radius", "get_ssil_radius");
1279 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssil_intensity", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_ssil_intensity", "get_ssil_intensity");
1280 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssil_sharpness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ssil_sharpness", "get_ssil_sharpness");
1281 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssil_normal_rejection", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ssil_normal_rejection", "get_ssil_normal_rejection");
1282
1283 // SDFGI
1284
1285 ClassDB::bind_method(D_METHOD("set_sdfgi_enabled", "enabled"), &Environment::set_sdfgi_enabled);
1286 ClassDB::bind_method(D_METHOD("is_sdfgi_enabled"), &Environment::is_sdfgi_enabled);
1287 ClassDB::bind_method(D_METHOD("set_sdfgi_cascades", "amount"), &Environment::set_sdfgi_cascades);
1288 ClassDB::bind_method(D_METHOD("get_sdfgi_cascades"), &Environment::get_sdfgi_cascades);
1289 ClassDB::bind_method(D_METHOD("set_sdfgi_min_cell_size", "size"), &Environment::set_sdfgi_min_cell_size);
1290 ClassDB::bind_method(D_METHOD("get_sdfgi_min_cell_size"), &Environment::get_sdfgi_min_cell_size);
1291 ClassDB::bind_method(D_METHOD("set_sdfgi_max_distance", "distance"), &Environment::set_sdfgi_max_distance);
1292 ClassDB::bind_method(D_METHOD("get_sdfgi_max_distance"), &Environment::get_sdfgi_max_distance);
1293 ClassDB::bind_method(D_METHOD("set_sdfgi_cascade0_distance", "distance"), &Environment::set_sdfgi_cascade0_distance);
1294 ClassDB::bind_method(D_METHOD("get_sdfgi_cascade0_distance"), &Environment::get_sdfgi_cascade0_distance);
1295 ClassDB::bind_method(D_METHOD("set_sdfgi_y_scale", "scale"), &Environment::set_sdfgi_y_scale);
1296 ClassDB::bind_method(D_METHOD("get_sdfgi_y_scale"), &Environment::get_sdfgi_y_scale);
1297 ClassDB::bind_method(D_METHOD("set_sdfgi_use_occlusion", "enable"), &Environment::set_sdfgi_use_occlusion);
1298 ClassDB::bind_method(D_METHOD("is_sdfgi_using_occlusion"), &Environment::is_sdfgi_using_occlusion);
1299 ClassDB::bind_method(D_METHOD("set_sdfgi_bounce_feedback", "amount"), &Environment::set_sdfgi_bounce_feedback);
1300 ClassDB::bind_method(D_METHOD("get_sdfgi_bounce_feedback"), &Environment::get_sdfgi_bounce_feedback);
1301 ClassDB::bind_method(D_METHOD("set_sdfgi_read_sky_light", "enable"), &Environment::set_sdfgi_read_sky_light);
1302 ClassDB::bind_method(D_METHOD("is_sdfgi_reading_sky_light"), &Environment::is_sdfgi_reading_sky_light);
1303 ClassDB::bind_method(D_METHOD("set_sdfgi_energy", "amount"), &Environment::set_sdfgi_energy);
1304 ClassDB::bind_method(D_METHOD("get_sdfgi_energy"), &Environment::get_sdfgi_energy);
1305 ClassDB::bind_method(D_METHOD("set_sdfgi_normal_bias", "bias"), &Environment::set_sdfgi_normal_bias);
1306 ClassDB::bind_method(D_METHOD("get_sdfgi_normal_bias"), &Environment::get_sdfgi_normal_bias);
1307 ClassDB::bind_method(D_METHOD("set_sdfgi_probe_bias", "bias"), &Environment::set_sdfgi_probe_bias);
1308 ClassDB::bind_method(D_METHOD("get_sdfgi_probe_bias"), &Environment::get_sdfgi_probe_bias);
1309
1310 ADD_GROUP("SDFGI", "sdfgi_");
1311 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_enabled"), "set_sdfgi_enabled", "is_sdfgi_enabled");
1312 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_use_occlusion"), "set_sdfgi_use_occlusion", "is_sdfgi_using_occlusion");
1313 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_read_sky_light"), "set_sdfgi_read_sky_light", "is_sdfgi_reading_sky_light");
1314 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_bounce_feedback", PROPERTY_HINT_RANGE, "0,1.99,0.01"), "set_sdfgi_bounce_feedback", "get_sdfgi_bounce_feedback");
1315 ADD_PROPERTY(PropertyInfo(Variant::INT, "sdfgi_cascades", PROPERTY_HINT_RANGE, "1,8,1"), "set_sdfgi_cascades", "get_sdfgi_cascades");
1316 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_min_cell_size", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_sdfgi_min_cell_size", "get_sdfgi_min_cell_size");
1317 // Don't store the values of `sdfgi_cascade0_distance` and `sdfgi_max_distance`
1318 // as they're derived from `sdfgi_min_cell_size`.
1319 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_cascade0_distance", PROPERTY_HINT_RANGE, "0.1,16384,0.1,or_greater", PROPERTY_USAGE_EDITOR), "set_sdfgi_cascade0_distance", "get_sdfgi_cascade0_distance");
1320 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_max_distance", PROPERTY_HINT_RANGE, "0.1,16384,0.1,or_greater", PROPERTY_USAGE_EDITOR), "set_sdfgi_max_distance", "get_sdfgi_max_distance");
1321 ADD_PROPERTY(PropertyInfo(Variant::INT, "sdfgi_y_scale", PROPERTY_HINT_ENUM, "50% (Compact),75% (Balanced),100% (Sparse)"), "set_sdfgi_y_scale", "get_sdfgi_y_scale");
1322 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_energy"), "set_sdfgi_energy", "get_sdfgi_energy");
1323 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_normal_bias"), "set_sdfgi_normal_bias", "get_sdfgi_normal_bias");
1324 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_probe_bias"), "set_sdfgi_probe_bias", "get_sdfgi_probe_bias");
1325
1326 // Glow
1327
1328 ClassDB::bind_method(D_METHOD("set_glow_enabled", "enabled"), &Environment::set_glow_enabled);
1329 ClassDB::bind_method(D_METHOD("is_glow_enabled"), &Environment::is_glow_enabled);
1330 ClassDB::bind_method(D_METHOD("set_glow_level", "idx", "intensity"), &Environment::set_glow_level);
1331 ClassDB::bind_method(D_METHOD("get_glow_level", "idx"), &Environment::get_glow_level);
1332 ClassDB::bind_method(D_METHOD("set_glow_normalized", "normalize"), &Environment::set_glow_normalized);
1333 ClassDB::bind_method(D_METHOD("is_glow_normalized"), &Environment::is_glow_normalized);
1334 ClassDB::bind_method(D_METHOD("set_glow_intensity", "intensity"), &Environment::set_glow_intensity);
1335 ClassDB::bind_method(D_METHOD("get_glow_intensity"), &Environment::get_glow_intensity);
1336 ClassDB::bind_method(D_METHOD("set_glow_strength", "strength"), &Environment::set_glow_strength);
1337 ClassDB::bind_method(D_METHOD("get_glow_strength"), &Environment::get_glow_strength);
1338 ClassDB::bind_method(D_METHOD("set_glow_mix", "mix"), &Environment::set_glow_mix);
1339 ClassDB::bind_method(D_METHOD("get_glow_mix"), &Environment::get_glow_mix);
1340 ClassDB::bind_method(D_METHOD("set_glow_bloom", "amount"), &Environment::set_glow_bloom);
1341 ClassDB::bind_method(D_METHOD("get_glow_bloom"), &Environment::get_glow_bloom);
1342 ClassDB::bind_method(D_METHOD("set_glow_blend_mode", "mode"), &Environment::set_glow_blend_mode);
1343 ClassDB::bind_method(D_METHOD("get_glow_blend_mode"), &Environment::get_glow_blend_mode);
1344 ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_threshold", "threshold"), &Environment::set_glow_hdr_bleed_threshold);
1345 ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_threshold"), &Environment::get_glow_hdr_bleed_threshold);
1346 ClassDB::bind_method(D_METHOD("set_glow_hdr_bleed_scale", "scale"), &Environment::set_glow_hdr_bleed_scale);
1347 ClassDB::bind_method(D_METHOD("get_glow_hdr_bleed_scale"), &Environment::get_glow_hdr_bleed_scale);
1348 ClassDB::bind_method(D_METHOD("set_glow_hdr_luminance_cap", "amount"), &Environment::set_glow_hdr_luminance_cap);
1349 ClassDB::bind_method(D_METHOD("get_glow_hdr_luminance_cap"), &Environment::get_glow_hdr_luminance_cap);
1350 ClassDB::bind_method(D_METHOD("set_glow_map_strength", "strength"), &Environment::set_glow_map_strength);
1351 ClassDB::bind_method(D_METHOD("get_glow_map_strength"), &Environment::get_glow_map_strength);
1352 ClassDB::bind_method(D_METHOD("set_glow_map", "mode"), &Environment::set_glow_map);
1353 ClassDB::bind_method(D_METHOD("get_glow_map"), &Environment::get_glow_map);
1354
1355 ADD_GROUP("Glow", "glow_");
1356 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_enabled"), "set_glow_enabled", "is_glow_enabled");
1357 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/1", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 0);
1358 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/2", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 1);
1359 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/3", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 2);
1360 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/4", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 3);
1361 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/5", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 4);
1362 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/6", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 5);
1363 ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/7", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 6);
1364 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_normalized"), "set_glow_normalized", "is_glow_normalized");
1365 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_intensity", PROPERTY_HINT_RANGE, "0.0,8.0,0.01"), "set_glow_intensity", "get_glow_intensity");
1366 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_strength", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"), "set_glow_strength", "get_glow_strength");
1367 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_mix", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_glow_mix", "get_glow_mix");
1368 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_bloom", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_glow_bloom", "get_glow_bloom");
1369 ADD_PROPERTY(PropertyInfo(Variant::INT, "glow_blend_mode", PROPERTY_HINT_ENUM, "Additive,Screen,Softlight,Replace,Mix"), "set_glow_blend_mode", "get_glow_blend_mode");
1370 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_hdr_threshold", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_threshold", "get_glow_hdr_bleed_threshold");
1371 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_hdr_scale", PROPERTY_HINT_RANGE, "0.0,4.0,0.01"), "set_glow_hdr_bleed_scale", "get_glow_hdr_bleed_scale");
1372 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_hdr_luminance_cap", PROPERTY_HINT_RANGE, "0.0,256.0,0.01"), "set_glow_hdr_luminance_cap", "get_glow_hdr_luminance_cap");
1373 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_map_strength", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_glow_map_strength", "get_glow_map_strength");
1374 ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "glow_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_glow_map", "get_glow_map");
1375
1376 // Fog
1377
1378 ClassDB::bind_method(D_METHOD("set_fog_enabled", "enabled"), &Environment::set_fog_enabled);
1379 ClassDB::bind_method(D_METHOD("is_fog_enabled"), &Environment::is_fog_enabled);
1380 ClassDB::bind_method(D_METHOD("set_fog_light_color", "light_color"), &Environment::set_fog_light_color);
1381 ClassDB::bind_method(D_METHOD("get_fog_light_color"), &Environment::get_fog_light_color);
1382 ClassDB::bind_method(D_METHOD("set_fog_light_energy", "light_energy"), &Environment::set_fog_light_energy);
1383 ClassDB::bind_method(D_METHOD("get_fog_light_energy"), &Environment::get_fog_light_energy);
1384 ClassDB::bind_method(D_METHOD("set_fog_sun_scatter", "sun_scatter"), &Environment::set_fog_sun_scatter);
1385 ClassDB::bind_method(D_METHOD("get_fog_sun_scatter"), &Environment::get_fog_sun_scatter);
1386
1387 ClassDB::bind_method(D_METHOD("set_fog_density", "density"), &Environment::set_fog_density);
1388 ClassDB::bind_method(D_METHOD("get_fog_density"), &Environment::get_fog_density);
1389
1390 ClassDB::bind_method(D_METHOD("set_fog_height", "height"), &Environment::set_fog_height);
1391 ClassDB::bind_method(D_METHOD("get_fog_height"), &Environment::get_fog_height);
1392
1393 ClassDB::bind_method(D_METHOD("set_fog_height_density", "height_density"), &Environment::set_fog_height_density);
1394 ClassDB::bind_method(D_METHOD("get_fog_height_density"), &Environment::get_fog_height_density);
1395
1396 ClassDB::bind_method(D_METHOD("set_fog_aerial_perspective", "aerial_perspective"), &Environment::set_fog_aerial_perspective);
1397 ClassDB::bind_method(D_METHOD("get_fog_aerial_perspective"), &Environment::get_fog_aerial_perspective);
1398
1399 ClassDB::bind_method(D_METHOD("set_fog_sky_affect", "sky_affect"), &Environment::set_fog_sky_affect);
1400 ClassDB::bind_method(D_METHOD("get_fog_sky_affect"), &Environment::get_fog_sky_affect);
1401
1402 ADD_GROUP("Fog", "fog_");
1403 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_enabled"), "set_fog_enabled", "is_fog_enabled");
1404 ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_fog_light_color", "get_fog_light_color");
1405 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_light_energy", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_fog_light_energy", "get_fog_light_energy");
1406 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_sun_scatter", PROPERTY_HINT_RANGE, "0,1,0.01,or_greater"), "set_fog_sun_scatter", "get_fog_sun_scatter");
1407
1408 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_density", PROPERTY_HINT_RANGE, "0,1,0.0001,or_greater"), "set_fog_density", "get_fog_density");
1409 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_aerial_perspective", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_fog_aerial_perspective", "get_fog_aerial_perspective");
1410 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_sky_affect", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_fog_sky_affect", "get_fog_sky_affect");
1411 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height", PROPERTY_HINT_RANGE, "-1024,1024,0.01,or_less,or_greater,suffix:m"), "set_fog_height", "get_fog_height");
1412 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height_density", PROPERTY_HINT_RANGE, "-16,16,0.0001,or_less,or_greater"), "set_fog_height_density", "get_fog_height_density");
1413
1414 ClassDB::bind_method(D_METHOD("set_volumetric_fog_enabled", "enabled"), &Environment::set_volumetric_fog_enabled);
1415 ClassDB::bind_method(D_METHOD("is_volumetric_fog_enabled"), &Environment::is_volumetric_fog_enabled);
1416 ClassDB::bind_method(D_METHOD("set_volumetric_fog_emission", "color"), &Environment::set_volumetric_fog_emission);
1417 ClassDB::bind_method(D_METHOD("get_volumetric_fog_emission"), &Environment::get_volumetric_fog_emission);
1418 ClassDB::bind_method(D_METHOD("set_volumetric_fog_albedo", "color"), &Environment::set_volumetric_fog_albedo);
1419 ClassDB::bind_method(D_METHOD("get_volumetric_fog_albedo"), &Environment::get_volumetric_fog_albedo);
1420 ClassDB::bind_method(D_METHOD("set_volumetric_fog_density", "density"), &Environment::set_volumetric_fog_density);
1421 ClassDB::bind_method(D_METHOD("get_volumetric_fog_density"), &Environment::get_volumetric_fog_density);
1422 ClassDB::bind_method(D_METHOD("set_volumetric_fog_emission_energy", "begin"), &Environment::set_volumetric_fog_emission_energy);
1423 ClassDB::bind_method(D_METHOD("get_volumetric_fog_emission_energy"), &Environment::get_volumetric_fog_emission_energy);
1424 ClassDB::bind_method(D_METHOD("set_volumetric_fog_anisotropy", "anisotropy"), &Environment::set_volumetric_fog_anisotropy);
1425 ClassDB::bind_method(D_METHOD("get_volumetric_fog_anisotropy"), &Environment::get_volumetric_fog_anisotropy);
1426 ClassDB::bind_method(D_METHOD("set_volumetric_fog_length", "length"), &Environment::set_volumetric_fog_length);
1427 ClassDB::bind_method(D_METHOD("get_volumetric_fog_length"), &Environment::get_volumetric_fog_length);
1428 ClassDB::bind_method(D_METHOD("set_volumetric_fog_detail_spread", "detail_spread"), &Environment::set_volumetric_fog_detail_spread);
1429 ClassDB::bind_method(D_METHOD("get_volumetric_fog_detail_spread"), &Environment::get_volumetric_fog_detail_spread);
1430 ClassDB::bind_method(D_METHOD("set_volumetric_fog_gi_inject", "gi_inject"), &Environment::set_volumetric_fog_gi_inject);
1431 ClassDB::bind_method(D_METHOD("get_volumetric_fog_gi_inject"), &Environment::get_volumetric_fog_gi_inject);
1432 ClassDB::bind_method(D_METHOD("set_volumetric_fog_ambient_inject", "enabled"), &Environment::set_volumetric_fog_ambient_inject);
1433 ClassDB::bind_method(D_METHOD("get_volumetric_fog_ambient_inject"), &Environment::get_volumetric_fog_ambient_inject);
1434 ClassDB::bind_method(D_METHOD("set_volumetric_fog_sky_affect", "sky_affect"), &Environment::set_volumetric_fog_sky_affect);
1435 ClassDB::bind_method(D_METHOD("get_volumetric_fog_sky_affect"), &Environment::get_volumetric_fog_sky_affect);
1436 ClassDB::bind_method(D_METHOD("set_volumetric_fog_temporal_reprojection_enabled", "enabled"), &Environment::set_volumetric_fog_temporal_reprojection_enabled);
1437 ClassDB::bind_method(D_METHOD("is_volumetric_fog_temporal_reprojection_enabled"), &Environment::is_volumetric_fog_temporal_reprojection_enabled);
1438 ClassDB::bind_method(D_METHOD("set_volumetric_fog_temporal_reprojection_amount", "temporal_reprojection_amount"), &Environment::set_volumetric_fog_temporal_reprojection_amount);
1439 ClassDB::bind_method(D_METHOD("get_volumetric_fog_temporal_reprojection_amount"), &Environment::get_volumetric_fog_temporal_reprojection_amount);
1440
1441 ADD_GROUP("Volumetric Fog", "volumetric_fog_");
1442 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "volumetric_fog_enabled"), "set_volumetric_fog_enabled", "is_volumetric_fog_enabled");
1443 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_density", PROPERTY_HINT_RANGE, "0,1,0.0001,or_greater"), "set_volumetric_fog_density", "get_volumetric_fog_density");
1444 ADD_PROPERTY(PropertyInfo(Variant::COLOR, "volumetric_fog_albedo", PROPERTY_HINT_COLOR_NO_ALPHA), "set_volumetric_fog_albedo", "get_volumetric_fog_albedo");
1445 ADD_PROPERTY(PropertyInfo(Variant::COLOR, "volumetric_fog_emission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_volumetric_fog_emission", "get_volumetric_fog_emission");
1446 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_emission_energy", PROPERTY_HINT_RANGE, "0,1024,0.01,or_greater"), "set_volumetric_fog_emission_energy", "get_volumetric_fog_emission_energy");
1447 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_gi_inject", PROPERTY_HINT_RANGE, "0.0,16,0.01,exp"), "set_volumetric_fog_gi_inject", "get_volumetric_fog_gi_inject");
1448 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_anisotropy", PROPERTY_HINT_RANGE, "-0.9,0.9,0.01"), "set_volumetric_fog_anisotropy", "get_volumetric_fog_anisotropy");
1449 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_length", PROPERTY_HINT_RANGE, "0.01,1024,0.01,or_greater,suffix:m"), "set_volumetric_fog_length", "get_volumetric_fog_length");
1450 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_detail_spread", PROPERTY_HINT_EXP_EASING, "positive_only"), "set_volumetric_fog_detail_spread", "get_volumetric_fog_detail_spread");
1451 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_ambient_inject", PROPERTY_HINT_RANGE, "0.0,16,0.01,exp"), "set_volumetric_fog_ambient_inject", "get_volumetric_fog_ambient_inject");
1452 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_sky_affect", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_volumetric_fog_sky_affect", "get_volumetric_fog_sky_affect");
1453 ADD_SUBGROUP("Temporal Reprojection", "volumetric_fog_temporal_reprojection_");
1454 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "volumetric_fog_temporal_reprojection_enabled"), "set_volumetric_fog_temporal_reprojection_enabled", "is_volumetric_fog_temporal_reprojection_enabled");
1455 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "volumetric_fog_temporal_reprojection_amount", PROPERTY_HINT_RANGE, "0.5,0.99,0.001"), "set_volumetric_fog_temporal_reprojection_amount", "get_volumetric_fog_temporal_reprojection_amount");
1456
1457 // Adjustment
1458
1459 ClassDB::bind_method(D_METHOD("set_adjustment_enabled", "enabled"), &Environment::set_adjustment_enabled);
1460 ClassDB::bind_method(D_METHOD("is_adjustment_enabled"), &Environment::is_adjustment_enabled);
1461 ClassDB::bind_method(D_METHOD("set_adjustment_brightness", "brightness"), &Environment::set_adjustment_brightness);
1462 ClassDB::bind_method(D_METHOD("get_adjustment_brightness"), &Environment::get_adjustment_brightness);
1463 ClassDB::bind_method(D_METHOD("set_adjustment_contrast", "contrast"), &Environment::set_adjustment_contrast);
1464 ClassDB::bind_method(D_METHOD("get_adjustment_contrast"), &Environment::get_adjustment_contrast);
1465 ClassDB::bind_method(D_METHOD("set_adjustment_saturation", "saturation"), &Environment::set_adjustment_saturation);
1466 ClassDB::bind_method(D_METHOD("get_adjustment_saturation"), &Environment::get_adjustment_saturation);
1467 ClassDB::bind_method(D_METHOD("set_adjustment_color_correction", "color_correction"), &Environment::set_adjustment_color_correction);
1468 ClassDB::bind_method(D_METHOD("get_adjustment_color_correction"), &Environment::get_adjustment_color_correction);
1469
1470 ADD_GROUP("Adjustments", "adjustment_");
1471 ADD_PROPERTY(PropertyInfo(Variant::BOOL, "adjustment_enabled"), "set_adjustment_enabled", "is_adjustment_enabled");
1472 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "adjustment_brightness", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_brightness", "get_adjustment_brightness");
1473 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "adjustment_contrast", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_contrast", "get_adjustment_contrast");
1474 ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation");
1475 ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D,Texture3D"), "set_adjustment_color_correction", "get_adjustment_color_correction");
1476
1477 // Constants
1478
1479 BIND_ENUM_CONSTANT(BG_CLEAR_COLOR);
1480 BIND_ENUM_CONSTANT(BG_COLOR);
1481 BIND_ENUM_CONSTANT(BG_SKY);
1482 BIND_ENUM_CONSTANT(BG_CANVAS);
1483 BIND_ENUM_CONSTANT(BG_KEEP);
1484 BIND_ENUM_CONSTANT(BG_CAMERA_FEED);
1485 BIND_ENUM_CONSTANT(BG_MAX);
1486
1487 BIND_ENUM_CONSTANT(AMBIENT_SOURCE_BG);
1488 BIND_ENUM_CONSTANT(AMBIENT_SOURCE_DISABLED);
1489 BIND_ENUM_CONSTANT(AMBIENT_SOURCE_COLOR);
1490 BIND_ENUM_CONSTANT(AMBIENT_SOURCE_SKY);
1491
1492 BIND_ENUM_CONSTANT(REFLECTION_SOURCE_BG);
1493 BIND_ENUM_CONSTANT(REFLECTION_SOURCE_DISABLED);
1494 BIND_ENUM_CONSTANT(REFLECTION_SOURCE_SKY);
1495
1496 BIND_ENUM_CONSTANT(TONE_MAPPER_LINEAR);
1497 BIND_ENUM_CONSTANT(TONE_MAPPER_REINHARDT);
1498 BIND_ENUM_CONSTANT(TONE_MAPPER_FILMIC);
1499 BIND_ENUM_CONSTANT(TONE_MAPPER_ACES);
1500
1501 BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_ADDITIVE);
1502 BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SCREEN);
1503 BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_SOFTLIGHT);
1504 BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_REPLACE);
1505 BIND_ENUM_CONSTANT(GLOW_BLEND_MODE_MIX);
1506
1507 BIND_ENUM_CONSTANT(SDFGI_Y_SCALE_50_PERCENT);
1508 BIND_ENUM_CONSTANT(SDFGI_Y_SCALE_75_PERCENT);
1509 BIND_ENUM_CONSTANT(SDFGI_Y_SCALE_100_PERCENT);
1510}
1511
1512Environment::Environment() {
1513 environment = RS::get_singleton()->environment_create();
1514
1515 set_camera_feed_id(bg_camera_feed_id);
1516
1517 glow_levels.resize(7);
1518 glow_levels.write[0] = 0.0;
1519 glow_levels.write[1] = 0.0;
1520 glow_levels.write[2] = 1.0;
1521 glow_levels.write[3] = 0.0;
1522 glow_levels.write[4] = 1.0;
1523 glow_levels.write[5] = 0.0;
1524 glow_levels.write[6] = 0.0;
1525
1526 _update_ambient_light();
1527 _update_tonemap();
1528 _update_ssr();
1529 _update_ssao();
1530 _update_ssil();
1531 _update_sdfgi();
1532 _update_glow();
1533 _update_fog();
1534 _update_adjustment();
1535 _update_volumetric_fog();
1536 _update_bg_energy();
1537 notify_property_list_changed();
1538}
1539
1540Environment::~Environment() {
1541 ERR_FAIL_NULL(RenderingServer::get_singleton());
1542 RS::get_singleton()->free(environment);
1543}
1544