diff options
42 files changed, 1288 insertions, 881 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); diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 69ab068648..7a84a5329d 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -995,15 +995,15 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat } aiMaterial *ai_material = state.assimp_scene->mMaterials[ai_mesh->mMaterialIndex]; - Ref<SpatialMaterial> mat; + Ref<StandardMaterial3D> mat; mat.instance(); int32_t mat_two_sided = 0; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_TWOSIDED, mat_two_sided)) { if (mat_two_sided > 0) { - mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); } else { - mat->set_cull_mode(SpatialMaterial::CULL_BACK); + mat->set_cull_mode(StandardMaterial3D::CULL_BACK); } } @@ -1015,7 +1015,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Culling handling for meshes // cull all back faces - mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // Now process materials aiTextureType base_color = aiTextureType_BASE_COLOR; @@ -1028,13 +1028,11 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // anything transparent must be culled if (image_data.raw_image->detect_alpha() != Image::ALPHA_NONE) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); - mat->set_cull_mode( - SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode } - mat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, image_data.texture); } } @@ -1048,22 +1046,18 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // anything transparent must be culled if (image_data.raw_image->detect_alpha() != Image::ALPHA_NONE) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); - mat->set_cull_mode( - SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode } - mat->set_texture(SpatialMaterial::TEXTURE_ALBEDO, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_ALBEDO, image_data.texture); } aiColor4D clr_diffuse; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_COLOR_DIFFUSE, clr_diffuse)) { if (Math::is_equal_approx(clr_diffuse.a, 1.0f) == false) { - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_depth_draw_mode(SpatialMaterial::DepthDrawMode::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); - mat->set_cull_mode( - SpatialMaterial::CULL_DISABLED); // since you can see both sides in transparent mode + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + mat->set_cull_mode(StandardMaterial3D::CULL_DISABLED); // since you can see both sides in transparent mode } mat->set_albedo(Color(clr_diffuse.r, clr_diffuse.g, clr_diffuse.b, clr_diffuse.a)); } @@ -1078,14 +1072,14 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_normal, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } else { aiString texture_path; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_NORMAL_TEXTURE, AI_PROPERTIES, texture_path)) { if (AssimpUtils::CreateAssimpTexture(state, texture_path, filename, path, image_data)) { - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } } } @@ -1100,8 +1094,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_normal_camera, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } } @@ -1114,8 +1108,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_emission_color, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::Feature::FEATURE_NORMAL_MAPPING, true); - mat->set_texture(SpatialMaterial::TEXTURE_NORMAL, image_data.texture); + mat->set_feature(StandardMaterial3D::Feature::FEATURE_NORMAL_MAPPING, true); + mat->set_texture(StandardMaterial3D::TEXTURE_NORMAL, image_data.texture); } } @@ -1128,7 +1122,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_metalness, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_texture(SpatialMaterial::TEXTURE_METALLIC, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_METALLIC, image_data.texture); } } @@ -1141,7 +1135,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_roughness, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_ROUGHNESS, image_data.texture); } } @@ -1154,16 +1148,16 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_emissive, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::FEATURE_EMISSION, true); - mat->set_texture(SpatialMaterial::TEXTURE_EMISSION, image_data.texture); + mat->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); + mat->set_texture(StandardMaterial3D::TEXTURE_EMISSION, image_data.texture); } else { // Process emission textures aiString texture_emissive_path; if (AI_SUCCESS == ai_material->Get(AI_MATKEY_FBX_MAYA_EMISSION_TEXTURE, AI_PROPERTIES, texture_emissive_path)) { if (AssimpUtils::CreateAssimpTexture(state, texture_emissive_path, filename, path, image_data)) { - mat->set_feature(SpatialMaterial::FEATURE_EMISSION, true); - mat->set_texture(SpatialMaterial::TEXTURE_EMISSION, image_data.texture); + mat->set_feature(StandardMaterial3D::FEATURE_EMISSION, true); + mat->set_texture(StandardMaterial3D::TEXTURE_EMISSION, image_data.texture); } } else { float pbr_emission = 0.0f; @@ -1183,7 +1177,7 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_specular, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_texture(SpatialMaterial::TEXTURE_METALLIC, image_data.texture); + mat->set_texture(StandardMaterial3D::TEXTURE_METALLIC, image_data.texture); } } @@ -1196,8 +1190,8 @@ EditorSceneImporterAssimp::_generate_mesh_from_surface_indices(ImportState &stat // Process texture normal map if (AssimpUtils::GetAssimpTexture(state, ai_material, tex_ao_map, filename, path, image_data)) { AssimpUtils::set_texture_mapping_mode(image_data.map_mode, image_data.texture); - mat->set_feature(SpatialMaterial::FEATURE_AMBIENT_OCCLUSION, true); - mat->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, image_data.texture); + mat->set_feature(StandardMaterial3D::FEATURE_AMBIENT_OCCLUSION, true); + mat->set_texture(StandardMaterial3D::TEXTURE_AMBIENT_OCCLUSION, image_data.texture); } } diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index dae1719aa9..69f3d1b393 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -890,8 +890,8 @@ void SpaceBullet::update_gravity() { static ImmediateGeometry *motionVec(NULL); static ImmediateGeometry *normalLine(NULL); -static Ref<SpatialMaterial> red_mat; -static Ref<SpatialMaterial> blue_mat; +static Ref<StandardMaterial3D> red_mat; +static Ref<StandardMaterial3D> blue_mat; #endif bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, bool p_infinite_inertia, PhysicsServer::MotionResult *r_result, bool p_exclude_raycast_shapes) { @@ -908,21 +908,21 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f motionVec->set_as_toplevel(true); normalLine->set_as_toplevel(true); - red_mat = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - red_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + red_mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + red_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); red_mat->set_line_width(20.0); - red_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - red_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - red_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + red_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + red_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + red_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); red_mat->set_albedo(Color(1, 0, 0, 1)); motionVec->set_material_override(red_mat); - blue_mat = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - blue_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + blue_mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + blue_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); blue_mat->set_line_width(20.0); - blue_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - blue_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - blue_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); + blue_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + blue_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + blue_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); blue_mat->set_albedo(Color(0, 0, 1, 1)); normalLine->set_material_override(blue_mat); } diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index c8a72ff813..33e4e9748c 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -896,7 +896,7 @@ void CSGMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("get_material"), &CSGMesh::get_material); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGMesh::set_mesh(const Ref<Mesh> &p_mesh) { @@ -1059,7 +1059,7 @@ void CSGSphere::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "radial_segments", PROPERTY_HINT_RANGE, "1,100,1"), "set_radial_segments", "get_radial_segments"); ADD_PROPERTY(PropertyInfo(Variant::INT, "rings", PROPERTY_HINT_RANGE, "1,100,1"), "set_rings", "get_rings"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGSphere::set_radius(const float p_radius) { @@ -1245,7 +1245,7 @@ void CSGBox::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "width", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_width", "get_width"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_height", "get_height"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth", PROPERTY_HINT_EXP_RANGE, "0.001,1000.0,0.001,or_greater"), "set_depth", "get_depth"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGBox::set_width(const float p_width) { @@ -1462,7 +1462,7 @@ void CSGCylinder::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cone"), "set_cone", "is_cone"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGCylinder::set_radius(const float p_radius) { @@ -1689,7 +1689,7 @@ void CSGTorus::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_sides", "get_sides"); ADD_PROPERTY(PropertyInfo(Variant::INT, "ring_sides", PROPERTY_HINT_RANGE, "3,64,1"), "set_ring_sides", "get_ring_sides"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); } void CSGTorus::set_inner_radius(const float p_inner_radius) { @@ -2330,7 +2330,7 @@ void CSGPolygon::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_continuous_u"), "set_path_continuous_u", "is_path_continuous_u"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "path_joined"), "set_path_joined", "is_path_joined"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_faces"), "set_smooth_faces", "get_smooth_faces"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); BIND_ENUM_CONSTANT(MODE_DEPTH); BIND_ENUM_CONSTANT(MODE_SPIN); diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 7b846569dc..2144ff264f 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -1446,8 +1446,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { inner_mat.instance(); inner_mat->set_albedo(Color(0.7, 0.7, 1.0, 0.2)); - inner_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - inner_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + inner_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + inner_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); d[VS::ARRAY_VERTEX] = triangles; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_TRIANGLES, d); @@ -1456,13 +1456,14 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { outer_mat.instance(); 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_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + + outer_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + outer_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); 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_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); d[VS::ARRAY_VERTEX] = lines; VisualServer::get_singleton()->mesh_add_surface_from_arrays(selection_mesh, VS::PRIMITIVE_LINES, d); @@ -1489,10 +1490,10 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { accumulated_floor_delta = 0.0; indicator_mat.instance(); - indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - indicator_mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + indicator_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + indicator_mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + indicator_mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); indicator_mat->set_albedo(Color(0.8, 0.5, 0.1)); } diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 5e6221b4f0..d6459cee0a 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -125,10 +125,10 @@ class GridMapEditor : public VBoxContainer { List<ClipboardItem> clipboard_items; - Ref<SpatialMaterial> indicator_mat; - Ref<SpatialMaterial> inner_mat; - Ref<SpatialMaterial> outer_mat; - Ref<SpatialMaterial> selection_floor_mat; + Ref<StandardMaterial3D> indicator_mat; + Ref<StandardMaterial3D> inner_mat; + Ref<StandardMaterial3D> outer_mat; + Ref<StandardMaterial3D> selection_floor_mat; bool updating; diff --git a/scene/3d/cpu_particles.cpp b/scene/3d/cpu_particles.cpp index e8760983e9..22b453f837 100644 --- a/scene/3d/cpu_particles.cpp +++ b/scene/3d/cpu_particles.cpp @@ -209,14 +209,14 @@ String CPUParticles::get_configuration_warning() const { mesh_found = true; for (int j = 0; j < get_mesh()->get_surface_count(); j++) { anim_material_found = Object::cast_to<ShaderMaterial>(get_mesh()->surface_get_material(j).ptr()) != NULL; - SpatialMaterial *spat = Object::cast_to<SpatialMaterial>(get_mesh()->surface_get_material(j).ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_mesh()->surface_get_material(j).ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); } } anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != NULL; - SpatialMaterial *spat = Object::cast_to<SpatialMaterial>(get_material_override().ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_material_override().ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); if (!mesh_found) { if (warnings != String()) @@ -228,7 +228,7 @@ String CPUParticles::get_configuration_warning() const { get_param_curve(PARAM_ANIM_SPEED).is_valid() || get_param_curve(PARAM_ANIM_OFFSET).is_valid())) { if (warnings != String()) warnings += "\n"; - warnings += "- " + TTR("CPUParticles animation requires the usage of a SpatialMaterial whose Billboard Mode is set to \"Particle Billboard\"."); + warnings += "- " + TTR("CPUParticles animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\"."); } return warnings; diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index e14fa9e9af..4731210768 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -101,7 +101,7 @@ void MeshInstance::_get_property_list(List<PropertyInfo> *p_list) const { if (mesh.is_valid()) { for (int i = 0; i < mesh->get_surface_count(); i++) { - p_list->push_back(PropertyInfo(Variant::OBJECT, "material/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial")); + p_list->push_back(PropertyInfo(Variant::OBJECT, "material/" + itos(i), PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D")); } } } @@ -355,12 +355,12 @@ void MeshInstance::create_debug_tangents() { if (lines.size()) { - Ref<SpatialMaterial> sm; + Ref<StandardMaterial3D> sm; sm.instance(); - sm->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - sm->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - sm->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + sm->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + sm->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + sm->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); Ref<ArrayMesh> am; am.instance(); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index add563d991..9fe626474e 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -254,16 +254,16 @@ String Particles::get_configuration_warning() const { meshes_found = true; for (int j = 0; j < draw_passes[i]->get_surface_count(); j++) { anim_material_found = Object::cast_to<ShaderMaterial>(draw_passes[i]->surface_get_material(j).ptr()) != NULL; - SpatialMaterial *spat = Object::cast_to<SpatialMaterial>(draw_passes[i]->surface_get_material(j).ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(draw_passes[i]->surface_get_material(j).ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); } if (anim_material_found) break; } } anim_material_found = anim_material_found || Object::cast_to<ShaderMaterial>(get_material_override().ptr()) != NULL; - SpatialMaterial *spat = Object::cast_to<SpatialMaterial>(get_material_override().ptr()); - anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == SpatialMaterial::BILLBOARD_PARTICLES); + StandardMaterial3D *spat = Object::cast_to<StandardMaterial3D>(get_material_override().ptr()); + anim_material_found = anim_material_found || (spat && spat->get_billboard_mode() == StandardMaterial3D::BILLBOARD_PARTICLES); if (!meshes_found) { if (warnings != String()) @@ -282,7 +282,7 @@ String Particles::get_configuration_warning() const { process->get_param_texture(ParticlesMaterial::PARAM_ANIM_SPEED).is_valid() || process->get_param_texture(ParticlesMaterial::PARAM_ANIM_OFFSET).is_valid())) { if (warnings != String()) warnings += "\n"; - warnings += "- " + TTR("Particles animation requires the usage of a SpatialMaterial whose Billboard Mode is set to \"Particle Billboard\"."); + warnings += "- " + TTR("Particles animation requires the usage of a StandardMaterial3D whose Billboard Mode is set to \"Particle Billboard\"."); } } diff --git a/scene/3d/ray_cast.cpp b/scene/3d/ray_cast.cpp index 616ab7cf40..0c976b9fb1 100644 --- a/scene/3d/ray_cast.cpp +++ b/scene/3d/ray_cast.cpp @@ -186,7 +186,7 @@ void RayCast::_notification(int p_what) { _update_raycast_state(); if (prev_collision_state != collided && get_tree()->is_debugging_collisions_hint()) { if (debug_material.is_valid()) { - Ref<SpatialMaterial> line_material = static_cast<Ref<SpatialMaterial> >(debug_material); + Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D> >(debug_material); line_material->set_albedo(collided ? Color(1.0, 0, 0) : Color(1.0, 0.8, 0.6)); } } @@ -333,10 +333,10 @@ void RayCast::_bind_methods() { void RayCast::_create_debug_shape() { if (!debug_material.is_valid()) { - debug_material = Ref<SpatialMaterial>(memnew(SpatialMaterial)); + debug_material = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); - Ref<SpatialMaterial> line_material = static_cast<Ref<SpatialMaterial> >(debug_material); - line_material->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + Ref<StandardMaterial3D> line_material = static_cast<Ref<StandardMaterial3D> >(debug_material); + line_material->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); line_material->set_albedo(Color(1.0, 0.8, 0.6)); } diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 50965b5a93..04f00a527e 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -286,14 +286,14 @@ SpriteBase3D::AlphaCutMode SpriteBase3D::get_alpha_cut_mode() const { return alpha_cut; } -void SpriteBase3D::set_billboard_mode(SpatialMaterial::BillboardMode p_mode) { +void SpriteBase3D::set_billboard_mode(StandardMaterial3D::BillboardMode p_mode) { ERR_FAIL_INDEX(p_mode, 3); billboard_mode = p_mode; _queue_update(); } -SpatialMaterial::BillboardMode SpriteBase3D::get_billboard_mode() const { +StandardMaterial3D::BillboardMode SpriteBase3D::get_billboard_mode() const { return billboard_mode; } @@ -377,7 +377,7 @@ SpriteBase3D::SpriteBase3D() { flags[i] = i == FLAG_TRANSPARENT || i == FLAG_DOUBLE_SIDED; alpha_cut = ALPHA_CUT_DISABLED; - billboard_mode = SpatialMaterial::BILLBOARD_DISABLED; + billboard_mode = StandardMaterial3D::BILLBOARD_DISABLED; axis = Vector3::AXIS_Z; pixel_size = 0.01; modulate = Color(1, 1, 1, 1); @@ -480,7 +480,7 @@ void Sprite3D::_draw() { tangent = Plane(1, 0, 0, 1); } - RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y); + RID mat = StandardMaterial3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y); VS::get_singleton()->immediate_set_material(immediate, mat); VS::get_singleton()->immediate_begin(immediate, VS::PRIMITIVE_TRIANGLES, texture->get_rid()); @@ -810,7 +810,7 @@ void AnimatedSprite3D::_draw() { tangent = Plane(1, 0, 0, -1); } - RID mat = SpatialMaterial::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == SpatialMaterial::BILLBOARD_ENABLED, get_billboard_mode() == SpatialMaterial::BILLBOARD_FIXED_Y); + RID mat = StandardMaterial3D::get_material_rid_for_2d(get_draw_flag(FLAG_SHADED), get_draw_flag(FLAG_TRANSPARENT), get_draw_flag(FLAG_DOUBLE_SIDED), get_alpha_cut_mode() == ALPHA_CUT_DISCARD, get_alpha_cut_mode() == ALPHA_CUT_OPAQUE_PREPASS, get_billboard_mode() == StandardMaterial3D::BILLBOARD_ENABLED, get_billboard_mode() == StandardMaterial3D::BILLBOARD_FIXED_Y); VS::get_singleton()->immediate_set_material(immediate, mat); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 8ec07b46ca..9c31a667b5 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -80,7 +80,7 @@ private: bool flags[FLAG_MAX]; AlphaCutMode alpha_cut; - SpatialMaterial::BillboardMode billboard_mode; + StandardMaterial3D::BillboardMode billboard_mode; bool pending_update; void _im_update(); @@ -131,8 +131,8 @@ public: void set_alpha_cut_mode(AlphaCutMode p_mode); AlphaCutMode get_alpha_cut_mode() const; - void set_billboard_mode(SpatialMaterial::BillboardMode p_mode); - SpatialMaterial::BillboardMode get_billboard_mode() const; + void set_billboard_mode(StandardMaterial3D::BillboardMode p_mode); + StandardMaterial3D::BillboardMode get_billboard_mode() const; virtual Rect2 get_item_rect() const = 0; diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index 4574dfac5f..45ceb86298 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -294,7 +294,7 @@ void GeometryInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("get_aabb"), &GeometryInstance::get_aabb); ADD_GROUP("Geometry", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial"), "set_material_override", "get_material_override"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material_override", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D"), "set_material_override", "get_material_override"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cast_shadow", PROPERTY_HINT_ENUM, "Off,On,Double-Sided,Shadows Only"), "set_cast_shadows_setting", "get_cast_shadows_setting"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "extra_cull_margin", PROPERTY_HINT_RANGE, "0,16384,0.01"), "set_extra_cull_margin", "get_extra_cull_margin"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_in_baked_light"), "set_flag", "get_flag", FLAG_USE_BAKED_LIGHT); diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp index db8d7f0851..412c53e36b 100644 --- a/scene/3d/voxel_light_baker.cpp +++ b/scene/3d/voxel_light_baker.cpp @@ -515,7 +515,7 @@ Vector<Color> VoxelLightBaker::_get_bake_texture(Ref<Image> p_image, const Color VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material> p_material) { //this way of obtaining materials is inaccurate and also does not support some compressed formats very well - Ref<SpatialMaterial> mat = p_material; + Ref<StandardMaterial3D> mat = p_material; Ref<Material> material = mat; //hack for now @@ -527,7 +527,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material if (mat.is_valid()) { - Ref<Texture2D> albedo_tex = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO); + Ref<Texture2D> albedo_tex = mat->get_texture(StandardMaterial3D::TEXTURE_ALBEDO); Ref<Image> img_albedo; if (albedo_tex.is_valid()) { @@ -538,7 +538,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive } - Ref<Texture2D> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); + Ref<Texture2D> emission_tex = mat->get_texture(StandardMaterial3D::TEXTURE_EMISSION); Color emission_col = mat->get_emission(); float emission_energy = mat->get_emission_energy(); @@ -550,7 +550,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material img_emission = emission_tex->get_data(); } - if (mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD) { + if (mat->get_emission_operator() == StandardMaterial3D::EMISSION_OP_ADD) { mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy); } else { mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0)); @@ -2392,11 +2392,11 @@ Ref<MultiMesh> VoxelLightBaker::create_debug_multimesh(DebugMode p_mode) { } { - Ref<SpatialMaterial> fsm; + Ref<StandardMaterial3D> fsm; fsm.instance(); - fsm->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - fsm->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - fsm->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + fsm->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + fsm->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + fsm->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); fsm->set_albedo(Color(1, 1, 1, 1)); mesh->surface_set_material(0, fsm); diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index 32ceeb4dbf..fe062e0a20 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -79,7 +79,7 @@ void RootMotionView::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - VS::get_singleton()->immediate_set_material(immediate, SpatialMaterial::get_material_rid_for_2d(false, true, false, false, false)); + VS::get_singleton()->immediate_set_material(immediate, StandardMaterial3D::get_material_rid_for_2d(false, true, false, false, false)); first = true; } diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index f7c392f8c5..a27f8c4d94 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -792,11 +792,11 @@ Ref<Material> SceneTree::get_debug_navigation_material() { if (navigation_material.is_valid()) return navigation_material; - Ref<SpatialMaterial> 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_SRGB_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref<StandardMaterial3D> 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_SRGB_VERTEX_COLOR, true); + line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_albedo(get_debug_navigation_color()); navigation_material = line_material; @@ -809,11 +809,11 @@ Ref<Material> SceneTree::get_debug_navigation_disabled_material() { if (navigation_disabled_material.is_valid()) return navigation_disabled_material; - Ref<SpatialMaterial> 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_SRGB_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref<StandardMaterial3D> 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_SRGB_VERTEX_COLOR, true); + line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_albedo(get_debug_navigation_disabled_color()); navigation_disabled_material = line_material; @@ -825,11 +825,11 @@ Ref<Material> SceneTree::get_debug_collision_material() { if (collision_material.is_valid()) return collision_material; - Ref<SpatialMaterial> 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_SRGB_VERTEX_COLOR, true); - line_material->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref<StandardMaterial3D> 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_SRGB_VERTEX_COLOR, true); + line_material->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); line_material->set_albedo(get_debug_collisions_color()); collision_material = line_material; @@ -844,11 +844,11 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() { debug_contact_mesh = Ref<ArrayMesh>(memnew(ArrayMesh)); - Ref<SpatialMaterial> mat = Ref<SpatialMaterial>(memnew(SpatialMaterial)); - mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); - mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); - mat->set_flag(SpatialMaterial::FLAG_SRGB_VERTEX_COLOR, true); - mat->set_flag(SpatialMaterial::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); + Ref<StandardMaterial3D> mat = Ref<StandardMaterial3D>(memnew(StandardMaterial3D)); + mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED); + mat->set_transparency(StandardMaterial3D::TRANSPARENCY_ALPHA); + mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); + mat->set_flag(StandardMaterial3D::FLAG_ALBEDO_FROM_VERTEX_COLOR, true); mat->set_albedo(get_debug_collision_contact_color()); Vector3 diamond[6] = { diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index e0ac7c9e0c..de7600d417 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -621,9 +621,11 @@ void register_scene_types() { ClassDB::register_class<SphereMesh>(); ClassDB::register_class<PointMesh>(); ClassDB::register_virtual_class<Material>(); - ClassDB::register_class<SpatialMaterial>(); - SceneTree::add_idle_callback(SpatialMaterial::flush_changes); - SpatialMaterial::init_shaders(); + ClassDB::register_virtual_class<BaseMaterial3D>(); + ClassDB::register_class<StandardMaterial3D>(); + ClassDB::register_class<ORMMaterial3D>(); + SceneTree::add_idle_callback(BaseMaterial3D::flush_changes); + BaseMaterial3D::init_shaders(); ClassDB::register_class<MeshLibrary>(); @@ -732,7 +734,7 @@ void register_scene_types() { #ifndef DISABLE_DEPRECATED ClassDB::add_compatibility_class("ImageSkyBox", "PanoramaSky"); - ClassDB::add_compatibility_class("FixedSpatialMaterial", "SpatialMaterial"); + ClassDB::add_compatibility_class("SpatialMaterial", "StandardMaterial3D"); ClassDB::add_compatibility_class("Mesh", "ArrayMesh"); ClassDB::add_compatibility_class("AnimationTreePlayer", "AnimationTree"); #endif @@ -807,9 +809,9 @@ void unregister_scene_types() { ResourceLoader::remove_resource_format_loader(resource_loader_bmfont); resource_loader_bmfont.unref(); - //SpatialMaterial is not initialised when 3D is disabled, so it shouldn't be cleaned up either + //StandardMaterial3D is not initialised when 3D is disabled, so it shouldn't be cleaned up either #ifndef _3D_DISABLED - SpatialMaterial::finish_shaders(); + BaseMaterial3D::finish_shaders(); #endif // _3D_DISABLED ParticlesMaterial::finish_shaders(); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 8569d998e4..cc6b55c316 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -290,18 +290,18 @@ ShaderMaterial::~ShaderMaterial() { ///////////////////////////////// -Mutex *SpatialMaterial::material_mutex = NULL; -SelfList<SpatialMaterial>::List *SpatialMaterial::dirty_materials = NULL; -Map<SpatialMaterial::MaterialKey, SpatialMaterial::ShaderData> SpatialMaterial::shader_map; -SpatialMaterial::ShaderNames *SpatialMaterial::shader_names = NULL; +Mutex *BaseMaterial3D::material_mutex = NULL; +SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = NULL; +Map<BaseMaterial3D::MaterialKey, BaseMaterial3D::ShaderData> BaseMaterial3D::shader_map; +BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = NULL; -void SpatialMaterial::init_shaders() { +void BaseMaterial3D::init_shaders() { #ifndef NO_THREADS material_mutex = Mutex::create(); #endif - dirty_materials = memnew(SelfList<SpatialMaterial>::List); + dirty_materials = memnew(SelfList<BaseMaterial3D>::List); shader_names = memnew(ShaderNames); @@ -317,7 +317,7 @@ void SpatialMaterial::init_shaders() { shader_names->clearcoat = "clearcoat"; shader_names->clearcoat_gloss = "clearcoat_gloss"; shader_names->anisotropy = "anisotropy_ratio"; - shader_names->depth_scale = "depth_scale"; + shader_names->heightmap_scale = "heightmap_scale"; shader_names->subsurface_scattering_strength = "subsurface_scattering_strength"; shader_names->transmission = "transmission"; shader_names->refraction = "refraction"; @@ -332,9 +332,9 @@ void SpatialMaterial::init_shaders() { shader_names->particles_anim_h_frames = "particles_anim_h_frames"; shader_names->particles_anim_v_frames = "particles_anim_v_frames"; shader_names->particles_anim_loop = "particles_anim_loop"; - shader_names->depth_min_layers = "depth_min_layers"; - shader_names->depth_max_layers = "depth_max_layers"; - shader_names->depth_flip = "depth_flip"; + shader_names->heightmap_min_layers = "heightmap_min_layers"; + shader_names->heightmap_max_layers = "heightmap_max_layers"; + shader_names->heightmap_flip = "heightmap_flip"; shader_names->grow = "grow"; @@ -345,11 +345,10 @@ void SpatialMaterial::init_shaders() { shader_names->distance_fade_max = "distance_fade_max"; shader_names->metallic_texture_channel = "metallic_texture_channel"; - shader_names->roughness_texture_channel = "roughness_texture_channel"; shader_names->ao_texture_channel = "ao_texture_channel"; shader_names->clearcoat_texture_channel = "clearcoat_texture_channel"; shader_names->rim_texture_channel = "rim_texture_channel"; - shader_names->depth_texture_channel = "depth_texture_channel"; + shader_names->heightmap_texture_channel = "heightmap_texture_channel"; shader_names->refraction_texture_channel = "refraction_texture_channel"; shader_names->alpha_scissor_threshold = "alpha_scissor_threshold"; @@ -362,18 +361,19 @@ void SpatialMaterial::init_shaders() { shader_names->texture_names[TEXTURE_CLEARCOAT] = "texture_clearcoat"; shader_names->texture_names[TEXTURE_FLOWMAP] = "texture_flowmap"; shader_names->texture_names[TEXTURE_AMBIENT_OCCLUSION] = "texture_ambient_occlusion"; - shader_names->texture_names[TEXTURE_DEPTH] = "texture_depth"; + shader_names->texture_names[TEXTURE_HEIGHTMAP] = "texture_heightmap"; shader_names->texture_names[TEXTURE_SUBSURFACE_SCATTERING] = "texture_subsurface_scattering"; shader_names->texture_names[TEXTURE_TRANSMISSION] = "texture_transmission"; shader_names->texture_names[TEXTURE_REFRACTION] = "texture_refraction"; shader_names->texture_names[TEXTURE_DETAIL_MASK] = "texture_detail_mask"; shader_names->texture_names[TEXTURE_DETAIL_ALBEDO] = "texture_detail_albedo"; shader_names->texture_names[TEXTURE_DETAIL_NORMAL] = "texture_detail_normal"; + shader_names->texture_names[TEXTURE_ORM] = "texture_orm"; } -Ref<SpatialMaterial> SpatialMaterial::materials_for_2d[SpatialMaterial::MAX_MATERIALS_FOR_2D]; +Ref<StandardMaterial3D> BaseMaterial3D::materials_for_2d[BaseMaterial3D::MAX_MATERIALS_FOR_2D]; -void SpatialMaterial::finish_shaders() { +void BaseMaterial3D::finish_shaders() { for (int i = 0; i < MAX_MATERIALS_FOR_2D; i++) { materials_for_2d[i].unref(); @@ -389,7 +389,7 @@ void SpatialMaterial::finish_shaders() { memdelete(shader_names); } -void SpatialMaterial::_update_shader() { +void BaseMaterial3D::_update_shader() { dirty_materials->remove(&element); @@ -415,6 +415,22 @@ void SpatialMaterial::_update_shader() { return; } + String texfilter_str; + switch (texture_filter) { + case TEXTURE_FILTER_NEAREST: texfilter_str = "filter_nearest"; break; + case TEXTURE_FILTER_LINEAR: texfilter_str = "filter_linear"; break; + case TEXTURE_FILTER_NEAREST_WITH_MIMPAMPS: texfilter_str = "filter_nearest_mipmap"; break; + case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS: texfilter_str = "filter_linear_mipmap"; break; + case TEXTURE_FILTER_NEAREST_WITH_MIMPAMPS_ANISOTROPIC: texfilter_str = "filter_nearest_mipmap_aniso"; break; + case TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: texfilter_str = "filter_linear_mipmap_aniso"; break; + } + + if (flags[FLAG_USE_TEXTURE_REPEAT]) { + texfilter_str += ",repeat_enable"; + } else { + texfilter_str += ",repeat_disable"; + } + //must create a shader! String code = "shader_type spatial;\nrender_mode "; @@ -434,7 +450,10 @@ void SpatialMaterial::_update_shader() { case DEPTH_DRAW_OPAQUE_ONLY: code += ",depth_draw_opaque"; break; case DEPTH_DRAW_ALWAYS: code += ",depth_draw_always"; break; case DEPTH_DRAW_DISABLED: code += ",depth_draw_never"; break; - case DEPTH_DRAW_ALPHA_OPAQUE_PREPASS: code += ",depth_draw_alpha_prepass"; break; + } + + if (transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS) { + code += ",depth_prepass_alpha"; } switch (cull_mode) { @@ -457,36 +476,28 @@ void SpatialMaterial::_update_shader() { case SPECULAR_DISABLED: code += ",specular_disabled"; break; } - if (flags[FLAG_UNSHADED]) { + if (shading_mode == SHADING_MODE_UNSHADED) { code += ",unshaded"; } if (flags[FLAG_DISABLE_DEPTH_TEST]) { code += ",depth_test_disabled"; } - if (flags[FLAG_USE_VERTEX_LIGHTING]) { + if (shading_mode == SHADING_MODE_PER_VERTEX) { code += ",vertex_lighting"; } - if (flags[FLAG_TRIPLANAR_USE_WORLD] && (flags[FLAG_UV1_USE_TRIPLANAR] || flags[FLAG_UV2_USE_TRIPLANAR])) { - code += ",world_vertex_coords"; - } if (flags[FLAG_DONT_RECEIVE_SHADOWS]) { code += ",shadows_disabled"; } if (flags[FLAG_DISABLE_AMBIENT_LIGHT]) { code += ",ambient_light_disabled"; } - if (flags[FLAG_ENSURE_CORRECT_NORMALS]) { - code += ",ensure_correct_normals"; - } if (flags[FLAG_USE_SHADOW_TO_OPACITY]) { code += ",shadow_to_opacity"; } code += ";\n"; code += "uniform vec4 albedo : hint_color;\n"; - code += "uniform sampler2D texture_albedo : hint_albedo;\n"; - code += "uniform float specular;\n"; - code += "uniform float metallic;\n"; + code += "uniform sampler2D texture_albedo : hint_albedo," + texfilter_str + ";\n"; if (grow_enabled) { code += "uniform float grow;\n"; } @@ -499,21 +510,41 @@ void SpatialMaterial::_update_shader() { code += "uniform float distance_fade_max;\n"; } - if (flags[FLAG_USE_ALPHA_SCISSOR]) { + if (transparency == TRANSPARENCY_ALPHA_SCISSOR) { code += "uniform float alpha_scissor_threshold;\n"; } - code += "uniform float roughness : hint_range(0,1);\n"; + code += "uniform float point_size : hint_range(0,128);\n"; - if (textures[TEXTURE_METALLIC] != NULL) { - code += "uniform sampler2D texture_metallic : hint_white;\n"; + //TODO ALL HINTS + if (!orm) { + code += "uniform float roughness : hint_range(0,1);\n"; + code += "uniform sampler2D texture_metallic : hint_white," + texfilter_str + ";\n"; code += "uniform vec4 metallic_texture_channel;\n"; - } + switch (roughness_texture_channel) { + case TEXTURE_CHANNEL_RED: { + code += "uniform sampler2D texture_roughness : hint_roughness_r," + texfilter_str + ";\n"; + } break; + case TEXTURE_CHANNEL_GREEN: { + code += "uniform sampler2D texture_roughness : hint_roughness_g," + texfilter_str + ";\n"; + } break; + case TEXTURE_CHANNEL_BLUE: { + code += "uniform sampler2D texture_roughness : hint_roughness_b," + texfilter_str + ";\n"; + } break; + case TEXTURE_CHANNEL_ALPHA: { + code += "uniform sampler2D texture_roughness : hint_roughness_a," + texfilter_str + ";\n"; + } break; + case TEXTURE_CHANNEL_GRAYSCALE: { + code += "uniform sampler2D texture_roughness : hint_roughness_gray," + texfilter_str + ";\n"; + } break; + } - if (textures[TEXTURE_ROUGHNESS] != NULL) { - code += "uniform sampler2D texture_roughness : hint_white;\n"; - code += "uniform vec4 roughness_texture_channel;\n"; + code += "uniform float specular;\n"; + code += "uniform float metallic;\n"; + } else { + code += "uniform sampler2D texture_orm : hint_roughness_g," + texfilter_str + ";\n"; } + if (billboard_mode == BILLBOARD_PARTICLES) { code += "uniform int particles_anim_h_frames;\n"; code += "uniform int particles_anim_v_frames;\n"; @@ -522,34 +553,34 @@ void SpatialMaterial::_update_shader() { if (features[FEATURE_EMISSION]) { - code += "uniform sampler2D texture_emission : hint_black_albedo;\n"; + code += "uniform sampler2D texture_emission : hint_black_albedo," + texfilter_str + ";\n"; code += "uniform vec4 emission : hint_color;\n"; code += "uniform float emission_energy;\n"; } if (features[FEATURE_REFRACTION]) { - code += "uniform sampler2D texture_refraction;\n"; + code += "uniform sampler2D texture_refraction : " + texfilter_str + ";\n"; code += "uniform float refraction : hint_range(-16,16);\n"; code += "uniform vec4 refraction_texture_channel;\n"; } if (features[FEATURE_NORMAL_MAPPING]) { - code += "uniform sampler2D texture_normal : hint_normal;\n"; + code += "uniform sampler2D texture_normal : hint_roughness_normal," + texfilter_str + ";\n"; code += "uniform float normal_scale : hint_range(-16,16);\n"; } if (features[FEATURE_RIM]) { code += "uniform float rim : hint_range(0,1);\n"; code += "uniform float rim_tint : hint_range(0,1);\n"; - code += "uniform sampler2D texture_rim : hint_white;\n"; + code += "uniform sampler2D texture_rim : hint_white," + texfilter_str + ";\n"; } if (features[FEATURE_CLEARCOAT]) { code += "uniform float clearcoat : hint_range(0,1);\n"; code += "uniform float clearcoat_gloss : hint_range(0,1);\n"; - code += "uniform sampler2D texture_clearcoat : hint_white;\n"; + code += "uniform sampler2D texture_clearcoat : hint_white," + texfilter_str + ";\n"; } if (features[FEATURE_ANISOTROPY]) { code += "uniform float anisotropy_ratio : hint_range(0,256);\n"; - code += "uniform sampler2D texture_flowmap : hint_aniso;\n"; + code += "uniform sampler2D texture_flowmap : hint_aniso," + texfilter_str + ";\n"; } if (features[FEATURE_AMBIENT_OCCLUSION]) { code += "uniform sampler2D texture_ambient_occlusion : hint_white;\n"; @@ -558,29 +589,29 @@ void SpatialMaterial::_update_shader() { } if (features[FEATURE_DETAIL]) { - code += "uniform sampler2D texture_detail_albedo : hint_albedo;\n"; - code += "uniform sampler2D texture_detail_normal : hint_normal;\n"; - code += "uniform sampler2D texture_detail_mask : hint_white;\n"; + code += "uniform sampler2D texture_detail_albedo : hint_albedo," + texfilter_str + ";\n"; + code += "uniform sampler2D texture_detail_normal : hint_normal," + texfilter_str + ";\n"; + code += "uniform sampler2D texture_detail_mask : hint_white," + texfilter_str + ";\n"; } if (features[FEATURE_SUBSURACE_SCATTERING]) { code += "uniform float subsurface_scattering_strength : hint_range(0,1);\n"; - code += "uniform sampler2D texture_subsurface_scattering : hint_white;\n"; + code += "uniform sampler2D texture_subsurface_scattering : hint_white," + texfilter_str + ";\n"; } if (features[FEATURE_TRANSMISSION]) { code += "uniform vec4 transmission : hint_color;\n"; - code += "uniform sampler2D texture_transmission : hint_black;\n"; + code += "uniform sampler2D texture_transmission : hint_black," + texfilter_str + ";\n"; } - if (features[FEATURE_DEPTH_MAPPING]) { - code += "uniform sampler2D texture_depth : hint_black;\n"; - code += "uniform float depth_scale;\n"; - code += "uniform int depth_min_layers;\n"; - code += "uniform int depth_max_layers;\n"; - code += "uniform vec2 depth_flip;\n"; + if (features[FEATURE_HEIGHT_MAPPING]) { + code += "uniform sampler2D texture_heightmap : hint_black," + texfilter_str + ";\n"; + code += "uniform float heightmap_scale;\n"; + code += "uniform int heightmap_min_layers;\n"; + code += "uniform int heightmap_max_layers;\n"; + code += "uniform vec2 heightmap_flip;\n"; } if (flags[FLAG_UV1_USE_TRIPLANAR]) { code += "varying vec3 uv1_triplanar_pos;\n"; @@ -618,7 +649,7 @@ void SpatialMaterial::_update_shader() { code += "\tPOINT_SIZE=point_size;\n"; } - if (flags[FLAG_USE_VERTEX_LIGHTING]) { + if (shading_mode == SHADING_MODE_PER_VERTEX) { code += "\tROUGHNESS=roughness;\n"; } @@ -750,33 +781,49 @@ void SpatialMaterial::_update_shader() { code += "\tvec2 base_uv2 = UV2;\n"; } - if (!VisualServer::get_singleton()->is_low_end() && features[FEATURE_DEPTH_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //depthmap not supported with triplanar + if (!VisualServer::get_singleton()->is_low_end() && features[FEATURE_HEIGHT_MAPPING] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //heightmap not supported with triplanar code += "\t{\n"; - code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*depth_flip.x,-BINORMAL*depth_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-) + code += "\t\tvec3 view_dir = normalize(normalize(-VERTEX)*mat3(TANGENT*heightmap_flip.x,-BINORMAL*heightmap_flip.y,NORMAL));\n"; // binormal is negative due to mikktspace, flip 'unflips' it ;-) if (deep_parallax) { - code += "\t\tfloat num_layers = mix(float(depth_max_layers),float(depth_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n"; + code += "\t\tfloat num_layers = mix(float(heightmap_max_layers),float(heightmap_min_layers), abs(dot(vec3(0.0, 0.0, 1.0), view_dir)));\n"; code += "\t\tfloat layer_depth = 1.0 / num_layers;\n"; code += "\t\tfloat current_layer_depth = 0.0;\n"; - code += "\t\tvec2 P = view_dir.xy * depth_scale;\n"; + code += "\t\tvec2 P = view_dir.xy * heightmap_scale;\n"; code += "\t\tvec2 delta = P / num_layers;\n"; code += "\t\tvec2 ofs = base_uv;\n"; - code += "\t\tfloat depth = textureLod(texture_depth, ofs,0.0).r;\n"; + if (flags[FLAG_INVERT_HEIGHTMAP]) { + code += "\t\tfloat depth = texture(texture_heightmap, ofs).r;\n"; + } else { + code += "\t\tfloat depth = 1.0 - texture(texture_heightmap, ofs).r;\n"; + } code += "\t\tfloat current_depth = 0.0;\n"; code += "\t\twhile(current_depth < depth) {\n"; code += "\t\t\tofs -= delta;\n"; - code += "\t\t\tdepth = textureLod(texture_depth, ofs,0.0).r;\n"; + if (flags[FLAG_INVERT_HEIGHTMAP]) { + code += "\t\t\tdepth = texture(texture_heightmap, ofs).r;\n"; + } else { + code += "\t\t\tdepth = 1.0 - texture(texture_heightmap, ofs).r;\n"; + } code += "\t\t\tcurrent_depth += layer_depth;\n"; code += "\t\t}\n"; code += "\t\tvec2 prev_ofs = ofs + delta;\n"; code += "\t\tfloat after_depth = depth - current_depth;\n"; - code += "\t\tfloat before_depth = textureLod(texture_depth, prev_ofs, 0.0).r - current_depth + layer_depth;\n"; + if (flags[FLAG_INVERT_HEIGHTMAP]) { + code += "\t\tfloat before_depth = texture(texture_heightmap, prev_ofs).r - current_depth + layer_depth;\n"; + } else { + code += "\t\tfloat before_depth = ( 1.0 - texture(texture_heightmap, prev_ofs).r ) - current_depth + layer_depth;\n"; + } code += "\t\tfloat weight = after_depth / (after_depth - before_depth);\n"; code += "\t\tofs = mix(ofs,prev_ofs,weight);\n"; } else { - code += "\t\tfloat depth = texture(texture_depth, base_uv).r;\n"; - code += "\t\tvec2 ofs = base_uv - view_dir.xy / view_dir.z * (depth * depth_scale);\n"; + if (flags[FLAG_INVERT_HEIGHTMAP]) { + code += "\t\tfloat depth = texture(texture_heightmap, base_uv).r;\n"; + } else { + code += "\t\tfloat depth = 1.0 - texture(texture_heightmap, base_uv).r;\n"; + } + code += "\t\tvec2 ofs = base_uv - view_dir.xy / view_dir.z * (depth * heightmap_scale);\n"; } code += "\t\tbase_uv=ofs;\n"; @@ -806,29 +853,49 @@ void SpatialMaterial::_update_shader() { } code += "\tALBEDO = albedo.rgb * albedo_tex.rgb;\n"; - if (textures[TEXTURE_METALLIC] != NULL) { + if (!orm) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { code += "\tfloat metallic_tex = dot(triplanar_texture(texture_metallic,uv1_power_normal,uv1_triplanar_pos),metallic_texture_channel);\n"; } else { code += "\tfloat metallic_tex = dot(texture(texture_metallic,base_uv),metallic_texture_channel);\n"; } code += "\tMETALLIC = metallic_tex * metallic;\n"; - } else { - code += "\tMETALLIC = metallic;\n"; - } - if (textures[TEXTURE_ROUGHNESS] != NULL) { + switch (roughness_texture_channel) { + case TEXTURE_CHANNEL_RED: { + code += "\tvec4 roughness_texture_channel = vec4(1.0,0.0,0.0,0.0);\n"; + } break; + case TEXTURE_CHANNEL_GREEN: { + code += "\tvec4 roughness_texture_channel = vec4(0.0,1.0,0.0,0.0);\n"; + } break; + case TEXTURE_CHANNEL_BLUE: { + code += "\tvec4 roughness_texture_channel = vec4(0.0,0.0,1.0,0.0);\n"; + } break; + case TEXTURE_CHANNEL_ALPHA: { + code += "\tvec4 roughness_texture_channel = vec4(0.0,0.0,0.0,1.0);\n"; + } break; + case TEXTURE_CHANNEL_GRAYSCALE: { + code += "\tvec4 roughness_texture_channel = vec4(0.333333,0.333333,0.333333,0.0);\n"; + } break; + } + if (flags[FLAG_UV1_USE_TRIPLANAR]) { code += "\tfloat roughness_tex = dot(triplanar_texture(texture_roughness,uv1_power_normal,uv1_triplanar_pos),roughness_texture_channel);\n"; } else { code += "\tfloat roughness_tex = dot(texture(texture_roughness,base_uv),roughness_texture_channel);\n"; } code += "\tROUGHNESS = roughness_tex * roughness;\n"; + code += "\tSPECULAR = specular;\n"; } else { - code += "\tROUGHNESS = roughness;\n"; - } + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tfloat orm_tex = triplanar_texture(texture_orm,uv1_power_normal,uv1_triplanar_pos);\n"; + } else { + code += "\tfloat orm_tex = texture(texture_orm,base_uv);\n"; + } - code += "\tSPECULAR = specular;\n"; + code += "\tROUGHNESS = orm_tex.g;\n"; + code += "\tMETALLIC = orm_tex.b;\n"; + } if (features[FEATURE_NORMAL_MAPPING]) { if (flags[FLAG_UV1_USE_TRIPLANAR]) { @@ -878,8 +945,10 @@ void SpatialMaterial::_update_shader() { code += "\tALBEDO *= 1.0 - ref_amount;\n"; code += "\tALPHA = 1.0;\n"; - } else if (features[FEATURE_TRANSPARENT] || flags[FLAG_USE_ALPHA_SCISSOR] || flags[FLAG_USE_SHADOW_TO_OPACITY] || (distance_fade == DISTANCE_FADE_PIXEL_ALPHA) || proximity_fade_enabled) { + } else if (transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS || flags[FLAG_USE_SHADOW_TO_OPACITY] || (distance_fade == DISTANCE_FADE_PIXEL_ALPHA) || proximity_fade_enabled) { code += "\tALPHA = albedo.a * albedo_tex.a;\n"; + } else if (transparency == TRANSPARENCY_ALPHA_SCISSOR) { + code += "\tif (albedo.a * albedo_tex.a < alpha_scissor_threshold) discard;\n"; } if (proximity_fade_enabled) { @@ -965,18 +1034,23 @@ void SpatialMaterial::_update_shader() { } if (features[FEATURE_AMBIENT_OCCLUSION]) { - if (flags[FLAG_AO_ON_UV2]) { - if (flags[FLAG_UV2_USE_TRIPLANAR]) { - code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_triplanar_pos),ao_texture_channel);\n"; + + if (!orm) { + if (flags[FLAG_AO_ON_UV2]) { + if (flags[FLAG_UV2_USE_TRIPLANAR]) { + code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv2_power_normal,uv2_triplanar_pos),ao_texture_channel);\n"; + } else { + code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n"; + } } else { - code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv2),ao_texture_channel);\n"; + if (flags[FLAG_UV1_USE_TRIPLANAR]) { + code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_triplanar_pos),ao_texture_channel);\n"; + } else { + code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; + } } } else { - if (flags[FLAG_UV1_USE_TRIPLANAR]) { - code += "\tAO = dot(triplanar_texture(texture_ambient_occlusion,uv1_power_normal,uv1_triplanar_pos),ao_texture_channel);\n"; - } else { - code += "\tAO = dot(texture(texture_ambient_occlusion,base_uv),ao_texture_channel);\n"; - } + code += "\tAO = orm_tex.r;\n"; } code += "\tAO_LIGHT_AFFECT = ao_light_affect;\n"; @@ -1043,10 +1117,6 @@ void SpatialMaterial::_update_shader() { code += "\tALBEDO.rgb = mix(ALBEDO.rgb,detail,detail_mask_tex.r);\n"; } - if (flags[FLAG_USE_ALPHA_SCISSOR]) { - code += "\tALPHA_SCISSOR=alpha_scissor_threshold;\n"; - } - code += "}\n"; ShaderData shader_data; @@ -1060,7 +1130,7 @@ void SpatialMaterial::_update_shader() { VS::get_singleton()->material_set_shader(_get_material(), shader_data.shader); } -void SpatialMaterial::flush_changes() { +void BaseMaterial3D::flush_changes() { if (material_mutex) material_mutex->lock(); @@ -1074,7 +1144,7 @@ void SpatialMaterial::flush_changes() { material_mutex->unlock(); } -void SpatialMaterial::_queue_shader_change() { +void BaseMaterial3D::_queue_shader_change() { if (material_mutex) material_mutex->lock(); @@ -1087,7 +1157,7 @@ void SpatialMaterial::_queue_shader_change() { material_mutex->unlock(); } -bool SpatialMaterial::_is_shader_dirty() const { +bool BaseMaterial3D::_is_shader_dirty() const { bool dirty = false; @@ -1101,188 +1171,188 @@ bool SpatialMaterial::_is_shader_dirty() const { return dirty; } -void SpatialMaterial::set_albedo(const Color &p_albedo) { +void BaseMaterial3D::set_albedo(const Color &p_albedo) { albedo = p_albedo; VS::get_singleton()->material_set_param(_get_material(), shader_names->albedo, p_albedo); } -Color SpatialMaterial::get_albedo() const { +Color BaseMaterial3D::get_albedo() const { return albedo; } -void SpatialMaterial::set_specular(float p_specular) { +void BaseMaterial3D::set_specular(float p_specular) { specular = p_specular; VS::get_singleton()->material_set_param(_get_material(), shader_names->specular, p_specular); } -float SpatialMaterial::get_specular() const { +float BaseMaterial3D::get_specular() const { return specular; } -void SpatialMaterial::set_roughness(float p_roughness) { +void BaseMaterial3D::set_roughness(float p_roughness) { roughness = p_roughness; VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness, p_roughness); } -float SpatialMaterial::get_roughness() const { +float BaseMaterial3D::get_roughness() const { return roughness; } -void SpatialMaterial::set_metallic(float p_metallic) { +void BaseMaterial3D::set_metallic(float p_metallic) { metallic = p_metallic; VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic, p_metallic); } -float SpatialMaterial::get_metallic() const { +float BaseMaterial3D::get_metallic() const { return metallic; } -void SpatialMaterial::set_emission(const Color &p_emission) { +void BaseMaterial3D::set_emission(const Color &p_emission) { emission = p_emission; VS::get_singleton()->material_set_param(_get_material(), shader_names->emission, p_emission); } -Color SpatialMaterial::get_emission() const { +Color BaseMaterial3D::get_emission() const { return emission; } -void SpatialMaterial::set_emission_energy(float p_emission_energy) { +void BaseMaterial3D::set_emission_energy(float p_emission_energy) { emission_energy = p_emission_energy; VS::get_singleton()->material_set_param(_get_material(), shader_names->emission_energy, p_emission_energy); } -float SpatialMaterial::get_emission_energy() const { +float BaseMaterial3D::get_emission_energy() const { return emission_energy; } -void SpatialMaterial::set_normal_scale(float p_normal_scale) { +void BaseMaterial3D::set_normal_scale(float p_normal_scale) { normal_scale = p_normal_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->normal_scale, p_normal_scale); } -float SpatialMaterial::get_normal_scale() const { +float BaseMaterial3D::get_normal_scale() const { return normal_scale; } -void SpatialMaterial::set_rim(float p_rim) { +void BaseMaterial3D::set_rim(float p_rim) { rim = p_rim; VS::get_singleton()->material_set_param(_get_material(), shader_names->rim, p_rim); } -float SpatialMaterial::get_rim() const { +float BaseMaterial3D::get_rim() const { return rim; } -void SpatialMaterial::set_rim_tint(float p_rim_tint) { +void BaseMaterial3D::set_rim_tint(float p_rim_tint) { rim_tint = p_rim_tint; VS::get_singleton()->material_set_param(_get_material(), shader_names->rim_tint, p_rim_tint); } -float SpatialMaterial::get_rim_tint() const { +float BaseMaterial3D::get_rim_tint() const { return rim_tint; } -void SpatialMaterial::set_ao_light_affect(float p_ao_light_affect) { +void BaseMaterial3D::set_ao_light_affect(float p_ao_light_affect) { ao_light_affect = p_ao_light_affect; VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_light_affect, p_ao_light_affect); } -float SpatialMaterial::get_ao_light_affect() const { +float BaseMaterial3D::get_ao_light_affect() const { return ao_light_affect; } -void SpatialMaterial::set_clearcoat(float p_clearcoat) { +void BaseMaterial3D::set_clearcoat(float p_clearcoat) { clearcoat = p_clearcoat; VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat, p_clearcoat); } -float SpatialMaterial::get_clearcoat() const { +float BaseMaterial3D::get_clearcoat() const { return clearcoat; } -void SpatialMaterial::set_clearcoat_gloss(float p_clearcoat_gloss) { +void BaseMaterial3D::set_clearcoat_gloss(float p_clearcoat_gloss) { clearcoat_gloss = p_clearcoat_gloss; VS::get_singleton()->material_set_param(_get_material(), shader_names->clearcoat_gloss, p_clearcoat_gloss); } -float SpatialMaterial::get_clearcoat_gloss() const { +float BaseMaterial3D::get_clearcoat_gloss() const { return clearcoat_gloss; } -void SpatialMaterial::set_anisotropy(float p_anisotropy) { +void BaseMaterial3D::set_anisotropy(float p_anisotropy) { anisotropy = p_anisotropy; VS::get_singleton()->material_set_param(_get_material(), shader_names->anisotropy, p_anisotropy); } -float SpatialMaterial::get_anisotropy() const { +float BaseMaterial3D::get_anisotropy() const { return anisotropy; } -void SpatialMaterial::set_depth_scale(float p_depth_scale) { +void BaseMaterial3D::set_heightmap_scale(float p_heightmap_scale) { - depth_scale = p_depth_scale; - VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_scale, p_depth_scale); + heightmap_scale = p_heightmap_scale; + VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_scale, p_heightmap_scale); } -float SpatialMaterial::get_depth_scale() const { +float BaseMaterial3D::get_heightmap_scale() const { - return depth_scale; + return heightmap_scale; } -void SpatialMaterial::set_subsurface_scattering_strength(float p_subsurface_scattering_strength) { +void BaseMaterial3D::set_subsurface_scattering_strength(float p_subsurface_scattering_strength) { subsurface_scattering_strength = p_subsurface_scattering_strength; VS::get_singleton()->material_set_param(_get_material(), shader_names->subsurface_scattering_strength, subsurface_scattering_strength); } -float SpatialMaterial::get_subsurface_scattering_strength() const { +float BaseMaterial3D::get_subsurface_scattering_strength() const { return subsurface_scattering_strength; } -void SpatialMaterial::set_transmission(const Color &p_transmission) { +void BaseMaterial3D::set_transmission(const Color &p_transmission) { transmission = p_transmission; VS::get_singleton()->material_set_param(_get_material(), shader_names->transmission, transmission); } -Color SpatialMaterial::get_transmission() const { +Color BaseMaterial3D::get_transmission() const { return transmission; } -void SpatialMaterial::set_refraction(float p_refraction) { +void BaseMaterial3D::set_refraction(float p_refraction) { refraction = p_refraction; VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction, refraction); } -float SpatialMaterial::get_refraction() const { +float BaseMaterial3D::get_refraction() const { return refraction; } -void SpatialMaterial::set_detail_uv(DetailUV p_detail_uv) { +void BaseMaterial3D::set_detail_uv(DetailUV p_detail_uv) { if (detail_uv == p_detail_uv) return; @@ -1290,12 +1360,12 @@ void SpatialMaterial::set_detail_uv(DetailUV p_detail_uv) { detail_uv = p_detail_uv; _queue_shader_change(); } -SpatialMaterial::DetailUV SpatialMaterial::get_detail_uv() const { +BaseMaterial3D::DetailUV BaseMaterial3D::get_detail_uv() const { return detail_uv; } -void SpatialMaterial::set_blend_mode(BlendMode p_mode) { +void BaseMaterial3D::set_blend_mode(BlendMode p_mode) { if (blend_mode == p_mode) return; @@ -1303,22 +1373,52 @@ void SpatialMaterial::set_blend_mode(BlendMode p_mode) { blend_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::BlendMode SpatialMaterial::get_blend_mode() const { +BaseMaterial3D::BlendMode BaseMaterial3D::get_blend_mode() const { return blend_mode; } -void SpatialMaterial::set_detail_blend_mode(BlendMode p_mode) { +void BaseMaterial3D::set_detail_blend_mode(BlendMode p_mode) { detail_blend_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::BlendMode SpatialMaterial::get_detail_blend_mode() const { +BaseMaterial3D::BlendMode BaseMaterial3D::get_detail_blend_mode() const { return detail_blend_mode; } -void SpatialMaterial::set_depth_draw_mode(DepthDrawMode p_mode) { +void BaseMaterial3D::set_transparency(Transparency p_transparency) { + + if (transparency == p_transparency) { + return; + } + + transparency = p_transparency; + _queue_shader_change(); + _change_notify(); +} + +BaseMaterial3D::Transparency BaseMaterial3D::get_transparency() const { + return transparency; +} + +void BaseMaterial3D::set_shading_mode(ShadingMode p_shading_mode) { + + if (shading_mode == p_shading_mode) { + return; + } + + shading_mode = p_shading_mode; + _queue_shader_change(); + _change_notify(); +} + +BaseMaterial3D::ShadingMode BaseMaterial3D::get_shading_mode() const { + return shading_mode; +} + +void BaseMaterial3D::set_depth_draw_mode(DepthDrawMode p_mode) { if (depth_draw_mode == p_mode) return; @@ -1326,12 +1426,12 @@ void SpatialMaterial::set_depth_draw_mode(DepthDrawMode p_mode) { depth_draw_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::DepthDrawMode SpatialMaterial::get_depth_draw_mode() const { +BaseMaterial3D::DepthDrawMode BaseMaterial3D::get_depth_draw_mode() const { return depth_draw_mode; } -void SpatialMaterial::set_cull_mode(CullMode p_mode) { +void BaseMaterial3D::set_cull_mode(CullMode p_mode) { if (cull_mode == p_mode) return; @@ -1339,12 +1439,12 @@ void SpatialMaterial::set_cull_mode(CullMode p_mode) { cull_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::CullMode SpatialMaterial::get_cull_mode() const { +BaseMaterial3D::CullMode BaseMaterial3D::get_cull_mode() const { return cull_mode; } -void SpatialMaterial::set_diffuse_mode(DiffuseMode p_mode) { +void BaseMaterial3D::set_diffuse_mode(DiffuseMode p_mode) { if (diffuse_mode == p_mode) return; @@ -1352,12 +1452,12 @@ void SpatialMaterial::set_diffuse_mode(DiffuseMode p_mode) { diffuse_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::DiffuseMode SpatialMaterial::get_diffuse_mode() const { +BaseMaterial3D::DiffuseMode BaseMaterial3D::get_diffuse_mode() const { return diffuse_mode; } -void SpatialMaterial::set_specular_mode(SpecularMode p_mode) { +void BaseMaterial3D::set_specular_mode(SpecularMode p_mode) { if (specular_mode == p_mode) return; @@ -1365,12 +1465,12 @@ void SpatialMaterial::set_specular_mode(SpecularMode p_mode) { specular_mode = p_mode; _queue_shader_change(); } -SpatialMaterial::SpecularMode SpatialMaterial::get_specular_mode() const { +BaseMaterial3D::SpecularMode BaseMaterial3D::get_specular_mode() const { return specular_mode; } -void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) { +void BaseMaterial3D::set_flag(Flags p_flag, bool p_enabled) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); @@ -1378,19 +1478,19 @@ void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) { return; flags[p_flag] = p_enabled; - if ((p_flag == FLAG_USE_ALPHA_SCISSOR) || (p_flag == FLAG_UNSHADED) || (p_flag == FLAG_USE_SHADOW_TO_OPACITY)) { + if ((p_flag == FLAG_USE_SHADOW_TO_OPACITY) || (p_flag == FLAG_USE_TEXTURE_REPEAT)) { _change_notify(); } _queue_shader_change(); } -bool SpatialMaterial::get_flag(Flags p_flag) const { +bool BaseMaterial3D::get_flag(Flags p_flag) const { ERR_FAIL_INDEX_V(p_flag, FLAG_MAX, false); return flags[p_flag]; } -void SpatialMaterial::set_feature(Feature p_feature, bool p_enabled) { +void BaseMaterial3D::set_feature(Feature p_feature, bool p_enabled) { ERR_FAIL_INDEX(p_feature, FEATURE_MAX); if (features[p_feature] == p_enabled) @@ -1401,13 +1501,13 @@ void SpatialMaterial::set_feature(Feature p_feature, bool p_enabled) { _queue_shader_change(); } -bool SpatialMaterial::get_feature(Feature p_feature) const { +bool BaseMaterial3D::get_feature(Feature p_feature) const { ERR_FAIL_INDEX_V(p_feature, FEATURE_MAX, false); return features[p_feature]; } -void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture) { +void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture) { ERR_FAIL_INDEX(p_param, TEXTURE_MAX); textures[p_param] = p_texture; @@ -1417,14 +1517,14 @@ void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture2D> &p_ _queue_shader_change(); } -Ref<Texture2D> SpatialMaterial::get_texture(TextureParam p_param) const { +Ref<Texture2D> BaseMaterial3D::get_texture(TextureParam p_param) const { ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref<Texture2D>()); return textures[p_param]; } -Ref<Texture2D> SpatialMaterial::get_texture_by_name(StringName p_name) const { - for (int i = 0; i < (int)SpatialMaterial::TEXTURE_MAX; i++) { +Ref<Texture2D> BaseMaterial3D::get_texture_by_name(StringName p_name) const { + for (int i = 0; i < (int)BaseMaterial3D::TEXTURE_MAX; i++) { TextureParam param = TextureParam(i); if (p_name == shader_names->texture_names[param]) return textures[param]; @@ -1432,26 +1532,35 @@ Ref<Texture2D> SpatialMaterial::get_texture_by_name(StringName p_name) const { return Ref<Texture2D>(); } -void SpatialMaterial::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { +void BaseMaterial3D::set_texture_filter(TextureFilter p_filter) { + texture_filter = p_filter; + _queue_shader_change(); +} + +BaseMaterial3D::TextureFilter BaseMaterial3D::get_texture_filter() const { + return texture_filter; +} + +void BaseMaterial3D::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const { if (property.name.begins_with(text) && property.name != text + "_enabled" && !features[feature]) { property.usage = 0; } } -void SpatialMaterial::_validate_high_end(const String &text, PropertyInfo &property) const { +void BaseMaterial3D::_validate_high_end(const String &text, PropertyInfo &property) const { if (property.name.begins_with(text)) { property.usage |= PROPERTY_USAGE_HIGH_END_GFX; } } -void SpatialMaterial::_validate_property(PropertyInfo &property) const { +void BaseMaterial3D::_validate_property(PropertyInfo &property) const { _validate_feature("normal", FEATURE_NORMAL_MAPPING, property); _validate_feature("emission", FEATURE_EMISSION, property); _validate_feature("rim", FEATURE_RIM, property); _validate_feature("clearcoat", FEATURE_CLEARCOAT, property); _validate_feature("anisotropy", FEATURE_ANISOTROPY, property); _validate_feature("ao", FEATURE_AMBIENT_OCCLUSION, property); - _validate_feature("depth", FEATURE_DEPTH_MAPPING, property); + _validate_feature("heightmap", FEATURE_HEIGHT_MAPPING, property); _validate_feature("subsurf_scatter", FEATURE_SUBSURACE_SCATTERING, property); _validate_feature("transmission", FEATURE_TRANSMISSION, property); _validate_feature("refraction", FEATURE_REFRACTION, property); @@ -1461,7 +1570,7 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { _validate_high_end("subsurf_scatter", property); _validate_high_end("anisotropy", property); _validate_high_end("clearcoat", property); - _validate_high_end("depth", property); + _validate_high_end("heightmap", property); if (property.name.begins_with("particles_anim_") && billboard_mode != BILLBOARD_PARTICLES) { property.usage = 0; @@ -1479,48 +1588,67 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { property.usage = 0; } - if (property.name == "params_alpha_scissor_threshold" && !flags[FLAG_USE_ALPHA_SCISSOR]) { + if (property.name == "alpha_scissor_threshold" && transparency != TRANSPARENCY_ALPHA_SCISSOR) { property.usage = 0; } - if ((property.name == "depth_min_layers" || property.name == "depth_max_layers") && !deep_parallax) { + if ((property.name == "heightmap_min_layers" || property.name == "heightmap_max_layers") && !deep_parallax) { property.usage = 0; } - if (flags[FLAG_UNSHADED]) { - if (property.name.begins_with("anisotropy")) { - property.usage = 0; - } + if (orm) { - if (property.name.begins_with("ao")) { - property.usage = 0; + if (property.name == "shading_mode") { + property.hint_string = "Unshaded,PerPixel"; //vertex not supported in ORM mode, since no individual roughness. } - - if (property.name.begins_with("clearcoat")) { + if (property.name.begins_with("roughness") || property.name.begins_with("metallic") || property.name.begins_with("ao_texture")) { property.usage = 0; } - if (property.name.begins_with("emission")) { + } else { + if (property.name == "orm_texture") { property.usage = 0; } + } - if (property.name.begins_with("metallic")) { - property.usage = 0; - } + if (shading_mode != SHADING_MODE_PER_PIXEL) { - if (property.name.begins_with("normal")) { - property.usage = 0; + if (shading_mode != SHADING_MODE_PER_VERTEX) { + + //these may still work per vertex + if (property.name.begins_with("ao")) { + property.usage = 0; + } + if (property.name.begins_with("emission")) { + property.usage = 0; + } + + if (property.name.begins_with("metallic")) { + property.usage = 0; + } + if (property.name.begins_with("rim")) { + property.usage = 0; + } + + if (property.name.begins_with("roughness")) { + property.usage = 0; + } + + if (property.name.begins_with("subsurf_scatter")) { + property.usage = 0; + } } - if (property.name.begins_with("rim")) { + //these definitely only need per pixel + if (property.name.begins_with("anisotropy")) { property.usage = 0; } - if (property.name.begins_with("roughness")) { + if (property.name.begins_with("clearcoat")) { property.usage = 0; } - if (property.name.begins_with("subsurf_scatter")) { + if (property.name.begins_with("normal")) { property.usage = 0; } @@ -1530,211 +1658,211 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { } } -void SpatialMaterial::set_point_size(float p_point_size) { +void BaseMaterial3D::set_point_size(float p_point_size) { point_size = p_point_size; VS::get_singleton()->material_set_param(_get_material(), shader_names->point_size, p_point_size); } -float SpatialMaterial::get_point_size() const { +float BaseMaterial3D::get_point_size() const { return point_size; } -void SpatialMaterial::set_uv1_scale(const Vector3 &p_scale) { +void BaseMaterial3D::set_uv1_scale(const Vector3 &p_scale) { uv1_scale = p_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_scale, p_scale); } -Vector3 SpatialMaterial::get_uv1_scale() const { +Vector3 BaseMaterial3D::get_uv1_scale() const { return uv1_scale; } -void SpatialMaterial::set_uv1_offset(const Vector3 &p_offset) { +void BaseMaterial3D::set_uv1_offset(const Vector3 &p_offset) { uv1_offset = p_offset; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_offset, p_offset); } -Vector3 SpatialMaterial::get_uv1_offset() const { +Vector3 BaseMaterial3D::get_uv1_offset() const { return uv1_offset; } -void SpatialMaterial::set_uv1_triplanar_blend_sharpness(float p_sharpness) { +void BaseMaterial3D::set_uv1_triplanar_blend_sharpness(float p_sharpness) { uv1_triplanar_sharpness = p_sharpness; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness); } -float SpatialMaterial::get_uv1_triplanar_blend_sharpness() const { +float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const { return uv1_triplanar_sharpness; } -void SpatialMaterial::set_uv2_scale(const Vector3 &p_scale) { +void BaseMaterial3D::set_uv2_scale(const Vector3 &p_scale) { uv2_scale = p_scale; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_scale, p_scale); } -Vector3 SpatialMaterial::get_uv2_scale() const { +Vector3 BaseMaterial3D::get_uv2_scale() const { return uv2_scale; } -void SpatialMaterial::set_uv2_offset(const Vector3 &p_offset) { +void BaseMaterial3D::set_uv2_offset(const Vector3 &p_offset) { uv2_offset = p_offset; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_offset, p_offset); } -Vector3 SpatialMaterial::get_uv2_offset() const { +Vector3 BaseMaterial3D::get_uv2_offset() const { return uv2_offset; } -void SpatialMaterial::set_uv2_triplanar_blend_sharpness(float p_sharpness) { +void BaseMaterial3D::set_uv2_triplanar_blend_sharpness(float p_sharpness) { uv2_triplanar_sharpness = p_sharpness; VS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness); } -float SpatialMaterial::get_uv2_triplanar_blend_sharpness() const { +float BaseMaterial3D::get_uv2_triplanar_blend_sharpness() const { return uv2_triplanar_sharpness; } -void SpatialMaterial::set_billboard_mode(BillboardMode p_mode) { +void BaseMaterial3D::set_billboard_mode(BillboardMode p_mode) { billboard_mode = p_mode; _queue_shader_change(); _change_notify(); } -SpatialMaterial::BillboardMode SpatialMaterial::get_billboard_mode() const { +BaseMaterial3D::BillboardMode BaseMaterial3D::get_billboard_mode() const { return billboard_mode; } -void SpatialMaterial::set_particles_anim_h_frames(int p_frames) { +void BaseMaterial3D::set_particles_anim_h_frames(int p_frames) { particles_anim_h_frames = p_frames; VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_h_frames, p_frames); } -int SpatialMaterial::get_particles_anim_h_frames() const { +int BaseMaterial3D::get_particles_anim_h_frames() const { return particles_anim_h_frames; } -void SpatialMaterial::set_particles_anim_v_frames(int p_frames) { +void BaseMaterial3D::set_particles_anim_v_frames(int p_frames) { particles_anim_v_frames = p_frames; VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_v_frames, p_frames); } -int SpatialMaterial::get_particles_anim_v_frames() const { +int BaseMaterial3D::get_particles_anim_v_frames() const { return particles_anim_v_frames; } -void SpatialMaterial::set_particles_anim_loop(bool p_loop) { +void BaseMaterial3D::set_particles_anim_loop(bool p_loop) { particles_anim_loop = p_loop; VS::get_singleton()->material_set_param(_get_material(), shader_names->particles_anim_loop, particles_anim_loop); } -bool SpatialMaterial::get_particles_anim_loop() const { +bool BaseMaterial3D::get_particles_anim_loop() const { return particles_anim_loop; } -void SpatialMaterial::set_depth_deep_parallax(bool p_enable) { +void BaseMaterial3D::set_heightmap_deep_parallax(bool p_enable) { deep_parallax = p_enable; _queue_shader_change(); _change_notify(); } -bool SpatialMaterial::is_depth_deep_parallax_enabled() const { +bool BaseMaterial3D::is_heightmap_deep_parallax_enabled() const { return deep_parallax; } -void SpatialMaterial::set_depth_deep_parallax_min_layers(int p_layer) { +void BaseMaterial3D::set_heightmap_deep_parallax_min_layers(int p_layer) { deep_parallax_min_layers = p_layer; - VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_min_layers, p_layer); + VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_min_layers, p_layer); } -int SpatialMaterial::get_depth_deep_parallax_min_layers() const { +int BaseMaterial3D::get_heightmap_deep_parallax_min_layers() const { return deep_parallax_min_layers; } -void SpatialMaterial::set_depth_deep_parallax_max_layers(int p_layer) { +void BaseMaterial3D::set_heightmap_deep_parallax_max_layers(int p_layer) { deep_parallax_max_layers = p_layer; - VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_max_layers, p_layer); + VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_max_layers, p_layer); } -int SpatialMaterial::get_depth_deep_parallax_max_layers() const { +int BaseMaterial3D::get_heightmap_deep_parallax_max_layers() const { return deep_parallax_max_layers; } -void SpatialMaterial::set_depth_deep_parallax_flip_tangent(bool p_flip) { +void BaseMaterial3D::set_heightmap_deep_parallax_flip_tangent(bool p_flip) { - depth_parallax_flip_tangent = p_flip; - VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_flip, Vector2(depth_parallax_flip_tangent ? -1 : 1, depth_parallax_flip_binormal ? -1 : 1)); + heightmap_parallax_flip_tangent = p_flip; + VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1)); } -bool SpatialMaterial::get_depth_deep_parallax_flip_tangent() const { +bool BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent() const { - return depth_parallax_flip_tangent; + return heightmap_parallax_flip_tangent; } -void SpatialMaterial::set_depth_deep_parallax_flip_binormal(bool p_flip) { +void BaseMaterial3D::set_heightmap_deep_parallax_flip_binormal(bool p_flip) { - depth_parallax_flip_binormal = p_flip; - VS::get_singleton()->material_set_param(_get_material(), shader_names->depth_flip, Vector2(depth_parallax_flip_tangent ? -1 : 1, depth_parallax_flip_binormal ? -1 : 1)); + heightmap_parallax_flip_binormal = p_flip; + VS::get_singleton()->material_set_param(_get_material(), shader_names->heightmap_flip, Vector2(heightmap_parallax_flip_tangent ? -1 : 1, heightmap_parallax_flip_binormal ? -1 : 1)); } -bool SpatialMaterial::get_depth_deep_parallax_flip_binormal() const { +bool BaseMaterial3D::get_heightmap_deep_parallax_flip_binormal() const { - return depth_parallax_flip_binormal; + return heightmap_parallax_flip_binormal; } -void SpatialMaterial::set_grow_enabled(bool p_enable) { +void BaseMaterial3D::set_grow_enabled(bool p_enable) { grow_enabled = p_enable; _queue_shader_change(); _change_notify(); } -bool SpatialMaterial::is_grow_enabled() const { +bool BaseMaterial3D::is_grow_enabled() const { return grow_enabled; } -void SpatialMaterial::set_alpha_scissor_threshold(float p_threshold) { +void BaseMaterial3D::set_alpha_scissor_threshold(float p_threshold) { alpha_scissor_threshold = p_threshold; VS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_scissor_threshold, p_threshold); } -float SpatialMaterial::get_alpha_scissor_threshold() const { +float BaseMaterial3D::get_alpha_scissor_threshold() const { return alpha_scissor_threshold; } -void SpatialMaterial::set_grow(float p_grow) { +void BaseMaterial3D::set_grow(float p_grow) { grow = p_grow; VS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow); } -float SpatialMaterial::get_grow() const { +float BaseMaterial3D::get_grow() const { return grow; } -static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) { +static Plane _get_texture_mask(BaseMaterial3D::TextureChannel p_channel) { static const Plane masks[5] = { Plane(1, 0, 0, 0), Plane(0, 1, 0, 0), @@ -1746,50 +1874,50 @@ static Plane _get_texture_mask(SpatialMaterial::TextureChannel p_channel) { return masks[p_channel]; } -void SpatialMaterial::set_metallic_texture_channel(TextureChannel p_channel) { +void BaseMaterial3D::set_metallic_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); metallic_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->metallic_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_metallic_texture_channel() const { +BaseMaterial3D::TextureChannel BaseMaterial3D::get_metallic_texture_channel() const { return metallic_texture_channel; } -void SpatialMaterial::set_roughness_texture_channel(TextureChannel p_channel) { +void BaseMaterial3D::set_roughness_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); roughness_texture_channel = p_channel; - VS::get_singleton()->material_set_param(_get_material(), shader_names->roughness_texture_channel, _get_texture_mask(p_channel)); + _queue_shader_change(); } -SpatialMaterial::TextureChannel SpatialMaterial::get_roughness_texture_channel() const { +BaseMaterial3D::TextureChannel BaseMaterial3D::get_roughness_texture_channel() const { return roughness_texture_channel; } -void SpatialMaterial::set_ao_texture_channel(TextureChannel p_channel) { +void BaseMaterial3D::set_ao_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); ao_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->ao_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_ao_texture_channel() const { +BaseMaterial3D::TextureChannel BaseMaterial3D::get_ao_texture_channel() const { return ao_texture_channel; } -void SpatialMaterial::set_refraction_texture_channel(TextureChannel p_channel) { +void BaseMaterial3D::set_refraction_texture_channel(TextureChannel p_channel) { ERR_FAIL_INDEX(p_channel, 5); refraction_texture_channel = p_channel; VS::get_singleton()->material_set_param(_get_material(), shader_names->refraction_texture_channel, _get_texture_mask(p_channel)); } -SpatialMaterial::TextureChannel SpatialMaterial::get_refraction_texture_channel() const { +BaseMaterial3D::TextureChannel BaseMaterial3D::get_refraction_texture_channel() const { return refraction_texture_channel; } -RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y) { +RID BaseMaterial3D::get_material_rid_for_2d(bool p_shaded, bool p_transparent, bool p_double_sided, bool p_cut_alpha, bool p_opaque_prepass, bool p_billboard, bool p_billboard_y) { int version = 0; if (p_shaded) @@ -1811,16 +1939,14 @@ RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent, return materials_for_2d[version]->get_rid(); } - Ref<SpatialMaterial> material; + Ref<StandardMaterial3D> material; material.instance(); - material->set_flag(FLAG_UNSHADED, !p_shaded); - material->set_feature(FEATURE_TRANSPARENT, p_transparent); + material->set_shading_mode(p_shaded ? SHADING_MODE_PER_PIXEL : SHADING_MODE_UNSHADED); + material->set_transparency(p_transparent ? (p_opaque_prepass ? TRANSPARENCY_ALPHA_DEPTH_PRE_PASS : (p_cut_alpha ? TRANSPARENCY_ALPHA_SCISSOR : TRANSPARENCY_ALPHA)) : TRANSPARENCY_DISABLED); material->set_cull_mode(p_double_sided ? CULL_DISABLED : CULL_BACK); - material->set_depth_draw_mode(p_opaque_prepass ? DEPTH_DRAW_ALPHA_OPAQUE_PREPASS : DEPTH_DRAW_OPAQUE_ONLY); material->set_flag(FLAG_SRGB_VERTEX_COLOR, true); material->set_flag(FLAG_ALBEDO_FROM_VERTEX_COLOR, true); - material->set_flag(FLAG_USE_ALPHA_SCISSOR, p_cut_alpha); if (p_billboard || p_billboard_y) { material->set_flag(FLAG_BILLBOARD_KEEP_SCALE, true); material->set_billboard_mode(p_billboard_y ? BILLBOARD_FIXED_Y : BILLBOARD_ENABLED); @@ -1831,67 +1957,67 @@ RID SpatialMaterial::get_material_rid_for_2d(bool p_shaded, bool p_transparent, return materials_for_2d[version]->get_rid(); } -void SpatialMaterial::set_on_top_of_alpha() { - set_feature(FEATURE_TRANSPARENT, true); +void BaseMaterial3D::set_on_top_of_alpha() { + set_transparency(TRANSPARENCY_DISABLED); set_render_priority(RENDER_PRIORITY_MAX); set_flag(FLAG_DISABLE_DEPTH_TEST, true); } -void SpatialMaterial::set_proximity_fade(bool p_enable) { +void BaseMaterial3D::set_proximity_fade(bool p_enable) { proximity_fade_enabled = p_enable; _queue_shader_change(); _change_notify(); } -bool SpatialMaterial::is_proximity_fade_enabled() const { +bool BaseMaterial3D::is_proximity_fade_enabled() const { return proximity_fade_enabled; } -void SpatialMaterial::set_proximity_fade_distance(float p_distance) { +void BaseMaterial3D::set_proximity_fade_distance(float p_distance) { proximity_fade_distance = p_distance; VS::get_singleton()->material_set_param(_get_material(), shader_names->proximity_fade_distance, p_distance); } -float SpatialMaterial::get_proximity_fade_distance() const { +float BaseMaterial3D::get_proximity_fade_distance() const { return proximity_fade_distance; } -void SpatialMaterial::set_distance_fade(DistanceFadeMode p_mode) { +void BaseMaterial3D::set_distance_fade(DistanceFadeMode p_mode) { distance_fade = p_mode; _queue_shader_change(); _change_notify(); } -SpatialMaterial::DistanceFadeMode SpatialMaterial::get_distance_fade() const { +BaseMaterial3D::DistanceFadeMode BaseMaterial3D::get_distance_fade() const { return distance_fade; } -void SpatialMaterial::set_distance_fade_max_distance(float p_distance) { +void BaseMaterial3D::set_distance_fade_max_distance(float p_distance) { distance_fade_max_distance = p_distance; VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_max, distance_fade_max_distance); } -float SpatialMaterial::get_distance_fade_max_distance() const { +float BaseMaterial3D::get_distance_fade_max_distance() const { return distance_fade_max_distance; } -void SpatialMaterial::set_distance_fade_min_distance(float p_distance) { +void BaseMaterial3D::set_distance_fade_min_distance(float p_distance) { distance_fade_min_distance = p_distance; VS::get_singleton()->material_set_param(_get_material(), shader_names->distance_fade_min, distance_fade_min_distance); } -float SpatialMaterial::get_distance_fade_min_distance() const { +float BaseMaterial3D::get_distance_fade_min_distance() const { return distance_fade_min_distance; } -void SpatialMaterial::set_emission_operator(EmissionOperator p_op) { +void BaseMaterial3D::set_emission_operator(EmissionOperator p_op) { if (emission_op == p_op) return; @@ -1899,230 +2025,226 @@ void SpatialMaterial::set_emission_operator(EmissionOperator p_op) { _queue_shader_change(); } -SpatialMaterial::EmissionOperator SpatialMaterial::get_emission_operator() const { +BaseMaterial3D::EmissionOperator BaseMaterial3D::get_emission_operator() const { return emission_op; } -RID SpatialMaterial::get_shader_rid() const { +RID BaseMaterial3D::get_shader_rid() const { ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); return shader_map[current_key].shader; } -Shader::Mode SpatialMaterial::get_shader_mode() const { +Shader::Mode BaseMaterial3D::get_shader_mode() const { return Shader::MODE_SPATIAL; } -void SpatialMaterial::_bind_methods() { +void BaseMaterial3D::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &BaseMaterial3D::set_albedo); + ClassDB::bind_method(D_METHOD("get_albedo"), &BaseMaterial3D::get_albedo); + + ClassDB::bind_method(D_METHOD("set_transparency", "transparency"), &BaseMaterial3D::set_transparency); + ClassDB::bind_method(D_METHOD("get_transparency"), &BaseMaterial3D::get_transparency); + + ClassDB::bind_method(D_METHOD("set_shading_mode", "shading_mode"), &BaseMaterial3D::set_shading_mode); + ClassDB::bind_method(D_METHOD("get_shading_mode"), &BaseMaterial3D::get_shading_mode); + + ClassDB::bind_method(D_METHOD("set_specular", "specular"), &BaseMaterial3D::set_specular); + ClassDB::bind_method(D_METHOD("get_specular"), &BaseMaterial3D::get_specular); - ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo); - ClassDB::bind_method(D_METHOD("get_albedo"), &SpatialMaterial::get_albedo); + ClassDB::bind_method(D_METHOD("set_metallic", "metallic"), &BaseMaterial3D::set_metallic); + ClassDB::bind_method(D_METHOD("get_metallic"), &BaseMaterial3D::get_metallic); - ClassDB::bind_method(D_METHOD("set_specular", "specular"), &SpatialMaterial::set_specular); - ClassDB::bind_method(D_METHOD("get_specular"), &SpatialMaterial::get_specular); + ClassDB::bind_method(D_METHOD("set_roughness", "roughness"), &BaseMaterial3D::set_roughness); + ClassDB::bind_method(D_METHOD("get_roughness"), &BaseMaterial3D::get_roughness); - ClassDB::bind_method(D_METHOD("set_metallic", "metallic"), &SpatialMaterial::set_metallic); - ClassDB::bind_method(D_METHOD("get_metallic"), &SpatialMaterial::get_metallic); + ClassDB::bind_method(D_METHOD("set_emission", "emission"), &BaseMaterial3D::set_emission); + ClassDB::bind_method(D_METHOD("get_emission"), &BaseMaterial3D::get_emission); - ClassDB::bind_method(D_METHOD("set_roughness", "roughness"), &SpatialMaterial::set_roughness); - ClassDB::bind_method(D_METHOD("get_roughness"), &SpatialMaterial::get_roughness); + ClassDB::bind_method(D_METHOD("set_emission_energy", "emission_energy"), &BaseMaterial3D::set_emission_energy); + ClassDB::bind_method(D_METHOD("get_emission_energy"), &BaseMaterial3D::get_emission_energy); - ClassDB::bind_method(D_METHOD("set_emission", "emission"), &SpatialMaterial::set_emission); - ClassDB::bind_method(D_METHOD("get_emission"), &SpatialMaterial::get_emission); + ClassDB::bind_method(D_METHOD("set_normal_scale", "normal_scale"), &BaseMaterial3D::set_normal_scale); + ClassDB::bind_method(D_METHOD("get_normal_scale"), &BaseMaterial3D::get_normal_scale); - ClassDB::bind_method(D_METHOD("set_emission_energy", "emission_energy"), &SpatialMaterial::set_emission_energy); - ClassDB::bind_method(D_METHOD("get_emission_energy"), &SpatialMaterial::get_emission_energy); + ClassDB::bind_method(D_METHOD("set_rim", "rim"), &BaseMaterial3D::set_rim); + ClassDB::bind_method(D_METHOD("get_rim"), &BaseMaterial3D::get_rim); - ClassDB::bind_method(D_METHOD("set_normal_scale", "normal_scale"), &SpatialMaterial::set_normal_scale); - ClassDB::bind_method(D_METHOD("get_normal_scale"), &SpatialMaterial::get_normal_scale); + ClassDB::bind_method(D_METHOD("set_rim_tint", "rim_tint"), &BaseMaterial3D::set_rim_tint); + ClassDB::bind_method(D_METHOD("get_rim_tint"), &BaseMaterial3D::get_rim_tint); - ClassDB::bind_method(D_METHOD("set_rim", "rim"), &SpatialMaterial::set_rim); - ClassDB::bind_method(D_METHOD("get_rim"), &SpatialMaterial::get_rim); + ClassDB::bind_method(D_METHOD("set_clearcoat", "clearcoat"), &BaseMaterial3D::set_clearcoat); + ClassDB::bind_method(D_METHOD("get_clearcoat"), &BaseMaterial3D::get_clearcoat); - ClassDB::bind_method(D_METHOD("set_rim_tint", "rim_tint"), &SpatialMaterial::set_rim_tint); - ClassDB::bind_method(D_METHOD("get_rim_tint"), &SpatialMaterial::get_rim_tint); + ClassDB::bind_method(D_METHOD("set_clearcoat_gloss", "clearcoat_gloss"), &BaseMaterial3D::set_clearcoat_gloss); + ClassDB::bind_method(D_METHOD("get_clearcoat_gloss"), &BaseMaterial3D::get_clearcoat_gloss); - ClassDB::bind_method(D_METHOD("set_clearcoat", "clearcoat"), &SpatialMaterial::set_clearcoat); - ClassDB::bind_method(D_METHOD("get_clearcoat"), &SpatialMaterial::get_clearcoat); + ClassDB::bind_method(D_METHOD("set_anisotropy", "anisotropy"), &BaseMaterial3D::set_anisotropy); + ClassDB::bind_method(D_METHOD("get_anisotropy"), &BaseMaterial3D::get_anisotropy); - ClassDB::bind_method(D_METHOD("set_clearcoat_gloss", "clearcoat_gloss"), &SpatialMaterial::set_clearcoat_gloss); - ClassDB::bind_method(D_METHOD("get_clearcoat_gloss"), &SpatialMaterial::get_clearcoat_gloss); + ClassDB::bind_method(D_METHOD("set_heightmap_scale", "heightmap_scale"), &BaseMaterial3D::set_heightmap_scale); + ClassDB::bind_method(D_METHOD("get_heightmap_scale"), &BaseMaterial3D::get_heightmap_scale); - ClassDB::bind_method(D_METHOD("set_anisotropy", "anisotropy"), &SpatialMaterial::set_anisotropy); - ClassDB::bind_method(D_METHOD("get_anisotropy"), &SpatialMaterial::get_anisotropy); + ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &BaseMaterial3D::set_subsurface_scattering_strength); + ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &BaseMaterial3D::get_subsurface_scattering_strength); - ClassDB::bind_method(D_METHOD("set_depth_scale", "depth_scale"), &SpatialMaterial::set_depth_scale); - ClassDB::bind_method(D_METHOD("get_depth_scale"), &SpatialMaterial::get_depth_scale); + ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &BaseMaterial3D::set_transmission); + ClassDB::bind_method(D_METHOD("get_transmission"), &BaseMaterial3D::get_transmission); - ClassDB::bind_method(D_METHOD("set_subsurface_scattering_strength", "strength"), &SpatialMaterial::set_subsurface_scattering_strength); - ClassDB::bind_method(D_METHOD("get_subsurface_scattering_strength"), &SpatialMaterial::get_subsurface_scattering_strength); + ClassDB::bind_method(D_METHOD("set_refraction", "refraction"), &BaseMaterial3D::set_refraction); + ClassDB::bind_method(D_METHOD("get_refraction"), &BaseMaterial3D::get_refraction); - ClassDB::bind_method(D_METHOD("set_transmission", "transmission"), &SpatialMaterial::set_transmission); - ClassDB::bind_method(D_METHOD("get_transmission"), &SpatialMaterial::get_transmission); + ClassDB::bind_method(D_METHOD("set_point_size", "point_size"), &BaseMaterial3D::set_point_size); + ClassDB::bind_method(D_METHOD("get_point_size"), &BaseMaterial3D::get_point_size); - 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_detail_uv", "detail_uv"), &BaseMaterial3D::set_detail_uv); + ClassDB::bind_method(D_METHOD("get_detail_uv"), &BaseMaterial3D::get_detail_uv); - 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); + ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &BaseMaterial3D::set_blend_mode); + ClassDB::bind_method(D_METHOD("get_blend_mode"), &BaseMaterial3D::get_blend_mode); - ClassDB::bind_method(D_METHOD("set_detail_uv", "detail_uv"), &SpatialMaterial::set_detail_uv); - ClassDB::bind_method(D_METHOD("get_detail_uv"), &SpatialMaterial::get_detail_uv); + ClassDB::bind_method(D_METHOD("set_depth_draw_mode", "depth_draw_mode"), &BaseMaterial3D::set_depth_draw_mode); + ClassDB::bind_method(D_METHOD("get_depth_draw_mode"), &BaseMaterial3D::get_depth_draw_mode); - ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &SpatialMaterial::set_blend_mode); - ClassDB::bind_method(D_METHOD("get_blend_mode"), &SpatialMaterial::get_blend_mode); + ClassDB::bind_method(D_METHOD("set_cull_mode", "cull_mode"), &BaseMaterial3D::set_cull_mode); + ClassDB::bind_method(D_METHOD("get_cull_mode"), &BaseMaterial3D::get_cull_mode); - ClassDB::bind_method(D_METHOD("set_depth_draw_mode", "depth_draw_mode"), &SpatialMaterial::set_depth_draw_mode); - ClassDB::bind_method(D_METHOD("get_depth_draw_mode"), &SpatialMaterial::get_depth_draw_mode); + ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &BaseMaterial3D::set_diffuse_mode); + ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &BaseMaterial3D::get_diffuse_mode); - ClassDB::bind_method(D_METHOD("set_cull_mode", "cull_mode"), &SpatialMaterial::set_cull_mode); - ClassDB::bind_method(D_METHOD("get_cull_mode"), &SpatialMaterial::get_cull_mode); + ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &BaseMaterial3D::set_specular_mode); + ClassDB::bind_method(D_METHOD("get_specular_mode"), &BaseMaterial3D::get_specular_mode); - ClassDB::bind_method(D_METHOD("set_diffuse_mode", "diffuse_mode"), &SpatialMaterial::set_diffuse_mode); - ClassDB::bind_method(D_METHOD("get_diffuse_mode"), &SpatialMaterial::get_diffuse_mode); + ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &BaseMaterial3D::set_flag); + ClassDB::bind_method(D_METHOD("get_flag", "flag"), &BaseMaterial3D::get_flag); - ClassDB::bind_method(D_METHOD("set_specular_mode", "specular_mode"), &SpatialMaterial::set_specular_mode); - ClassDB::bind_method(D_METHOD("get_specular_mode"), &SpatialMaterial::get_specular_mode); + ClassDB::bind_method(D_METHOD("set_texture_filter", "mode"), &BaseMaterial3D::set_texture_filter); + ClassDB::bind_method(D_METHOD("get_texture_filter"), &BaseMaterial3D::get_texture_filter); - ClassDB::bind_method(D_METHOD("set_flag", "flag", "enable"), &SpatialMaterial::set_flag); - ClassDB::bind_method(D_METHOD("get_flag", "flag"), &SpatialMaterial::get_flag); + ClassDB::bind_method(D_METHOD("set_feature", "feature", "enable"), &BaseMaterial3D::set_feature); + ClassDB::bind_method(D_METHOD("get_feature", "feature"), &BaseMaterial3D::get_feature); - ClassDB::bind_method(D_METHOD("set_feature", "feature", "enable"), &SpatialMaterial::set_feature); - ClassDB::bind_method(D_METHOD("get_feature", "feature"), &SpatialMaterial::get_feature); + ClassDB::bind_method(D_METHOD("set_texture", "param", "texture"), &BaseMaterial3D::set_texture); + ClassDB::bind_method(D_METHOD("get_texture", "param"), &BaseMaterial3D::get_texture); - ClassDB::bind_method(D_METHOD("set_texture", "param", "texture"), &SpatialMaterial::set_texture); - ClassDB::bind_method(D_METHOD("get_texture", "param"), &SpatialMaterial::get_texture); + ClassDB::bind_method(D_METHOD("set_detail_blend_mode", "detail_blend_mode"), &BaseMaterial3D::set_detail_blend_mode); + ClassDB::bind_method(D_METHOD("get_detail_blend_mode"), &BaseMaterial3D::get_detail_blend_mode); - ClassDB::bind_method(D_METHOD("set_detail_blend_mode", "detail_blend_mode"), &SpatialMaterial::set_detail_blend_mode); - ClassDB::bind_method(D_METHOD("get_detail_blend_mode"), &SpatialMaterial::get_detail_blend_mode); + ClassDB::bind_method(D_METHOD("set_uv1_scale", "scale"), &BaseMaterial3D::set_uv1_scale); + ClassDB::bind_method(D_METHOD("get_uv1_scale"), &BaseMaterial3D::get_uv1_scale); - ClassDB::bind_method(D_METHOD("set_uv1_scale", "scale"), &SpatialMaterial::set_uv1_scale); - ClassDB::bind_method(D_METHOD("get_uv1_scale"), &SpatialMaterial::get_uv1_scale); + ClassDB::bind_method(D_METHOD("set_uv1_offset", "offset"), &BaseMaterial3D::set_uv1_offset); + ClassDB::bind_method(D_METHOD("get_uv1_offset"), &BaseMaterial3D::get_uv1_offset); - ClassDB::bind_method(D_METHOD("set_uv1_offset", "offset"), &SpatialMaterial::set_uv1_offset); - ClassDB::bind_method(D_METHOD("get_uv1_offset"), &SpatialMaterial::get_uv1_offset); + ClassDB::bind_method(D_METHOD("set_uv1_triplanar_blend_sharpness", "sharpness"), &BaseMaterial3D::set_uv1_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("get_uv1_triplanar_blend_sharpness"), &BaseMaterial3D::get_uv1_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("set_uv1_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv1_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("get_uv1_triplanar_blend_sharpness"), &SpatialMaterial::get_uv1_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("set_uv2_scale", "scale"), &BaseMaterial3D::set_uv2_scale); + ClassDB::bind_method(D_METHOD("get_uv2_scale"), &BaseMaterial3D::get_uv2_scale); - ClassDB::bind_method(D_METHOD("set_uv2_scale", "scale"), &SpatialMaterial::set_uv2_scale); - ClassDB::bind_method(D_METHOD("get_uv2_scale"), &SpatialMaterial::get_uv2_scale); + ClassDB::bind_method(D_METHOD("set_uv2_offset", "offset"), &BaseMaterial3D::set_uv2_offset); + ClassDB::bind_method(D_METHOD("get_uv2_offset"), &BaseMaterial3D::get_uv2_offset); - ClassDB::bind_method(D_METHOD("set_uv2_offset", "offset"), &SpatialMaterial::set_uv2_offset); - ClassDB::bind_method(D_METHOD("get_uv2_offset"), &SpatialMaterial::get_uv2_offset); + ClassDB::bind_method(D_METHOD("set_uv2_triplanar_blend_sharpness", "sharpness"), &BaseMaterial3D::set_uv2_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("get_uv2_triplanar_blend_sharpness"), &BaseMaterial3D::get_uv2_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("set_uv2_triplanar_blend_sharpness", "sharpness"), &SpatialMaterial::set_uv2_triplanar_blend_sharpness); - ClassDB::bind_method(D_METHOD("get_uv2_triplanar_blend_sharpness"), &SpatialMaterial::get_uv2_triplanar_blend_sharpness); + ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &BaseMaterial3D::set_billboard_mode); + ClassDB::bind_method(D_METHOD("get_billboard_mode"), &BaseMaterial3D::get_billboard_mode); - ClassDB::bind_method(D_METHOD("set_billboard_mode", "mode"), &SpatialMaterial::set_billboard_mode); - ClassDB::bind_method(D_METHOD("get_billboard_mode"), &SpatialMaterial::get_billboard_mode); + ClassDB::bind_method(D_METHOD("set_particles_anim_h_frames", "frames"), &BaseMaterial3D::set_particles_anim_h_frames); + ClassDB::bind_method(D_METHOD("get_particles_anim_h_frames"), &BaseMaterial3D::get_particles_anim_h_frames); - ClassDB::bind_method(D_METHOD("set_particles_anim_h_frames", "frames"), &SpatialMaterial::set_particles_anim_h_frames); - ClassDB::bind_method(D_METHOD("get_particles_anim_h_frames"), &SpatialMaterial::get_particles_anim_h_frames); + ClassDB::bind_method(D_METHOD("set_particles_anim_v_frames", "frames"), &BaseMaterial3D::set_particles_anim_v_frames); + ClassDB::bind_method(D_METHOD("get_particles_anim_v_frames"), &BaseMaterial3D::get_particles_anim_v_frames); - ClassDB::bind_method(D_METHOD("set_particles_anim_v_frames", "frames"), &SpatialMaterial::set_particles_anim_v_frames); - ClassDB::bind_method(D_METHOD("get_particles_anim_v_frames"), &SpatialMaterial::get_particles_anim_v_frames); + ClassDB::bind_method(D_METHOD("set_particles_anim_loop", "loop"), &BaseMaterial3D::set_particles_anim_loop); + ClassDB::bind_method(D_METHOD("get_particles_anim_loop"), &BaseMaterial3D::get_particles_anim_loop); - ClassDB::bind_method(D_METHOD("set_particles_anim_loop", "loop"), &SpatialMaterial::set_particles_anim_loop); - ClassDB::bind_method(D_METHOD("get_particles_anim_loop"), &SpatialMaterial::get_particles_anim_loop); + ClassDB::bind_method(D_METHOD("set_heightmap_deep_parallax", "enable"), &BaseMaterial3D::set_heightmap_deep_parallax); + ClassDB::bind_method(D_METHOD("is_heightmap_deep_parallax_enabled"), &BaseMaterial3D::is_heightmap_deep_parallax_enabled); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax", "enable"), &SpatialMaterial::set_depth_deep_parallax); - ClassDB::bind_method(D_METHOD("is_depth_deep_parallax_enabled"), &SpatialMaterial::is_depth_deep_parallax_enabled); + ClassDB::bind_method(D_METHOD("set_heightmap_deep_parallax_min_layers", "layer"), &BaseMaterial3D::set_heightmap_deep_parallax_min_layers); + ClassDB::bind_method(D_METHOD("get_heightmap_deep_parallax_min_layers"), &BaseMaterial3D::get_heightmap_deep_parallax_min_layers); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_min_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_min_layers); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_min_layers"), &SpatialMaterial::get_depth_deep_parallax_min_layers); + ClassDB::bind_method(D_METHOD("set_heightmap_deep_parallax_max_layers", "layer"), &BaseMaterial3D::set_heightmap_deep_parallax_max_layers); + ClassDB::bind_method(D_METHOD("get_heightmap_deep_parallax_max_layers"), &BaseMaterial3D::get_heightmap_deep_parallax_max_layers); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_max_layers", "layer"), &SpatialMaterial::set_depth_deep_parallax_max_layers); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_max_layers"), &SpatialMaterial::get_depth_deep_parallax_max_layers); + ClassDB::bind_method(D_METHOD("set_heightmap_deep_parallax_flip_tangent", "flip"), &BaseMaterial3D::set_heightmap_deep_parallax_flip_tangent); + ClassDB::bind_method(D_METHOD("get_heightmap_deep_parallax_flip_tangent"), &BaseMaterial3D::get_heightmap_deep_parallax_flip_tangent); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_flip_tangent", "flip"), &SpatialMaterial::set_depth_deep_parallax_flip_tangent); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_flip_tangent"), &SpatialMaterial::get_depth_deep_parallax_flip_tangent); + ClassDB::bind_method(D_METHOD("set_heightmap_deep_parallax_flip_binormal", "flip"), &BaseMaterial3D::set_heightmap_deep_parallax_flip_binormal); + ClassDB::bind_method(D_METHOD("get_heightmap_deep_parallax_flip_binormal"), &BaseMaterial3D::get_heightmap_deep_parallax_flip_binormal); - ClassDB::bind_method(D_METHOD("set_depth_deep_parallax_flip_binormal", "flip"), &SpatialMaterial::set_depth_deep_parallax_flip_binormal); - ClassDB::bind_method(D_METHOD("get_depth_deep_parallax_flip_binormal"), &SpatialMaterial::get_depth_deep_parallax_flip_binormal); + ClassDB::bind_method(D_METHOD("set_grow", "amount"), &BaseMaterial3D::set_grow); + ClassDB::bind_method(D_METHOD("get_grow"), &BaseMaterial3D::get_grow); - ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow); - ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow); + ClassDB::bind_method(D_METHOD("set_emission_operator", "operator"), &BaseMaterial3D::set_emission_operator); + ClassDB::bind_method(D_METHOD("get_emission_operator"), &BaseMaterial3D::get_emission_operator); - ClassDB::bind_method(D_METHOD("set_emission_operator", "operator"), &SpatialMaterial::set_emission_operator); - ClassDB::bind_method(D_METHOD("get_emission_operator"), &SpatialMaterial::get_emission_operator); + ClassDB::bind_method(D_METHOD("set_ao_light_affect", "amount"), &BaseMaterial3D::set_ao_light_affect); + ClassDB::bind_method(D_METHOD("get_ao_light_affect"), &BaseMaterial3D::get_ao_light_affect); - ClassDB::bind_method(D_METHOD("set_ao_light_affect", "amount"), &SpatialMaterial::set_ao_light_affect); - ClassDB::bind_method(D_METHOD("get_ao_light_affect"), &SpatialMaterial::get_ao_light_affect); + ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &BaseMaterial3D::set_alpha_scissor_threshold); + ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &BaseMaterial3D::get_alpha_scissor_threshold); - ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &SpatialMaterial::set_alpha_scissor_threshold); - ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &SpatialMaterial::get_alpha_scissor_threshold); + ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &BaseMaterial3D::set_grow_enabled); + ClassDB::bind_method(D_METHOD("is_grow_enabled"), &BaseMaterial3D::is_grow_enabled); - ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &SpatialMaterial::set_grow_enabled); - ClassDB::bind_method(D_METHOD("is_grow_enabled"), &SpatialMaterial::is_grow_enabled); + ClassDB::bind_method(D_METHOD("set_metallic_texture_channel", "channel"), &BaseMaterial3D::set_metallic_texture_channel); + ClassDB::bind_method(D_METHOD("get_metallic_texture_channel"), &BaseMaterial3D::get_metallic_texture_channel); - ClassDB::bind_method(D_METHOD("set_metallic_texture_channel", "channel"), &SpatialMaterial::set_metallic_texture_channel); - ClassDB::bind_method(D_METHOD("get_metallic_texture_channel"), &SpatialMaterial::get_metallic_texture_channel); + ClassDB::bind_method(D_METHOD("set_roughness_texture_channel", "channel"), &BaseMaterial3D::set_roughness_texture_channel); + ClassDB::bind_method(D_METHOD("get_roughness_texture_channel"), &BaseMaterial3D::get_roughness_texture_channel); - ClassDB::bind_method(D_METHOD("set_roughness_texture_channel", "channel"), &SpatialMaterial::set_roughness_texture_channel); - ClassDB::bind_method(D_METHOD("get_roughness_texture_channel"), &SpatialMaterial::get_roughness_texture_channel); + ClassDB::bind_method(D_METHOD("set_ao_texture_channel", "channel"), &BaseMaterial3D::set_ao_texture_channel); + ClassDB::bind_method(D_METHOD("get_ao_texture_channel"), &BaseMaterial3D::get_ao_texture_channel); - ClassDB::bind_method(D_METHOD("set_ao_texture_channel", "channel"), &SpatialMaterial::set_ao_texture_channel); - ClassDB::bind_method(D_METHOD("get_ao_texture_channel"), &SpatialMaterial::get_ao_texture_channel); + ClassDB::bind_method(D_METHOD("set_refraction_texture_channel", "channel"), &BaseMaterial3D::set_refraction_texture_channel); + ClassDB::bind_method(D_METHOD("get_refraction_texture_channel"), &BaseMaterial3D::get_refraction_texture_channel); - ClassDB::bind_method(D_METHOD("set_refraction_texture_channel", "channel"), &SpatialMaterial::set_refraction_texture_channel); - ClassDB::bind_method(D_METHOD("get_refraction_texture_channel"), &SpatialMaterial::get_refraction_texture_channel); + ClassDB::bind_method(D_METHOD("set_proximity_fade", "enabled"), &BaseMaterial3D::set_proximity_fade); + ClassDB::bind_method(D_METHOD("is_proximity_fade_enabled"), &BaseMaterial3D::is_proximity_fade_enabled); - ClassDB::bind_method(D_METHOD("set_proximity_fade", "enabled"), &SpatialMaterial::set_proximity_fade); - ClassDB::bind_method(D_METHOD("is_proximity_fade_enabled"), &SpatialMaterial::is_proximity_fade_enabled); + ClassDB::bind_method(D_METHOD("set_proximity_fade_distance", "distance"), &BaseMaterial3D::set_proximity_fade_distance); + ClassDB::bind_method(D_METHOD("get_proximity_fade_distance"), &BaseMaterial3D::get_proximity_fade_distance); - ClassDB::bind_method(D_METHOD("set_proximity_fade_distance", "distance"), &SpatialMaterial::set_proximity_fade_distance); - ClassDB::bind_method(D_METHOD("get_proximity_fade_distance"), &SpatialMaterial::get_proximity_fade_distance); + ClassDB::bind_method(D_METHOD("set_distance_fade", "mode"), &BaseMaterial3D::set_distance_fade); + ClassDB::bind_method(D_METHOD("get_distance_fade"), &BaseMaterial3D::get_distance_fade); - ClassDB::bind_method(D_METHOD("set_distance_fade", "mode"), &SpatialMaterial::set_distance_fade); - ClassDB::bind_method(D_METHOD("get_distance_fade"), &SpatialMaterial::get_distance_fade); + ClassDB::bind_method(D_METHOD("set_distance_fade_max_distance", "distance"), &BaseMaterial3D::set_distance_fade_max_distance); + ClassDB::bind_method(D_METHOD("get_distance_fade_max_distance"), &BaseMaterial3D::get_distance_fade_max_distance); - ClassDB::bind_method(D_METHOD("set_distance_fade_max_distance", "distance"), &SpatialMaterial::set_distance_fade_max_distance); - ClassDB::bind_method(D_METHOD("get_distance_fade_max_distance"), &SpatialMaterial::get_distance_fade_max_distance); + ClassDB::bind_method(D_METHOD("set_distance_fade_min_distance", "distance"), &BaseMaterial3D::set_distance_fade_min_distance); + ClassDB::bind_method(D_METHOD("get_distance_fade_min_distance"), &BaseMaterial3D::get_distance_fade_min_distance); - ClassDB::bind_method(D_METHOD("set_distance_fade_min_distance", "distance"), &SpatialMaterial::set_distance_fade_min_distance); - ClassDB::bind_method(D_METHOD("get_distance_fade_min_distance"), &SpatialMaterial::get_distance_fade_min_distance); + ADD_GROUP("Transparency", ""); + ADD_PROPERTY(PropertyInfo(Variant::INT, "transparency", PROPERTY_HINT_ENUM, "Disabled,Alpha,AlphaScissor,DepthPrePass"), "set_transparency", "get_transparency"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "alpha_scissor_threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_alpha_scissor_threshold", "get_alpha_scissor_threshold"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "depth_draw", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never"), "set_depth_draw_mode", "get_depth_draw_mode"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "no_depth_test"), "set_flag", "get_flag", FLAG_DISABLE_DEPTH_TEST); + + ADD_GROUP("Shading", ""); + ADD_PROPERTY(PropertyInfo(Variant::INT, "shading_mode", PROPERTY_HINT_ENUM, "Unshaded,PerPixel,PerVetex"), "set_shading_mode", "get_shading_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "diffuse_mode", PROPERTY_HINT_ENUM, "Burley,Lambert,Lambert Wrap,Oren Nayar,Toon"), "set_diffuse_mode", "get_diffuse_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "disable_ambient_light"), "set_flag", "get_flag", FLAG_DISABLE_AMBIENT_LIGHT); - ADD_GROUP("Flags", "flags_"); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_transparent"), "set_feature", "get_feature", FEATURE_TRANSPARENT); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_shadow_to_opacity"), "set_flag", "get_flag", FLAG_USE_SHADOW_TO_OPACITY); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_unshaded"), "set_flag", "get_flag", FLAG_UNSHADED); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_vertex_lighting"), "set_flag", "get_flag", FLAG_USE_VERTEX_LIGHTING); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_no_depth_test"), "set_flag", "get_flag", FLAG_DISABLE_DEPTH_TEST); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_world_triplanar"), "set_flag", "get_flag", FLAG_TRIPLANAR_USE_WORLD); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_albedo_tex_force_srgb"), "set_flag", "get_flag", FLAG_ALBEDO_TEXTURE_FORCE_SRGB); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_do_not_receive_shadows"), "set_flag", "get_flag", FLAG_DONT_RECEIVE_SHADOWS); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_disable_ambient_light"), "set_flag", "get_flag", FLAG_DISABLE_AMBIENT_LIGHT); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_ensure_correct_normals"), "set_flag", "get_flag", FLAG_ENSURE_CORRECT_NORMALS); ADD_GROUP("Vertex Color", "vertex_color"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_use_as_albedo"), "set_flag", "get_flag", FLAG_ALBEDO_FROM_VERTEX_COLOR); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_is_srgb"), "set_flag", "get_flag", FLAG_SRGB_VERTEX_COLOR); - ADD_GROUP("Parameters", "params_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_diffuse_mode", PROPERTY_HINT_ENUM, "Burley,Lambert,Lambert Wrap,Oren Nayar,Toon"), "set_diffuse_mode", "get_diffuse_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_specular_mode", PROPERTY_HINT_ENUM, "SchlickGGX,Blinn,Phong,Toon,Disabled"), "set_specular_mode", "get_specular_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "params_depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never,Opaque Pre-Pass"), "set_depth_draw_mode", "get_depth_draw_mode"); - 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); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "params_grow"), "set_grow_enabled", "is_grow_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_grow_amount", PROPERTY_HINT_RANGE, "-16,16,0.001"), "set_grow", "get_grow"); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "params_use_alpha_scissor"), "set_flag", "get_flag", FLAG_USE_ALPHA_SCISSOR); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "params_alpha_scissor_threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_alpha_scissor_threshold", "get_alpha_scissor_threshold"); - ADD_GROUP("Particles Anim", "particles_anim_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "particles_anim_loop"), "set_particles_anim_loop", "get_particles_anim_loop"); - ADD_GROUP("Albedo", "albedo_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "albedo_color"), "set_albedo", "get_albedo"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ALBEDO); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "albedo_tex_force_srgb"), "set_flag", "get_flag", FLAG_ALBEDO_TEXTURE_FORCE_SRGB); + + ADD_GROUP("ORM", "orm_"); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "orm_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ORM); ADD_GROUP("Metallic", "metallic_"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic"); @@ -2172,15 +2294,16 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_on_uv2"), "set_flag", "get_flag", FLAG_AO_ON_UV2); ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_ao_texture_channel", "get_ao_texture_channel"); - ADD_GROUP("Depth", "depth_"); - ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "depth_enabled"), "set_feature", "get_feature", FEATURE_DEPTH_MAPPING); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "depth_scale", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_depth_scale", "get_depth_scale"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_deep_parallax"), "set_depth_deep_parallax", "is_depth_deep_parallax_enabled"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "depth_min_layers", PROPERTY_HINT_RANGE, "1,32,1"), "set_depth_deep_parallax_min_layers", "get_depth_deep_parallax_min_layers"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "depth_max_layers", PROPERTY_HINT_RANGE, "1,32,1"), "set_depth_deep_parallax_max_layers", "get_depth_deep_parallax_max_layers"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_flip_tangent"), "set_depth_deep_parallax_flip_tangent", "get_depth_deep_parallax_flip_tangent"); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_flip_binormal"), "set_depth_deep_parallax_flip_binormal", "get_depth_deep_parallax_flip_binormal"); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "depth_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DEPTH); + ADD_GROUP("Height", "heightmap_"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "heightmap_enabled"), "set_feature", "get_feature", FEATURE_HEIGHT_MAPPING); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "heightmap_scale", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_heightmap_scale", "get_heightmap_scale"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "heightmap_deep_parallax"), "set_heightmap_deep_parallax", "is_heightmap_deep_parallax_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "heightmap_min_layers", PROPERTY_HINT_RANGE, "1,32,1"), "set_heightmap_deep_parallax_min_layers", "get_heightmap_deep_parallax_min_layers"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "heightmap_max_layers", PROPERTY_HINT_RANGE, "1,32,1"), "set_heightmap_deep_parallax_max_layers", "get_heightmap_deep_parallax_max_layers"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "heightmap_flip_tangent"), "set_heightmap_deep_parallax_flip_tangent", "get_heightmap_deep_parallax_flip_tangent"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "heightmap_flip_binormal"), "set_heightmap_deep_parallax_flip_binormal", "get_heightmap_deep_parallax_flip_binormal"); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "heightmap_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_HEIGHTMAP); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "heightmap_flip_texture"), "set_flag", "get_flag", FLAG_INVERT_HEIGHTMAP); ADD_GROUP("Subsurf Scatter", "subsurf_scatter_"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_enabled"), "set_feature", "get_feature", FEATURE_SUBSURACE_SCATTERING); @@ -2211,13 +2334,39 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_offset"), "set_uv1_offset", "get_uv1_offset"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv1_triplanar"), "set_flag", "get_flag", FLAG_UV1_USE_TRIPLANAR); ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv1_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv1_triplanar_blend_sharpness", "get_uv1_triplanar_blend_sharpness"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv1_world_triplanar"), "set_flag", "get_flag", FLAG_UV1_USE_WORLD_TRIPLANAR); ADD_GROUP("UV2", "uv2_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_scale"), "set_uv2_scale", "get_uv2_scale"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv2_offset"), "set_uv2_offset", "get_uv2_offset"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_TRIPLANAR); ADD_PROPERTY(PropertyInfo(Variant::REAL, "uv2_triplanar_sharpness", PROPERTY_HINT_EXP_EASING), "set_uv2_triplanar_blend_sharpness", "get_uv2_triplanar_blend_sharpness"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "uv2_world_triplanar"), "set_flag", "get_flag", FLAG_UV2_USE_WORLD_TRIPLANAR); + + ADD_GROUP("Sampling", "texture_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_filter", PROPERTY_HINT_ENUM, "Nearest,Linear,MipmapNearest,MipmapLinear,MipmapNearestAniso,MipmapLinearAniso"), "set_texture_filter", "get_texture_filter"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "texture_repeat"), "set_flag", "get_flag", FLAG_USE_TEXTURE_REPEAT); + + ADD_GROUP("Shadows", ""); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "disable_receive_shadows"), "set_flag", "get_flag", FLAG_DONT_RECEIVE_SHADOWS); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "shadow_to_opacity"), "set_flag", "get_flag", FLAG_USE_SHADOW_TO_OPACITY); + ADD_GROUP("Billboard", "billboard_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "billboard_mode", PROPERTY_HINT_ENUM, "Disabled,Enabled,Y-Billboard,Particle Billboard"), "set_billboard_mode", "get_billboard_mode"); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "billboard_keep_scale"), "set_flag", "get_flag", FLAG_BILLBOARD_KEEP_SCALE); + + ADD_GROUP("Particles Anim", "particles_anim_"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_h_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_h_frames", "get_particles_anim_h_frames"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "particles_anim_v_frames", PROPERTY_HINT_RANGE, "1,128,1"), "set_particles_anim_v_frames", "get_particles_anim_v_frames"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "particles_anim_loop"), "set_particles_anim_loop", "get_particles_anim_loop"); + + ADD_GROUP("Grow", "grow_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "grow"), "set_grow_enabled", "is_grow_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "grow_amount", PROPERTY_HINT_RANGE, "-16,16,0.001"), "set_grow", "get_grow"); + ADD_GROUP("Transform", ""); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "use_point_size"), "set_flag", "get_flag", FLAG_USE_POINT_SIZE); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "point_size", PROPERTY_HINT_RANGE, "0.1,128,0.1"), "set_point_size", "get_point_size"); ADD_GROUP("Proximity Fade", "proximity_fade_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "proximity_fade_enable"), "set_proximity_fade", "is_proximity_fade_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "proximity_fade_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_proximity_fade_distance", "get_proximity_fade_distance"); @@ -2226,6 +2375,11 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "distance_fade_min_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_distance_fade_min_distance", "get_distance_fade_min_distance"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "distance_fade_max_distance", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_distance_fade_max_distance", "get_distance_fade_max_distance"); + BIND_ENUM_CONSTANT(TRANSPARENCY_DISABLED); + BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA); + BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA_SCISSOR); + BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + BIND_ENUM_CONSTANT(TEXTURE_ALBEDO); BIND_ENUM_CONSTANT(TEXTURE_METALLIC); BIND_ENUM_CONSTANT(TEXTURE_ROUGHNESS); @@ -2235,7 +2389,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(TEXTURE_CLEARCOAT); BIND_ENUM_CONSTANT(TEXTURE_FLOWMAP); BIND_ENUM_CONSTANT(TEXTURE_AMBIENT_OCCLUSION); - BIND_ENUM_CONSTANT(TEXTURE_DEPTH); + BIND_ENUM_CONSTANT(TEXTURE_HEIGHTMAP); BIND_ENUM_CONSTANT(TEXTURE_SUBSURFACE_SCATTERING); BIND_ENUM_CONSTANT(TEXTURE_TRANSMISSION); BIND_ENUM_CONSTANT(TEXTURE_REFRACTION); @@ -2247,14 +2401,13 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(DETAIL_UV_1); BIND_ENUM_CONSTANT(DETAIL_UV_2); - BIND_ENUM_CONSTANT(FEATURE_TRANSPARENT); BIND_ENUM_CONSTANT(FEATURE_EMISSION); BIND_ENUM_CONSTANT(FEATURE_NORMAL_MAPPING); BIND_ENUM_CONSTANT(FEATURE_RIM); BIND_ENUM_CONSTANT(FEATURE_CLEARCOAT); BIND_ENUM_CONSTANT(FEATURE_ANISOTROPY); BIND_ENUM_CONSTANT(FEATURE_AMBIENT_OCCLUSION); - BIND_ENUM_CONSTANT(FEATURE_DEPTH_MAPPING); + BIND_ENUM_CONSTANT(FEATURE_HEIGHT_MAPPING); BIND_ENUM_CONSTANT(FEATURE_SUBSURACE_SCATTERING); BIND_ENUM_CONSTANT(FEATURE_TRANSMISSION); BIND_ENUM_CONSTANT(FEATURE_REFRACTION); @@ -2269,14 +2422,11 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(DEPTH_DRAW_OPAQUE_ONLY); BIND_ENUM_CONSTANT(DEPTH_DRAW_ALWAYS); BIND_ENUM_CONSTANT(DEPTH_DRAW_DISABLED); - BIND_ENUM_CONSTANT(DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); BIND_ENUM_CONSTANT(CULL_BACK); BIND_ENUM_CONSTANT(CULL_FRONT); BIND_ENUM_CONSTANT(CULL_DISABLED); - BIND_ENUM_CONSTANT(FLAG_UNSHADED); - BIND_ENUM_CONSTANT(FLAG_USE_VERTEX_LIGHTING); BIND_ENUM_CONSTANT(FLAG_DISABLE_DEPTH_TEST); BIND_ENUM_CONSTANT(FLAG_ALBEDO_FROM_VERTEX_COLOR); BIND_ENUM_CONSTANT(FLAG_SRGB_VERTEX_COLOR); @@ -2285,15 +2435,15 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_BILLBOARD_KEEP_SCALE); BIND_ENUM_CONSTANT(FLAG_UV1_USE_TRIPLANAR); BIND_ENUM_CONSTANT(FLAG_UV2_USE_TRIPLANAR); + BIND_ENUM_CONSTANT(FLAG_UV1_USE_WORLD_TRIPLANAR); + BIND_ENUM_CONSTANT(FLAG_UV2_USE_WORLD_TRIPLANAR); BIND_ENUM_CONSTANT(FLAG_AO_ON_UV2); BIND_ENUM_CONSTANT(FLAG_EMISSION_ON_UV2); - BIND_ENUM_CONSTANT(FLAG_USE_ALPHA_SCISSOR); - BIND_ENUM_CONSTANT(FLAG_TRIPLANAR_USE_WORLD); BIND_ENUM_CONSTANT(FLAG_ALBEDO_TEXTURE_FORCE_SRGB); BIND_ENUM_CONSTANT(FLAG_DONT_RECEIVE_SHADOWS); BIND_ENUM_CONSTANT(FLAG_DISABLE_AMBIENT_LIGHT); - BIND_ENUM_CONSTANT(FLAG_ENSURE_CORRECT_NORMALS); BIND_ENUM_CONSTANT(FLAG_USE_SHADOW_TO_OPACITY); + BIND_ENUM_CONSTANT(FLAG_USE_TEXTURE_REPEAT); BIND_ENUM_CONSTANT(FLAG_MAX); BIND_ENUM_CONSTANT(DIFFUSE_BURLEY); @@ -2328,10 +2478,13 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(DISTANCE_FADE_OBJECT_DITHER); } -SpatialMaterial::SpatialMaterial() : +BaseMaterial3D::BaseMaterial3D(bool p_orm) : element(this) { + orm = p_orm; // Initialize to the same values as the shader + transparency = TRANSPARENCY_DISABLED; + shading_mode = SHADING_MODE_PER_PIXEL; set_albedo(Color(1.0, 1.0, 1.0, 1.0)); set_specular(0.5); set_roughness(1.0); @@ -2344,7 +2497,7 @@ SpatialMaterial::SpatialMaterial() : set_clearcoat(1); set_clearcoat_gloss(0.5); set_anisotropy(0); - set_depth_scale(0.05); + set_heightmap_scale(0.05); set_subsurface_scattering_strength(0); set_transmission(Color(0, 0, 0)); set_refraction(0.05); @@ -2379,11 +2532,11 @@ SpatialMaterial::SpatialMaterial() : set_grow(0.0); deep_parallax = false; - depth_parallax_flip_tangent = false; - depth_parallax_flip_binormal = false; - set_depth_deep_parallax_min_layers(8); - set_depth_deep_parallax_max_layers(32); - set_depth_deep_parallax_flip_tangent(false); //also sets binormal + heightmap_parallax_flip_tangent = false; + heightmap_parallax_flip_binormal = false; + set_heightmap_deep_parallax_min_layers(8); + set_heightmap_deep_parallax_max_layers(32); + set_heightmap_deep_parallax_flip_tangent(false); //also sets binormal detail_uv = DETAIL_UV_1; blend_mode = BLEND_MODE_MIX; @@ -2393,6 +2546,8 @@ SpatialMaterial::SpatialMaterial() : for (int i = 0; i < FLAG_MAX; i++) { flags[i] = 0; } + flags[FLAG_USE_TEXTURE_REPEAT] = true; + diffuse_mode = DIFFUSE_BURLEY; specular_mode = SPECULAR_SCHLICK_GGX; @@ -2402,10 +2557,11 @@ SpatialMaterial::SpatialMaterial() : current_key.key = 0; current_key.invalid_key = 1; + texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS; _queue_shader_change(); } -SpatialMaterial::~SpatialMaterial() { +BaseMaterial3D::~BaseMaterial3D() { if (material_mutex) material_mutex->lock(); @@ -2424,3 +2580,95 @@ SpatialMaterial::~SpatialMaterial() { if (material_mutex) material_mutex->unlock(); } + +////////////////////// +#ifndef DISABLE_DEPRECATED + +bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value) { + if (p_name == "flags_transparent") { + bool transparent = p_value; + if (transparent) { + set_transparency(TRANSPARENCY_ALPHA); + } + return true; + } else if (p_name == "flags_unshaded") { + bool unshaded = p_value; + if (unshaded) { + set_shading_mode(SHADING_MODE_UNSHADED); + } + return true; + } else if (p_name == "flags_vertex_lighting") { + bool vertex_lit = p_value; + if (vertex_lit && get_shading_mode() != SHADING_MODE_UNSHADED) { + set_shading_mode(SHADING_MODE_PER_VERTEX); + } + return true; + } else if (p_name == "params_use_alpha_scissor") { + bool use_scissor = p_value; + if (use_scissor) { + set_transparency(TRANSPARENCY_ALPHA_SCISSOR); + } + return true; + } else if (p_name == "params_depth_draw_mode") { + int mode = p_value; + if (mode == 3) { + set_transparency(TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); + } + return true; + } else if (p_name == "depth_enabled") { + bool enabled = p_value; + if (enabled) { + set_feature(FEATURE_HEIGHT_MAPPING, true); + set_flag(FLAG_INVERT_HEIGHTMAP, true); + } + return true; + } else { + static const Pair<const char *, const char *> remaps[] = { + { "flags_use_shadow_to_opacity", "shadow_to_opacity" }, + { "flags_use_shadow_to_opacity", "shadow_to_opacity" }, + { "flags_no_depth_test", "no_depth_test" }, + { "flags_use_point_size", "use_point_size" }, + { "flags_fixed_size", "fixed_Size" }, + { "flags_albedo_tex_force_srg", "albedo_tex_force_srgb" }, + { "flags_do_not_receive_shadows", "disable_receive_shadows" }, + { "flags_disable_ambient_light", "disable_ambient_light" }, + { "params_diffuse_mode", "diffuse_mode" }, + { "params_specular_mode", "specular_mode" }, + { "params_blend_mode", "blend_mode" }, + { "params_cull_mode", "cull_mode" }, + { "params_depth_draw_mode", "params_depth_draw_mode" }, + { "params_point_size", "point_size" }, + { "params_billboard_mode", "billboard_mode" }, + { "params_billboard_keep_scale", "billboard_keep_scale" }, + { "params_grow", "grow" }, + { "params_grow_amount", "grow_amount" }, + { "params_alpha_scissor_threshold", "alpha_scissor_threshold" }, + + { "depth_scale", "heightmap_scale" }, + { "depth_deep_parallax", "heightmap_deep_parallax" }, + { "depth_min_layers", "heightmap_min_layers" }, + { "depth_max_layers", "heightmap_max_layers" }, + { "depth_flip_tangent", "heightmap_flip_tangent" }, + { "depth_flip_binormal", "heightmap_flip_binormal" }, + { "depth_texture", "heightmap_texture" }, + + { NULL, NULL }, + }; + + int idx = 0; + while (remaps[idx].first) { + if (p_name == remaps[idx].first) { + set(remaps[idx].second, p_value); + return true; + } + idx++; + } + + print_line("remapped parameter not found: " + String(p_name)); + return true; + } + + return false; +} + +#endif diff --git a/scene/resources/material.h b/scene/resources/material.h index a1b6fd34ea..328c868f2a 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -106,9 +106,11 @@ public: ~ShaderMaterial(); }; -class SpatialMaterial : public Material { +class StandardMaterial3D; - GDCLASS(SpatialMaterial, Material); +class BaseMaterial3D : public Material { + + GDCLASS(BaseMaterial3D, Material); public: enum TextureParam { @@ -121,31 +123,56 @@ public: TEXTURE_CLEARCOAT, TEXTURE_FLOWMAP, TEXTURE_AMBIENT_OCCLUSION, - TEXTURE_DEPTH, + TEXTURE_HEIGHTMAP, TEXTURE_SUBSURFACE_SCATTERING, TEXTURE_TRANSMISSION, TEXTURE_REFRACTION, TEXTURE_DETAIL_MASK, TEXTURE_DETAIL_ALBEDO, TEXTURE_DETAIL_NORMAL, + TEXTURE_ORM, TEXTURE_MAX }; + enum TextureFilter { + TEXTURE_FILTER_NEAREST, + TEXTURE_FILTER_LINEAR, + TEXTURE_FILTER_NEAREST_WITH_MIMPAMPS, + TEXTURE_FILTER_LINEAR_WITH_MIPMAPS, + TEXTURE_FILTER_NEAREST_WITH_MIMPAMPS_ANISOTROPIC, + TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC, + TEXTURE_FILTER_MAX + }; + enum DetailUV { DETAIL_UV_1, DETAIL_UV_2 }; + enum Transparency { + TRANSPARENCY_DISABLED, + TRANSPARENCY_ALPHA, + TRANSPARENCY_ALPHA_SCISSOR, + TRANSPARENCY_ALPHA_DEPTH_PRE_PASS, + TRANSPARENCY_MAX, + }; + + enum ShadingMode { + SHADING_MODE_UNSHADED, + SHADING_MODE_PER_PIXEL, + SHADING_MODE_PER_VERTEX, + SHADING_MODE_MAX + }; + enum Feature { - FEATURE_TRANSPARENT, FEATURE_EMISSION, FEATURE_NORMAL_MAPPING, FEATURE_RIM, FEATURE_CLEARCOAT, FEATURE_ANISOTROPY, FEATURE_AMBIENT_OCCLUSION, - FEATURE_DEPTH_MAPPING, + FEATURE_HEIGHT_MAPPING, FEATURE_SUBSURACE_SCATTERING, FEATURE_TRANSMISSION, FEATURE_REFRACTION, @@ -164,8 +191,6 @@ public: DEPTH_DRAW_OPAQUE_ONLY, DEPTH_DRAW_ALWAYS, DEPTH_DRAW_DISABLED, - DEPTH_DRAW_ALPHA_OPAQUE_PREPASS - }; enum CullMode { @@ -175,8 +200,6 @@ public: }; enum Flags { - FLAG_UNSHADED, - FLAG_USE_VERTEX_LIGHTING, FLAG_DISABLE_DEPTH_TEST, FLAG_ALBEDO_FROM_VERTEX_COLOR, FLAG_SRGB_VERTEX_COLOR, @@ -185,15 +208,16 @@ public: FLAG_BILLBOARD_KEEP_SCALE, FLAG_UV1_USE_TRIPLANAR, FLAG_UV2_USE_TRIPLANAR, - FLAG_TRIPLANAR_USE_WORLD, + FLAG_UV1_USE_WORLD_TRIPLANAR, + FLAG_UV2_USE_WORLD_TRIPLANAR, FLAG_AO_ON_UV2, FLAG_EMISSION_ON_UV2, - FLAG_USE_ALPHA_SCISSOR, FLAG_ALBEDO_TEXTURE_FORCE_SRGB, FLAG_DONT_RECEIVE_SHADOWS, - FLAG_ENSURE_CORRECT_NORMALS, FLAG_DISABLE_AMBIENT_LIGHT, FLAG_USE_SHADOW_TO_OPACITY, + FLAG_USE_TEXTURE_REPEAT, + FLAG_INVERT_HEIGHTMAP, FLAG_MAX }; @@ -244,12 +268,12 @@ private: union MaterialKey { struct { - uint64_t feature_mask : 12; + uint64_t feature_mask : FEATURE_MAX; uint64_t detail_uv : 1; uint64_t blend_mode : 2; uint64_t depth_draw_mode : 2; uint64_t cull_mode : 2; - uint64_t flags : 19; + uint64_t flags : FLAG_MAX; uint64_t detail_blend_mode : 2; uint64_t diffuse_mode : 3; uint64_t specular_mode : 3; @@ -260,8 +284,10 @@ private: uint64_t proximity_fade : 1; uint64_t distance_fade : 2; uint64_t emission_op : 1; - uint64_t texture_metallic : 1; - uint64_t texture_roughness : 1; + uint64_t texture_filter : 3; + uint64_t transparency : 2; + uint64_t shading_mode : 2; + uint64_t roughness_channel : 3; }; uint64_t key; @@ -293,6 +319,10 @@ private: mk.blend_mode = blend_mode; mk.depth_draw_mode = depth_draw_mode; mk.cull_mode = cull_mode; + mk.texture_filter = texture_filter; + mk.transparency = transparency; + mk.shading_mode = shading_mode; + mk.roughness_channel = roughness_texture_channel; for (int i = 0; i < FLAG_MAX; i++) { if (flags[i]) { mk.flags |= ((uint64_t)1 << i); @@ -307,8 +337,6 @@ private: mk.proximity_fade = proximity_fade_enabled; mk.distance_fade = distance_fade; mk.emission_op = emission_op; - mk.texture_metallic = textures[TEXTURE_METALLIC].is_valid() ? 1 : 0; - mk.texture_roughness = textures[TEXTURE_ROUGHNESS].is_valid() ? 1 : 0; return mk; } @@ -326,7 +354,7 @@ private: StringName clearcoat; StringName clearcoat_gloss; StringName anisotropy; - StringName depth_scale; + StringName heightmap_scale; StringName subsurface_scattering_strength; StringName transmission; StringName refraction; @@ -338,9 +366,9 @@ private: StringName particles_anim_h_frames; StringName particles_anim_v_frames; StringName particles_anim_loop; - StringName depth_min_layers; - StringName depth_max_layers; - StringName depth_flip; + StringName heightmap_min_layers; + StringName heightmap_max_layers; + StringName heightmap_flip; StringName uv1_blend_sharpness; StringName uv2_blend_sharpness; StringName grow; @@ -350,11 +378,10 @@ private: StringName ao_light_affect; StringName metallic_texture_channel; - StringName roughness_texture_channel; StringName ao_texture_channel; StringName clearcoat_texture_channel; StringName rim_texture_channel; - StringName depth_texture_channel; + StringName heightmap_texture_channel; StringName refraction_texture_channel; StringName alpha_scissor_threshold; @@ -362,15 +389,17 @@ private: }; static Mutex *material_mutex; - static SelfList<SpatialMaterial>::List *dirty_materials; + static SelfList<BaseMaterial3D>::List *dirty_materials; static ShaderNames *shader_names; - SelfList<SpatialMaterial> element; + SelfList<BaseMaterial3D> element; void _update_shader(); _FORCE_INLINE_ void _queue_shader_change(); _FORCE_INLINE_ bool _is_shader_dirty() const; + bool orm; + Color albedo; float specular; float metallic; @@ -383,7 +412,7 @@ private: float clearcoat; float clearcoat_gloss; float anisotropy; - float depth_scale; + float heightmap_scale; float subsurface_scattering_strength; Color transmission; float refraction; @@ -395,6 +424,10 @@ private: int particles_anim_h_frames; int particles_anim_v_frames; bool particles_anim_loop; + Transparency transparency; + ShadingMode shading_mode; + + TextureFilter texture_filter; Vector3 uv1_scale; Vector3 uv1_offset; @@ -409,8 +442,8 @@ private: bool deep_parallax; int deep_parallax_min_layers; int deep_parallax_max_layers; - bool depth_parallax_flip_tangent; - bool depth_parallax_flip_binormal; + bool heightmap_parallax_flip_tangent; + bool heightmap_parallax_flip_binormal; bool proximity_fade_enabled; float proximity_fade_distance; @@ -442,7 +475,7 @@ private: static const int MAX_MATERIALS_FOR_2D = 128; - static Ref<SpatialMaterial> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff + static Ref<StandardMaterial3D> materials_for_2d[MAX_MATERIALS_FOR_2D]; //used by Sprite3D and other stuff void _validate_high_end(const String &text, PropertyInfo &property) const; @@ -491,23 +524,23 @@ public: void set_anisotropy(float p_anisotropy); float get_anisotropy() const; - void set_depth_scale(float p_depth_scale); - float get_depth_scale() const; + void set_heightmap_scale(float p_heightmap_scale); + float get_heightmap_scale() const; - void set_depth_deep_parallax(bool p_enable); - bool is_depth_deep_parallax_enabled() const; + void set_heightmap_deep_parallax(bool p_enable); + bool is_heightmap_deep_parallax_enabled() const; - void set_depth_deep_parallax_min_layers(int p_layer); - int get_depth_deep_parallax_min_layers() const; + void set_heightmap_deep_parallax_min_layers(int p_layer); + int get_heightmap_deep_parallax_min_layers() const; - void set_depth_deep_parallax_max_layers(int p_layer); - int get_depth_deep_parallax_max_layers() const; + void set_heightmap_deep_parallax_max_layers(int p_layer); + int get_heightmap_deep_parallax_max_layers() const; - void set_depth_deep_parallax_flip_tangent(bool p_flip); - bool get_depth_deep_parallax_flip_tangent() const; + void set_heightmap_deep_parallax_flip_tangent(bool p_flip); + bool get_heightmap_deep_parallax_flip_tangent() const; - void set_depth_deep_parallax_flip_binormal(bool p_flip); - bool get_depth_deep_parallax_flip_binormal() const; + void set_heightmap_deep_parallax_flip_binormal(bool p_flip); + bool get_heightmap_deep_parallax_flip_binormal() const; void set_subsurface_scattering_strength(float p_subsurface_scattering_strength); float get_subsurface_scattering_strength() const; @@ -521,6 +554,12 @@ public: void set_point_size(float p_point_size); float get_point_size() const; + void set_transparency(Transparency p_transparency); + Transparency get_transparency() const; + + void set_shading_mode(ShadingMode p_shading_mode); + ShadingMode get_shading_mode() const; + void set_detail_uv(DetailUV p_detail_uv); DetailUV get_detail_uv() const; @@ -550,6 +589,9 @@ public: // Used only for shader material conversion Ref<Texture2D> get_texture_by_name(StringName p_name) const; + void set_texture_filter(TextureFilter p_filter); + TextureFilter get_texture_filter() const; + void set_feature(Feature p_feature, bool p_enabled); bool get_feature(Feature p_feature) const; @@ -630,23 +672,45 @@ public: virtual Shader::Mode get_shader_mode() const; - SpatialMaterial(); - virtual ~SpatialMaterial(); + BaseMaterial3D(bool p_orm); + virtual ~BaseMaterial3D(); }; -VARIANT_ENUM_CAST(SpatialMaterial::TextureParam) -VARIANT_ENUM_CAST(SpatialMaterial::DetailUV) -VARIANT_ENUM_CAST(SpatialMaterial::Feature) -VARIANT_ENUM_CAST(SpatialMaterial::BlendMode) -VARIANT_ENUM_CAST(SpatialMaterial::DepthDrawMode) -VARIANT_ENUM_CAST(SpatialMaterial::CullMode) -VARIANT_ENUM_CAST(SpatialMaterial::Flags) -VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode) -VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode) -VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode) -VARIANT_ENUM_CAST(SpatialMaterial::TextureChannel) -VARIANT_ENUM_CAST(SpatialMaterial::EmissionOperator) -VARIANT_ENUM_CAST(SpatialMaterial::DistanceFadeMode) +VARIANT_ENUM_CAST(BaseMaterial3D::TextureParam) +VARIANT_ENUM_CAST(BaseMaterial3D::TextureFilter) +VARIANT_ENUM_CAST(BaseMaterial3D::ShadingMode) +VARIANT_ENUM_CAST(BaseMaterial3D::Transparency) +VARIANT_ENUM_CAST(BaseMaterial3D::DetailUV) +VARIANT_ENUM_CAST(BaseMaterial3D::Feature) +VARIANT_ENUM_CAST(BaseMaterial3D::BlendMode) +VARIANT_ENUM_CAST(BaseMaterial3D::DepthDrawMode) +VARIANT_ENUM_CAST(BaseMaterial3D::CullMode) +VARIANT_ENUM_CAST(BaseMaterial3D::Flags) +VARIANT_ENUM_CAST(BaseMaterial3D::DiffuseMode) +VARIANT_ENUM_CAST(BaseMaterial3D::SpecularMode) +VARIANT_ENUM_CAST(BaseMaterial3D::BillboardMode) +VARIANT_ENUM_CAST(BaseMaterial3D::TextureChannel) +VARIANT_ENUM_CAST(BaseMaterial3D::EmissionOperator) +VARIANT_ENUM_CAST(BaseMaterial3D::DistanceFadeMode) + +class StandardMaterial3D : public BaseMaterial3D { + GDCLASS(StandardMaterial3D, BaseMaterial3D) +protected: +#ifndef DISABLE_DEPRECATED + bool _set(const StringName &p_name, const Variant &p_value); +#endif + +public: + StandardMaterial3D() : + BaseMaterial3D(false) {} +}; + +class ORMMaterial3D : public BaseMaterial3D { + GDCLASS(ORMMaterial3D, BaseMaterial3D) +public: + ORMMaterial3D() : + BaseMaterial3D(true) {} +}; ////////////////////// diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index e102d944e8..ec5989b862 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -1041,7 +1041,7 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const { if (surfaces[i].is_2d) { p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,CanvasItemMaterial", PROPERTY_USAGE_EDITOR)); } else { - p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,SpatialMaterial", PROPERTY_USAGE_EDITOR)); + p_list->push_back(PropertyInfo(Variant::OBJECT, "surface_" + itos(i + 1) + "/material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,StandardMaterial3D", PROPERTY_USAGE_EDITOR)); } } } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 79d030b8ab..fa0ded12a1 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -206,7 +206,7 @@ void PrimitiveMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("set_flip_faces", "flip_faces"), &PrimitiveMesh::set_flip_faces); ClassDB::bind_method(D_METHOD("get_flip_faces"), &PrimitiveMesh::get_flip_faces); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "StandardMaterial3D,ShaderMaterial"), "set_material", "get_material"); ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "flip_faces"), "set_flip_faces", "get_flip_faces"); } diff --git a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp index 1a94f11334..0da86f23a7 100644 --- a/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_canvas_rd.cpp @@ -2356,6 +2356,7 @@ RasterizerCanvasRD::RasterizerCanvasRD(RasterizerStorageRD *p_storage) { actions.base_uniform_string = "material."; actions.default_filter = ShaderLanguage::FILTER_LINEAR; actions.default_repeat = ShaderLanguage::REPEAT_DISABLE; + actions.base_varying_index = 4; shader.compiler.initialize(actions); } diff --git a/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp index bf4d7e4fc8..7164624c9f 100644 --- a/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_scene_forward_rd.cpp @@ -273,13 +273,13 @@ void RasterizerSceneForwardRD::ShaderData::set_code(const String &p_code) { for (int i = 0; i < CULL_VARIANT_MAX; i++) { - RD::PolygonCullMode cull_mode_rd_table[3][CULL_VARIANT_MAX] = { + RD::PolygonCullMode cull_mode_rd_table[CULL_VARIANT_MAX][3] = { { RD::POLYGON_CULL_DISABLED, RD::POLYGON_CULL_FRONT, RD::POLYGON_CULL_BACK }, { RD::POLYGON_CULL_DISABLED, RD::POLYGON_CULL_BACK, RD::POLYGON_CULL_FRONT }, { RD::POLYGON_CULL_DISABLED, RD::POLYGON_CULL_DISABLED, RD::POLYGON_CULL_DISABLED } }; - RD::PolygonCullMode cull_mode_rd = cull_mode_rd_table[cull][i]; + RD::PolygonCullMode cull_mode_rd = cull_mode_rd_table[i][cull]; for (int j = 0; j < VS::PRIMITIVE_MAX; j++) { @@ -309,7 +309,7 @@ void RasterizerSceneForwardRD::ShaderData::set_code(const String &p_code) { depth_stencil.enable_depth_write = false; //alpha does not draw depth } } else if (uses_depth_pre_pass && (k == SHADER_VERSION_DEPTH_PASS || k == SHADER_VERSION_DEPTH_PASS_DP || k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL || k == SHADER_VERSION_DEPTH_PASS_WITH_NORMAL_AND_ROUGHNESS)) { - if (k == SHADER_VERSION_DEPTH_PASS || k == k == SHADER_VERSION_DEPTH_PASS_DP) { + if (k == SHADER_VERSION_DEPTH_PASS || k == SHADER_VERSION_DEPTH_PASS_DP) { //none, blend state contains nothing } else { blend_state = blend_state_opaque; //writes to normal and roughness in opaque way @@ -2703,11 +2703,13 @@ RasterizerSceneForwardRD::RasterizerSceneForwardRD(RasterizerStorageRD *p_storag actions.render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; actions.render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; actions.render_mode_defines["shadow_to_opacity"] = "#define USE_SHADOW_TO_OPACITY\n"; + actions.render_mode_defines["unshaded"] = "#define MODE_UNSHADED\n"; actions.sampler_array_name = "material_samplers"; actions.base_texture_binding_index = 1; actions.texture_layout_set = 2; actions.base_uniform_string = "material."; + actions.base_varying_index = 10; actions.default_filter = ShaderLanguage::FILTER_LINEAR_MIPMAP; actions.default_repeat = ShaderLanguage::REPEAT_ENABLE; diff --git a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp index 7cf93a82e0..e73efa1e12 100644 --- a/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp +++ b/servers/visual/rasterizer_rd/rasterizer_storage_rd.cpp @@ -1649,6 +1649,7 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va if (!texture.is_valid()) { const Map<StringName, RID>::Element *W = p_default_textures.find(uniform_name); if (W) { + texture = W->get(); } } @@ -1673,11 +1674,12 @@ void RasterizerStorageRD::MaterialData::update_textures(const Map<StringName, Va } break; } } else { - bool srgb = p_use_linear_color && p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO; + bool srgb = p_use_linear_color && (p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_ALBEDO || p_texture_uniforms[i].hint == ShaderLanguage::ShaderNode::Uniform::HINT_BLACK_ALBEDO); Texture *tex = singleton->texture_owner.getornull(texture); if (tex) { + rd_texture = (srgb && tex->rd_texture_srgb.is_valid()) ? tex->rd_texture_srgb : tex->rd_texture; #ifdef TOOLS_ENABLED if (tex->detect_3d_callback && p_use_linear_color) { diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp b/servers/visual/rasterizer_rd/shader_compiler_rd.cpp index 1aa48a82fc..4572345334 100644 --- a/servers/visual/rasterizer_rd/shader_compiler_rd.cpp +++ b/servers/visual/rasterizer_rd/shader_compiler_rd.cpp @@ -366,7 +366,7 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge r_gen_code.fragment_global += ucode; GeneratedCode::Texture texture; - texture.name = _mkid(E->key()); + texture.name = E->key(); texture.hint = E->get().hint; texture.type = E->get().type; texture.filter = E->get().filter; @@ -452,6 +452,8 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge } #endif + uint32_t index = p_default_actions.base_varying_index; + for (Map<StringName, SL::ShaderNode::Varying>::Element *E = pnode->varyings.front(); E; E = E->next()) { String vcode; @@ -460,8 +462,9 @@ String ShaderCompilerRD::_dump_node_code(const SL::Node *p_node, int p_level, Ge vcode += _typestr(E->get().type); vcode += " " + _mkid(E->key()); vcode += ";\n"; - r_gen_code.vertex_global += interp_mode + "out " + vcode; - r_gen_code.fragment_global += interp_mode + "in " + vcode; + r_gen_code.vertex_global += "layout(location=" + itos(index) + ") " + interp_mode + "out " + vcode; + r_gen_code.fragment_global += "layout(location=" + itos(index) + ") " + interp_mode + "in " + vcode; + index++; } for (Map<StringName, SL::ShaderNode::Constant>::Element *E = pnode->constants.front(); E; E = E->next()) { diff --git a/servers/visual/rasterizer_rd/shader_compiler_rd.h b/servers/visual/rasterizer_rd/shader_compiler_rd.h index 3572a73a2d..67fc39005a 100644 --- a/servers/visual/rasterizer_rd/shader_compiler_rd.h +++ b/servers/visual/rasterizer_rd/shader_compiler_rd.h @@ -53,9 +53,10 @@ public: ShaderLanguage::TextureFilter default_filter; ShaderLanguage::TextureRepeat default_repeat; String sampler_array_name; - int base_texture_binding_index; - int texture_layout_set; + int base_texture_binding_index = 0; + int texture_layout_set = 0; String base_uniform_string; + uint32_t base_varying_index = 0; }; private: diff --git a/servers/visual/rasterizer_rd/shaders/scene_forward.glsl b/servers/visual/rasterizer_rd/shaders/scene_forward.glsl index 1bd11c4288..bacf6f3e67 100644 --- a/servers/visual/rasterizer_rd/shaders/scene_forward.glsl +++ b/servers/visual/rasterizer_rd/shaders/scene_forward.glsl @@ -351,6 +351,8 @@ layout(location = 0) out vec4 frag_color; // E. Heitz, "Understanding the Masking-Shadowing Function in Microfacet-Based BRDFs", J. Comp. Graph. Tech. 3 (2) (2014). // Eqns 71-72 and 85-86 (see also Eqns 43 and 80). +#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) + float G_GGX_2cos(float cos_theta_m, float alpha) { // Schlick's approximation // C. Schlick, "An Inexpensive BRDF Model for Physically-based Rendering", Computer Graphics Forum. 13 (3): 233 (1994) @@ -892,6 +894,10 @@ void reflection_process(uint ref_index, vec3 vertex, vec3 normal,float roughness } #endif //USE_LIGHTMAP } + +#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) + + void main() { #ifdef MODE_DUAL_PARABOLOID @@ -1030,7 +1036,8 @@ FRAGMENT_SHADER_CODE vec3 diffuse_light = vec3(0.0, 0.0, 0.0); vec3 ambient_light = vec3( 0.0, 0.0, 0.0); -#ifndef MODE_RENDER_DEPTH +#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) + if (scene_data.use_reflection_cubemap){ vec3 ref_vec = reflect(-view, normal); @@ -1070,7 +1077,8 @@ FRAGMENT_SHADER_CODE } #endif // USE_LIGHTMAP -#endif // MODE_RENDER_DEPTH +#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) + //radiance @@ -1080,7 +1088,7 @@ FRAGMENT_SHADER_CODE specular_blob_intensity *= specular * 2.0; #endif -#ifndef MODE_RENDER_DEPTH +#if !defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) //gi probes //lightmap @@ -1306,7 +1314,7 @@ FRAGMENT_SHADER_CODE } -#endif //!MODE_RENDER_DEPTH + #ifdef USE_SHADOW_TO_OPACITY alpha = min(alpha, clamp(length(ambient_light), 0.0, 1.0)); @@ -1327,6 +1335,7 @@ FRAGMENT_SHADER_CODE #endif // USE_SHADOW_TO_OPACITY +#endif //!defined(MODE_RENDER_DEPTH) && !defined(MODE_UNSHADED) #ifdef MODE_RENDER_DEPTH @@ -1351,7 +1360,7 @@ FRAGMENT_SHADER_CODE #ifdef MODE_MULTIPLE_RENDER_TARGETS -#ifdef USE_NO_SHADING +#ifdef MODE_UNSHADED diffuse_buffer = vec4(albedo.rgb, 0.0); specular_buffer = vec4(0.0); @@ -1364,7 +1373,7 @@ FRAGMENT_SHADER_CODE #else //MODE_MULTIPLE_RENDER_TARGETS -#ifdef USE_NO_SHADING +#ifdef MODE_UNSHADED frag_color = vec4(albedo, alpha); #else frag_color = vec4(emission + ambient_light + diffuse_light + specular_light, alpha); diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index 5ef51e3e1a..d405dade6f 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -5169,143 +5169,145 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct if (tk.type == TK_COLON) { //hint - - tk = _get_token(); - if (tk.type == TK_HINT_WHITE_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_WHITE; - } else if (tk.type == TK_HINT_BLACK_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_BLACK; - } else if (tk.type == TK_HINT_NORMAL_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_NORMAL; - } else if (tk.type == TK_HINT_ROUGHNESS_NORMAL_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_NORMAL; - } else if (tk.type == TK_HINT_ROUGHNESS_R) { - uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_R; - } else if (tk.type == TK_HINT_ROUGHNESS_G) { - uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_G; - } else if (tk.type == TK_HINT_ROUGHNESS_B) { - uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_B; - } else if (tk.type == TK_HINT_ROUGHNESS_A) { - uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_A; - } else if (tk.type == TK_HINT_ROUGHNESS_GRAY) { - uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_GRAY; - } else if (tk.type == TK_HINT_ANISO_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_ANISO; - } else if (tk.type == TK_HINT_ALBEDO_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_ALBEDO; - } else if (tk.type == TK_HINT_BLACK_ALBEDO_TEXTURE) { - uniform2.hint = ShaderNode::Uniform::HINT_BLACK_ALBEDO; - } else if (tk.type == TK_HINT_COLOR) { - if (type != TYPE_VEC4) { - _set_error("Color hint is for vec4 only"); - return ERR_PARSE_ERROR; - } - uniform2.hint = ShaderNode::Uniform::HINT_COLOR; - } else if (tk.type == TK_HINT_RANGE) { - - uniform2.hint = ShaderNode::Uniform::HINT_RANGE; - if (type != TYPE_FLOAT && type != TYPE_INT) { - _set_error("Range hint is for float and int only"); - return ERR_PARSE_ERROR; - } - - tk = _get_token(); - if (tk.type != TK_PARENTHESIS_OPEN) { - _set_error("Expected '(' after hint_range"); - return ERR_PARSE_ERROR; - } - + do { tk = _get_token(); + if (tk.type == TK_HINT_WHITE_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_WHITE; + } else if (tk.type == TK_HINT_BLACK_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_BLACK; + } else if (tk.type == TK_HINT_NORMAL_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_NORMAL; + } else if (tk.type == TK_HINT_ROUGHNESS_NORMAL_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_NORMAL; + } else if (tk.type == TK_HINT_ROUGHNESS_R) { + uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_R; + } else if (tk.type == TK_HINT_ROUGHNESS_G) { + uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_G; + } else if (tk.type == TK_HINT_ROUGHNESS_B) { + uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_B; + } else if (tk.type == TK_HINT_ROUGHNESS_A) { + uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_A; + } else if (tk.type == TK_HINT_ROUGHNESS_GRAY) { + uniform2.hint = ShaderNode::Uniform::HINT_ROUGHNESS_GRAY; + } else if (tk.type == TK_HINT_ANISO_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_ANISO; + } else if (tk.type == TK_HINT_ALBEDO_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_ALBEDO; + } else if (tk.type == TK_HINT_BLACK_ALBEDO_TEXTURE) { + uniform2.hint = ShaderNode::Uniform::HINT_BLACK_ALBEDO; + } else if (tk.type == TK_HINT_COLOR) { + if (type != TYPE_VEC4) { + _set_error("Color hint is for vec4 only"); + return ERR_PARSE_ERROR; + } + uniform2.hint = ShaderNode::Uniform::HINT_COLOR; + } else if (tk.type == TK_HINT_RANGE) { - float sign = 1.0; + uniform2.hint = ShaderNode::Uniform::HINT_RANGE; + if (type != TYPE_FLOAT && type != TYPE_INT) { + _set_error("Range hint is for float and int only"); + return ERR_PARSE_ERROR; + } - if (tk.type == TK_OP_SUB) { - sign = -1.0; tk = _get_token(); - } - - if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) { - _set_error("Expected integer constant"); - return ERR_PARSE_ERROR; - } + if (tk.type != TK_PARENTHESIS_OPEN) { + _set_error("Expected '(' after hint_range"); + return ERR_PARSE_ERROR; + } - uniform2.hint_range[0] = tk.constant; - uniform2.hint_range[0] *= sign; + tk = _get_token(); - tk = _get_token(); + float sign = 1.0; - if (tk.type != TK_COMMA) { - _set_error("Expected ',' after integer constant"); - return ERR_PARSE_ERROR; - } + if (tk.type == TK_OP_SUB) { + sign = -1.0; + tk = _get_token(); + } - tk = _get_token(); + if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) { + _set_error("Expected integer constant"); + return ERR_PARSE_ERROR; + } - sign = 1.0; + uniform2.hint_range[0] = tk.constant; + uniform2.hint_range[0] *= sign; - if (tk.type == TK_OP_SUB) { - sign = -1.0; tk = _get_token(); - } - if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) { - _set_error("Expected integer constant after ','"); - return ERR_PARSE_ERROR; - } + if (tk.type != TK_COMMA) { + _set_error("Expected ',' after integer constant"); + return ERR_PARSE_ERROR; + } - uniform2.hint_range[1] = tk.constant; - uniform2.hint_range[1] *= sign; + tk = _get_token(); - tk = _get_token(); + sign = 1.0; - if (tk.type == TK_COMMA) { - tk = _get_token(); + if (tk.type == TK_OP_SUB) { + sign = -1.0; + tk = _get_token(); + } if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) { _set_error("Expected integer constant after ','"); return ERR_PARSE_ERROR; } - uniform2.hint_range[2] = tk.constant; + uniform2.hint_range[1] = tk.constant; + uniform2.hint_range[1] *= sign; + tk = _get_token(); - } else { - if (type == TYPE_INT) { - uniform2.hint_range[2] = 1; + + if (tk.type == TK_COMMA) { + tk = _get_token(); + + if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) { + _set_error("Expected integer constant after ','"); + return ERR_PARSE_ERROR; + } + + uniform2.hint_range[2] = tk.constant; + tk = _get_token(); } else { - uniform2.hint_range[2] = 0.001; + if (type == TYPE_INT) { + uniform2.hint_range[2] = 1; + } else { + uniform2.hint_range[2] = 0.001; + } + } + + if (tk.type != TK_PARENTHESIS_CLOSE) { + _set_error("Expected ','"); + return ERR_PARSE_ERROR; } + } else if (tk.type == TK_FILTER_LINEAR) { + uniform2.filter = FILTER_LINEAR; + } else if (tk.type == TK_FILTER_NEAREST) { + uniform2.filter = FILTER_NEAREST; + } else if (tk.type == TK_FILTER_NEAREST_MIPMAP) { + uniform2.filter = FILTER_NEAREST_MIPMAP; + } else if (tk.type == TK_FILTER_LINEAR_MIPMAP) { + uniform2.filter = FILTER_LINEAR_MIPMAP; + } else if (tk.type == TK_FILTER_NEAREST_MIPMAP_ANISO) { + uniform2.filter = FILTER_NEAREST_MIPMAP_ANISO; + } else if (tk.type == TK_FILTER_LINEAR_MIPMAP_ANISO) { + uniform2.filter = FILTER_LINEAR_MIPMAP_ANISO; + } else if (tk.type == TK_REPEAT_DISABLE) { + uniform2.repeat = REPEAT_DISABLE; + } else if (tk.type == TK_REPEAT_ENABLE) { + uniform2.repeat = REPEAT_ENABLE; + } else { + _set_error("Expected valid type hint after ':'."); } - if (tk.type != TK_PARENTHESIS_CLOSE) { - _set_error("Expected ','"); + if (uniform2.hint != ShaderNode::Uniform::HINT_RANGE && uniform2.hint != ShaderNode::Uniform::HINT_NONE && uniform2.hint != ShaderNode::Uniform::HINT_COLOR && type <= TYPE_MAT4) { + _set_error("This hint is only for sampler types"); return ERR_PARSE_ERROR; } - } else if (tk.type == TK_FILTER_LINEAR) { - uniform2.filter = FILTER_LINEAR; - } else if (tk.type == TK_FILTER_NEAREST) { - uniform2.filter = FILTER_NEAREST; - } else if (tk.type == TK_FILTER_NEAREST_MIPMAP) { - uniform2.filter = FILTER_NEAREST_MIPMAP; - } else if (tk.type == TK_FILTER_LINEAR_MIPMAP) { - uniform2.filter = FILTER_LINEAR_MIPMAP; - } else if (tk.type == TK_FILTER_NEAREST_MIPMAP_ANISO) { - uniform2.filter = FILTER_NEAREST_MIPMAP_ANISO; - } else if (tk.type == TK_FILTER_LINEAR_MIPMAP_ANISO) { - uniform2.filter = FILTER_LINEAR_MIPMAP_ANISO; - } else if (tk.type == TK_REPEAT_DISABLE) { - uniform2.repeat = REPEAT_DISABLE; - } else if (tk.type == TK_REPEAT_ENABLE) { - uniform2.repeat = REPEAT_ENABLE; - } else { - _set_error("Expected valid type hint after ':'."); - } - if (uniform2.hint != ShaderNode::Uniform::HINT_RANGE && uniform2.hint != ShaderNode::Uniform::HINT_NONE && uniform2.hint != ShaderNode::Uniform::HINT_COLOR && type <= TYPE_MAT4) { - _set_error("This hint is only for sampler types"); - return ERR_PARSE_ERROR; - } + tk = _get_token(); - tk = _get_token(); + } while (tk.type == TK_COMMA); } if (tk.type == TK_OP_ASSIGN) { |