diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-10-18 17:32:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-18 17:32:19 +0200 |
commit | d9e5c355e5738eb23d3208db5240240df4bd1226 (patch) | |
tree | 116225f4849a09b52d6f0cb837b4a79562889bfd /scene | |
parent | 0cee3021927bc246a42c589cc28199a4c51f2909 (diff) | |
parent | 8c21c26fb559503cedc41eebd7806d05d10874a2 (diff) |
Merge pull request #41418 from clayjohn/Vulkan-aerial
Add aerial perspective to fixed fog
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/environment.cpp | 24 | ||||
-rw-r--r-- | scene/resources/environment.h | 3 |
2 files changed, 26 insertions, 1 deletions
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index ee8e63266d..3df539c86e 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -44,6 +44,9 @@ void Environment::set_background(BGMode p_bg) { bg_mode = p_bg; RS::get_singleton()->environment_set_background(environment, RS::EnvironmentBG(p_bg)); _change_notify(); + if (bg_mode != BG_SKY) { + set_fog_aerial_perspective(0.0); + } } Environment::BGMode Environment::get_background() const { @@ -739,6 +742,14 @@ float Environment::get_fog_height_density() const { return fog_height_density; } +void Environment::set_fog_aerial_perspective(float p_aerial_perspective) { + fog_aerial_perspective = p_aerial_perspective; + _update_fog(); +} +float Environment::get_fog_aerial_perspective() const { + return fog_aerial_perspective; +} + void Environment::_update_fog() { RS::get_singleton()->environment_set_fog( environment, @@ -748,7 +759,8 @@ void Environment::_update_fog() { fog_sun_scatter, fog_density, fog_height, - fog_height_density); + fog_height_density, + fog_aerial_perspective); } // Volumetric Fog @@ -887,6 +899,12 @@ void Environment::_validate_property(PropertyInfo &property) const { } } + if (property.name == "fog_aerial_perspective") { + if (bg_mode != BG_SKY) { + property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; + } + } + if (property.name == "glow_intensity" && glow_blend_mode == GLOW_BLEND_MODE_MIX) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } @@ -1219,6 +1237,9 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_fog_height_density", "height_density"), &Environment::set_fog_height_density); ClassDB::bind_method(D_METHOD("get_fog_height_density"), &Environment::get_fog_height_density); + ClassDB::bind_method(D_METHOD("set_fog_aerial_perspective", "aerial_perspective"), &Environment::set_fog_aerial_perspective); + ClassDB::bind_method(D_METHOD("get_fog_aerial_perspective"), &Environment::get_fog_aerial_perspective); + ADD_GROUP("Fog", "fog_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_enabled"), "set_fog_enabled", "is_fog_enabled"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_fog_light_color", "get_fog_light_color"); @@ -1226,6 +1247,7 @@ void Environment::_bind_methods() { 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"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_density", PROPERTY_HINT_RANGE, "0,16,0.0001"), "set_fog_density", "get_fog_density"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_aerial_perspective", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_fog_aerial_perspective", "get_fog_aerial_perspective"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height", PROPERTY_HINT_RANGE, "-1024,1024,0.01,or_lesser,or_greater"), "set_fog_height", "get_fog_height"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height_density", PROPERTY_HINT_RANGE, "0,128,0.001,or_greater"), "set_fog_height_density", "get_fog_height_density"); diff --git a/scene/resources/environment.h b/scene/resources/environment.h index d4d84f31aa..0514f0ec3c 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -190,6 +190,7 @@ private: float fog_density = 0.001; float fog_height = 0.0; float fog_height_density = 0.0; //can be negative to invert effect + float fog_aerial_perspective = 0.0; void _update_fog(); @@ -368,6 +369,8 @@ public: float get_fog_height() const; void set_fog_height_density(float p_amount); float get_fog_height_density() const; + void set_fog_aerial_perspective(float p_aerial_perspective); + float get_fog_aerial_perspective() const; // Volumetric Fog void set_volumetric_fog_enabled(bool p_enable); |