diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_node.cpp | 4 | ||||
-rw-r--r-- | editor/icons/icon_o_r_m_material_3d.svg | 66 | ||||
-rw-r--r-- | editor/icons/icon_standard_material_3d.svg | 11 | ||||
-rw-r--r-- | editor/import/editor_import_collada.cpp | 34 | ||||
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 35 | ||||
-rw-r--r-- | editor/import/resource_importer_obj.cpp | 22 | ||||
-rw-r--r-- | editor/import/resource_importer_scene.cpp | 8 | ||||
-rw-r--r-- | editor/plugins/collision_polygon_editor_plugin.cpp | 24 | ||||
-rw-r--r-- | editor/plugins/collision_polygon_editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.cpp | 12 | ||||
-rw-r--r-- | editor/plugins/material_editor_plugin.h | 4 | ||||
-rw-r--r-- | editor/plugins/path_editor_plugin.cpp | 6 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.cpp | 118 | ||||
-rw-r--r-- | editor/plugins/spatial_editor_plugin.h | 18 | ||||
-rw-r--r-- | editor/spatial_editor_gizmos.cpp | 14 |
15 files changed, 229 insertions, 151 deletions
diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f4749da309..567d0fe33d 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5824,7 +5824,7 @@ EditorNode::EditorNode() { EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false); EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true); EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true); - EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "SpatialMaterial,Script,MeshLibrary,TileSet"); + EDITOR_DEF("interface/inspector/resources_to_open_in_new_inspector", "StandardMaterial3D,ORMMaterial3D,Script,MeshLibrary,TileSet"); EDITOR_DEF("interface/inspector/default_color_picker_mode", 0); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "interface/inspector/default_color_picker_mode", PROPERTY_HINT_ENUM, "RGB,HSV,RAW", PROPERTY_USAGE_DEFAULT)); EDITOR_DEF("run/auto_save/save_before_running", true); @@ -6718,7 +6718,7 @@ EditorNode::EditorNode() { resource_preview->add_preview_generator(Ref<EditorFontPreviewPlugin>(memnew(EditorFontPreviewPlugin))); { - Ref<SpatialMaterialConversionPlugin> spatial_mat_convert; + Ref<StandardMaterial3DConversionPlugin> spatial_mat_convert; spatial_mat_convert.instance(); resource_conversion_plugins.push_back(spatial_mat_convert); diff --git a/editor/icons/icon_o_r_m_material_3d.svg b/editor/icons/icon_o_r_m_material_3d.svg new file mode 100644 index 0000000000..3dd6013436 --- /dev/null +++ b/editor/icons/icon_o_r_m_material_3d.svg @@ -0,0 +1,66 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="16" + height="16" + version="1.1" + viewBox="0 0 16 16" + id="svg18" + sodipodi:docname="icon_o_r_m_material_3d.svg" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)"> + <metadata + id="metadata24"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs22" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1010" + inkscape:window-height="553" + id="namedview20" + showgrid="false" + inkscape:zoom="7.375" + inkscape:cx="16.698858" + inkscape:cy="18.275823" + inkscape:window-x="345" + inkscape:window-y="144" + inkscape:window-maximized="0" + inkscape:current-layer="svg18" /> + <path + inkscape:connector-curvature="0" + id="path4541" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:Uroob;-inkscape-font-specification:Uroob;letter-spacing:0px;word-spacing:0px;fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.33291078" + d="m 5.0534707,10.652714 q 0,0.729229 -0.4538398,1.253141 -0.4538403,0.516832 -1.0868283,0.516832 H 2.3184864 q -0.6389592,0 -1.1047425,-0.509753 -0.47175502,-0.509751 -0.47175502,-1.26022 V 5.1304021 q 0,-0.7575473 0.47175502,-1.2672998 0.4717549,-0.5097517 1.1047425,-0.5097517 h 1.1943162 q 0.6270165,0 1.0868283,0.516832 0.4538398,0.5168313 0.4538398,1.2602195 z M 3.9726148,10.419078 V 5.3640385 q 0,-0.5734707 -0.3344086,-0.8141867 Q 3.5307175,4.4648927 3.381428,4.471973 H 2.3901454 q -0.2567779,0 -0.4120391,0.2690357 -0.1552611,0.2690357 -0.1552611,0.6230298 v 5.0550395 q 0,0.559311 0.3164938,0.807108 0.1074885,0.08496 0.2508064,0.08496 H 3.381428 q 0.2746925,0 0.4359254,-0.276116 0.1552614,-0.276115 0.1552614,-0.61595 z" /> + <path + inkscape:connector-curvature="0" + id="path4543" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:Uroob;-inkscape-font-specification:Uroob;letter-spacing:0px;word-spacing:0px;fill:#008000;fill-opacity:1;stroke:none;stroke-width:0.32084218" + d="M 9.9872948,12.451006 H 8.9445586 L 7.4747449,8.5287488 H 6.6815992 V 12.451006 H 5.6721419 V 3.37459 h 2.739956 q 0.5435541,0 0.9318066,0.4601926 0.3882524,0.4601933 0.3882524,1.1540217 V 7.112771 q 0,1.0053443 -0.6766682,1.3168588 -0.2107668,0.099119 -0.4659043,0.099119 z M 8.7282467,6.808336 V 5.2224407 q 0,-0.4743524 -0.2884169,-0.6867495 -0.088743,-0.070798 -0.2052192,-0.063719 H 6.6815992 v 2.9452329 h 1.7194053 q 0.2828702,-0.00708 0.3161488,-0.389394 0.011093,-0.1132781 0.011093,-0.2194752 z" /> + <path + inkscape:connector-curvature="0" + id="path4545" + style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:40px;line-height:1.25;font-family:Uroob;-inkscape-font-specification:Uroob;letter-spacing:0px;word-spacing:0px;fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:0.31984535" + d="m 10.201004,3.7285848 q 0,-0.4106342 0.529158,-0.3681546 0.126777,0.014161 0.209458,0.014161 v 0.00708 h 0.115753 l 1.692202,4.9205216 1.697714,-4.9205216 h 0.06063 v -0.00708 h 0.463013 q 0.198434,0 0.297651,0.212397 0.03307,0.063719 0.03307,0.1415978 v 8.694102 h -1.01422 V 6.8224966 L 13.227119,10.050925 H 12.273535 L 11.21522,7.1198527 v 5.3028353 h -1.014218 z" /> +</svg> diff --git a/editor/icons/icon_standard_material_3d.svg b/editor/icons/icon_standard_material_3d.svg new file mode 100644 index 0000000000..aa8bfc9a5b --- /dev/null +++ b/editor/icons/icon_standard_material_3d.svg @@ -0,0 +1,11 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1036.4)"> +<path transform="translate(0 1036.4)" d="m7.9629 1.002a1.0001 1.0001 0 0 0 -0.41016 0.10352l-3.7891 1.8945h8.4727l-3.7891-1.8945a1.0001 1.0001 0 0 0 -0.48438 -0.10352z" fill="#ff7070"/> +<path transform="translate(0 1036.4)" d="m3.7637 3l-2.2109 1.1055a1.0001 1.0001 0 0 0 -0.55273 0.89453h3.2363l3.7637-1.8809 3.7637 1.8809h3.2363a1.0001 1.0001 0 0 0 -0.55273 -0.89453l-2.2109-1.1055h-8.4727z" fill="#ffeb70"/> +<path transform="translate(0 1036.4)" d="m1 5v2h2v-0.38086l0.76172 0.38086h8.4766l0.76172-0.38086v0.38086h2v-2h-3.2363l-3.7637 1.8828-3.7637-1.8828h-3.2363z" fill="#9dff70"/> +<path transform="translate(0 1036.4)" d="m1 7v2h2v-2h-2zm2.7617 0l3.2383 1.6191v0.38086h2v-0.38086l3.2383-1.6191h-8.4766zm9.2383 0v2h2v-2h-2z" fill="#70ffb9"/> +<path transform="translate(0 1036.4)" d="m1 9v2h3.2344l-1.2344-0.61719v-1.3828h-2zm6 0v2h2v-2h-2zm6 0v1.3828l-1.2344 0.61719h3.2344v-2h-2z" fill="#70deff"/> +<path transform="translate(0 1036.4)" d="m3.7637 13l3.7891 1.8945a1.0001 1.0001 0 0 0 0.48438 0.10547 1.0001 1.0001 0 0 0 0.41016 -0.10547l3.7891-1.8945h-8.4727z" fill="#ff70ac"/> +<path transform="translate(0 1036.4)" d="m1 11a1.0001 1.0001 0 0 0 0.55273 0.89453l2.2109 1.1055h8.4727l2.2109-1.1055a1.0001 1.0001 0 0 0 0.55273 -0.89453h-3.2344l-2.7656 1.3828v-1.3828h-2v1.3828l-2.7656-1.3828h-3.2344z" fill="#9f70ff"/> +</g> +</svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index f1e54739b3..2f97f4aa31 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -363,7 +363,7 @@ Error ColladaImport::_create_material(const String &p_target) { ERR_FAIL_COND_V(!collada.state.effect_map.has(src_mat.instance_effect), ERR_INVALID_PARAMETER); Collada::Effect &effect = collada.state.effect_map[src_mat.instance_effect]; - Ref<SpatialMaterial> material = memnew(SpatialMaterial); + Ref<StandardMaterial3D> material = memnew(StandardMaterial3D); if (src_mat.name != "") material->set_name(src_mat.name); @@ -383,9 +383,9 @@ Error ColladaImport::_create_material(const String &p_target) { Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { - material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture); material->set_albedo(Color(1, 1, 1, 1)); - //material->set_parameter(SpatialMaterial::PARAM_DIFFUSE,Color(1,1,1,1)); + //material->set_parameter(StandardMaterial3D::PARAM_DIFFUSE,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } @@ -407,11 +407,11 @@ Error ColladaImport::_create_material(const String &p_target) { Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { - material->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); + material->set_texture(StandardMaterial3D::TEXTURE_METALLIC, texture); material->set_specular(1.0); - //material->set_texture(SpatialMaterial::PARAM_SPECULAR,texture); - //material->set_parameter(SpatialMaterial::PARAM_SPECULAR,Color(1,1,1,1)); + //material->set_texture(StandardMaterial3D::PARAM_SPECULAR,texture); + //material->set_parameter(StandardMaterial3D::PARAM_SPECULAR,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } @@ -435,18 +435,18 @@ Error ColladaImport::_create_material(const String &p_target) { Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); - material->set_texture(SpatialMaterial::TEXTURE_EMISSION, texture); + material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); + material->set_texture(StandardMaterial3D::TEXTURE_EMISSION, texture); material->set_emission(Color(1, 1, 1, 1)); - //material->set_parameter(SpatialMaterial::PARAM_EMISSION,Color(1,1,1,1)); + //material->set_parameter(StandardMaterial3D::PARAM_EMISSION,Color(1,1,1,1)); } else { missing_textures.push_back(texfile.get_file()); } } } else { if (effect.emission.color != Color()) { - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); + material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); material->set_emission(effect.emission.color); } } @@ -464,11 +464,11 @@ Error ColladaImport::_create_material(const String &p_target) { Ref<Texture2D> texture = ResourceLoader::load(texfile, "Texture2D"); if (texture.is_valid()) { - material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); - material->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); + material->set_feature(StandardMaterial3D::FEATURE_NORMAL_MAPPING, true); + material->set_texture(StandardMaterial3D::TEXTURE_NORMAL, texture); //material->set_emission(Color(1,1,1,1)); - //material->set_texture(SpatialMaterial::PARAM_NORMAL,texture); + //material->set_texture(StandardMaterial3D::PARAM_NORMAL,texture); } else { //missing_textures.push_back(texfile.get_file()); } @@ -479,9 +479,11 @@ Error ColladaImport::_create_material(const String &p_target) { material->set_roughness(roughness); if (effect.double_sided) { - material->set_cull_mode(SpatialMaterial::CULL_DISABLED); + material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); + } + if (effect.unshaded) { + material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); } - material->set_flag(SpatialMaterial::FLAG_UNSHADED, effect.unshaded); material_cache[p_target] = material; return OK; @@ -877,7 +879,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me { - Ref<SpatialMaterial> material; + Ref<StandardMaterial3D> material; { diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 7d5fd9be75..65da85b684 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1385,7 +1385,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { const Dictionary &d = materials[i]; - Ref<SpatialMaterial> material; + Ref<StandardMaterial3D> material; material.instance(); if (d.has("name")) { material->set_name(d["name"]); @@ -1405,7 +1405,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (mr.has("baseColorTexture")) { const Dictionary &bct = mr["baseColorTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, _get_texture(state, bct["index"])); + material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, _get_texture(state, bct["index"])); } if (!mr.has("baseColorFactor")) { material->set_albedo(Color(1, 1, 1)); @@ -1428,10 +1428,10 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { const Dictionary &bct = mr["metallicRoughnessTexture"]; if (bct.has("index")) { const Ref<Texture2D> t = _get_texture(state, bct["index"]); - material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); - material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); - material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); - material->set_roughness_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_GREEN); + material->set_texture(StandardMaterial3D::TEXTURE_METALLIC, t); + material->set_metallic_texture_channel(StandardMaterial3D::TEXTURE_CHANNEL_BLUE); + material->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, t); + material->set_roughness_texture_channel(StandardMaterial3D::TEXTURE_CHANNEL_GREEN); if (!mr.has("metallicFactor")) { material->set_metallic(1); } @@ -1445,8 +1445,8 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (d.has("normalTexture")) { const Dictionary &bct = d["normalTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_NORMAL, _get_texture(state, bct["index"])); - material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); + material->set_texture(StandardMaterial3D::TEXTURE_NORMAL, _get_texture(state, bct["index"])); + material->set_feature(StandardMaterial3D::FEATURE_NORMAL_MAPPING, true); } if (bct.has("scale")) { material->set_normal_scale(bct["scale"]); @@ -1455,9 +1455,9 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (d.has("occlusionTexture")) { const Dictionary &bct = d["occlusionTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"])); - material->set_ao_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED); - material->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true); + material->set_texture(StandardMaterial3D::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"])); + material->set_ao_texture_channel(StandardMaterial3D::TEXTURE_CHANNEL_RED); + material->set_feature(StandardMaterial3D::FEATURE_AMBIENT_OCCLUSION, true); } } @@ -1465,7 +1465,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { const Array &arr = d["emissiveFactor"]; ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR); const Color c = Color(arr[0], arr[1], arr[2]).to_srgb(); - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); + material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); material->set_emission(c); } @@ -1473,8 +1473,8 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (d.has("emissiveTexture")) { const Dictionary &bct = d["emissiveTexture"]; if (bct.has("index")) { - material->set_texture(SpatialMaterial::TEXTURE_EMISSION, _get_texture(state, bct["index"])); - material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); + material->set_texture(StandardMaterial3D::TEXTURE_EMISSION, _get_texture(state, bct["index"])); + material->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); material->set_emission(Color(0, 0, 0)); } } @@ -1482,17 +1482,16 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (d.has("doubleSided")) { const bool ds = d["doubleSided"]; if (ds) { - material->set_cull_mode(SpatialMaterial::CULL_DISABLED); + material->set_cull_mode(StandardMaterial3D::CULL_DISABLED); } } if (d.has("alphaMode")) { const String &am = d["alphaMode"]; if (am == "BLEND") { - material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - material->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); + material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); } else if (am == "MASK") { - material->set_flag(SpatialMaterial::FLAG_USE_ALPHA_SCISSOR, true); + material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_SCISSOR); if (d.has("alphaCutoff")) { material->set_alpha_scissor_threshold(d["alphaCutoff"]); } else { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index fedf1be94f..7fd3bcc478 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -42,12 +42,12 @@ uint32_t EditorOBJImporter::get_import_flags() const { return IMPORT_SCENE; } -static Error _parse_material_library(const String &p_path, Map<String, Ref<SpatialMaterial> > &material_map, List<String> *r_missing_deps) { +static Error _parse_material_library(const String &p_path, Map<String, Ref<StandardMaterial3D> > &material_map, List<String> *r_missing_deps) { FileAccessRef f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open MTL file '%s', it may not exist or not be readable.", p_path)); - Ref<SpatialMaterial> current; + Ref<StandardMaterial3D> current; String current_name; String base_path = p_path.get_base_dir(); while (true) { @@ -102,7 +102,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati c.a = d; current->set_albedo(c); if (c.a < 0.99) { - current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + current->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); } } else if (l.begins_with("Tr ")) { //normal @@ -114,7 +114,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati c.a = 1.0 - d; current->set_albedo(c); if (c.a < 0.99) { - current->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + current->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); } } else if (l.begins_with("map_Ka ")) { @@ -136,7 +136,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + current->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -156,7 +156,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_texture(SpatialMaterial::TEXTURE_METALLIC, texture); + current->set_texture(StandardMaterial3D::TEXTURE_METALLIC, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -176,7 +176,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, texture); + current->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -190,8 +190,8 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati Ref<Texture2D> texture = ResourceLoader::load(path); if (texture.is_valid()) { - current->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); - current->set_texture(SpatialMaterial::TEXTURE_NORMAL, texture); + current->set_feature(StandardMaterial3D::FEATURE_NORMAL_MAPPING, true); + current->set_texture(StandardMaterial3D::TEXTURE_NORMAL, texture); } else if (r_missing_deps) { r_missing_deps->push_back(path); } @@ -221,7 +221,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p Vector<Vector2> uvs; String name; - Map<String, Map<String, Ref<SpatialMaterial> > > material_map; + Map<String, Map<String, Ref<StandardMaterial3D> > > material_map; Ref<SurfaceTool> surf_tool = memnew(SurfaceTool); surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES); @@ -397,7 +397,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p current_material_library = l.replace("mtllib", "").strip_edges(); if (!material_map.has(current_material_library)) { - Map<String, Ref<SpatialMaterial> > lib; + Map<String, Ref<StandardMaterial3D> > lib; Error err = _parse_material_library(current_material_library, lib, r_missing_deps); if (err == ERR_CANT_OPEN) { String dir = p_path.get_base_dir(); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 0774d0b5dc..2c2b05d6fc 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -324,19 +324,19 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Mesh> for (int i = 0; i < m->get_surface_count(); i++) { - Ref<SpatialMaterial> mat = m->surface_get_material(i); + Ref<StandardMaterial3D> mat = m->surface_get_material(i); if (!mat.is_valid()) continue; if (_teststr(mat->get_name(), "alpha")) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); mat->set_name(_fixstr(mat->get_name(), "alpha")); } if (_teststr(mat->get_name(), "vcol")) { - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); mat->set_name(_fixstr(mat->get_name(), "vcol")); } } diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 32075e82be..3de67589ee 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -545,22 +545,22 @@ Polygon3DEditor::Polygon3DEditor(EditorNode *p_editor) { imgeom = memnew(ImmediateGeometry); imgeom->set_transform(Transform(Basis(), Vector3(0, 0, 0.00001))); - line_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - 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); + line_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + line_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + line_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); line_material->set_albedo(Color(1, 1, 1)); - handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); - handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); + handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); Ref<Texture2D> handle = editor->get_gui_base()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle->get_width()); - handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle); + handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle); pointsm = memnew(MeshInstance); imgeom->add_child(pointsm); diff --git a/editor/plugins/collision_polygon_editor_plugin.h b/editor/plugins/collision_polygon_editor_plugin.h index 1871c6ee7e..3b6c25ac17 100644 --- a/editor/plugins/collision_polygon_editor_plugin.h +++ b/editor/plugins/collision_polygon_editor_plugin.h @@ -57,8 +57,8 @@ class Polygon3DEditor : public HBoxContainer { ToolButton *button_create; ToolButton *button_edit; - Ref<SpatialMaterial> line_material; - Ref<SpatialMaterial> handle_material; + Ref<StandardMaterial3D> line_material; + Ref<StandardMaterial3D> handle_material; EditorNode *editor; Panel *panel; diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index c4e6d37e7f..4e44082853 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -237,18 +237,18 @@ MaterialEditorPlugin::MaterialEditorPlugin(EditorNode *p_node) { add_inspector_plugin(plugin); } -String SpatialMaterialConversionPlugin::converts_to() const { +String StandardMaterial3DConversionPlugin::converts_to() const { return "ShaderMaterial"; } -bool SpatialMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { +bool StandardMaterial3DConversionPlugin::handles(const Ref<Resource> &p_resource) const { - Ref<SpatialMaterial> mat = p_resource; + Ref<StandardMaterial3D> mat = p_resource; return mat.is_valid(); } -Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) const { +Ref<Resource> StandardMaterial3DConversionPlugin::convert(const Ref<Resource> &p_resource) const { - Ref<SpatialMaterial> mat = p_resource; + Ref<StandardMaterial3D> mat = p_resource; ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); Ref<ShaderMaterial> smat; @@ -268,7 +268,7 @@ Ref<Resource> SpatialMaterialConversionPlugin::convert(const Ref<Resource> &p_re for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { - // Texture parameter has to be treated specially since SpatialMaterial saved it + // Texture parameter has to be treated specially since StandardMaterial3D saved it // as RID but ShaderMaterial needs Texture itself Ref<Texture2D> texture = mat->get_texture_by_name(E->get().name); if (texture.is_valid()) { diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 7f0a373dc7..95a6c4bf8f 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -100,8 +100,8 @@ public: MaterialEditorPlugin(EditorNode *p_node); }; -class SpatialMaterialConversionPlugin : public EditorResourceConversionPlugin { - GDCLASS(SpatialMaterialConversionPlugin, EditorResourceConversionPlugin); +class StandardMaterial3DConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(StandardMaterial3DConversionPlugin, EditorResourceConversionPlugin); public: virtual String converts_to() const; diff --git a/editor/plugins/path_editor_plugin.cpp b/editor/plugins/path_editor_plugin.cpp index 67889bc074..92f21d8428 100644 --- a/editor/plugins/path_editor_plugin.cpp +++ b/editor/plugins/path_editor_plugin.cpp @@ -221,9 +221,9 @@ void PathSpatialGizmo::redraw() { clear(); - Ref<SpatialMaterial> path_material = gizmo_plugin->get_material("path_material", this); - Ref<SpatialMaterial> path_thin_material = gizmo_plugin->get_material("path_thin_material", this); - Ref<SpatialMaterial> handles_material = gizmo_plugin->get_material("handles"); + Ref<StandardMaterial3D> path_material = gizmo_plugin->get_material("path_material", this); + Ref<StandardMaterial3D> path_thin_material = gizmo_plugin->get_material("path_thin_material", this); + Ref<StandardMaterial3D> handles_material = gizmo_plugin->get_material("handles"); Ref<Curve3D> c = path->get_curve(); if (c.is_null()) diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index e062246665..7c7585ff12 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4194,12 +4194,12 @@ void SpatialEditor::_generate_selection_box() { st->add_vertex(b); } - Ref<SpatialMaterial> mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); mat->set_albedo(Color(1, 1, 1)); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); st->set_material(mat); selection_box = st->commit(); } @@ -4753,9 +4753,9 @@ void SpatialEditor::_init_indicators() { grid_enabled = true; indicator_mat.instance(); - indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); Vector<Color> origin_colors; Vector<Vector3> origin_points; @@ -4838,14 +4838,14 @@ void SpatialEditor::_init_indicators() { scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); - Ref<SpatialMaterial> mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); mat->set_on_top_of_alpha(); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); mat->set_albedo(col); gizmo_color[i] = mat; - Ref<SpatialMaterial> mat_hl = mat->duplicate(); + Ref<StandardMaterial3D> mat_hl = mat->duplicate(); mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0)); gizmo_color_hl[i] = mat_hl; @@ -4933,17 +4933,17 @@ void SpatialEditor::_init_indicators() { surftool->add_vertex(points[2]); surftool->add_vertex(points[3]); - Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial); - plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref<StandardMaterial3D> plane_mat = memnew(StandardMaterial3D); + plane_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); plane_mat->set_on_top_of_alpha(); - plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + plane_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + plane_mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); plane_mat->set_albedo(col); plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides surftool->set_material(plane_mat); surftool->commit(move_plane_gizmo[i]); - Ref<SpatialMaterial> plane_mat_hl = plane_mat->duplicate(); + Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate(); plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0)); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } @@ -5063,17 +5063,17 @@ void SpatialEditor::_init_indicators() { surftool->add_vertex(points[2]); surftool->add_vertex(points[3]); - Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial); - plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref<StandardMaterial3D> plane_mat = memnew(StandardMaterial3D); + plane_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); plane_mat->set_on_top_of_alpha(); - plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + plane_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + plane_mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); plane_mat->set_albedo(col); plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides surftool->set_material(plane_mat); surftool->commit(scale_plane_gizmo[i]); - Ref<SpatialMaterial> plane_mat_hl = plane_mat->duplicate(); + Ref<StandardMaterial3D> plane_mat_hl = plane_mat->duplicate(); plane_mat_hl->set_albedo(Color(col.r, col.g, col.b, 1.0)); plane_gizmo_color_hl[i] = plane_mat_hl; // needed, so we can draw planes from both sides } @@ -6139,13 +6139,13 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); - Vector<Ref<SpatialMaterial> > mats; + Vector<Ref<StandardMaterial3D> > mats; for (int i = 0; i < 4; i++) { bool selected = i % 2 == 1; bool instanced = i < 2; - Ref<SpatialMaterial> material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + Ref<StandardMaterial3D> material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); Color color = instanced ? instanced_color : p_color; @@ -6154,17 +6154,17 @@ void EditorSpatialGizmoPlugin::create_material(const String &p_name, const Color } material->set_albedo(color); - material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - material->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN + 1); + material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + material->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN + 1); if (p_use_vertex_color) { - material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); } if (p_billboard) { - material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED); + material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); } if (p_on_top && selected) { @@ -6181,13 +6181,13 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const Color instanced_color = EDITOR_DEF("editors/3d_gizmos/gizmo_colors/instanced", Color(0.7, 0.7, 0.7, 0.6)); - Vector<Ref<SpatialMaterial> > icons; + Vector<Ref<StandardMaterial3D> > icons; for (int i = 0; i < 4; i++) { bool selected = i % 2 == 1; bool instanced = i < 2; - Ref<SpatialMaterial> icon = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + Ref<StandardMaterial3D> icon = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); Color color = instanced ? instanced_color : p_albedo; @@ -6197,16 +6197,16 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const icon->set_albedo(color); - icon->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - icon->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - icon->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - icon->set_cull_mode(SpatialMaterial::CULL_DISABLED); - icon->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_DISABLED); - icon->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - icon->set_texture(SpatialMaterial::TEXTURE_ALBEDO, p_texture); - icon->set_flag(SpatialMaterial::FLAG_FIXED_SIZE, true); - icon->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED); - icon->set_render_priority(SpatialMaterial::RENDER_PRIORITY_MIN); + icon->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + icon->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + icon->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + icon->set_cull_mode(StandardMaterial3D::CULL_DISABLED); + icon->set_depth_draw_mode(StandardMaterial3D::DEPTH_DRAW_DISABLED); + icon->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + icon->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, p_texture); + icon->set_flag(StandardMaterial3D::FLAG_FIXED_SIZE, true); + icon->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); + icon->set_render_priority(StandardMaterial3D::RENDER_PRIORITY_MIN); if (p_on_top && selected) { icon->set_on_top_of_alpha(); @@ -6219,46 +6219,46 @@ void EditorSpatialGizmoPlugin::create_icon_material(const String &p_name, const } void EditorSpatialGizmoPlugin::create_handle_material(const String &p_name, bool p_billboard) { - Ref<SpatialMaterial> handle_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + Ref<StandardMaterial3D> handle_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - handle_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - handle_material->set_flag(SpatialMaterial::FLAG_USE_POINT_SIZE, true); + handle_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + handle_material->set_flag(StandardMaterial3D::FLAG_USE_POINT_SIZE, true); Ref<Texture2D> handle_t = SpatialEditor::get_singleton()->get_icon("Editor3DHandle", "EditorIcons"); handle_material->set_point_size(handle_t->get_width()); - handle_material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, handle_t); + handle_material->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, handle_t); handle_material->set_albedo(Color(1, 1, 1)); - handle_material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - handle_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - handle_material->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + handle_material->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + handle_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + handle_material->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); handle_material->set_on_top_of_alpha(); if (p_billboard) { - handle_material->set_billboard_mode(SpatialMaterial::BILLBOARD_ENABLED); + handle_material->set_billboard_mode(StandardMaterial3D::BILLBOARD_ENABLED); handle_material->set_on_top_of_alpha(); } - materials[p_name] = Vector<Ref<SpatialMaterial> >(); + materials[p_name] = Vector<Ref<StandardMaterial3D> >(); materials[p_name].push_back(handle_material); } -void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<SpatialMaterial> p_material) { - materials[p_name] = Vector<Ref<SpatialMaterial> >(); +void EditorSpatialGizmoPlugin::add_material(const String &p_name, Ref<StandardMaterial3D> p_material) { + materials[p_name] = Vector<Ref<StandardMaterial3D> >(); materials[p_name].push_back(p_material); } -Ref<SpatialMaterial> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) { - ERR_FAIL_COND_V(!materials.has(p_name), Ref<SpatialMaterial>()); - ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<SpatialMaterial>()); +Ref<StandardMaterial3D> EditorSpatialGizmoPlugin::get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo) { + ERR_FAIL_COND_V(!materials.has(p_name), Ref<StandardMaterial3D>()); + ERR_FAIL_COND_V(materials[p_name].size() == 0, Ref<StandardMaterial3D>()); if (p_gizmo.is_null() || materials[p_name].size() == 1) return materials[p_name][0]; int index = (p_gizmo->is_selected() ? 1 : 0) + (p_gizmo->is_editable() ? 2 : 0); - Ref<SpatialMaterial> mat = materials[p_name][index]; + Ref<StandardMaterial3D> mat = materials[p_name][index]; if (current_state == ON_TOP && p_gizmo->is_selected()) { - mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, true); + mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, true); } else { - mat->set_flag(SpatialMaterial::FLAG_DISABLE_DEPTH_TEST, false); + mat->set_flag(StandardMaterial3D::FLAG_DISABLE_DEPTH_TEST, false); } return mat; diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index f82d796cda..790e058fe8 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -527,10 +527,10 @@ private: bool grid_enabled; Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3], scale_plane_gizmo[3]; - Ref<SpatialMaterial> gizmo_color[3]; - Ref<SpatialMaterial> plane_gizmo_color[3]; - Ref<SpatialMaterial> gizmo_color_hl[3]; - Ref<SpatialMaterial> plane_gizmo_color_hl[3]; + Ref<StandardMaterial3D> gizmo_color[3]; + Ref<StandardMaterial3D> plane_gizmo_color[3]; + Ref<StandardMaterial3D> gizmo_color_hl[3]; + Ref<StandardMaterial3D> plane_gizmo_color_hl[3]; int over_gizmo_handle; @@ -539,8 +539,8 @@ private: RID indicators_instance; RID cursor_mesh; RID cursor_instance; - Ref<SpatialMaterial> indicator_mat; - Ref<SpatialMaterial> cursor_material; + Ref<StandardMaterial3D> indicator_mat; + Ref<StandardMaterial3D> cursor_material; // Scene drag and drop support Spatial *preview_node; @@ -776,7 +776,7 @@ public: private: int current_state; List<EditorSpatialGizmo *> current_gizmos; - HashMap<String, Vector<Ref<SpatialMaterial> > > materials; + HashMap<String, Vector<Ref<StandardMaterial3D> > > materials; protected: static void _bind_methods(); @@ -787,9 +787,9 @@ public: void create_material(const String &p_name, const Color &p_color, bool p_billboard = false, bool p_on_top = false, bool p_use_vertex_color = false); void create_icon_material(const String &p_name, const Ref<Texture2D> &p_texture, bool p_on_top = false, const Color &p_albedo = Color(1, 1, 1, 1)); void create_handle_material(const String &p_name, bool p_billboard = false); - void add_material(const String &p_name, Ref<SpatialMaterial> p_material); + void add_material(const String &p_name, Ref<StandardMaterial3D> p_material); - Ref<SpatialMaterial> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>()); + Ref<StandardMaterial3D> get_material(const String &p_name, const Ref<EditorSpatialGizmo> &p_gizmo = Ref<EditorSpatialGizmo>()); virtual String get_name() const; virtual int get_priority() const; diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 1120d566be..68c6c12a6d 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -1580,11 +1580,11 @@ Position3DSpatialGizmoPlugin::Position3DSpatialGizmoPlugin() { cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor")); cursor_colors.push_back(EditorNode::get_singleton()->get_gui_base()->get_color("axis_z_color", "Editor")); - Ref<SpatialMaterial> mat = memnew(SpatialMaterial); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - 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); + Ref<StandardMaterial3D> mat = memnew(StandardMaterial3D); + mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); Array d; d.resize(VS::ARRAY_MAX); @@ -1991,7 +1991,7 @@ void RayCastSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3()); lines.push_back(raycast->get_cast_to()); - const Ref<SpatialMaterial> material = + const Ref<StandardMaterial3D> material = get_material(raycast->is_enabled() ? "shape_material" : "shape_material_disabled", p_gizmo); p_gizmo->add_lines(lines, material); @@ -2011,7 +2011,7 @@ void SpringArmSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { lines.push_back(Vector3()); lines.push_back(Vector3(0, 0, 1.0) * spring_arm->get_length()); - Ref<SpatialMaterial> material = get_material("shape_material", p_gizmo); + Ref<StandardMaterial3D> material = get_material("shape_material", p_gizmo); p_gizmo->add_lines(lines, material); p_gizmo->add_collision_segments(lines); |