diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/3d/baked_lightmap.cpp | 6 | ||||
-rw-r--r-- | scene/3d/light_3d.cpp | 10 | ||||
-rw-r--r-- | scene/3d/light_3d.h | 4 | ||||
-rw-r--r-- | scene/3d/reflection_probe.cpp | 68 | ||||
-rw-r--r-- | scene/3d/reflection_probe.h | 24 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 4 | ||||
-rw-r--r-- | scene/main/viewport.h | 6 | ||||
-rw-r--r-- | scene/resources/environment.cpp | 192 | ||||
-rw-r--r-- | scene/resources/environment.h | 67 |
9 files changed, 329 insertions, 52 deletions
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index a41eaf9da0..e867891ec0 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -894,13 +894,13 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, String p_image_d if (Object::cast_to<DirectionalLight3D>(light)) { DirectionalLight3D *l = Object::cast_to<DirectionalLight3D>(light); - lightmapper->add_directional_light(light->get_bake_mode() == Light3D::BAKE_ALL, -xf.basis.get_axis(Vector3::AXIS_Z).normalized(), l->get_color(), l->get_param(Light3D::PARAM_ENERGY), l->get_param(Light3D::PARAM_SIZE)); + lightmapper->add_directional_light(light->get_bake_mode() == Light3D::BAKE_STATIC, -xf.basis.get_axis(Vector3::AXIS_Z).normalized(), l->get_color(), l->get_param(Light3D::PARAM_ENERGY), l->get_param(Light3D::PARAM_SIZE)); } else if (Object::cast_to<OmniLight3D>(light)) { OmniLight3D *l = Object::cast_to<OmniLight3D>(light); - lightmapper->add_omni_light(light->get_bake_mode() == Light3D::BAKE_ALL, xf.origin, l->get_color(), l->get_param(Light3D::PARAM_ENERGY), l->get_param(Light3D::PARAM_RANGE), l->get_param(Light3D::PARAM_ATTENUATION), l->get_param(Light3D::PARAM_SIZE)); + lightmapper->add_omni_light(light->get_bake_mode() == Light3D::BAKE_STATIC, xf.origin, l->get_color(), l->get_param(Light3D::PARAM_ENERGY), l->get_param(Light3D::PARAM_RANGE), l->get_param(Light3D::PARAM_ATTENUATION), l->get_param(Light3D::PARAM_SIZE)); } else if (Object::cast_to<SpotLight3D>(light)) { SpotLight3D *l = Object::cast_to<SpotLight3D>(light); - lightmapper->add_spot_light(light->get_bake_mode() == Light3D::BAKE_ALL, xf.origin, -xf.basis.get_axis(Vector3::AXIS_Z).normalized(), l->get_color(), l->get_param(Light3D::PARAM_ENERGY), l->get_param(Light3D::PARAM_RANGE), l->get_param(Light3D::PARAM_ATTENUATION), l->get_param(Light3D::PARAM_SPOT_ANGLE), l->get_param(Light3D::PARAM_SPOT_ATTENUATION), l->get_param(Light3D::PARAM_SIZE)); + lightmapper->add_spot_light(light->get_bake_mode() == Light3D::BAKE_STATIC, xf.origin, -xf.basis.get_axis(Vector3::AXIS_Z).normalized(), l->get_color(), l->get_param(Light3D::PARAM_ENERGY), l->get_param(Light3D::PARAM_RANGE), l->get_param(Light3D::PARAM_ATTENUATION), l->get_param(Light3D::PARAM_SPOT_ANGLE), l->get_param(Light3D::PARAM_SPOT_ATTENUATION), l->get_param(Light3D::PARAM_SIZE)); } } for (int i = 0; i < probes_found.size(); i++) { diff --git a/scene/3d/light_3d.cpp b/scene/3d/light_3d.cpp index 9270b548b7..cc1622722e 100644 --- a/scene/3d/light_3d.cpp +++ b/scene/3d/light_3d.cpp @@ -144,7 +144,7 @@ Vector<Face3> Light3D::get_faces(uint32_t p_usage_flags) const { void Light3D::set_bake_mode(BakeMode p_mode) { bake_mode = p_mode; - RS::get_singleton()->light_set_use_gi(light, p_mode != BAKE_DISABLED); + RS::get_singleton()->light_set_bake_mode(light, RS::LightBakeMode(p_mode)); } Light3D::BakeMode Light3D::get_bake_mode() const { @@ -261,7 +261,7 @@ void Light3D::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "light_angular_distance", PROPERTY_HINT_RANGE, "0,90,0.01"), "set_param", "get_param", PARAM_SIZE); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "light_negative"), "set_negative", "is_negative"); ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "light_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SPECULAR); - ADD_PROPERTY(PropertyInfo(Variant::INT, "light_bake_mode", PROPERTY_HINT_ENUM, "Disable,Indirect,All"), "set_bake_mode", "get_bake_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "light_bake_mode", PROPERTY_HINT_ENUM, "Disabled,Dynamic,Static"), "set_bake_mode", "get_bake_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "light_cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask"); ADD_GROUP("Shadow", "shadow_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled"), "set_shadow", "has_shadow"); @@ -296,8 +296,8 @@ void Light3D::_bind_methods() { BIND_ENUM_CONSTANT(PARAM_MAX); BIND_ENUM_CONSTANT(BAKE_DISABLED); - BIND_ENUM_CONSTANT(BAKE_INDIRECT); - BIND_ENUM_CONSTANT(BAKE_ALL); + BIND_ENUM_CONSTANT(BAKE_DYNAMIC); + BIND_ENUM_CONSTANT(BAKE_STATIC); } Light3D::Light3D(RenderingServer::LightType p_type) { @@ -319,7 +319,7 @@ Light3D::Light3D(RenderingServer::LightType p_type) { RS::get_singleton()->instance_set_base(get_instance(), light); reverse_cull = false; - bake_mode = BAKE_INDIRECT; + bake_mode = BAKE_DYNAMIC; editor_only = false; set_color(Color(1, 1, 1, 1)); diff --git a/scene/3d/light_3d.h b/scene/3d/light_3d.h index f16773f6ae..09fc81b216 100644 --- a/scene/3d/light_3d.h +++ b/scene/3d/light_3d.h @@ -64,8 +64,8 @@ public: enum BakeMode { BAKE_DISABLED, - BAKE_INDIRECT, - BAKE_ALL + BAKE_DYNAMIC, + BAKE_STATIC }; private: diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index b1f19053d9..c7948395d3 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -39,31 +39,32 @@ float ReflectionProbe::get_intensity() const { return intensity; } -void ReflectionProbe::set_interior_ambient(Color p_ambient) { - interior_ambient = p_ambient; - RS::get_singleton()->reflection_probe_set_interior_ambient(probe, p_ambient); +void ReflectionProbe::set_ambient_mode(AmbientMode p_mode) { + ambient_mode = p_mode; + RS::get_singleton()->reflection_probe_set_ambient_mode(probe, RS::ReflectionProbeAmbientMode(p_mode)); + _change_notify(); } -void ReflectionProbe::set_interior_ambient_energy(float p_energy) { - interior_ambient_energy = p_energy; - RS::get_singleton()->reflection_probe_set_interior_ambient_energy(probe, p_energy); +ReflectionProbe::AmbientMode ReflectionProbe::get_ambient_mode() const { + return ambient_mode; } -float ReflectionProbe::get_interior_ambient_energy() const { - return interior_ambient_energy; +void ReflectionProbe::set_ambient_color(Color p_ambient) { + ambient_color = p_ambient; + RS::get_singleton()->reflection_probe_set_ambient_color(probe, p_ambient); } -Color ReflectionProbe::get_interior_ambient() const { - return interior_ambient; +void ReflectionProbe::set_ambient_color_energy(float p_energy) { + ambient_color_energy = p_energy; + RS::get_singleton()->reflection_probe_set_ambient_energy(probe, p_energy); } -void ReflectionProbe::set_interior_ambient_probe_contribution(float p_contribution) { - interior_ambient_probe_contribution = p_contribution; - RS::get_singleton()->reflection_probe_set_interior_ambient_probe_contribution(probe, p_contribution); +float ReflectionProbe::get_ambient_color_energy() const { + return ambient_color_energy; } -float ReflectionProbe::get_interior_ambient_probe_contribution() const { - return interior_ambient_probe_contribution; +Color ReflectionProbe::get_ambient_color() const { + return ambient_color; } void ReflectionProbe::set_max_distance(float p_distance) { @@ -130,7 +131,6 @@ bool ReflectionProbe::is_box_projection_enabled() const { void ReflectionProbe::set_as_interior(bool p_enable) { interior = p_enable; RS::get_singleton()->reflection_probe_set_as_interior(probe, interior); - _change_notify(); } bool ReflectionProbe::is_set_as_interior() const { @@ -176,8 +176,8 @@ Vector<Face3> ReflectionProbe::get_faces(uint32_t p_usage_flags) const { } void ReflectionProbe::_validate_property(PropertyInfo &property) const { - if (property.name == "interior/ambient_color" || property.name == "interior/ambient_energy" || property.name == "interior/ambient_contrib") { - if (!interior) { + if (property.name == "interior/ambient_color" || property.name == "interior/ambient_color_energy") { + if (ambient_mode != AMBIENT_COLOR) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; } } @@ -187,14 +187,14 @@ void ReflectionProbe::_bind_methods() { ClassDB::bind_method(D_METHOD("set_intensity", "intensity"), &ReflectionProbe::set_intensity); ClassDB::bind_method(D_METHOD("get_intensity"), &ReflectionProbe::get_intensity); - ClassDB::bind_method(D_METHOD("set_interior_ambient", "ambient"), &ReflectionProbe::set_interior_ambient); - ClassDB::bind_method(D_METHOD("get_interior_ambient"), &ReflectionProbe::get_interior_ambient); + ClassDB::bind_method(D_METHOD("set_ambient_mode", "ambient"), &ReflectionProbe::set_ambient_mode); + ClassDB::bind_method(D_METHOD("get_ambient_mode"), &ReflectionProbe::get_ambient_mode); - ClassDB::bind_method(D_METHOD("set_interior_ambient_energy", "ambient_energy"), &ReflectionProbe::set_interior_ambient_energy); - ClassDB::bind_method(D_METHOD("get_interior_ambient_energy"), &ReflectionProbe::get_interior_ambient_energy); + ClassDB::bind_method(D_METHOD("set_ambient_color", "ambient"), &ReflectionProbe::set_ambient_color); + ClassDB::bind_method(D_METHOD("get_ambient_color"), &ReflectionProbe::get_ambient_color); - ClassDB::bind_method(D_METHOD("set_interior_ambient_probe_contribution", "ambient_probe_contribution"), &ReflectionProbe::set_interior_ambient_probe_contribution); - ClassDB::bind_method(D_METHOD("get_interior_ambient_probe_contribution"), &ReflectionProbe::get_interior_ambient_probe_contribution); + ClassDB::bind_method(D_METHOD("set_ambient_color_energy", "ambient_energy"), &ReflectionProbe::set_ambient_color_energy); + ClassDB::bind_method(D_METHOD("get_ambient_color_energy"), &ReflectionProbe::get_ambient_color_energy); ClassDB::bind_method(D_METHOD("set_max_distance", "max_distance"), &ReflectionProbe::set_max_distance); ClassDB::bind_method(D_METHOD("get_max_distance"), &ReflectionProbe::get_max_distance); @@ -226,24 +226,28 @@ void ReflectionProbe::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "origin_offset"), "set_origin_offset", "get_origin_offset"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "box_projection"), "set_enable_box_projection", "is_box_projection_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior"), "set_as_interior", "is_set_as_interior"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "enable_shadows"), "set_enable_shadows", "are_shadows_enabled"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask"); - ADD_GROUP("Interior", "interior_"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interior_enable"), "set_as_interior", "is_set_as_interior"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "interior_ambient_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_interior_ambient", "get_interior_ambient"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "interior_ambient_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_interior_ambient_energy", "get_interior_ambient_energy"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "interior_ambient_contrib", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_interior_ambient_probe_contribution", "get_interior_ambient_probe_contribution"); + ADD_GROUP("Ambient", "ambient_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "ambient_mode", PROPERTY_HINT_ENUM, "Disabled,Environment,ConstantColor"), "set_ambient_mode", "get_ambient_mode"); + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ambient_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ambient_color", "get_ambient_color"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ambient_color_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_ambient_color_energy", "get_ambient_color_energy"); BIND_ENUM_CONSTANT(UPDATE_ONCE); BIND_ENUM_CONSTANT(UPDATE_ALWAYS); + + BIND_ENUM_CONSTANT(AMBIENT_DISABLED); + BIND_ENUM_CONSTANT(AMBIENT_ENVIRONMENT); + BIND_ENUM_CONSTANT(AMBIENT_COLOR); } ReflectionProbe::ReflectionProbe() { intensity = 1.0; - interior_ambient = Color(0, 0, 0); - interior_ambient_probe_contribution = 0; - interior_ambient_energy = 1.0; + ambient_mode = AMBIENT_ENVIRONMENT; + ambient_color = Color(0, 0, 0); + ambient_color_energy = 1.0; max_distance = 0; extents = Vector3(1, 1, 1); origin_offset = Vector3(0, 0, 0); diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index 3867d13435..c708804f96 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -45,6 +45,12 @@ public: UPDATE_ALWAYS, }; + enum AmbientMode { + AMBIENT_DISABLED, + AMBIENT_ENVIRONMENT, + AMBIENT_COLOR + }; + private: RID probe; float intensity; @@ -54,9 +60,9 @@ private: bool box_projection; bool enable_shadows; bool interior; - Color interior_ambient; - float interior_ambient_energy; - float interior_ambient_probe_contribution; + AmbientMode ambient_mode; + Color ambient_color; + float ambient_color_energy; uint32_t cull_mask; UpdateMode update_mode; @@ -69,11 +75,14 @@ public: void set_intensity(float p_intensity); float get_intensity() const; - void set_interior_ambient(Color p_ambient); - Color get_interior_ambient() const; + void set_ambient_mode(AmbientMode p_mode); + AmbientMode get_ambient_mode() const; + + void set_ambient_color(Color p_ambient); + Color get_ambient_color() const; - void set_interior_ambient_energy(float p_energy); - float get_interior_ambient_energy() const; + void set_ambient_color_energy(float p_energy); + float get_ambient_color_energy() const; void set_interior_ambient_probe_contribution(float p_contribution); float get_interior_ambient_probe_contribution() const; @@ -109,6 +118,7 @@ public: ~ReflectionProbe(); }; +VARIANT_ENUM_CAST(ReflectionProbe::AmbientMode); VARIANT_ENUM_CAST(ReflectionProbe::UpdateMode); #endif // REFLECTIONPROBE_H diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 8544d67ecc..606f39370b 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3404,9 +3404,11 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS); BIND_ENUM_CONSTANT(DEBUG_DRAW_SCENE_LUMINANCE); BIND_ENUM_CONSTANT(DEBUG_DRAW_SSAO); - BIND_ENUM_CONSTANT(DEBUG_DRAW_ROUGHNESS_LIMITER); BIND_ENUM_CONSTANT(DEBUG_DRAW_PSSM_SPLITS); BIND_ENUM_CONSTANT(DEBUG_DRAW_DECAL_ATLAS); + BIND_ENUM_CONSTANT(DEBUG_DRAW_SDFGI); + BIND_ENUM_CONSTANT(DEBUG_DRAW_SDFGI_PROBES); + BIND_ENUM_CONSTANT(DEBUG_DRAW_GI_BUFFER); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_NEAREST); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR); diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 4536b558f9..11fe4f00d2 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -137,9 +137,11 @@ public: DEBUG_DRAW_DIRECTIONAL_SHADOW_ATLAS, DEBUG_DRAW_SCENE_LUMINANCE, DEBUG_DRAW_SSAO, - DEBUG_DRAW_ROUGHNESS_LIMITER, DEBUG_DRAW_PSSM_SPLITS, - DEBUG_DRAW_DECAL_ATLAS + DEBUG_DRAW_DECAL_ATLAS, + DEBUG_DRAW_SDFGI, + DEBUG_DRAW_SDFGI_PROBES, + DEBUG_DRAW_GI_BUFFER, }; enum DefaultCanvasItemTextureFilter { diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 80ee0c148d..854a9ee9da 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -745,6 +745,135 @@ bool Environment::_set(const StringName &p_name, const Variant &p_value) { } #endif +void Environment::set_sdfgi_enabled(bool p_enabled) { + sdfgi_enabled = p_enabled; + _update_sdfgi(); +} + +bool Environment::is_sdfgi_enabled() const { + return sdfgi_enabled; +} + +void Environment::set_sdfgi_cascades(SDFGICascades p_cascades) { + sdfgi_cascades = p_cascades; + _update_sdfgi(); +} +Environment::SDFGICascades Environment::get_sdfgi_cascades() const { + return sdfgi_cascades; +} + +void Environment::set_sdfgi_min_cell_size(float p_size) { + sdfgi_min_cell_size = p_size; + _change_notify("sdfgi_max_distance"); + _change_notify("sdfgi_cascade0_distance"); + _update_sdfgi(); +} +float Environment::get_sdfgi_min_cell_size() const { + return sdfgi_min_cell_size; +} + +void Environment::set_sdfgi_max_distance(float p_size) { + p_size /= 64.0; + int cc[3] = { 4, 6, 8 }; + int cascades = cc[sdfgi_cascades]; + for (int i = 0; i < cascades; i++) { + p_size *= 0.5; //halve for each cascade + } + sdfgi_min_cell_size = p_size; + _change_notify("sdfgi_min_cell_size"); + _change_notify("sdfgi_cascade0_distance"); + _update_sdfgi(); +} +float Environment::get_sdfgi_max_distance() const { + float md = sdfgi_min_cell_size; + md *= 64.0; + int cc[3] = { 4, 6, 8 }; + int cascades = cc[sdfgi_cascades]; + for (int i = 0; i < cascades; i++) { + md *= 2.0; + } + return md; +} + +void Environment::set_sdfgi_cascade0_distance(float p_size) { + sdfgi_min_cell_size = p_size / 64.0; + _change_notify("sdfgi_min_cell_size"); + _change_notify("sdfgi_max_distance"); + _update_sdfgi(); +} +float Environment::get_sdfgi_cascade0_distance() const { + return sdfgi_min_cell_size * 64.0; +} + +void Environment::set_sdfgi_use_occlusion(bool p_enable) { + sdfgi_use_occlusion = p_enable; + _update_sdfgi(); +} + +bool Environment::is_sdfgi_using_occlusion() const { + return sdfgi_use_occlusion; +} + +void Environment::set_sdfgi_use_multi_bounce(bool p_enable) { + sdfgi_use_multibounce = p_enable; + _update_sdfgi(); +} +bool Environment::is_sdfgi_using_multi_bounce() const { + return sdfgi_use_multibounce; +} + +void Environment::set_sdfgi_use_enhance_ssr(bool p_enable) { + sdfgi_enhance_ssr = p_enable; + _update_sdfgi(); +} +bool Environment::is_sdfgi_using_enhance_ssr() const { + return sdfgi_enhance_ssr; +} + +void Environment::set_sdfgi_read_sky_light(bool p_enable) { + sdfgi_read_sky_light = p_enable; + _update_sdfgi(); +} + +bool Environment::is_sdfgi_reading_sky_light() const { + return sdfgi_read_sky_light; +} + +void Environment::set_sdfgi_energy(float p_energy) { + sdfgi_energy = p_energy; + _update_sdfgi(); +} +float Environment::get_sdfgi_energy() const { + return sdfgi_energy; +} + +void Environment::set_sdfgi_normal_bias(float p_bias) { + sdfgi_normal_bias = p_bias; + _update_sdfgi(); +} +float Environment::get_sdfgi_normal_bias() const { + return sdfgi_normal_bias; +} + +void Environment::set_sdfgi_probe_bias(float p_bias) { + sdfgi_probe_bias = p_bias; + _update_sdfgi(); +} +float Environment::get_sdfgi_probe_bias() const { + return sdfgi_probe_bias; +} + +void Environment::set_sdfgi_y_scale(SDFGIYScale p_y_scale) { + sdfgi_y_scale = p_y_scale; + _update_sdfgi(); +} +Environment::SDFGIYScale Environment::get_sdfgi_y_scale() const { + return sdfgi_y_scale; +} +void Environment::_update_sdfgi() { + RS::get_singleton()->environment_set_sdfgi(environment, sdfgi_enabled, RS::EnvironmentSDFGICascades(sdfgi_cascades), sdfgi_min_cell_size, RS::EnvironmentSDFGIYScale(sdfgi_y_scale), sdfgi_use_occlusion, sdfgi_use_multibounce, sdfgi_read_sky_light, sdfgi_enhance_ssr, sdfgi_energy, sdfgi_normal_bias, sdfgi_probe_bias); +} + void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_background", "mode"), &Environment::set_background); ClassDB::bind_method(D_METHOD("set_sky", "sky"), &Environment::set_sky); @@ -944,6 +1073,56 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "ssao_blur", PROPERTY_HINT_ENUM, "Disabled,1x1,2x2,3x3"), "set_ssao_blur", "get_ssao_blur"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "ssao_edge_sharpness", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_ssao_edge_sharpness", "get_ssao_edge_sharpness"); + ClassDB::bind_method(D_METHOD("set_sdfgi_enabled", "enabled"), &Environment::set_sdfgi_enabled); + ClassDB::bind_method(D_METHOD("is_sdfgi_enabled"), &Environment::is_sdfgi_enabled); + + ClassDB::bind_method(D_METHOD("set_sdfgi_cascades", "amount"), &Environment::set_sdfgi_cascades); + ClassDB::bind_method(D_METHOD("get_sdfgi_cascades"), &Environment::get_sdfgi_cascades); + + ClassDB::bind_method(D_METHOD("set_sdfgi_min_cell_size", "strength"), &Environment::set_sdfgi_min_cell_size); + ClassDB::bind_method(D_METHOD("get_sdfgi_min_cell_size"), &Environment::get_sdfgi_min_cell_size); + + ClassDB::bind_method(D_METHOD("set_sdfgi_max_distance", "strength"), &Environment::set_sdfgi_max_distance); + ClassDB::bind_method(D_METHOD("get_sdfgi_max_distance"), &Environment::get_sdfgi_max_distance); + + ClassDB::bind_method(D_METHOD("set_sdfgi_cascade0_distance", "strength"), &Environment::set_sdfgi_cascade0_distance); + ClassDB::bind_method(D_METHOD("get_sdfgi_cascade0_distance"), &Environment::get_sdfgi_cascade0_distance); + + ClassDB::bind_method(D_METHOD("set_sdfgi_use_occlusion", "enable"), &Environment::set_sdfgi_use_occlusion); + ClassDB::bind_method(D_METHOD("is_sdfgi_using_occlusion"), &Environment::is_sdfgi_using_occlusion); + + ClassDB::bind_method(D_METHOD("set_sdfgi_use_multi_bounce", "enable"), &Environment::set_sdfgi_use_multi_bounce); + ClassDB::bind_method(D_METHOD("is_sdfgi_using_multi_bounce"), &Environment::is_sdfgi_using_multi_bounce); + + ClassDB::bind_method(D_METHOD("set_sdfgi_read_sky_light", "enable"), &Environment::set_sdfgi_read_sky_light); + ClassDB::bind_method(D_METHOD("is_sdfgi_reading_sky_light"), &Environment::is_sdfgi_reading_sky_light); + + ClassDB::bind_method(D_METHOD("set_sdfgi_energy", "amount"), &Environment::set_sdfgi_energy); + ClassDB::bind_method(D_METHOD("get_sdfgi_energy"), &Environment::get_sdfgi_energy); + + ClassDB::bind_method(D_METHOD("set_sdfgi_normal_bias", "bias"), &Environment::set_sdfgi_normal_bias); + ClassDB::bind_method(D_METHOD("get_sdfgi_normal_bias"), &Environment::get_sdfgi_normal_bias); + + ClassDB::bind_method(D_METHOD("set_sdfgi_probe_bias", "bias"), &Environment::set_sdfgi_probe_bias); + ClassDB::bind_method(D_METHOD("get_sdfgi_probe_bias"), &Environment::get_sdfgi_probe_bias); + + ClassDB::bind_method(D_METHOD("set_sdfgi_y_scale", "scale"), &Environment::set_sdfgi_y_scale); + ClassDB::bind_method(D_METHOD("get_sdfgi_y_scale"), &Environment::get_sdfgi_y_scale); + + ADD_GROUP("SDFGI", "sdfgi_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_enabled"), "set_sdfgi_enabled", "is_sdfgi_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_use_multi_bounce"), "set_sdfgi_use_multi_bounce", "is_sdfgi_using_multi_bounce"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_use_occlusion"), "set_sdfgi_use_occlusion", "is_sdfgi_using_occlusion"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdfgi_read_sky_light"), "set_sdfgi_read_sky_light", "is_sdfgi_reading_sky_light"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sdfgi_cascades", PROPERTY_HINT_ENUM, "4 Cascades,6 Cascades,8 Cascades"), "set_sdfgi_cascades", "get_sdfgi_cascades"); + 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"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_cascade0_distance", PROPERTY_HINT_RANGE, "0.1,16384,0.1,or_greater"), "set_sdfgi_cascade0_distance", "get_sdfgi_cascade0_distance"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_max_distance", PROPERTY_HINT_RANGE, "0.1,16384,0.1,or_greater"), "set_sdfgi_max_distance", "get_sdfgi_max_distance"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sdfgi_y_scale", PROPERTY_HINT_ENUM, "Disable,75%,50%"), "set_sdfgi_y_scale", "get_sdfgi_y_scale"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_energy"), "set_sdfgi_energy", "get_sdfgi_energy"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_normal_bias"), "set_sdfgi_normal_bias", "get_sdfgi_normal_bias"); + ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "sdfgi_probe_bias"), "set_sdfgi_probe_bias", "get_sdfgi_probe_bias"); + ClassDB::bind_method(D_METHOD("set_glow_enabled", "enabled"), &Environment::set_glow_enabled); ClassDB::bind_method(D_METHOD("is_glow_enabled"), &Environment::is_glow_enabled); @@ -1128,6 +1307,19 @@ Environment::Environment() { set_fog_color(Color(0.5, 0.6, 0.7)); set_fog_sun_color(Color(1.0, 0.9, 0.7)); + + sdfgi_enabled = false; + sdfgi_cascades = SDFGI_CASCADES_6; + sdfgi_min_cell_size = 0.2; + sdfgi_use_occlusion = false; + sdfgi_use_multibounce = false; + sdfgi_read_sky_light = false; + sdfgi_enhance_ssr = false; + sdfgi_energy = 1.0; + sdfgi_normal_bias = 1.1; + sdfgi_probe_bias = 1.1; + sdfgi_y_scale = SDFGI_Y_SCALE_DISABLED; + _update_sdfgi(); } Environment::~Environment() { diff --git a/scene/resources/environment.h b/scene/resources/environment.h index b8caa59aab..83a5fe939c 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -86,6 +86,18 @@ public: SSAO_BLUR_3x3 }; + enum SDFGICascades { + SDFGI_CASCADES_4, + SDFGI_CASCADES_6, + SDFGI_CASCADES_8, + }; + + enum SDFGIYScale { + SDFGI_Y_SCALE_DISABLED, + SDFGI_Y_SCALE_75_PERCENT, + SDFGI_Y_SCALE_50_PERCENT, + }; + private: RID environment; @@ -163,6 +175,20 @@ private: float fog_height_max; float fog_height_curve; + bool sdfgi_enabled; + SDFGICascades sdfgi_cascades; + float sdfgi_min_cell_size; + bool sdfgi_use_occlusion; + bool sdfgi_use_multibounce; + bool sdfgi_read_sky_light; + bool sdfgi_enhance_ssr; + float sdfgi_energy; + float sdfgi_normal_bias; + float sdfgi_probe_bias; + SDFGIYScale sdfgi_y_scale; + + void _update_sdfgi(); + protected: static void _bind_methods(); virtual void _validate_property(PropertyInfo &property) const; @@ -354,6 +380,45 @@ public: void set_fog_height_curve(float p_distance); float get_fog_height_curve() const; + void set_sdfgi_enabled(bool p_enabled); + bool is_sdfgi_enabled() const; + + void set_sdfgi_cascades(SDFGICascades p_cascades); + SDFGICascades get_sdfgi_cascades() const; + + void set_sdfgi_min_cell_size(float p_size); + float get_sdfgi_min_cell_size() const; + + void set_sdfgi_cascade0_distance(float p_size); + float get_sdfgi_cascade0_distance() const; + + void set_sdfgi_max_distance(float p_size); + float get_sdfgi_max_distance() const; + + void set_sdfgi_use_occlusion(bool p_enable); + bool is_sdfgi_using_occlusion() const; + + void set_sdfgi_use_multi_bounce(bool p_enable); + bool is_sdfgi_using_multi_bounce() const; + + void set_sdfgi_use_enhance_ssr(bool p_enable); + bool is_sdfgi_using_enhance_ssr() const; + + void set_sdfgi_read_sky_light(bool p_enable); + bool is_sdfgi_reading_sky_light() const; + + void set_sdfgi_energy(float p_energy); + float get_sdfgi_energy() const; + + void set_sdfgi_normal_bias(float p_bias); + float get_sdfgi_normal_bias() const; + + void set_sdfgi_probe_bias(float p_bias); + float get_sdfgi_probe_bias() const; + + void set_sdfgi_y_scale(SDFGIYScale p_y_scale); + SDFGIYScale get_sdfgi_y_scale() const; + virtual RID get_rid() const; Environment(); @@ -366,6 +431,8 @@ VARIANT_ENUM_CAST(Environment::ReflectionSource) VARIANT_ENUM_CAST(Environment::ToneMapper) VARIANT_ENUM_CAST(Environment::GlowBlendMode) VARIANT_ENUM_CAST(Environment::SSAOBlur) +VARIANT_ENUM_CAST(Environment::SDFGICascades) +VARIANT_ENUM_CAST(Environment::SDFGIYScale) class CameraEffects : public Resource { GDCLASS(CameraEffects, Resource); |