Modernized default 3D material, fixes material bugs.
This commit is contained in:
parent
6deffa62fb
commit
dd3682e5fe
@ -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);
|
||||
|
||||
|
66
editor/icons/icon_o_r_m_material_3d.svg
Normal file
66
editor/icons/icon_o_r_m_material_3d.svg
Normal file
@ -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>
|
After Width: | Height: | Size: 4.1 KiB |
11
editor/icons/icon_standard_material_3d.svg
Normal file
11
editor/icons/icon_standard_material_3d.svg
Normal file
@ -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>
|
After Width: | Height: | Size: 1.4 KiB |
@ -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;
|
||||
|
||||
{
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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()) {
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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\".");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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] = {
|
||||
|
@ -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();
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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) {}
|
||||
};
|
||||
|
||||
//////////////////////
|
||||
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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");
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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()) {
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
do {
|
||||
tk = _get_token();
|
||||
if (tk.type != TK_PARENTHESIS_OPEN) {
|
||||
_set_error("Expected '(' after hint_range");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
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) {
|
||||
|
||||
tk = _get_token();
|
||||
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;
|
||||
}
|
||||
|
||||
float sign = 1.0;
|
||||
|
||||
if (tk.type == TK_OP_SUB) {
|
||||
sign = -1.0;
|
||||
tk = _get_token();
|
||||
}
|
||||
if (tk.type != TK_PARENTHESIS_OPEN) {
|
||||
_set_error("Expected '(' after hint_range");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
if (tk.type != TK_REAL_CONSTANT && tk.type != TK_INT_CONSTANT) {
|
||||
_set_error("Expected integer constant");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
uniform2.hint_range[0] = tk.constant;
|
||||
uniform2.hint_range[0] *= sign;
|
||||
|
||||
tk = _get_token();
|
||||
|
||||
if (tk.type != TK_COMMA) {
|
||||
_set_error("Expected ',' after integer constant");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
tk = _get_token();
|
||||
|
||||
sign = 1.0;
|
||||
|
||||
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;
|
||||
}
|
||||
float sign = 1.0;
|
||||
|
||||
uniform2.hint_range[1] = tk.constant;
|
||||
uniform2.hint_range[1] *= sign;
|
||||
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;
|
||||
}
|
||||
|
||||
uniform2.hint_range[0] = tk.constant;
|
||||
uniform2.hint_range[0] *= sign;
|
||||
|
||||
if (tk.type == TK_COMMA) {
|
||||
tk = _get_token();
|
||||
|
||||
if (tk.type != TK_COMMA) {
|
||||
_set_error("Expected ',' after integer constant");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
|
||||
tk = _get_token();
|
||||
|
||||
sign = 1.0;
|
||||
|
||||
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user