diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index f2b4fdfdf13..612b21204d8 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -549,7 +549,6 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { line_material = Ref(memnew(SpatialMaterial)); line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - line_material->set_line_width(3.0); line_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index beee7b87f0c..1120d566bef 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1585,7 +1585,7 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_line_width(3); + Array d; d.resize(VS::ARRAY_MAX); d[Mesh::ARRAY_VERTEX] = cursor_points; diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index a8cb039cb32..e1e0044cea6 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1458,14 +1458,12 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { outer_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.8)); outer_mat->set_on_top_of_alpha(); outer_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - outer_mat->set_line_width(3.0); outer_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); selection_floor_mat.instance(); selection_floor_mat->set_albedo(Color(0.80, 0.80, 1.0, 1)); selection_floor_mat->set_on_top_of_alpha(); selection_floor_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - selection_floor_mat->set_line_width(3.0); d[VS::ARRAY_VERTEX] = lines; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d); diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index fbe3cd7a3ed..7f764a737a0 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -337,7 +337,6 @@ void RayCast::_create_debug_shape() { Ref line_material = static_cast >(debug_material); line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - line_material->set_line_width(3.0); line_material->set_albedo(Color(1.0, 0.8, 0.6)); } diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index e90a917b27a..368d65cb85d 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -171,7 +171,7 @@ bool ShaderMaterial::property_can_revert(const String &p_name) { StringName pr = shader->remap_param(p_name); if (pr) { - Variant default_value = VisualServer::get_singleton()->material_get_param_default(_get_material(), pr); + Variant default_value = VisualServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr); Variant current_value; _get(p_name, current_value); return default_value.get_type() != Variant::NIL && default_value != current_value; @@ -185,7 +185,7 @@ Variant ShaderMaterial::property_get_revert(const String &p_name) { if (shader.is_valid()) { StringName pr = shader->remap_param(p_name); if (pr) { - r_ret = VisualServer::get_singleton()->material_get_param_default(_get_material(), pr); + r_ret = VisualServer::get_singleton()->shader_get_param_default(shader->get_rid(), pr); } } return r_ret; @@ -1530,17 +1530,6 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { } } -void SpatialMaterial::set_line_width(float p_line_width) { - - line_width = p_line_width; - VS::get_singleton()->material_set_line_width(_get_material(), line_width); -} - -float SpatialMaterial::get_line_width() const { - - return line_width; -} - void SpatialMaterial::set_point_size(float p_point_size) { point_size = p_point_size; @@ -1976,9 +1965,6 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &SpatialMaterial::set_refraction); ClassDB::bind_method(D_METHOD("get_refraction"), &SpatialMaterial::get_refraction); - ClassDB::bind_method(D_METHOD("set_line_width", "line_width"), &SpatialMaterial::set_line_width); - ClassDB::bind_method(D_METHOD("get_line_width"), &SpatialMaterial::get_line_width); - ClassDB::bind_method(D_METHOD("set_point_size", "point_size"), &SpatialMaterial::set_point_size); ClassDB::bind_method(D_METHOD("get_point_size"), &SpatialMaterial::get_point_size); @@ -2122,7 +2108,6 @@ void SpatialMaterial::_bind_methods() { 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"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_line_width", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_line_width", "get_line_width"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_point_size", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_point_size", "get_point_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "params_billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "params_billboard_keep_scale"), "set_flag", "get_flag", FLAG_BILLBOARD_KEEP_SCALE); @@ -2363,7 +2348,6 @@ SpatialMaterial::SpatialMaterial() : set_subsurface_scattering_strength(0); set_transmission(Color(0, 0, 0)); set_refraction(0.05); - set_line_width(1); set_point_size(1); set_uv1_offset(Vector3(0, 0, 0)); set_uv1_scale(Vector3(1, 1, 1)); diff --git a/scene/resources/material.h b/scene/resources/material.h index 38fb8b21723..a1b6fd34ea9 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -387,7 +387,6 @@ private: float subsurface_scattering_strength; Color transmission; float refraction; - float line_width; float point_size; float alpha_scissor_threshold; bool grow_enabled; @@ -519,9 +518,6 @@ public: void set_refraction(float p_refraction); float get_refraction() const; - void set_line_width(float p_line_width); - float get_line_width() const; - void set_point_size(float p_point_size); float get_point_size() const; diff --git a/servers/visual/rasterizer/rasterizer.h b/servers/visual/rasterizer/rasterizer.h index 46695f56478..7ee7107fabc 100644 --- a/servers/visual/rasterizer/rasterizer.h +++ b/servers/visual/rasterizer/rasterizer.h @@ -233,6 +233,7 @@ public: virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) = 0; virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const = 0; + virtual Variant shader_get_param_default(RID p_material, const StringName &p_param) const = 0; /* COMMON MATERIAL API */ @@ -244,9 +245,6 @@ public: virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0; virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0; - virtual Variant material_get_param_default(RID p_material, const StringName &p_param) const = 0; - - virtual void material_set_line_width(RID p_material, float p_width) = 0; virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0; diff --git a/servers/visual/rasterizer/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer/rasterizer_canvas_rd.cpp index 93f905b72b8..7e415e68689 100644 --- a/servers/visual/rasterizer/rasterizer_canvas_rd.cpp +++ b/servers/visual/rasterizer/rasterizer_canvas_rd.cpp @@ -1974,15 +1974,12 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) { RD::AttachmentFormat af_color; af_color.format = RD::DATA_FORMAT_R32_SFLOAT; af_color.usage_flags = RD::TEXTURE_USAGE_SAMPLING_BIT | RD::TEXTURE_USAGE_COLOR_ATTACHMENT_BIT; - af_color.samples = RenderingDevice::TEXTURE_SAMPLES_64; attachments.push_back(af_color); RD::AttachmentFormat af_depth; - af_depth.format = RD::DATA_FORMAT_D24_UNORM_S8_UINT; af_depth.format = RD::get_singleton()->texture_is_format_supported_for_usage(RD::DATA_FORMAT_X8_D24_UNORM_PACK32, RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) ? RD::DATA_FORMAT_X8_D24_UNORM_PACK32 : RD::DATA_FORMAT_D32_SFLOAT; af_depth.usage_flags = RD::TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; - af_depth.samples = RenderingDevice::TEXTURE_SAMPLES_64; attachments.push_back(af_depth); diff --git a/servers/visual/rasterizer/rasterizer_storage_rd.h b/servers/visual/rasterizer/rasterizer_storage_rd.h index bb9e20861f0..c4ed7f56d86 100644 --- a/servers/visual/rasterizer/rasterizer_storage_rd.h +++ b/servers/visual/rasterizer/rasterizer_storage_rd.h @@ -189,6 +189,26 @@ public: /* SHADER API */ + enum ShaderType { + SHADER_TYPE_2D, + SHADER_TYPE_3D, + SHADER_TYPE_3D_POST_PROCESS, + SHADER_TYPE_PARTICLES + }; + + class ShaderData { + public: + virtual void set_code(const String &p_Code) = 0; + virtual void set_default_texture_param(const StringName &p_name, RID p_texture) = 0; + virtual void get_param_list(List *p_param_list) const = 0; + virtual bool is_animated() const = 0; + virtual bool casts_shadows() const = 0; + virtual Variant get_default_parameter(const StringName &p_parameter) const = 0; + virtual ~ShaderData() {} + }; + + typedef ShaderData *(ShaderDataRequestFunction)(); + RID shader_create() { return RID(); } void shader_set_code(RID p_shader, const String &p_code) {} @@ -197,22 +217,29 @@ public: void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) {} RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const { return RID(); } + Variant shader_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); } /* COMMON MATERIAL API */ + struct MaterialData { + + virtual void set_render_priority(int p_priority) = 0; + virtual void set_next_pass(RID p_pass) = 0; + virtual void update_parameters(const Map &p_parameters) = 0; + virtual ~MaterialData() {} + }; + typedef MaterialData *(MaterialDataRequestFunction)(ShaderData *); + RID material_create() { return RID(); } - void material_set_render_priority(RID p_material, int priority) {} void material_set_shader(RID p_shader_material, RID p_shader) {} RID material_get_shader(RID p_shader_material) const { return RID(); } void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) {} Variant material_get_param(RID p_material, const StringName &p_param) const { return Variant(); } - Variant material_get_param_default(RID p_material, const StringName &p_param) const { return Variant(); } - - void material_set_line_width(RID p_material, float p_width) {} void material_set_next_pass(RID p_material, RID p_next_material) {} + void material_set_render_priority(RID p_material, int priority) {} bool material_is_animated(RID p_material) { return false; } bool material_casts_shadows(RID p_material) { return false; } diff --git a/servers/visual/rendering_device.h b/servers/visual/rendering_device.h index 11a3e7e0526..c9e2b9f820f 100644 --- a/servers/visual/rendering_device.h +++ b/servers/visual/rendering_device.h @@ -370,6 +370,11 @@ public: DataFormat format; TextureSamples samples; uint32_t usage_flags; + AttachmentFormat() { + format=DATA_FORMAT_R8G8B8A8_UNORM; + samples=TEXTURE_SAMPLES_1; + usage_flags=0; + } }; typedef int64_t FramebufferFormatID; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index feb454c4256..d84fb0b7154 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -202,6 +202,7 @@ public: BIND3(shader_set_default_texture_param, RID, const StringName &, RID) BIND2RC(RID, shader_get_default_texture_param, RID, const StringName &) + BIND2RC(Variant, shader_get_param_default, RID, const StringName &) /* COMMON MATERIAL API */ @@ -212,10 +213,8 @@ public: BIND3(material_set_param, RID, const StringName &, const Variant &) BIND2RC(Variant, material_get_param, RID, const StringName &) - BIND2RC(Variant, material_get_param_default, RID, const StringName &) BIND2(material_set_render_priority, RID, int) - BIND2(material_set_line_width, RID, float) BIND2(material_set_next_pass, RID, RID) /* MESH API */ diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index bd813be6b13..610aa9c305d 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -133,6 +133,7 @@ public: FUNC3(shader_set_default_texture_param, RID, const StringName &, RID) FUNC2RC(RID, shader_get_default_texture_param, RID, const StringName &) + FUNC2RC(Variant, shader_get_param_default, RID, const StringName &) /* COMMON MATERIAL API */ @@ -143,10 +144,8 @@ public: FUNC3(material_set_param, RID, const StringName &, const Variant &) FUNC2RC(Variant, material_get_param, RID, const StringName &) - FUNC2RC(Variant, material_get_param_default, RID, const StringName &) FUNC2(material_set_render_priority, RID, int) - FUNC2(material_set_line_width, RID, float) FUNC2(material_set_next_pass, RID, RID) /* MESH API */ diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 0b2b339a318..80f8ad3bf07 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1648,15 +1648,15 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("shader_get_param_list", "shader"), &VisualServer::_shader_get_param_list_bind); ClassDB::bind_method(D_METHOD("shader_set_default_texture_param", "shader", "name", "texture"), &VisualServer::shader_set_default_texture_param); ClassDB::bind_method(D_METHOD("shader_get_default_texture_param", "shader", "name"), &VisualServer::shader_get_default_texture_param); + ClassDB::bind_method(D_METHOD("shader_get_param_default", "material", "parameter"), &VisualServer::shader_get_param_default); ClassDB::bind_method(D_METHOD("material_create"), &VisualServer::material_create); ClassDB::bind_method(D_METHOD("material_set_shader", "shader_material", "shader"), &VisualServer::material_set_shader); ClassDB::bind_method(D_METHOD("material_get_shader", "shader_material"), &VisualServer::material_get_shader); ClassDB::bind_method(D_METHOD("material_set_param", "material", "parameter", "value"), &VisualServer::material_set_param); ClassDB::bind_method(D_METHOD("material_get_param", "material", "parameter"), &VisualServer::material_get_param); - ClassDB::bind_method(D_METHOD("material_get_param_default", "material", "parameter"), &VisualServer::material_get_param_default); ClassDB::bind_method(D_METHOD("material_set_render_priority", "material", "priority"), &VisualServer::material_set_render_priority); - ClassDB::bind_method(D_METHOD("material_set_line_width", "material", "width"), &VisualServer::material_set_line_width); + ClassDB::bind_method(D_METHOD("material_set_next_pass", "material", "next_material"), &VisualServer::material_set_next_pass); ClassDB::bind_method(D_METHOD("mesh_create"), &VisualServer::mesh_create); diff --git a/servers/visual_server.h b/servers/visual_server.h index 5d24a9cd84d..25c5903ef1c 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -177,6 +177,7 @@ public: virtual String shader_get_code(RID p_shader) const = 0; virtual void shader_get_param_list(RID p_shader, List *p_param_list) const = 0; Array _shader_get_param_list_bind(RID p_shader) const; + virtual Variant shader_get_param_default(RID p_shader, const StringName &p_param) const = 0; virtual void shader_set_default_texture_param(RID p_shader, const StringName &p_name, RID p_texture) = 0; virtual RID shader_get_default_texture_param(RID p_shader, const StringName &p_name) const = 0; @@ -195,11 +196,9 @@ public: virtual void material_set_param(RID p_material, const StringName &p_param, const Variant &p_value) = 0; virtual Variant material_get_param(RID p_material, const StringName &p_param) const = 0; - virtual Variant material_get_param_default(RID p_material, const StringName &p_param) const = 0; virtual void material_set_render_priority(RID p_material, int priority) = 0; - virtual void material_set_line_width(RID p_material, float p_width) = 0; virtual void material_set_next_pass(RID p_material, RID p_next_material) = 0; /* MESH API */