diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/navigation_polygon.cpp | 2 | ||||
-rw-r--r-- | scene/2d/ray_cast_2d.cpp | 18 | ||||
-rw-r--r-- | scene/2d/ray_cast_2d.h | 3 | ||||
-rw-r--r-- | scene/3d/SCsub | 3 | ||||
-rw-r--r-- | scene/3d/ray_cast.cpp | 18 | ||||
-rw-r--r-- | scene/3d/ray_cast.h | 3 | ||||
-rw-r--r-- | scene/gui/nine_patch_rect.cpp (renamed from scene/gui/patch_9_rect.cpp) | 4 | ||||
-rw-r--r-- | scene/gui/nine_patch_rect.h (renamed from scene/gui/patch_9_rect.h) | 8 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 18 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 4 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 2 | ||||
-rw-r--r-- | scene/register_scene_types.cpp | 11 | ||||
-rw-r--r-- | scene/resources/environment.cpp | 73 | ||||
-rw-r--r-- | scene/resources/environment.h | 29 | ||||
-rw-r--r-- | scene/resources/material.cpp | 10 | ||||
-rw-r--r-- | scene/resources/material.h | 2 |
16 files changed, 169 insertions, 39 deletions
diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index 35f94bff59..c53241e985 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -452,7 +452,7 @@ String NavigationPolygonInstance::get_configuration_warning() const { return String(); } - c = Object::cast_to<Node2D>(get_parent()); + c = Object::cast_to<Node2D>(c->get_parent()); } return TTR("NavigationPolygonInstance must be a child or grandchild to a Navigation2D node. It only provides navigation data."); diff --git a/scene/2d/ray_cast_2d.cpp b/scene/2d/ray_cast_2d.cpp index fa656bdcd3..ff23b3183b 100644 --- a/scene/2d/ray_cast_2d.cpp +++ b/scene/2d/ray_cast_2d.cpp @@ -61,6 +61,21 @@ void RayCast2D::set_type_mask(uint32_t p_mask) { type_mask = p_mask; } +void RayCast2D::set_collision_mask_bit(int p_bit, bool p_value) { + + uint32_t mask = get_collision_mask(); + if (p_value) + mask |= 1 << p_bit; + else + mask &= ~(1 << p_bit); + set_collision_mask(mask); +} + +bool RayCast2D::get_collision_mask_bit(int p_bit) const { + + return get_collision_mask() & (1 << p_bit); +} + uint32_t RayCast2D::get_type_mask() const { return type_mask; @@ -279,6 +294,9 @@ void RayCast2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast2D::set_collision_mask); ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast2D::get_collision_mask); + ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast2D::set_collision_mask_bit); + ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast2D::get_collision_mask_bit); + ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast2D::set_type_mask); ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast2D::get_type_mask); diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index da1be84307..c13ddfdc58 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -64,6 +64,9 @@ public: void set_collision_mask(uint32_t p_mask); uint32_t get_collision_mask() const; + void set_collision_mask_bit(int p_bit, bool p_value); + bool get_collision_mask_bit(int p_bit) const; + void set_type_mask(uint32_t p_mask); uint32_t get_type_mask() const; diff --git a/scene/3d/SCsub b/scene/3d/SCsub index 72739b527e..4008f4f196 100644 --- a/scene/3d/SCsub +++ b/scene/3d/SCsub @@ -7,6 +7,9 @@ if env['disable_3d']: env.scene_sources.append("3d/spatial.cpp") env.scene_sources.append("3d/skeleton.cpp") + env.scene_sources.append("3d/particles.cpp") + env.scene_sources.append("3d/visual_instance.cpp") + env.scene_sources.append("3d/scenario_fx.cpp") else: env.add_source_files(env.scene_sources, "*.cpp") diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 296bddf0a3..9f61cc64ea 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -63,6 +63,21 @@ void RayCast::set_type_mask(uint32_t p_mask) { type_mask = p_mask; } +void RayCast::set_collision_mask_bit(int p_bit, bool p_value) { + + uint32_t mask = get_collision_mask(); + if (p_value) + mask |= 1 << p_bit; + else + mask &= ~(1 << p_bit); + set_collision_mask(mask); +} + +bool RayCast::get_collision_mask_bit(int p_bit) const { + + return get_collision_mask() & (1 << p_bit); +} + uint32_t RayCast::get_type_mask() const { return type_mask; @@ -248,6 +263,9 @@ void RayCast::_bind_methods() { ClassDB::bind_method(D_METHOD("set_collision_mask", "mask"), &RayCast::set_collision_mask); ClassDB::bind_method(D_METHOD("get_collision_mask"), &RayCast::get_collision_mask); + ClassDB::bind_method(D_METHOD("set_collision_mask_bit", "bit", "value"), &RayCast::set_collision_mask_bit); + ClassDB::bind_method(D_METHOD("get_collision_mask_bit", "bit"), &RayCast::get_collision_mask_bit); + ClassDB::bind_method(D_METHOD("set_type_mask", "mask"), &RayCast::set_type_mask); ClassDB::bind_method(D_METHOD("get_type_mask"), &RayCast::get_type_mask); diff --git a/scene/3d/ray_cast.h b/scene/3d/ray_cast.h index cd3cf3c913..cac1596264 100644 --- a/scene/3d/ray_cast.h +++ b/scene/3d/ray_cast.h @@ -72,6 +72,9 @@ public: void set_collision_mask(uint32_t p_mask); uint32_t get_collision_mask() const; + void set_collision_mask_bit(int p_bit, bool p_value); + bool get_collision_mask_bit(int p_bit) const; + void set_type_mask(uint32_t p_mask); uint32_t get_type_mask() const; diff --git a/scene/gui/patch_9_rect.cpp b/scene/gui/nine_patch_rect.cpp index 92c34dd3f9..c02d80bba8 100644 --- a/scene/gui/patch_9_rect.cpp +++ b/scene/gui/nine_patch_rect.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* patch_9_rect.cpp */ +/* nine_patch_rect.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,7 +27,7 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "patch_9_rect.h" +#include "nine_patch_rect.h" #include "servers/visual_server.h" diff --git a/scene/gui/patch_9_rect.h b/scene/gui/nine_patch_rect.h index 808b7a1f5d..809daf9db3 100644 --- a/scene/gui/patch_9_rect.h +++ b/scene/gui/nine_patch_rect.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* patch_9_rect.h */ +/* nine_patch_rect.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef PATCH_9_FRAME_H -#define PATCH_9_FRAME_H +#ifndef NINE_PATCH_RECT_H +#define NINE_PATCH_RECT_H #include "scene/gui/control.h" /** @@ -81,4 +81,4 @@ public: }; VARIANT_ENUM_CAST(NinePatchRect::AxisStretchMode) -#endif // PATCH_9_FRAME_H +#endif // NINE_PATCH_RECT_H diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 977ba2da7c..acf6d55eb5 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -734,7 +734,7 @@ void TextEdit::_notification(int p_what) { if (str.length() == 0) { // draw line background if empty as we won't loop at at all - if (line == cursor.line) { + if (line == cursor.line && highlight_current_line) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); } @@ -965,7 +965,7 @@ void TextEdit::_notification(int p_what) { //current line highlighting bool in_selection = (selection.active && line >= selection.from_line && line <= selection.to_line && (line > selection.from_line || j >= selection.from_column) && (line < selection.to_line || j < selection.to_column)); - if (line == cursor.line) { + if (line == cursor.line && highlight_current_line) { // if its the first char draw behind line numbers if (j == 0) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, (char_ofs + char_margin), get_row_height()), cache.current_line_color); @@ -4732,6 +4732,15 @@ int TextEdit::get_breakpoint_gutter_width() const { return cache.breakpoint_gutter_width; } +void TextEdit::set_highlight_current_line(bool p_enabled) { + highlight_current_line = p_enabled; + update(); +} + +bool TextEdit::is_highlight_current_line_enabled() const { + return highlight_current_line; +} + bool TextEdit::is_text_field() const { return true; @@ -4859,6 +4868,9 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_syntax_coloring", "enable"), &TextEdit::set_syntax_coloring); ClassDB::bind_method(D_METHOD("is_syntax_coloring_enabled"), &TextEdit::is_syntax_coloring_enabled); + ClassDB::bind_method(D_METHOD("set_highlight_current_line", "enabled"), &TextEdit::set_highlight_current_line); + ClassDB::bind_method(D_METHOD("is_highlight_current_line_enabled"), &TextEdit::is_highlight_current_line_enabled); + ClassDB::bind_method(D_METHOD("set_smooth_scroll_enable", "enable"), &TextEdit::set_smooth_scroll_enabled); ClassDB::bind_method(D_METHOD("is_smooth_scroll_enabled"), &TextEdit::is_smooth_scroll_enabled); ClassDB::bind_method(D_METHOD("set_v_scroll_speed", "speed"), &TextEdit::set_v_scroll_speed); @@ -4870,6 +4882,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled"); @@ -4991,6 +5004,7 @@ TextEdit::TextEdit() { auto_brace_completion_enabled = false; brace_matching_enabled = false; highlight_all_occurrences = false; + highlight_current_line = false; indent_using_spaces = false; space_indent = " "; auto_indent = false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 03f412729d..b4b14d0139 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -253,6 +253,7 @@ class TextEdit : public Control { bool scroll_past_end_of_file_enabled; bool auto_brace_completion_enabled; bool brace_matching_enabled; + bool highlight_current_line; bool auto_indent; bool cut_copy_line; bool insert_mode; @@ -514,6 +515,9 @@ public: void set_show_line_numbers(bool p_show); bool is_show_line_numbers_enabled() const; + void set_highlight_current_line(bool p_enabled); + bool is_highlight_current_line_enabled() const; + void set_line_numbers_zero_padded(bool p_zero_padded); void set_show_line_length_guideline(bool p_show); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 931dcfed91..5c6f2b0d01 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1126,7 +1126,7 @@ int Tree::draw_item(const Point2i &p_pos, const Point2 &p_draw_ofs, const Size2 if (p_item->cells[i].selected && select_mode != SELECT_ROW) { - Rect2i r(item_rect.position, item_rect.size); + Rect2i r(cell_rect.position, cell_rect.size); if (p_item->cells[i].text.size() > 0) { float icon_width = p_item->cells[i].get_icon_size().width; r.position.x += icon_width; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index 75268aad1f..4d3e2c709c 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -86,7 +86,7 @@ #include "scene/gui/option_button.h" #include "scene/gui/panel.h" #include "scene/gui/panel_container.h" -#include "scene/gui/patch_9_rect.h" +#include "scene/gui/nine_patch_rect.h" #include "scene/gui/popup_menu.h" #include "scene/gui/progress_bar.h" #include "scene/gui/reference_rect.h" @@ -152,6 +152,10 @@ #include "scene/resources/world_2d.h" #include "scene/scene_string_names.h" +#include "scene/3d/particles.h" +#include "scene/3d/scenario_fx.h" +#include "scene/3d/spatial.h" + #ifndef _3D_DISABLED #include "scene/3d/area.h" #include "scene/3d/arvr_nodes.h" @@ -169,7 +173,6 @@ #include "scene/3d/multimesh_instance.h" #include "scene/3d/navigation.h" #include "scene/3d/navigation_mesh.h" -#include "scene/3d/particles.h" #include "scene/3d/path.h" #include "scene/3d/physics_body.h" #include "scene/3d/physics_joint.h" @@ -180,9 +183,7 @@ #include "scene/3d/reflection_probe.h" #include "scene/3d/remote_transform.h" #include "scene/3d/room_instance.h" -#include "scene/3d/scenario_fx.h" #include "scene/3d/skeleton.h" -#include "scene/3d/spatial.h" #include "scene/3d/sprite_3d.h" #include "scene/3d/vehicle_body.h" #include "scene/3d/visibility_notifier.h" @@ -551,7 +552,9 @@ void register_scene_types() { ClassDB::register_class<AudioStreamPlayer>(); ClassDB::register_class<AudioStreamPlayer2D>(); +#ifndef _3D_DISABLED ClassDB::register_class<AudioStreamPlayer3D>(); +#endif ClassDB::register_virtual_class<VideoStream>(); ClassDB::register_class<AudioStreamSample>(); diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 4c6fa7c8a1..232f690074 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -377,7 +377,7 @@ bool Environment::is_ssr_rough() const { void Environment::set_ssao_enabled(bool p_enable) { ssao_enabled = p_enable; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); _change_notify(); } @@ -389,7 +389,7 @@ bool Environment::is_ssao_enabled() const { void Environment::set_ssao_radius(float p_radius) { ssao_radius = p_radius; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_radius() const { @@ -399,7 +399,7 @@ float Environment::get_ssao_radius() const { void Environment::set_ssao_intensity(float p_intensity) { ssao_intensity = p_intensity; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_intensity() const { @@ -410,7 +410,7 @@ float Environment::get_ssao_intensity() const { void Environment::set_ssao_radius2(float p_radius) { ssao_radius2 = p_radius; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_radius2() const { @@ -420,7 +420,7 @@ float Environment::get_ssao_radius2() const { void Environment::set_ssao_intensity2(float p_intensity) { ssao_intensity2 = p_intensity; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_intensity2() const { @@ -430,7 +430,7 @@ float Environment::get_ssao_intensity2() const { void Environment::set_ssao_bias(float p_bias) { ssao_bias = p_bias; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_bias() const { @@ -440,7 +440,7 @@ float Environment::get_ssao_bias() const { void Environment::set_ssao_direct_light_affect(float p_direct_light_affect) { ssao_direct_light_affect = p_direct_light_affect; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } float Environment::get_ssao_direct_light_affect() const { @@ -450,7 +450,7 @@ float Environment::get_ssao_direct_light_affect() const { void Environment::set_ssao_color(const Color &p_color) { ssao_color = p_color; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } Color Environment::get_ssao_color() const { @@ -458,16 +458,38 @@ Color Environment::get_ssao_color() const { return ssao_color; } -void Environment::set_ssao_blur(bool p_enable) { +void Environment::set_ssao_blur(SSAOBlur p_blur) { - ssao_blur = p_enable; - VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, ssao_blur); + ssao_blur = p_blur; + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); } -bool Environment::is_ssao_blur_enabled() const { +Environment::SSAOBlur Environment::get_ssao_blur() const { return ssao_blur; } +void Environment::set_ssao_quality(SSAOQuality p_quality) { + + ssao_quality = p_quality; + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); +} + +Environment::SSAOQuality Environment::get_ssao_quality() const { + + return ssao_quality; +} + +void Environment::set_ssao_edge_sharpness(float p_edge_sharpness) { + + ssao_edge_sharpness = p_edge_sharpness; + VS::get_singleton()->environment_set_ssao(environment, ssao_enabled, ssao_radius, ssao_intensity, ssao_radius2, ssao_intensity2, ssao_bias, ssao_direct_light_affect, ssao_color, VS::EnvironmentSSAOQuality(ssao_quality), VS::EnvironmentSSAOBlur(ssao_blur), ssao_edge_sharpness); +} + +float Environment::get_ssao_edge_sharpness() const { + + return ssao_edge_sharpness; +} + void Environment::set_glow_enabled(bool p_enabled) { glow_enabled = p_enabled; @@ -988,8 +1010,14 @@ void Environment::_bind_methods() { ClassDB::bind_method(D_METHOD("set_ssao_color", "color"), &Environment::set_ssao_color); ClassDB::bind_method(D_METHOD("get_ssao_color"), &Environment::get_ssao_color); - ClassDB::bind_method(D_METHOD("set_ssao_blur", "enabled"), &Environment::set_ssao_blur); - ClassDB::bind_method(D_METHOD("is_ssao_blur_enabled"), &Environment::is_ssao_blur_enabled); + ClassDB::bind_method(D_METHOD("set_ssao_blur", "mode"), &Environment::set_ssao_blur); + ClassDB::bind_method(D_METHOD("get_ssao_blur"), &Environment::get_ssao_blur); + + ClassDB::bind_method(D_METHOD("set_ssao_quality", "quality"), &Environment::set_ssao_quality); + ClassDB::bind_method(D_METHOD("get_ssao_quality"), &Environment::get_ssao_quality); + + ClassDB::bind_method(D_METHOD("set_ssao_edge_sharpness", "edge_sharpness"), &Environment::set_ssao_edge_sharpness); + ClassDB::bind_method(D_METHOD("get_ssao_edge_sharpness"), &Environment::get_ssao_edge_sharpness); ADD_GROUP("SSAO", "ssao_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssao_enabled"), "set_ssao_enabled", "is_ssao_enabled"); @@ -1000,7 +1028,9 @@ void Environment::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_bias", PROPERTY_HINT_RANGE, "0.001,8,0.001"), "set_ssao_bias", "get_ssao_bias"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_light_affect", PROPERTY_HINT_RANGE, "0.00,1,0.01"), "set_ssao_direct_light_affect", "get_ssao_direct_light_affect"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "ssao_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_ssao_color", "get_ssao_color"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ssao_blur"), "set_ssao_blur", "is_ssao_blur_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "ssao_quality", PROPERTY_HINT_ENUM, "Low,Medium,High"), "set_ssao_quality", "get_ssao_quality"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "ssao_blur", PROPERTY_HINT_ENUM, "Disabled,1x1,2x2,3x3"), "set_ssao_blur", "get_ssao_blur"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "ssao_edge_sharpness", PROPERTY_HINT_RANGE, "0,32,0.01"), "set_ssao_edge_sharpness", "get_ssao_edge_sharpness"); ClassDB::bind_method(D_METHOD("set_dof_blur_far_enabled", "enabled"), &Environment::set_dof_blur_far_enabled); ClassDB::bind_method(D_METHOD("is_dof_blur_far_enabled"), &Environment::is_dof_blur_far_enabled); @@ -1134,6 +1164,15 @@ void Environment::_bind_methods() { BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_LOW); BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_MEDIUM); BIND_ENUM_CONSTANT(DOF_BLUR_QUALITY_HIGH); + + BIND_ENUM_CONSTANT(SSAO_BLUR_DISABLED); + BIND_ENUM_CONSTANT(SSAO_BLUR_1x1); + BIND_ENUM_CONSTANT(SSAO_BLUR_2x2); + BIND_ENUM_CONSTANT(SSAO_BLUR_3x3); + + BIND_ENUM_CONSTANT(SSAO_QUALITY_LOW); + BIND_ENUM_CONSTANT(SSAO_QUALITY_MEDIUM); + BIND_ENUM_CONSTANT(SSAO_QUALITY_HIGH); } Environment::Environment() { @@ -1179,7 +1218,9 @@ Environment::Environment() { ssao_intensity2 = 1; ssao_bias = 0.01; ssao_direct_light_affect = false; - ssao_blur = true; + ssao_blur = SSAO_BLUR_3x3; + set_ssao_edge_sharpness(4); + set_ssao_quality(SSAO_QUALITY_LOW); glow_enabled = false; glow_levels = (1 << 2) | (1 << 4); diff --git a/scene/resources/environment.h b/scene/resources/environment.h index 5909846074..418949a6ad 100644 --- a/scene/resources/environment.h +++ b/scene/resources/environment.h @@ -71,6 +71,19 @@ public: DOF_BLUR_QUALITY_HIGH, }; + enum SSAOBlur { + SSAO_BLUR_DISABLED, + SSAO_BLUR_1x1, + SSAO_BLUR_2x2, + SSAO_BLUR_3x3 + }; + + enum SSAOQuality { + SSAO_QUALITY_LOW, + SSAO_QUALITY_MEDIUM, + SSAO_QUALITY_HIGH + }; + private: RID environment; @@ -114,7 +127,9 @@ private: float ssao_bias; float ssao_direct_light_affect; Color ssao_color; - bool ssao_blur; + SSAOBlur ssao_blur; + float ssao_edge_sharpness; + SSAOQuality ssao_quality; bool glow_enabled; int glow_levels; @@ -261,8 +276,14 @@ public: void set_ssao_color(const Color &p_color); Color get_ssao_color() const; - void set_ssao_blur(bool p_enable); - bool is_ssao_blur_enabled() const; + void set_ssao_blur(SSAOBlur p_blur); + SSAOBlur get_ssao_blur() const; + + void set_ssao_quality(SSAOQuality p_quality); + SSAOQuality get_ssao_quality() const; + + void set_ssao_edge_sharpness(float p_edge_sharpness); + float get_ssao_edge_sharpness() const; void set_glow_enabled(bool p_enabled); bool is_glow_enabled() const; @@ -370,5 +391,7 @@ VARIANT_ENUM_CAST(Environment::BGMode) VARIANT_ENUM_CAST(Environment::ToneMapper) VARIANT_ENUM_CAST(Environment::GlowBlendMode) VARIANT_ENUM_CAST(Environment::DOFBlurQuality) +VARIANT_ENUM_CAST(Environment::SSAOQuality) +VARIANT_ENUM_CAST(Environment::SSAOBlur) #endif // ENVIRONMENT_H diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index b22a019319..12434b39fa 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -377,7 +377,7 @@ void SpatialMaterial::_update_shader() { case DIFFUSE_TOON: code += ",diffuse_toon"; break; } switch (specular_mode) { - case SPECULAR_GGX: code += ",specular_ggx"; break; + case SPECULAR_SCHLICK_GGX: code += ",specular_schlick_ggx"; break; case SPECULAR_BLINN: code += ",specular_blinn"; break; case SPECULAR_PHONG: code += ",specular_phong"; break; case SPECULAR_TOON: code += ",specular_toon"; break; @@ -1278,7 +1278,7 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { property.usage = 0; } - if (property.name == "proximity_fade_distacne" && !proximity_fade_enabled) { + if (property.name == "proximity_fade_distance" && !proximity_fade_enabled) { property.usage = 0; } @@ -1819,7 +1819,7 @@ void SpatialMaterial::_bind_methods() { ADD_GROUP("Parameters", "params_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Burley,Lambert,Lambert Wrap,Oren Nayar,Toon"), "set_diffuse_mode", "get_diffuse_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "GGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never,Opaque Pre-Pass"), "set_depth_draw_mode", "get_depth_draw_mode"); @@ -2006,7 +2006,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(DIFFUSE_OREN_NAYAR); BIND_ENUM_CONSTANT(DIFFUSE_TOON); - BIND_ENUM_CONSTANT(SPECULAR_GGX); + BIND_ENUM_CONSTANT(SPECULAR_SCHLICK_GGX); BIND_ENUM_CONSTANT(SPECULAR_BLINN); BIND_ENUM_CONSTANT(SPECULAR_PHONG); BIND_ENUM_CONSTANT(SPECULAR_TOON); @@ -2087,7 +2087,7 @@ SpatialMaterial::SpatialMaterial() flags[i] = 0; } diffuse_mode = DIFFUSE_LAMBERT; - specular_mode = SPECULAR_GGX; + specular_mode = SPECULAR_SCHLICK_GGX; for (int i = 0; i < FEATURE_MAX; i++) { features[i] = false; diff --git a/scene/resources/material.h b/scene/resources/material.h index 942fb42363..2425f1a174 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -193,7 +193,7 @@ public: }; enum SpecularMode { - SPECULAR_GGX, + SPECULAR_SCHLICK_GGX, SPECULAR_BLINN, SPECULAR_PHONG, SPECULAR_TOON, |