diff options
Diffstat (limited to 'servers')
16 files changed, 246 insertions, 86 deletions
diff --git a/servers/extensions/physics_server_2d_extension.cpp b/servers/extensions/physics_server_2d_extension.cpp index c56f31e6f9..36f3be2468 100644 --- a/servers/extensions/physics_server_2d_extension.cpp +++ b/servers/extensions/physics_server_2d_extension.cpp @@ -123,6 +123,8 @@ bool PhysicsServer2DExtension::body_test_motion_is_excluding_object(ObjectID p_o } void PhysicsServer2DExtension::_bind_methods() { + /* SHAPE API */ + GDVIRTUAL_BIND(_world_boundary_shape_create); GDVIRTUAL_BIND(_separation_ray_shape_create); GDVIRTUAL_BIND(_segment_shape_create); @@ -133,18 +135,32 @@ void PhysicsServer2DExtension::_bind_methods() { GDVIRTUAL_BIND(_concave_polygon_shape_create); GDVIRTUAL_BIND(_shape_set_data, "shape", "data"); + GDVIRTUAL_BIND(_shape_set_custom_solver_bias, "shape", "bias"); GDVIRTUAL_BIND(_shape_get_type, "shape"); GDVIRTUAL_BIND(_shape_get_data, "shape"); + GDVIRTUAL_BIND(_shape_get_custom_solver_bias, "shape"); + GDVIRTUAL_BIND(_shape_collide, "shape_A", "xform_A", "motion_A", "shape_B", "xform_B", "motion_B", "results", "result_max", "result_count"); + + /* SPACE API */ GDVIRTUAL_BIND(_space_create); GDVIRTUAL_BIND(_space_set_active, "space", "active"); GDVIRTUAL_BIND(_space_is_active, "space"); + GDVIRTUAL_BIND(_space_set_param, "space", "param", "value"); GDVIRTUAL_BIND(_space_get_param, "space", "param"); + GDVIRTUAL_BIND(_space_get_direct_state, "space"); + GDVIRTUAL_BIND(_space_set_debug_contacts, "space", "max_contacts"); + GDVIRTUAL_BIND(_space_get_contacts, "space"); + GDVIRTUAL_BIND(_space_get_contact_count, "space"); + + /* AREA API */ + GDVIRTUAL_BIND(_area_create); + GDVIRTUAL_BIND(_area_set_space, "area", "space"); GDVIRTUAL_BIND(_area_get_space, "area"); @@ -160,8 +176,11 @@ void PhysicsServer2DExtension::_bind_methods() { GDVIRTUAL_BIND(_area_remove_shape, "area", "shape_idx"); GDVIRTUAL_BIND(_area_clear_shapes, "area"); - GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); - GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); + GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); + GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); + + GDVIRTUAL_BIND(_area_attach_canvas_instance_id, "area", "id"); + GDVIRTUAL_BIND(_area_get_canvas_instance_id, "area"); GDVIRTUAL_BIND(_area_set_param, "area", "param", "value"); GDVIRTUAL_BIND(_area_set_transform, "area", "transform"); @@ -169,15 +188,16 @@ void PhysicsServer2DExtension::_bind_methods() { GDVIRTUAL_BIND(_area_get_param, "area", "param"); GDVIRTUAL_BIND(_area_get_transform, "area"); - GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); - GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); + GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); + GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); - GDVIRTUAL_BIND(_area_attach_canvas_instance_id, "area", "id"); - GDVIRTUAL_BIND(_area_get_canvas_instance_id, "area"); + GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); + GDVIRTUAL_BIND(_area_set_pickable, "area", "pickable"); GDVIRTUAL_BIND(_area_set_monitor_callback, "area", "callback"); GDVIRTUAL_BIND(_area_set_area_monitor_callback, "area", "callback"); - GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); + + /* BODY API */ GDVIRTUAL_BIND(_body_create); @@ -195,12 +215,12 @@ void PhysicsServer2DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_get_shape, "body", "shape_idx"); GDVIRTUAL_BIND(_body_get_shape_transform, "body", "shape_idx"); - GDVIRTUAL_BIND(_body_remove_shape, "body", "shape_idx"); - GDVIRTUAL_BIND(_body_clear_shapes, "body"); - GDVIRTUAL_BIND(_body_set_shape_disabled, "body", "shape_idx", "disabled"); GDVIRTUAL_BIND(_body_set_shape_as_one_way_collision, "body", "shape_idx", "enable", "margin"); + GDVIRTUAL_BIND(_body_remove_shape, "body", "shape_idx"); + GDVIRTUAL_BIND(_body_clear_shapes, "body"); + GDVIRTUAL_BIND(_body_attach_object_instance_id, "body", "id"); GDVIRTUAL_BIND(_body_get_object_instance_id, "body"); @@ -249,25 +269,39 @@ void PhysicsServer2DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_add_collision_exception, "body", "excepted_body"); GDVIRTUAL_BIND(_body_remove_collision_exception, "body", "excepted_body"); + GDVIRTUAL_BIND(_body_get_collision_exceptions, "body"); GDVIRTUAL_BIND(_body_set_max_contacts_reported, "body", "amount"); GDVIRTUAL_BIND(_body_get_max_contacts_reported, "body"); + GDVIRTUAL_BIND(_body_set_contacts_reported_depth_threshold, "body", "threshold"); + GDVIRTUAL_BIND(_body_get_contacts_reported_depth_threshold, "body"); + GDVIRTUAL_BIND(_body_set_omit_force_integration, "body", "enable"); GDVIRTUAL_BIND(_body_is_omitting_force_integration, "body"); + GDVIRTUAL_BIND(_body_set_state_sync_callback, "body", "callback"); GDVIRTUAL_BIND(_body_set_force_integration_callback, "body", "callable", "userdata"); - GDVIRTUAL_BIND(_body_test_motion, "body", "from", "motion", "margin", "collide_separation_ray", "recovery_as_collision", "result"); + GDVIRTUAL_BIND(_body_collide_shape, "body", "body_shape", "shape", "shape_xform", "motion", "results", "result_max", "result_count"); + + GDVIRTUAL_BIND(_body_set_pickable, "body", "pickable"); GDVIRTUAL_BIND(_body_get_direct_state, "body"); + GDVIRTUAL_BIND(_body_test_motion, "body", "from", "motion", "margin", "collide_separation_ray", "recovery_as_collision", "result"); + + /* JOINT API */ + GDVIRTUAL_BIND(_joint_create); GDVIRTUAL_BIND(_joint_clear, "joint"); GDVIRTUAL_BIND(_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_joint_get_param, "joint", "param"); + GDVIRTUAL_BIND(_joint_disable_collisions_between_bodies, "joint", "disable"); + GDVIRTUAL_BIND(_joint_is_disabled_collisions_between_bodies, "joint"); + GDVIRTUAL_BIND(_joint_make_pin, "joint", "anchor", "body_a", "body_b"); GDVIRTUAL_BIND(_joint_make_groove, "joint", "a_groove1", "a_groove2", "b_anchor", "body_a", "body_b"); GDVIRTUAL_BIND(_joint_make_damped_spring, "joint", "anchor_a", "anchor_b", "body_a", "body_b"); @@ -280,6 +314,8 @@ void PhysicsServer2DExtension::_bind_methods() { GDVIRTUAL_BIND(_joint_get_type, "joint"); + /* MISC */ + GDVIRTUAL_BIND(_free_rid, "rid"); GDVIRTUAL_BIND(_set_active, "active"); diff --git a/servers/extensions/physics_server_2d_extension.h b/servers/extensions/physics_server_2d_extension.h index 4c83664b14..3bd3d642c8 100644 --- a/servers/extensions/physics_server_2d_extension.h +++ b/servers/extensions/physics_server_2d_extension.h @@ -204,6 +204,8 @@ protected: public: // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. + /* SHAPE API */ + EXBIND0R(RID, world_boundary_shape_create) EXBIND0R(RID, separation_ray_shape_create) EXBIND0R(RID, segment_shape_create) @@ -252,6 +254,7 @@ public: EXBIND4(area_add_shape, RID, RID, const Transform2D &, bool) EXBIND3(area_set_shape, RID, int, RID) EXBIND3(area_set_shape_transform, RID, int, const Transform2D &) + EXBIND3(area_set_shape_disabled, RID, int, bool) EXBIND1RC(int, area_get_shape_count, RID) EXBIND2RC(RID, area_get_shape, RID, int) @@ -260,8 +263,6 @@ public: EXBIND2(area_remove_shape, RID, int) EXBIND1(area_clear_shapes, RID) - EXBIND3(area_set_shape_disabled, RID, int, bool) - EXBIND2(area_attach_object_instance_id, RID, ObjectID) EXBIND1RC(ObjectID, area_get_object_instance_id, RID) @@ -415,7 +416,6 @@ public: /* JOINT API */ EXBIND0R(RID, joint_create) - EXBIND1(joint_clear, RID) EXBIND3(joint_set_param, RID, JointParam, real_t) diff --git a/servers/extensions/physics_server_3d_extension.cpp b/servers/extensions/physics_server_3d_extension.cpp index 6ed5dca968..800284dc60 100644 --- a/servers/extensions/physics_server_3d_extension.cpp +++ b/servers/extensions/physics_server_3d_extension.cpp @@ -125,6 +125,8 @@ bool PhysicsServer3DExtension::body_test_motion_is_excluding_object(ObjectID p_o } void PhysicsServer3DExtension::_bind_methods() { + /* SHAPE API */ + GDVIRTUAL_BIND(_world_boundary_shape_create); GDVIRTUAL_BIND(_separation_ray_shape_create); GDVIRTUAL_BIND(_sphere_shape_create); @@ -137,18 +139,34 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_custom_shape_create); GDVIRTUAL_BIND(_shape_set_data, "shape", "data"); + GDVIRTUAL_BIND(_shape_set_custom_solver_bias, "shape", "bias"); + + GDVIRTUAL_BIND(_shape_set_margin, "shape", "margin"); + GDVIRTUAL_BIND(_shape_get_margin, "shape"); GDVIRTUAL_BIND(_shape_get_type, "shape"); GDVIRTUAL_BIND(_shape_get_data, "shape"); + GDVIRTUAL_BIND(_shape_get_custom_solver_bias, "shape"); + + /* SPACE API */ GDVIRTUAL_BIND(_space_create); GDVIRTUAL_BIND(_space_set_active, "space", "active"); GDVIRTUAL_BIND(_space_is_active, "space"); + GDVIRTUAL_BIND(_space_set_param, "space", "param", "value"); GDVIRTUAL_BIND(_space_get_param, "space", "param"); + GDVIRTUAL_BIND(_space_get_direct_state, "space"); + GDVIRTUAL_BIND(_space_set_debug_contacts, "space", "max_contacts"); + GDVIRTUAL_BIND(_space_get_contacts, "space"); + GDVIRTUAL_BIND(_space_get_contact_count, "space"); + + /* AREA API */ + GDVIRTUAL_BIND(_area_create); + GDVIRTUAL_BIND(_area_set_space, "area", "space"); GDVIRTUAL_BIND(_area_get_space, "area"); @@ -164,8 +182,8 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_area_remove_shape, "area", "shape_idx"); GDVIRTUAL_BIND(_area_clear_shapes, "area"); - GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); - GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); + GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); + GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); GDVIRTUAL_BIND(_area_set_param, "area", "param", "value"); GDVIRTUAL_BIND(_area_set_transform, "area", "transform"); @@ -173,14 +191,16 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_area_get_param, "area", "param"); GDVIRTUAL_BIND(_area_get_transform, "area"); - GDVIRTUAL_BIND(_area_attach_object_instance_id, "area", "id"); - GDVIRTUAL_BIND(_area_get_object_instance_id, "area"); + GDVIRTUAL_BIND(_area_set_collision_layer, "area", "layer"); + GDVIRTUAL_BIND(_area_set_collision_mask, "area", "mask"); + + GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); + GDVIRTUAL_BIND(_area_set_ray_pickable, "area", "enable"); GDVIRTUAL_BIND(_area_set_monitor_callback, "area", "callback"); GDVIRTUAL_BIND(_area_set_area_monitor_callback, "area", "callback"); - GDVIRTUAL_BIND(_area_set_monitorable, "area", "monitorable"); - GDVIRTUAL_BIND(_area_set_ray_pickable, "area", "enable"); + /* BODY API */ GDVIRTUAL_BIND(_body_create); @@ -190,15 +210,6 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_set_mode, "body", "mode"); GDVIRTUAL_BIND(_body_get_mode, "body"); - GDVIRTUAL_BIND(_body_set_collision_layer, "body", "layer"); - GDVIRTUAL_BIND(_body_get_collision_layer, "body"); - - GDVIRTUAL_BIND(_body_set_collision_mask, "body", "mask"); - GDVIRTUAL_BIND(_body_get_collision_mask, "body"); - - GDVIRTUAL_BIND(_body_set_collision_priority, "body", "priority"); - GDVIRTUAL_BIND(_body_get_collision_priority, "body"); - GDVIRTUAL_BIND(_body_add_shape, "body", "shape", "transform", "disabled"); GDVIRTUAL_BIND(_body_set_shape, "body", "shape_idx", "shape"); GDVIRTUAL_BIND(_body_set_shape_transform, "body", "shape_idx", "transform"); @@ -217,6 +228,18 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_set_enable_continuous_collision_detection, "body", "enable"); GDVIRTUAL_BIND(_body_is_continuous_collision_detection_enabled, "body"); + GDVIRTUAL_BIND(_body_set_collision_layer, "body", "layer"); + GDVIRTUAL_BIND(_body_get_collision_layer, "body"); + + GDVIRTUAL_BIND(_body_set_collision_mask, "body", "mask"); + GDVIRTUAL_BIND(_body_get_collision_mask, "body"); + + GDVIRTUAL_BIND(_body_set_collision_priority, "body", "priority"); + GDVIRTUAL_BIND(_body_get_collision_priority, "body"); + + GDVIRTUAL_BIND(_body_set_user_flags, "body", "flags"); + GDVIRTUAL_BIND(_body_get_user_flags, "body"); + GDVIRTUAL_BIND(_body_set_param, "body", "param", "value"); GDVIRTUAL_BIND(_body_get_param, "body", "param"); @@ -250,13 +273,18 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_add_collision_exception, "body", "excepted_body"); GDVIRTUAL_BIND(_body_remove_collision_exception, "body", "excepted_body"); + GDVIRTUAL_BIND(_body_get_collision_exceptions, "body"); GDVIRTUAL_BIND(_body_set_max_contacts_reported, "body", "amount"); GDVIRTUAL_BIND(_body_get_max_contacts_reported, "body"); + GDVIRTUAL_BIND(_body_set_contacts_reported_depth_threshold, "body", "threshold"); + GDVIRTUAL_BIND(_body_get_contacts_reported_depth_threshold, "body"); + GDVIRTUAL_BIND(_body_set_omit_force_integration, "body", "enable"); GDVIRTUAL_BIND(_body_is_omitting_force_integration, "body"); + GDVIRTUAL_BIND(_body_set_state_sync_callback, "body", "callback"); GDVIRTUAL_BIND(_body_set_force_integration_callback, "body", "callable", "userdata"); GDVIRTUAL_BIND(_body_set_ray_pickable, "body", "enable"); @@ -265,12 +293,68 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_body_get_direct_state, "body"); + /* SOFT BODY API */ + + GDVIRTUAL_BIND(_soft_body_create); + + GDVIRTUAL_BIND(_soft_body_update_rendering_server, "body", "rendering_server_handler"); + + GDVIRTUAL_BIND(_soft_body_set_space, "body", "space"); + GDVIRTUAL_BIND(_soft_body_get_space, "body"); + + GDVIRTUAL_BIND(_soft_body_set_ray_pickable, "body", "enable"); + + GDVIRTUAL_BIND(_soft_body_set_collision_layer, "body", "layer"); + GDVIRTUAL_BIND(_soft_body_get_collision_layer, "body"); + + GDVIRTUAL_BIND(_soft_body_set_collision_mask, "body", "mask"); + GDVIRTUAL_BIND(_soft_body_get_collision_mask, "body"); + + GDVIRTUAL_BIND(_soft_body_add_collision_exception, "body", "body_b"); + GDVIRTUAL_BIND(_soft_body_remove_collision_exception, "body", "body_b"); + GDVIRTUAL_BIND(_soft_body_get_collision_exceptions, "body"); + + GDVIRTUAL_BIND(_soft_body_set_state, "body", "state", "variant"); + GDVIRTUAL_BIND(_soft_body_get_state, "body", "state"); + + GDVIRTUAL_BIND(_soft_body_set_transform, "body", "transform"); + + GDVIRTUAL_BIND(_soft_body_set_simulation_precision, "body", "simulation_precision"); + GDVIRTUAL_BIND(_soft_body_get_simulation_precision, "body"); + + GDVIRTUAL_BIND(_soft_body_set_total_mass, "body", "total_mass"); + GDVIRTUAL_BIND(_soft_body_get_total_mass, "body"); + + GDVIRTUAL_BIND(_soft_body_set_linear_stiffness, "body", "linear_stiffness"); + GDVIRTUAL_BIND(_soft_body_get_linear_stiffness, "body"); + + GDVIRTUAL_BIND(_soft_body_set_pressure_coefficient, "body", "pressure_coefficient"); + GDVIRTUAL_BIND(_soft_body_get_pressure_coefficient, "body"); + + GDVIRTUAL_BIND(_soft_body_set_damping_coefficient, "body", "damping_coefficient"); + GDVIRTUAL_BIND(_soft_body_get_damping_coefficient, "body"); + + GDVIRTUAL_BIND(_soft_body_set_drag_coefficient, "body", "drag_coefficient"); + GDVIRTUAL_BIND(_soft_body_get_drag_coefficient, "body"); + + GDVIRTUAL_BIND(_soft_body_set_mesh, "body", "mesh"); + GDVIRTUAL_BIND(_soft_body_get_bounds, "body"); + GDVIRTUAL_BIND(_soft_body_move_point, "body", "point_index", "global_position"); + GDVIRTUAL_BIND(_soft_body_get_point_global_position, "body", "point_index"); + + GDVIRTUAL_BIND(_soft_body_remove_all_pinned_points, "body"); + GDVIRTUAL_BIND(_soft_body_pin_point, "body", "point_index", "pin"); + GDVIRTUAL_BIND(_soft_body_is_point_pinned, "body", "point_index"); + + /* JOINT API */ + GDVIRTUAL_BIND(_joint_create); GDVIRTUAL_BIND(_joint_clear, "joint"); GDVIRTUAL_BIND(_joint_make_pin, "joint", "body_A", "local_A", "body_B", "local_B"); + GDVIRTUAL_BIND(_pin_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_pin_joint_get_param, "joint", "param"); @@ -281,6 +365,7 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_pin_joint_get_local_b, "joint"); GDVIRTUAL_BIND(_joint_make_hinge, "joint", "body_A", "hinge_A", "body_B", "hinge_B"); + GDVIRTUAL_BIND(_joint_make_hinge_simple, "joint", "body_A", "pivot_A", "axis_A", "body_B", "pivot_B", "axis_B"); GDVIRTUAL_BIND(_hinge_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_hinge_joint_get_param, "joint", "param"); @@ -298,11 +383,6 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_cone_twist_joint_set_param, "joint", "param", "value"); GDVIRTUAL_BIND(_cone_twist_joint_get_param, "joint", "param"); - GDVIRTUAL_BIND(_joint_get_type, "joint"); - - GDVIRTUAL_BIND(_joint_set_solver_priority, "joint", "priority"); - GDVIRTUAL_BIND(_joint_get_solver_priority, "joint"); - GDVIRTUAL_BIND(_joint_make_generic_6dof, "joint", "body_A", "local_ref_A", "body_B", "local_ref_B"); GDVIRTUAL_BIND(_generic_6dof_joint_set_param, "joint", "axis", "param", "value"); @@ -311,6 +391,11 @@ void PhysicsServer3DExtension::_bind_methods() { GDVIRTUAL_BIND(_generic_6dof_joint_set_flag, "joint", "axis", "flag", "enable"); GDVIRTUAL_BIND(_generic_6dof_joint_get_flag, "joint", "axis", "flag"); + GDVIRTUAL_BIND(_joint_get_type, "joint"); + + GDVIRTUAL_BIND(_joint_set_solver_priority, "joint", "priority"); + GDVIRTUAL_BIND(_joint_get_solver_priority, "joint"); + GDVIRTUAL_BIND(_free_rid, "rid"); GDVIRTUAL_BIND(_set_active, "active"); diff --git a/servers/extensions/physics_server_3d_extension.h b/servers/extensions/physics_server_3d_extension.h index c84582bf31..b6ed346a3d 100644 --- a/servers/extensions/physics_server_3d_extension.h +++ b/servers/extensions/physics_server_3d_extension.h @@ -210,6 +210,8 @@ protected: public: // The warning is valid, but unavoidable. If the function is not overridden it will error anyway. + /* SHAPE API */ + EXBIND0R(RID, world_boundary_shape_create) EXBIND0R(RID, separation_ray_shape_create) EXBIND0R(RID, sphere_shape_create) @@ -262,6 +264,7 @@ public: EXBIND1RC(int, area_get_shape_count, RID) EXBIND2RC(RID, area_get_shape, RID, int) EXBIND2RC(Transform3D, area_get_shape_transform, RID, int) + EXBIND2(area_remove_shape, RID, int) EXBIND1(area_clear_shapes, RID) @@ -297,12 +300,11 @@ public: EXBIND4(body_add_shape, RID, RID, const Transform3D &, bool) EXBIND3(body_set_shape, RID, int, RID) EXBIND3(body_set_shape_transform, RID, int, const Transform3D &) + EXBIND3(body_set_shape_disabled, RID, int, bool) EXBIND1RC(int, body_get_shape_count, RID) - EXBIND2RC(Transform3D, body_get_shape_transform, RID, int) EXBIND2RC(RID, body_get_shape, RID, int) - - EXBIND3(body_set_shape_disabled, RID, int, bool) + EXBIND2RC(Transform3D, body_get_shape_transform, RID, int) EXBIND2(body_remove_shape, RID, int) EXBIND1(body_clear_shapes, RID) @@ -333,9 +335,9 @@ public: EXBIND3(body_set_state, RID, BodyState, const Variant &) EXBIND2RC(Variant, body_get_state, RID, BodyState) - EXBIND2(body_apply_torque_impulse, RID, const Vector3 &) EXBIND2(body_apply_central_impulse, RID, const Vector3 &) EXBIND3(body_apply_impulse, RID, const Vector3 &, const Vector3 &) + EXBIND2(body_apply_torque_impulse, RID, const Vector3 &) EXBIND2(body_apply_central_force, RID, const Vector3 &) EXBIND3(body_apply_force, RID, const Vector3 &, const Vector3 &) @@ -476,7 +478,6 @@ public: /* JOINT API */ EXBIND0R(RID, joint_create) - EXBIND1(joint_clear, RID) EXBIND5(joint_make_pin, RID, RID, const Vector3 &, RID, const Vector3 &) diff --git a/servers/rendering/renderer_rd/effects/ss_effects.cpp b/servers/rendering/renderer_rd/effects/ss_effects.cpp index 315bea2e67..582c5abbdd 100644 --- a/servers/rendering/renderer_rd/effects/ss_effects.cpp +++ b/servers/rendering/renderer_rd/effects/ss_effects.cpp @@ -443,6 +443,11 @@ void SSEffects::downsample_depth(RID p_depth_buffer, const Vector<RID> &p_depth_ RD::get_singleton()->draw_command_begin_label("Downsample Depth"); if (p_invalidate_uniform_set || use_full_mips != ss_effects.used_full_mips_last_frame || use_half_size != ss_effects.used_half_size_last_frame || use_mips != ss_effects.used_mips_last_frame) { + if (ss_effects.downsample_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(ss_effects.downsample_uniform_set)) { + RD::get_singleton()->free(ss_effects.downsample_uniform_set); + ss_effects.downsample_uniform_set = RID(); + } + Vector<RD::Uniform> uniforms; { RD::Uniform u; @@ -516,6 +521,7 @@ void SSEffects::downsample_depth(RID p_depth_buffer, const Vector<RID> &p_depth_ ss_effects.used_full_mips_last_frame = use_full_mips; ss_effects.used_half_size_last_frame = use_half_size; + ss_effects.used_mips_last_frame = use_mips; } /* SSIL */ @@ -1484,7 +1490,7 @@ void SSEffects::ssr_allocate_buffers(SSRRenderBuffers &p_ssr_buffers, const Rend } } -void SSEffects::screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const Color &p_metallic_mask, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets) { +void SSEffects::screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets) { UniformSetCacheRD *uniform_set_cache = UniformSetCacheRD::get_singleton(); ERR_FAIL_NULL(uniform_set_cache); MaterialStorage *material_storage = MaterialStorage::get_singleton(); @@ -1579,10 +1585,6 @@ void SSEffects::screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const R push_constant.proj_info[1] = -2.0f / (p_screen_size.height * p_projections[v].matrix[1][1]); push_constant.proj_info[2] = (1.0f - p_projections[v].matrix[0][2]) / p_projections[v].matrix[0][0]; push_constant.proj_info[3] = (1.0f + p_projections[v].matrix[1][2]) / p_projections[v].matrix[1][1]; - push_constant.metallic_mask[0] = CLAMP(p_metallic_mask.r * 255.0, 0, 255); - push_constant.metallic_mask[1] = CLAMP(p_metallic_mask.g * 255.0, 0, 255); - push_constant.metallic_mask[2] = CLAMP(p_metallic_mask.b * 255.0, 0, 255); - push_constant.metallic_mask[3] = CLAMP(p_metallic_mask.a * 255.0, 0, 255); ScreenSpaceReflectionMode mode = (p_roughness_quality != RS::ENV_SSR_ROUGHNESS_QUALITY_DISABLED) ? SCREEN_SPACE_REFLECTION_ROUGH : SCREEN_SPACE_REFLECTION_NORMAL; RID shader = ssr.shader.version_get_shader(ssr.shader_version, mode); diff --git a/servers/rendering/renderer_rd/effects/ss_effects.h b/servers/rendering/renderer_rd/effects/ss_effects.h index a60f3a48ab..d50319c46f 100644 --- a/servers/rendering/renderer_rd/effects/ss_effects.h +++ b/servers/rendering/renderer_rd/effects/ss_effects.h @@ -168,7 +168,7 @@ public: }; void ssr_allocate_buffers(SSRRenderBuffers &p_ssr_buffers, const RenderingDevice::DataFormat p_color_format, RenderingServer::EnvironmentSSRRoughnessQuality p_roughness_quality, const Size2i &p_screen_size, const uint32_t p_view_count); - void screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const Color &p_metallic_mask, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets); + void screen_space_reflection(SSRRenderBuffers &p_ssr_buffers, const RID *p_diffuse_slices, const RID *p_normal_roughness_slices, RS::EnvironmentSSRRoughnessQuality p_roughness_quality, const RID *p_metallic_slices, const RID *p_depth_slices, const Size2i &p_screen_size, int p_max_steps, float p_fade_in, float p_fade_out, float p_tolerance, const uint32_t p_view_count, const Projection *p_projections, const Vector3 *p_eye_offsets); void ssr_free(SSRRenderBuffers &p_ssr_buffers); /* subsurface scattering */ @@ -465,10 +465,7 @@ private: uint32_t orthogonal; // 4 - 52 float filter_mipmap_levels; // 4 - 56 uint32_t use_half_res; // 4 - 60 - uint8_t metallic_mask[4]; // 4 - 64 - - uint32_t view_index; // 4 - 68 - uint32_t pad[3]; // 12 - 80 + uint32_t view_index; // 4 - 64 // float projection[16]; // this is in our ScreenSpaceReflectionSceneData now }; diff --git a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp index a0f6e69fd5..dec5e23558 100644 --- a/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/render_forward_clustered.cpp @@ -124,7 +124,7 @@ void RenderForwardClustered::RenderBufferDataForwardClustered::configure(RenderS render_buffers = p_render_buffers; ERR_FAIL_NULL(render_buffers); - bool msaa_3d = render_buffers->get_msaa_3d(); + RS::ViewportMSAA msaa_3d = render_buffers->get_msaa_3d(); if (msaa_3d != RS::VIEWPORT_MSAA_DISABLED) { RD::DataFormat format = RD::DATA_FORMAT_R16G16B16A16_SFLOAT; @@ -1609,7 +1609,7 @@ void RenderForwardClustered::_render_scene(RenderDataRD *p_render_data, const Co for (uint32_t v = 0; v < p_render_data->view_count; v++) { specular_views[v] = rb_data->get_specular(v); } - _process_ssr(rb, color_only_framebuffer, normal_roughness_views, rb_data->get_specular(), specular_views, Color(0, 0, 0, 1), p_render_data->environment, p_render_data->view_projection, p_render_data->view_eye_offset, rb->get_msaa_3d() == RS::VIEWPORT_MSAA_DISABLED); + _process_ssr(rb, color_only_framebuffer, normal_roughness_views, rb_data->get_specular(), specular_views, p_render_data->environment, p_render_data->view_projection, p_render_data->view_eye_offset, rb->get_msaa_3d() == RS::VIEWPORT_MSAA_DISABLED); RD::get_singleton()->draw_command_end_label(); } else { //just mix specular back diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 78c83d1fb4..e2b06bc92f 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1328,7 +1328,7 @@ void RendererSceneRenderRD::_process_sss(Ref<RenderSceneBuffersRD> p_render_buff } } -void RendererSceneRenderRD::_process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_slices, RID p_specular_buffer, const RID *p_metallic_slices, const Color &p_metallic_mask, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive) { +void RendererSceneRenderRD::_process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_slices, RID p_specular_buffer, const RID *p_metallic_slices, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive) { ERR_FAIL_NULL(ss_effects); ERR_FAIL_COND(p_render_buffers.is_null()); @@ -1355,7 +1355,7 @@ void RendererSceneRenderRD::_process_ssr(Ref<RenderSceneBuffersRD> p_render_buff texture_slices[v] = p_render_buffers->get_internal_texture(v); depth_slices[v] = p_render_buffers->get_depth_texture(v); } - ss_effects->screen_space_reflection(p_render_buffers->ssr, texture_slices, p_normal_slices, ssr_roughness_quality, p_metallic_slices, p_metallic_mask, depth_slices, half_size, environment_get_ssr_max_steps(p_environment), environment_get_ssr_fade_in(p_environment), environment_get_ssr_fade_out(p_environment), environment_get_ssr_depth_tolerance(p_environment), view_count, p_projections, p_eye_offsets); + ss_effects->screen_space_reflection(p_render_buffers->ssr, texture_slices, p_normal_slices, ssr_roughness_quality, p_metallic_slices, depth_slices, half_size, environment_get_ssr_max_steps(p_environment), environment_get_ssr_fade_in(p_environment), environment_get_ssr_fade_out(p_environment), environment_get_ssr_depth_tolerance(p_environment), view_count, p_projections, p_eye_offsets); copy_effects->merge_specular(p_dest_framebuffer, p_specular_buffer, p_use_additive ? RID() : p_render_buffers->get_internal_texture(), p_render_buffers->ssr.output, view_count); } diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.h b/servers/rendering/renderer_rd/renderer_scene_render_rd.h index 76d2bc68fe..d47394989f 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.h +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.h @@ -138,7 +138,7 @@ protected: virtual RID _render_buffers_get_velocity_texture(Ref<RenderSceneBuffersRD> p_render_buffers) = 0; void _process_ssao(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, RID p_normal_buffer, const Projection &p_projection); - void _process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_buffer_slices, RID p_specular_buffer, const RID *p_metallic_slices, const Color &p_metallic_mask, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive); + void _process_ssr(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_dest_framebuffer, const RID *p_normal_buffer_slices, RID p_specular_buffer, const RID *p_metallic_slices, RID p_environment, const Projection *p_projections, const Vector3 *p_eye_offsets, bool p_use_additive); void _process_sss(Ref<RenderSceneBuffersRD> p_render_buffers, const Projection &p_camera); void _process_ssil(Ref<RenderSceneBuffersRD> p_render_buffers, RID p_environment, RID p_normal_buffer, const Projection &p_projection, const Transform3D &p_transform); diff --git a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl index 246ef81cb2..9f86643e52 100644 --- a/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl +++ b/servers/rendering/renderer_rd/shaders/effects/screen_space_reflection.glsl @@ -30,12 +30,7 @@ layout(push_constant, std430) uniform Params { bool orthogonal; float filter_mipmap_levels; bool use_half_res; - uint metallic_mask; - uint view_index; - uint pad1; - uint pad2; - uint pad3; } params; @@ -167,7 +162,7 @@ void main() { if (depth > z_to) { // if depth was surpassed - if (depth <= max(z_to, z_from) + params.depth_tolerance && -depth < params.camera_z_far) { + if (depth <= max(z_to, z_from) + params.depth_tolerance && -depth < params.camera_z_far * 0.95) { // check the depth tolerance and far clip // check that normal is valid found = true; @@ -231,18 +226,20 @@ void main() { } } - // Isn't this going to be overwritten after our endif? - final_color = imageLoad(source_diffuse, ivec2((final_pos - 0.5) * pixel_size)); - imageStore(blur_radius_image, ssC, vec4(blur_radius / 255.0)); //stored in r8 #endif // MODE_ROUGH final_color = vec4(imageLoad(source_diffuse, ivec2(final_pos - 0.5)).rgb, fade * margin_blend); - //change blend by metallic - vec4 metallic_mask = unpackUnorm4x8(params.metallic_mask); - final_color.a *= dot(metallic_mask, texelFetch(source_metallic, ssC << 1, 0)); + // Schlick term. + float metallic = texelFetch(source_metallic, ssC << 1, 0).w; + float f0 = mix(0.04, 1.0, metallic); // Assume a "specular" amount of 0.5 + normal.y = -normal.y; + float m = clamp(1.0 - dot(normalize(normal), -view_dir), 0.0, 1.0); + float m2 = m * m; + m = m2 * m2 * m; // pow(m,5) + final_color.a *= f0 + (1.0 - f0) * m; // Fresnel Schlick term. imageStore(ssr_image, ssC, final_color); diff --git a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl index 4e6e29b315..2fba1351f7 100644 --- a/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl +++ b/servers/rendering/renderer_rd/shaders/scene_forward_lights_inc.glsl @@ -97,11 +97,12 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte float diffuse_brdf_NL; // BRDF times N.L for calculating diffuse radiance #if defined(DIFFUSE_LAMBERT_WRAP) - // energy conserving lambert wrap shader - diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))); + // Energy conserving lambert wrap shader. + // https://web.archive.org/web/20210228210901/http://blog.stevemcauley.com/2011/12/03/energy-conserving-wrapped-diffuse/ + diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness))) * (1.0 / M_PI); #elif defined(DIFFUSE_TOON) - diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL); + diffuse_brdf_NL = smoothstep(-roughness, max(roughness, 0.01), NdotL) * (1.0 / M_PI); #elif defined(DIFFUSE_BURLEY) diff --git a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp index 576ec81124..16fdbc07f5 100644 --- a/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp +++ b/servers/rendering/renderer_rd/storage_rd/render_scene_buffers_rd.cpp @@ -128,6 +128,11 @@ void RenderSceneBuffersRD::cleanup() { ss_effects.linear_depth_slices.clear(); } + if (ss_effects.downsample_uniform_set.is_valid() && RD::get_singleton()->uniform_set_is_valid(ss_effects.downsample_uniform_set)) { + RD::get_singleton()->free(ss_effects.downsample_uniform_set); + ss_effects.downsample_uniform_set = RID(); + } + sse->ssao_free(ss_effects.ssao); sse->ssil_free(ss_effects.ssil); sse->ssr_free(ssr); @@ -535,7 +540,9 @@ void RenderSceneBuffersRD::ensure_velocity() { RD::TEXTURE_SAMPLES_8, }; - create_texture(RB_SCOPE_BUFFERS, RB_TEX_VELOCITY_MSAA, RD::DATA_FORMAT_R16G16_SFLOAT, msaa_usage_bits, ts[msaa_3d]); + RD::TextureSamples texture_samples = ts[msaa_3d]; + + create_texture(RB_SCOPE_BUFFERS, RB_TEX_VELOCITY_MSAA, RD::DATA_FORMAT_R16G16_SFLOAT, msaa_usage_bits, texture_samples); } create_texture(RB_SCOPE_BUFFERS, RB_TEX_VELOCITY, RD::DATA_FORMAT_R16G16_SFLOAT, usage_bits); diff --git a/servers/rendering/renderer_viewport.cpp b/servers/rendering/renderer_viewport.cpp index 1e30a7f77e..eacd9bbbc2 100644 --- a/servers/rendering/renderer_viewport.cpp +++ b/servers/rendering/renderer_viewport.cpp @@ -717,7 +717,14 @@ void RendererViewport::draw_viewports() { blit_to_screen_list[vp->viewport_to_screen] = Vector<BlitToScreen>(); } - blit_to_screen_list[vp->viewport_to_screen].push_back(blit); + if (OS::get_singleton()->get_current_rendering_driver_name() == "opengl3") { + Vector<BlitToScreen> blit_to_screen_vec; + blit_to_screen_vec.push_back(blit); + RSG::rasterizer->blit_render_targets_to_screen(vp->viewport_to_screen, blit_to_screen_vec.ptr(), 1); + RSG::rasterizer->end_frame(true); + } else { + blit_to_screen_list[vp->viewport_to_screen].push_back(blit); + } } } diff --git a/servers/rendering/rendering_server_default.cpp b/servers/rendering/rendering_server_default.cpp index 1f686069bd..9103b0cf56 100644 --- a/servers/rendering/rendering_server_default.cpp +++ b/servers/rendering/rendering_server_default.cpp @@ -91,7 +91,10 @@ void RenderingServerDefault::_draw(bool p_swap_buffers, double frame_step) { RSG::viewport->draw_viewports(); RSG::canvas_render->update(); - RSG::rasterizer->end_frame(p_swap_buffers); + if (OS::get_singleton()->get_current_rendering_driver_name() != "opengl3") { + // Already called for gl_compatibility renderer. + RSG::rasterizer->end_frame(p_swap_buffers); + } XRServer *xr_server = XRServer::get_singleton(); if (xr_server != nullptr) { diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index e2519ba8d1..6754d84cd4 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -1069,7 +1069,7 @@ String ShaderLanguage::get_uniform_hint_name(ShaderNode::Uniform::Hint p_hint) { result = "hint_range"; } break; case ShaderNode::Uniform::HINT_SOURCE_COLOR: { - result = "hint_color"; + result = "source_color"; } break; case ShaderNode::Uniform::HINT_NORMAL: { result = "hint_normal"; @@ -1171,6 +1171,10 @@ void ShaderLanguage::clear() { last_type = IDENTIFIER_MAX; current_uniform_group_name = ""; current_uniform_subgroup_name = ""; + current_uniform_hint = ShaderNode::Uniform::HINT_NONE; + current_uniform_filter = FILTER_DEFAULT; + current_uniform_repeat = REPEAT_DEFAULT; + current_uniform_instance_index_defined = false; completion_type = COMPLETION_NONE; completion_block = nullptr; @@ -8617,6 +8621,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f } custom_instance_index = tk.constant; + current_uniform_instance_index_defined = true; if (custom_instance_index >= MAX_INSTANCE_UNIFORM_INDICES) { _set_error(vformat(RTR("Allowed instance uniform indices must be within [0..%d] range."), MAX_INSTANCE_UNIFORM_INDICES - 1)); @@ -8682,6 +8687,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f return ERR_PARSE_ERROR; } else { uniform.hint = new_hint; + current_uniform_hint = new_hint; } } @@ -8695,6 +8701,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f return ERR_PARSE_ERROR; } else { uniform.filter = new_filter; + current_uniform_filter = new_filter; } } @@ -8708,6 +8715,7 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f return ERR_PARSE_ERROR; } else { uniform.repeat = new_repeat; + current_uniform_repeat = new_repeat; } } @@ -8775,6 +8783,11 @@ Error ShaderLanguage::_parse_shader(const HashMap<StringName, FunctionInfo> &p_f keyword_completion_context = CF_GLOBAL_SPACE; #endif // DEBUG_ENABLED completion_type = COMPLETION_NONE; + + current_uniform_hint = ShaderNode::Uniform::HINT_NONE; + current_uniform_filter = FILTER_DEFAULT; + current_uniform_repeat = REPEAT_DEFAULT; + current_uniform_instance_index_defined = false; } else { // varying ShaderNode::Varying varying; varying.type = type; @@ -10311,28 +10324,33 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ } break; case COMPLETION_HINT: { if (completion_base == DataType::TYPE_VEC3 || completion_base == DataType::TYPE_VEC4) { - ScriptLanguage::CodeCompletionOption option("source_color", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); - r_options->push_back(option); + if (current_uniform_hint == ShaderNode::Uniform::HINT_NONE) { + ScriptLanguage::CodeCompletionOption option("source_color", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); + r_options->push_back(option); + } } else if ((completion_base == DataType::TYPE_INT || completion_base == DataType::TYPE_FLOAT) && !completion_base_array) { - ScriptLanguage::CodeCompletionOption option("hint_range", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); + if (current_uniform_hint == ShaderNode::Uniform::HINT_NONE) { + ScriptLanguage::CodeCompletionOption option("hint_range", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); - if (completion_base == DataType::TYPE_INT) { - option.insert_text = "hint_range(0, 100, 1)"; - } else { - option.insert_text = "hint_range(0.0, 1.0, 0.1)"; - } + if (completion_base == DataType::TYPE_INT) { + option.insert_text = "hint_range(0, 100, 1)"; + } else { + option.insert_text = "hint_range(0.0, 1.0, 0.1)"; + } - r_options->push_back(option); + r_options->push_back(option); + } } else if ((int(completion_base) > int(TYPE_MAT4) && int(completion_base) < int(TYPE_STRUCT)) && !completion_base_array) { - static Vector<String> options; - - if (options.is_empty()) { + Vector<String> options; + if (current_uniform_filter == FILTER_DEFAULT) { options.push_back("filter_linear"); options.push_back("filter_linear_mipmap"); options.push_back("filter_linear_mipmap_anisotropic"); options.push_back("filter_nearest"); options.push_back("filter_nearest_mipmap"); options.push_back("filter_nearest_mipmap_anisotropic"); + } + if (current_uniform_hint == ShaderNode::Uniform::HINT_NONE) { options.push_back("hint_anisotropy"); options.push_back("hint_default_black"); options.push_back("hint_default_white"); @@ -10348,6 +10366,8 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ options.push_back("hint_normal_roughness_texture"); options.push_back("hint_depth_texture"); options.push_back("source_color"); + } + if (current_uniform_repeat == REPEAT_DEFAULT) { options.push_back("repeat_enable"); options.push_back("repeat_disable"); } @@ -10357,7 +10377,7 @@ Error ShaderLanguage::complete(const String &p_code, const ShaderCompileInfo &p_ r_options->push_back(option); } } - if (!completion_base_array) { + if (!completion_base_array && !current_uniform_instance_index_defined) { ScriptLanguage::CodeCompletionOption option("instance_index", ScriptLanguage::CODE_COMPLETION_KIND_PLAIN_TEXT); option.insert_text = "instance_index(0)"; r_options->push_back(option); diff --git a/servers/rendering/shader_language.h b/servers/rendering/shader_language.h index 75b713d167..e9f8c3b289 100644 --- a/servers/rendering/shader_language.h +++ b/servers/rendering/shader_language.h @@ -1050,6 +1050,10 @@ private: }; CompletionType completion_type; + ShaderNode::Uniform::Hint current_uniform_hint = ShaderNode::Uniform::HINT_NONE; + TextureFilter current_uniform_filter = FILTER_DEFAULT; + TextureRepeat current_uniform_repeat = REPEAT_DEFAULT; + bool current_uniform_instance_index_defined = false; int completion_line = 0; BlockNode *completion_block = nullptr; DataType completion_base; |