diff options
Diffstat (limited to 'scene')
-rw-r--r-- | scene/2d/light_occluder_2d.cpp | 14 | ||||
-rw-r--r-- | scene/2d/light_occluder_2d.h | 5 | ||||
-rw-r--r-- | scene/main/scene_tree.cpp | 8 | ||||
-rw-r--r-- | scene/main/viewport.cpp | 42 | ||||
-rw-r--r-- | scene/main/viewport.h | 26 | ||||
-rw-r--r-- | scene/resources/resource_format_text.cpp | 5 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.cpp | 15 | ||||
-rw-r--r-- | scene/resources/visual_shader_nodes.h | 1 |
8 files changed, 115 insertions, 1 deletions
diff --git a/scene/2d/light_occluder_2d.cpp b/scene/2d/light_occluder_2d.cpp index 0531762ed8..6908fbeada 100644 --- a/scene/2d/light_occluder_2d.cpp +++ b/scene/2d/light_occluder_2d.cpp @@ -265,6 +265,14 @@ String LightOccluder2D::get_configuration_warning() const { return warning; } +void LightOccluder2D::set_as_sdf_collision(bool p_enable) { + sdf_collision = p_enable; + RS::get_singleton()->canvas_light_occluder_set_as_sdf_collision(occluder, sdf_collision); +} +bool LightOccluder2D::is_set_as_sdf_collision() const { + return sdf_collision; +} + void LightOccluder2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_occluder_polygon", "polygon"), &LightOccluder2D::set_occluder_polygon); ClassDB::bind_method(D_METHOD("get_occluder_polygon"), &LightOccluder2D::get_occluder_polygon); @@ -272,14 +280,20 @@ void LightOccluder2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_occluder_light_mask", "mask"), &LightOccluder2D::set_occluder_light_mask); ClassDB::bind_method(D_METHOD("get_occluder_light_mask"), &LightOccluder2D::get_occluder_light_mask); + ClassDB::bind_method(D_METHOD("set_as_sdf_collision", "enable"), &LightOccluder2D::set_as_sdf_collision); + ClassDB::bind_method(D_METHOD("is_set_as_sdf_collision"), &LightOccluder2D::is_set_as_sdf_collision); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "occluder", PROPERTY_HINT_RESOURCE_TYPE, "OccluderPolygon2D"), "set_occluder_polygon", "get_occluder_polygon"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "sdf_collision"), "set_as_sdf_collision", "is_set_as_sdf_collision"); ADD_PROPERTY(PropertyInfo(Variant::INT, "light_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_occluder_light_mask", "get_occluder_light_mask"); } LightOccluder2D::LightOccluder2D() { occluder = RS::get_singleton()->canvas_light_occluder_create(); mask = 1; + set_notify_transform(true); + set_as_sdf_collision(true); } LightOccluder2D::~LightOccluder2D() { diff --git a/scene/2d/light_occluder_2d.h b/scene/2d/light_occluder_2d.h index 694097f985..97574af542 100644 --- a/scene/2d/light_occluder_2d.h +++ b/scene/2d/light_occluder_2d.h @@ -84,7 +84,7 @@ class LightOccluder2D : public Node2D { bool enabled; int mask; Ref<OccluderPolygon2D> occluder_polygon; - + bool sdf_collision; void _poly_changed(); protected: @@ -103,6 +103,9 @@ public: void set_occluder_light_mask(int p_mask); int get_occluder_light_mask() const; + void set_as_sdf_collision(bool p_enable); + bool is_set_as_sdf_collision() const; + String get_configuration_warning() const override; LightOccluder2D(); diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index cea6c6f0ae..9e396d4030 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1397,6 +1397,14 @@ SceneTree::SceneTree() { bool snap_2d_vertices = GLOBAL_DEF("rendering/quality/2d/snap_2d_vertices_to_pixel", false); root->set_snap_2d_vertices_to_pixel(snap_2d_vertices); + Viewport::SDFOversize sdf_oversize = Viewport::SDFOversize(int(GLOBAL_DEF("rendering/quality/2d_sdf/oversize", 1))); + root->set_sdf_oversize(sdf_oversize); + Viewport::SDFScale sdf_scale = Viewport::SDFScale(int(GLOBAL_DEF("rendering/quality/2d_sdf/scale", 1))); + root->set_sdf_scale(sdf_scale); + + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d_sdf/oversize", PropertyInfo(Variant::INT, "rendering/quality/2d_sdf/oversize", PROPERTY_HINT_ENUM, "100%,120%,150%,200%")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d_sdf/scale", PropertyInfo(Variant::INT, "rendering/quality/2d_sdf/scale", PROPERTY_HINT_ENUM, "100%,50%,25%")); + { //load default fallback environment //get possible extensions List<String> exts; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index c6d1bb6f9d..8049d4c817 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3388,6 +3388,24 @@ void Viewport::pass_mouse_focus_to(Viewport *p_viewport, Control *p_control) { } } +void Viewport::set_sdf_oversize(SDFOversize p_sdf_oversize) { + ERR_FAIL_INDEX(p_sdf_oversize, SDF_OVERSIZE_MAX); + sdf_oversize = p_sdf_oversize; + RS::get_singleton()->viewport_set_sdf_oversize_and_scale(viewport, RS::ViewportSDFOversize(sdf_oversize), RS::ViewportSDFScale(sdf_scale)); +} +Viewport::SDFOversize Viewport::get_sdf_oversize() const { + return sdf_oversize; +} + +void Viewport::set_sdf_scale(SDFScale p_sdf_scale) { + ERR_FAIL_INDEX(p_sdf_scale, SDF_SCALE_MAX); + sdf_scale = p_sdf_scale; + RS::get_singleton()->viewport_set_sdf_oversize_and_scale(viewport, RS::ViewportSDFOversize(sdf_oversize), RS::ViewportSDFScale(sdf_scale)); +} +Viewport::SDFScale Viewport::get_sdf_scale() const { + return sdf_scale; +} + void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_world_2d", "world_2d"), &Viewport::set_world_2d); ClassDB::bind_method(D_METHOD("get_world_2d"), &Viewport::get_world_2d); @@ -3487,6 +3505,12 @@ void Viewport::_bind_methods() { ClassDB::bind_method(D_METHOD("set_default_canvas_item_texture_repeat", "mode"), &Viewport::set_default_canvas_item_texture_repeat); ClassDB::bind_method(D_METHOD("get_default_canvas_item_texture_repeat"), &Viewport::get_default_canvas_item_texture_repeat); + ClassDB::bind_method(D_METHOD("set_sdf_oversize", "oversize"), &Viewport::set_sdf_oversize); + ClassDB::bind_method(D_METHOD("get_sdf_oversize"), &Viewport::get_sdf_oversize); + + ClassDB::bind_method(D_METHOD("set_sdf_scale", "scale"), &Viewport::set_sdf_scale); + ClassDB::bind_method(D_METHOD("get_sdf_scale"), &Viewport::get_sdf_scale); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "own_world_3d"), "set_use_own_world_3d", "is_using_own_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_3d", PROPERTY_HINT_RESOURCE_TYPE, "World3D"), "set_world_3d", "get_world_3d"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "world_2d", PROPERTY_HINT_RESOURCE_TYPE, "World2D", 0), "set_world_2d", "get_world_2d"); @@ -3511,6 +3535,9 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_embed_subwindows"), "set_embed_subwindows_hint", "get_embed_subwindows_hint"); + ADD_GROUP("SDF", "sdf_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sdf_oversize", PROPERTY_HINT_ENUM, "100%,120%,150%,200%"), "set_sdf_oversize", "get_sdf_oversize"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "sdf_scale", PROPERTY_HINT_ENUM, "100%,50%,25%"), "set_sdf_scale", "get_sdf_scale"); ADD_GROUP("Shadow Atlas", "shadow_atlas_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size"); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_0", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 0); @@ -3580,6 +3607,17 @@ void Viewport::_bind_methods() { BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_ENABLED); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MIRROR); BIND_ENUM_CONSTANT(DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX); + + BIND_ENUM_CONSTANT(SDF_OVERSIZE_100_PERCENT); + BIND_ENUM_CONSTANT(SDF_OVERSIZE_120_PERCENT); + BIND_ENUM_CONSTANT(SDF_OVERSIZE_150_PERCENT); + BIND_ENUM_CONSTANT(SDF_OVERSIZE_200_PERCENT); + BIND_ENUM_CONSTANT(SDF_OVERSIZE_MAX); + + BIND_ENUM_CONSTANT(SDF_SCALE_100_PERCENT); + BIND_ENUM_CONSTANT(SDF_SCALE_50_PERCENT); + BIND_ENUM_CONSTANT(SDF_SCALE_25_PERCENT); + BIND_ENUM_CONSTANT(SDF_SCALE_MAX); } Viewport::Viewport() { @@ -3666,6 +3704,10 @@ Viewport::Viewport() { default_canvas_item_texture_filter = DEFAULT_CANVAS_ITEM_TEXTURE_FILTER_LINEAR; default_canvas_item_texture_repeat = DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; + + sdf_oversize = SDF_OVERSIZE_120_PERCENT; + sdf_scale = SDF_SCALE_50_PERCENT; + set_sdf_oversize(SDF_OVERSIZE_120_PERCENT); //set to server } Viewport::~Viewport() { diff --git a/scene/main/viewport.h b/scene/main/viewport.h index 4be66ae79f..7ce202d27c 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -159,6 +159,21 @@ public: DEFAULT_CANVAS_ITEM_TEXTURE_REPEAT_MAX, }; + enum SDFOversize { + SDF_OVERSIZE_100_PERCENT, + SDF_OVERSIZE_120_PERCENT, + SDF_OVERSIZE_150_PERCENT, + SDF_OVERSIZE_200_PERCENT, + SDF_OVERSIZE_MAX + }; + + enum SDFScale { + SDF_SCALE_100_PERCENT, + SDF_SCALE_50_PERCENT, + SDF_SCALE_25_PERCENT, + SDF_SCALE_MAX + }; + enum { SUBWINDOW_CANVAS_LAYER = 1024 }; @@ -285,6 +300,9 @@ private: Ref<ViewportTexture> default_texture; Set<ViewportTexture *> viewport_textures; + SDFOversize sdf_oversize; + SDFScale sdf_scale; + enum SubWindowDrag { SUB_WINDOW_DRAG_DISABLED, SUB_WINDOW_DRAG_MOVE, @@ -572,6 +590,12 @@ public: bool gui_is_dragging() const; + void set_sdf_oversize(SDFOversize p_sdf_oversize); + SDFOversize get_sdf_oversize() const; + + void set_sdf_scale(SDFScale p_sdf_scale); + SDFScale get_sdf_scale() const; + void set_default_canvas_item_texture_filter(DefaultCanvasItemTextureFilter p_filter); DefaultCanvasItemTextureFilter get_default_canvas_item_texture_filter() const; @@ -650,6 +674,8 @@ VARIANT_ENUM_CAST(Viewport::ShadowAtlasQuadrantSubdiv); VARIANT_ENUM_CAST(Viewport::MSAA); VARIANT_ENUM_CAST(Viewport::ScreenSpaceAA); VARIANT_ENUM_CAST(Viewport::DebugDraw); +VARIANT_ENUM_CAST(Viewport::SDFScale); +VARIANT_ENUM_CAST(Viewport::SDFOversize); VARIANT_ENUM_CAST(SubViewport::ClearMode); VARIANT_ENUM_CAST(Viewport::RenderInfo); VARIANT_ENUM_CAST(Viewport::DefaultCanvasItemTextureFilter); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 1d5f29ab14..cf8be8fe15 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -838,6 +838,11 @@ Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_p f->seek(tag_end); uint8_t c = f->get_8(); + if (c == '\n' && !f->eof_reached()) { + // Skip first newline character since we added one + c = f->get_8(); + } + while (!f->eof_reached()) { fw->store_8(c); c = f->get_8(); diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp index 704d1b2ea8..a3358ea8c7 100644 --- a/scene/resources/visual_shader_nodes.cpp +++ b/scene/resources/visual_shader_nodes.cpp @@ -724,6 +724,10 @@ Vector<StringName> VisualShaderNodeTexture::get_editable_properties() const { } String VisualShaderNodeTexture::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (is_input_port_connected(2) && source != SOURCE_PORT) { + return TTR("The sampler port is connected but not used. Consider changing the source to 'SamplerPort'."); + } + if (source == SOURCE_TEXTURE) { return String(); // all good } @@ -980,6 +984,10 @@ void VisualShaderNodeSample3D::_bind_methods() { } String VisualShaderNodeSample3D::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (is_input_port_connected(2) && source != SOURCE_PORT) { + return TTR("The sampler port is connected but not used. Consider changing the source to 'SamplerPort'."); + } + if (source == SOURCE_TEXTURE) { return String(); // all good } @@ -1276,6 +1284,13 @@ Vector<StringName> VisualShaderNodeCubemap::get_editable_properties() const { return props; } +String VisualShaderNodeCubemap::get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const { + if (is_input_port_connected(2) && source != SOURCE_PORT) { + return TTR("The sampler port is connected but not used. Consider changing the source to 'SamplerPort'."); + } + return String(); +} + void VisualShaderNodeCubemap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubemap::set_source); ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubemap::get_source); diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h index d4d6540baf..4b39c76388 100644 --- a/scene/resources/visual_shader_nodes.h +++ b/scene/resources/visual_shader_nodes.h @@ -448,6 +448,7 @@ public: TextureType get_texture_type() const; virtual Vector<StringName> get_editable_properties() const override; + virtual String get_warning(Shader::Mode p_mode, VisualShader::Type p_type) const override; VisualShaderNodeCubemap(); }; |