summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/editor_import_collada.cpp42
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp36
-rw-r--r--editor/import/resource_importer_layered_texture.cpp22
-rw-r--r--editor/import/resource_importer_obj.cpp10
-rw-r--r--editor/import/resource_importer_scene.cpp15
-rw-r--r--editor/import/resource_importer_texture.cpp61
-rw-r--r--editor/import/resource_importer_wav.cpp35
7 files changed, 131 insertions, 90 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 22ea5883e8..d4bd4f85e6 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -119,7 +119,6 @@ Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_n
Collada::NodeJoint *joint = static_cast<Collada::NodeJoint *>(p_node);
- print_line("populating joint " + joint->name);
p_skeleton->add_bone(p_node->name);
if (p_parent >= 0)
p_skeleton->set_bone_parent(r_bone, p_parent);
@@ -137,8 +136,7 @@ Error ColladaImport::_populate_skeleton(Skeleton *p_skeleton, Collada::Node *p_n
p_skeleton->set_bone_rest(r_bone, collada.fix_transform(collada.state.bone_rest_map[joint->sid]));
//should map this bone to something for animation?
} else {
- print_line("no rest: " + joint->sid);
- WARN_PRINT("Joint has no rest...");
+ WARN_PRINT("Collada: Joint has no rest.");
}
int id = r_bone++;
@@ -585,9 +583,6 @@ static void _generate_tangents_and_binormals(const PoolVector<int> &p_indices, c
binormals.write[index_arrayr[idx * 3 + 1]] += binormal;
tangents.write[index_arrayr[idx * 3 + 2]] += tangent;
binormals.write[index_arrayr[idx * 3 + 2]] += binormal;
-
- //print_line(itos(idx)+" tangent: "+tangent);
- //print_line(itos(idx)+" binormal: "+binormal);
}
r_tangents.resize(vlen * 4);
@@ -1028,7 +1023,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
material = material_cache[target];
} else if (p.material != "") {
- print_line("Warning, unreferenced material in geometry instance: " + p.material);
+ WARN_PRINTS("Collada: Unreferenced material in geometry instance: " + p.material);
}
}
@@ -1352,7 +1347,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
mesh_cache[meshid] = mesh;
} else {
- print_line("Warning, will not import geometry: " + meshid);
+ WARN_PRINTS("Collada: Will not import geometry: " + meshid);
}
}
@@ -1379,7 +1374,7 @@ Error ColladaImport::_create_resources(Collada::Node *p_node, bool p_use_compres
mi->set_surface_material(i, material);
} else if (matname != "") {
- print_line("Warning, unreferenced material in geometry instance: " + matname);
+ WARN_PRINTS("Collada: Unreferenced material in geometry instance: " + matname);
}
}
}
@@ -1541,7 +1536,6 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im
for (int i = 0; i < collada.state.animation_tracks.size(); i++) {
const Collada::AnimationTrack &at = collada.state.animation_tracks[i];
- //print_line("CHANNEL: "+at.target+" PARAM: "+at.param);
String node;
@@ -1551,7 +1545,7 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im
node = node_name_map[at.target];
} else {
- print_line("Couldn't find node: " + at.target);
+ WARN_PRINTS("Collada: Couldn't find node: " + at.target);
continue;
}
} else {
@@ -1570,7 +1564,6 @@ void ColladaImport::create_animations(bool p_make_tracks_in_all_bones, bool p_im
}
create_animation(-1, p_make_tracks_in_all_bones, p_import_value_tracks);
- //print_line("clipcount: "+itos(collada.state.animation_clips.size()));
for (int i = 0; i < collada.state.animation_clips.size(); i++)
create_animation(i, p_make_tracks_in_all_bones, p_import_value_tracks);
}
@@ -1580,11 +1573,8 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Ref<Animation> animation = Ref<Animation>(memnew(Animation));
if (p_clip == -1) {
-
- //print_line("default");
animation->set_name("default");
} else {
- //print_line("clip name: "+collada.state.animation_clips[p_clip].name);
animation->set_name(collada.state.animation_clips[p_clip].name);
}
@@ -1658,7 +1648,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
}
- //print_line("anim len: "+rtos(anim_length));
animation->set_length(anim_length);
bool tracks_found = false;
@@ -1736,7 +1725,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
if (xform_idx == -1) {
- print_line("couldn't find matching node " + at.target + " xform for track " + at.param);
+ WARN_PRINTS("Collada: Couldn't find matching node " + at.target + " xform for track " + at.param);
continue;
}
@@ -1758,14 +1747,9 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
ERR_CONTINUE(data.size() > 1);
xf.data.write[cn] = data[0];
} else if (data.size() == xf.data.size()) {
-
xf.data = data;
} else {
-
- if (data.size() != xf.data.size()) {
- print_line("component " + at.component + " datasize " + itos(data.size()) + " xfdatasize " + itos(xf.data.size()));
- }
-
+ ERR_EXPLAIN("Component " + at.component + " has datasize " + itos(data.size()) + ", xfdatasize " + itos(xf.data.size()));
ERR_CONTINUE(data.size() != xf.data.size());
}
}
@@ -1781,7 +1765,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;
} else {
- ERR_PRINT("INVALID SKELETON!!!!");
+ ERR_PRINT("Collada: Invalid skeleton");
}
}
@@ -1812,8 +1796,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
if (E->get())
continue;
- //print_line("BONE LACKS ANIM: "+E->key());
-
NodeMap &nm = node_map[E->key()];
String path = scene->get_path_to(nm.node);
ERR_CONTINUE(nm.bone < 0);
@@ -1823,7 +1805,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
Collada::Node *cn = collada.state.scene_map[E->key()];
if (cn->ignore_anim) {
- print_line("warning, ignoring animation on node: " + path);
+ WARN_PRINTS("Collada: Ignoring animation on node: " + path);
continue;
}
@@ -1889,10 +1871,9 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
} else if (data.size() == 16) {
//matrix
- print_line("value keys for matrices not supported");
+ WARN_PRINT("Collada: Value keys for matrices not supported.");
} else {
-
- print_line("don't know what to do with this amount of value keys: " + itos(data.size()));
+ WARN_PRINTS("Collada: Unexpected amount of value keys: " + itos(data.size()));
}
animation->track_insert_key(track, time, value);
@@ -1994,7 +1975,6 @@ Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path
if (state.animations.size() == 0)
return Ref<Animation>();
Ref<Animation> anim = state.animations[0];
- print_line("Anim Load OK");
String base = p_path.get_basename().to_lower();
if (p_flags & IMPORT_ANIMATION_DETECT_LOOP) {
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 906d902b4a..4d5c292847 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -323,7 +323,7 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_
}
}
- print_line("total buffers: " + itos(state.buffers.size()));
+ print_verbose("glTF: Total buffers: " + itos(state.buffers.size()));
return OK;
}
@@ -359,7 +359,7 @@ Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) {
state.buffer_views.push_back(buffer_view);
}
- print_line("total buffer views: " + itos(state.buffer_views.size()));
+ print_verbose("glTF: Total buffer views: " + itos(state.buffer_views.size()));
return OK;
}
@@ -451,7 +451,7 @@ Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) {
state.accessors.push_back(accessor);
}
- print_line("total accessors: " + itos(state.accessors.size()));
+ print_verbose("glTF: Total accessors: " + itos(state.accessors.size()));
return OK;
}
@@ -501,8 +501,8 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe
const uint8_t *bufptr = buffer.ptr();
//use to debug
- //print_line("type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count));
- print_line("accessor offset" + itos(byte_offset) + " view offset: " + itos(bv.byte_offset) + " total buffer len: " + itos(buffer.size()) + " view len " + itos(bv.byte_length));
+ print_verbose("glTF: type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count));
+ print_verbose("glTF: accessor offset" + itos(byte_offset) + " view offset: " + itos(bv.byte_offset) + " total buffer len: " + itos(buffer.size()) + " view len " + itos(bv.byte_length));
int buffer_end = (stride * (count - 1)) + element_size;
ERR_FAIL_COND_V(buffer_end > bv.byte_length, ERR_PARSE_ERROR);
@@ -853,7 +853,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
Array meshes = state.json["meshes"];
for (int i = 0; i < meshes.size(); i++) {
- print_line("on mesh: " + itos(i));
+ print_verbose("glTF: Parsing mesh: " + itos(i));
Dictionary d = meshes[i];
GLTFMesh mesh;
@@ -935,7 +935,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
w[j + 3] /= total;
}
- //print_line(itos(j / 4) + ": " + itos(r[j + 0]) + ":" + rtos(w[j + 0]) + ", " + itos(r[j + 1]) + ":" + rtos(w[j + 1]) + ", " + itos(r[j + 2]) + ":" + rtos(w[j + 2]) + ", " + itos(r[j + 3]) + ":" + rtos(w[j + 3]));
+ //print_verbose(itos(j / 4) + ": " + itos(r[j + 0]) + ":" + rtos(w[j + 0]) + ", " + itos(r[j + 1]) + ":" + rtos(w[j + 1]) + ", " + itos(r[j + 2]) + ":" + rtos(w[j + 2]) + ", " + itos(r[j + 3]) + ":" + rtos(w[j + 3]));
}
}
array[Mesh::ARRAY_WEIGHTS] = weights;
@@ -996,7 +996,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
Array morphs;
//blend shapes
if (p.has("targets")) {
- print_line("has targets!");
+ print_verbose("glTF: Mesh has targets");
Array targets = p["targets"];
if (j == 0) {
@@ -1091,7 +1091,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
state.meshes.push_back(mesh);
}
- print_line("total meshes: " + itos(state.meshes.size()));
+ print_verbose("glTF: Total meshes: " + itos(state.meshes.size()));
return OK;
}
@@ -1183,7 +1183,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b
ERR_FAIL_V(ERR_FILE_CORRUPT);
}
- print_line("total images: " + itos(state.images.size()));
+ print_verbose("Total images: " + itos(state.images.size()));
return OK;
}
@@ -1338,7 +1338,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) {
state.materials.push_back(material);
}
- print_line("total materials: " + itos(state.materials.size()));
+ print_verbose("Total materials: " + itos(state.materials.size()));
return OK;
}
@@ -1381,12 +1381,11 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
skin.bones.push_back(bone);
}
- print_line("skin has skeleton? " + itos(d.has("skeleton")));
+ print_verbose("glTF: Skin has skeleton? " + itos(d.has("skeleton")));
if (d.has("skeleton")) {
int skeleton = d["skeleton"];
ERR_FAIL_INDEX_V(skeleton, state.nodes.size(), ERR_PARSE_ERROR);
- //state.nodes[skeleton]->skeleton_skin = state.skins.size();
- print_line("setting skeleton skin to" + itos(skeleton));
+ print_verbose("glTF: Setting skeleton skin to" + itos(skeleton));
skin.skeleton = skeleton;
if (!state.skeleton_nodes.has(skeleton)) {
state.skeleton_nodes[skeleton] = Vector<int>();
@@ -1443,7 +1442,7 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) {
*/
state.skins.push_back(skin);
}
- print_line("total skins: " + itos(state.skins.size()));
+ print_verbose("glTF: Total skins: " + itos(state.skins.size()));
//now
@@ -1496,7 +1495,7 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) {
state.cameras.push_back(camera);
}
- print_line("total cameras: " + itos(state.cameras.size()));
+ print_verbose("glTF: Total cameras: " + itos(state.cameras.size()));
return OK;
}
@@ -1574,7 +1573,6 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
}
}
- print_line("path: " + path);
PoolVector<float> times = _decode_accessor_as_floats(state, input, false);
if (path == "translation") {
PoolVector<Vector3> translations = _decode_accessor_as_vec3(state, output, false);
@@ -1624,7 +1622,7 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) {
state.animations.push_back(animation);
}
- print_line("total animations: " + itos(state.animations.size()));
+ print_verbose("glTF: Total animations: " + itos(state.animations.size()));
return OK;
}
@@ -1656,7 +1654,7 @@ void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node
if (n->mesh >= 0) {
ERR_FAIL_INDEX(n->mesh, state.meshes.size());
MeshInstance *mi = memnew(MeshInstance);
- print_line("**creating mesh for: " + n->name);
+ print_verbose("glTF: Creating mesh for: " + n->name);
GLTFMesh &mesh = state.meshes.write[n->mesh];
mi->set_mesh(mesh.mesh);
if (mesh.mesh->get_name() == "") {
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index 2f958a6fdd..db16f20ade 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -52,6 +52,7 @@ String ResourceImporterLayeredTexture::get_preset_name(int p_idx) const {
void ResourceImporterLayeredTexture::get_import_options(List<ImportOption> *r_options, int p_preset) const {
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 1 : 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), true));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/mipmaps"), p_preset == PRESET_COLOR_CORRECT ? 0 : 1));
@@ -163,6 +164,7 @@ void ResourceImporterLayeredTexture::_save_tex(const Vector<Ref<Image> > &p_imag
Error ResourceImporterLayeredTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
int compress_mode = p_options["compress/mode"];
+ int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"];
int repeat = p_options["flags/repeat"];
bool filter = p_options["flags/filter"];
bool mipmaps = p_options["flags/mipmaps"];
@@ -226,6 +228,26 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
//Android, GLES 2.x
bool ok_on_pc = false;
+ bool encode_bptc = false;
+
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) {
+
+ encode_bptc = true;
+
+ if (no_bptc_if_rgb) {
+ Image::DetectChannels channels = image->get_detected_channels();
+ if (channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) {
+ encode_bptc = false;
+ }
+ }
+ }
+
+ if (encode_bptc) {
+
+ _save_tex(slices, p_save_path + ".bptc." + extension, compress_mode, Image::COMPRESS_BPTC, mipmaps, tex_flags);
+ r_platform_variants->push_back("bptc");
+ ok_on_pc = true;
+ }
if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 5babf6419c..3f101cd04d 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -63,7 +63,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
material_map[current_name] = current;
} else if (l.begins_with("Ka ")) {
//uv
- print_line("Warning: Ambient light for material '" + current_name + "' is ignored in PBR");
+ WARN_PRINTS("OBJ: Ambient light for material '" + current_name + "' is ignored in PBR");
} else if (l.begins_with("Kd ")) {
//normal
@@ -119,7 +119,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Spati
} else if (l.begins_with("map_Ka ")) {
//uv
- print_line("Warning: Ambient light texture for material '" + current_name + "' is ignored in PBR");
+ WARN_PRINTS("OBJ: Ambient light texture for material '" + current_name + "' is ignored in PBR");
} else if (l.begins_with("map_Kd ")) {
//normal
@@ -335,8 +335,8 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
surf_tool->index();
- print_line("current material library " + current_material_library + " has " + itos(material_map.has(current_material_library)));
- print_line("current material " + current_material + " has " + itos(material_map.has(current_material_library) && material_map[current_material_library].has(current_material)));
+ print_verbose("OBJ: Current material library " + current_material_library + " has " + itos(material_map.has(current_material_library)));
+ print_verbose("OBJ: Current material " + current_material + " has " + itos(material_map.has(current_material_library) && material_map[current_material_library].has(current_material)));
if (material_map.has(current_material_library) && material_map[current_material_library].has(current_material)) {
surf_tool->set_material(material_map[current_material_library][current_material]);
@@ -350,7 +350,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh> > &r_meshes, bool p
mesh->surface_set_name(mesh->get_surface_count() - 1, current_group);
}
- print_line("Added surface :" + mesh->surface_get_name(mesh->get_surface_count() - 1));
+ print_verbose("OBJ: Added surface :" + mesh->surface_get_name(mesh->get_surface_count() - 1));
surf_tool->clear();
surf_tool->begin(Mesh::PRIMITIVE_TRIANGLES);
}
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index b5e3466b12..f544811eb0 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -281,12 +281,11 @@ static String _fixstr(const String &p_what, const String &p_str) {
Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode) {
- // children first..
+ // children first
for (int i = 0; i < p_node->get_child_count(); i++) {
Node *r = _fix_node(p_node->get_child(i), p_root, collision_map, p_light_bake_mode);
if (!r) {
- print_line("was erased...");
i--; //was erased
}
}
@@ -391,7 +390,6 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array
colshape->set_owner(p_node->get_owner());
} else if (p_node->has_meta("empty_draw_type")) {
String empty_draw_type = String(p_node->get_meta("empty_draw_type"));
- print_line(empty_draw_type);
StaticBody *sb = memnew(StaticBody);
sb->set_name(_fixstr(name, "colonly"));
Object::cast_to<Spatial>(sb)->set_transform(Object::cast_to<Spatial>(p_node)->get_transform());
@@ -723,15 +721,11 @@ void ResourceImporterScene::_filter_anim_tracks(Ref<Animation> anim, Set<String>
Ref<Animation> a = anim;
ERR_FAIL_COND(!a.is_valid());
- print_line("From Anim " + anim->get_name() + ":");
-
for (int j = 0; j < a->get_track_count(); j++) {
String path = a->track_get_path(j);
if (!keep.has(path)) {
-
- print_line("Remove: " + path);
a->remove_track(j);
j--;
}
@@ -899,8 +893,6 @@ void ResourceImporterScene::_find_meshes(Node *p_node, Map<Ref<ArrayMesh>, Trans
}
meshes[mesh] = transform;
-
- print_line("mesh transform: " + meshes[mesh]);
}
}
for (int i = 0; i < p_node->get_child_count(); i++) {
@@ -913,8 +905,6 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String
List<PropertyInfo> pi;
- print_line("node: " + String(p_node->get_name()));
-
if (p_make_animations) {
if (Object::cast_to<AnimationPlayer>(p_node)) {
AnimationPlayer *ap = Object::cast_to<AnimationPlayer>(p_node);
@@ -1316,7 +1306,6 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
if (bool(p_options["external_files/store_in_subdir"])) {
String subdir_name = p_source_file.get_file().get_basename();
DirAccess *da = DirAccess::open(base_path);
- print_line("at path " + da->get_current_dir() + " making " + subdir_name);
Error err = da->make_dir(subdir_name);
memdelete(da);
ERR_FAIL_COND_V(err != OK && err != ERR_ALREADY_EXISTS, err);
@@ -1421,7 +1410,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
Ref<PackedScene> packer = memnew(PackedScene);
packer->pack(scene);
- print_line("SAVING TO: " + p_save_path + ".scn");
+ print_verbose("Saving scene to: " + p_save_path + ".scn");
err = ResourceSaver::save(p_save_path + ".scn", packer); //do not take over, let the changed files reload themselves
ERR_FAIL_COND_V(err != OK, err);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 17a9394b51..d03395c070 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -164,6 +164,11 @@ bool ResourceImporterTexture::get_option_visibility(const String &p_option, cons
if (compress_mode != COMPRESS_LOSSY && compress_mode != COMPRESS_VIDEO_RAM) {
return false;
}
+ } else if (p_option == "compress/no_bptc_if_rgb" || p_option == "compress/hdr_mode") {
+ int compress_mode = int(p_options["compress/mode"]);
+ if (compress_mode != COMPRESS_VIDEO_RAM) {
+ return false;
+ }
}
return true;
@@ -188,7 +193,8 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/mode", PROPERTY_HINT_ENUM, "Lossless,Lossy,Video RAM,Uncompressed", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), p_preset == PRESET_3D ? 2 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "compress/lossy_quality", PROPERTY_HINT_RANGE, "0,1,0.01"), 0.7));
- r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "Compress,Force RGBE"), 0));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress/no_bptc_if_rgb"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/hdr_mode", PROPERTY_HINT_ENUM, "LDR Fallback,Force RGBE,RGBE Fallback"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "compress/normal_map", PROPERTY_HINT_ENUM, "Detect,Enable,Disabled"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "flags/repeat", PROPERTY_HINT_ENUM, "Disabled,Enabled,Mirrored"), p_preset == PRESET_3D ? 1 : 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "flags/filter"), p_preset == PRESET_2D_PIXEL ? false : true));
@@ -198,6 +204,7 @@ void ResourceImporterTexture::get_import_options(List<ImportOption> *r_options,
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/fix_alpha_border"), p_preset != PRESET_3D ? true : false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/premult_alpha"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/HDR_as_SRGB"), false));
+ r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "process/invert_color"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "stream"), false));
r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "size_limit", PROPERTY_HINT_RANGE, "0,4096,1"), 0));
r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "detect_3d"), p_preset == PRESET_DETECT));
@@ -346,6 +353,7 @@ void ResourceImporterTexture::_save_stex(const Ref<Image> &p_image, const String
Error ResourceImporterTexture::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) {
int compress_mode = p_options["compress/mode"];
+ int no_bptc_if_rgb = p_options["compress/no_bptc_if_rgb"];
float lossy = p_options["compress/lossy_quality"];
int repeat = p_options["flags/repeat"];
bool filter = p_options["flags/filter"];
@@ -354,9 +362,11 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
int srgb = p_options["flags/srgb"];
bool fix_alpha_border = p_options["process/fix_alpha_border"];
bool premult_alpha = p_options["process/premult_alpha"];
+ bool invert_color = p_options["process/invert_color"];
bool stream = p_options["stream"];
int size_limit = p_options["size_limit"];
bool force_rgbe = int(p_options["compress/hdr_mode"]) == 1;
+ bool rgbe_fallback = int(p_options["compress/hdr_mode"]) == 2;
bool hdr_as_srgb = p_options["process/HDR_as_SRGB"];
int normal = p_options["compress/normal_map"];
float scale = p_options["svg/scale"];
@@ -409,6 +419,19 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
image->premultiply_alpha();
}
+ if (invert_color) {
+ int height = image->get_height();
+ int width = image->get_width();
+
+ image->lock();
+ for (int i = 0; i < height; i++) {
+ for (int j = 0; j < width; j++) {
+ image->set_pixel(i, j, image->get_pixel(i, j).inverted());
+ }
+ }
+ image->unlock();
+ }
+
bool detect_3d = p_options["detect_3d"];
bool detect_srgb = srgb == 2;
bool detect_normal = normal == 0;
@@ -419,31 +442,59 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
//Android, GLES 2.x
bool ok_on_pc = false;
+ bool encode_bptc = false;
+ bool is_hdr = (image->get_format() >= Image::FORMAT_RF && image->get_format() <= Image::FORMAT_RGBE9995);
+ bool no_ldr_compression = (is_hdr && rgbe_fallback);
+
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_bptc")) {
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) {
+ encode_bptc = true;
+
+ if (no_bptc_if_rgb && !is_hdr) {
+ Image::DetectChannels channels = image->get_detected_channels();
+ if (channels != Image::DETECTED_LA && channels != Image::DETECTED_RGBA) {
+ encode_bptc = false;
+ }
+ }
+ }
+
+ if (encode_bptc) {
+
+ _save_stex(image, p_save_path + ".bptc.stex", compress_mode, lossy, Image::COMPRESS_BPTC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
+ r_platform_variants->push_back("bptc");
+ ok_on_pc = true;
+ }
+
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("s3tc");
ok_on_pc = true;
}
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".etc2.stex", compress_mode, lossy, Image::COMPRESS_ETC2, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("etc2");
}
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".etc.stex", compress_mode, lossy, Image::COMPRESS_ETC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("etc");
}
- if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc")) {
+ if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_pvrtc") && !no_ldr_compression) {
_save_stex(image, p_save_path + ".pvrtc.stex", compress_mode, lossy, Image::COMPRESS_PVRTC4, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal);
r_platform_variants->push_back("pvrtc");
}
+ if (is_hdr && rgbe_fallback) {
+ _save_stex(image, p_save_path + ".fallback.stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, true, detect_normal, force_normal);
+ r_platform_variants->push_back("fallback");
+ ok_on_pc = true;
+ }
+
if (!ok_on_pc) {
EditorNode::add_io_error("Warning, no suitable PC VRAM compression enabled in Project Settings. This texture will not display correcly on PC.");
}
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index 41f5a892eb..d04f29ea5e 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -157,15 +157,18 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
//Consider revision for engine version 3.0
compression_code = file->get_16();
if (compression_code != 1 && compression_code != 3) {
- ERR_PRINT("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
- break;
+ file->close();
+ memdelete(file);
+ ERR_EXPLAIN("Format not supported for WAVE file (not PCM). Save WAVE files as uncompressed PCM instead.");
+ ERR_FAIL_V(ERR_INVALID_DATA);
}
format_channels = file->get_16();
if (format_channels != 1 && format_channels != 2) {
-
- ERR_PRINT("Format not supported for WAVE file (not stereo or mono)");
- break;
+ file->close();
+ memdelete(file);
+ ERR_EXPLAIN("Format not supported for WAVE file (not stereo or mono).");
+ ERR_FAIL_V(ERR_INVALID_DATA);
}
format_freq = file->get_32(); //sampling rate
@@ -174,10 +177,11 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
file->get_16(); // block align (unused)
format_bits = file->get_16(); // bits per sample
- if (format_bits % 8) {
-
- ERR_PRINT("Strange number of bits in sample (not 8,16,24,32)");
- break;
+ if (format_bits % 8 || format_bits == 0) {
+ file->close();
+ memdelete(file);
+ ERR_EXPLAIN("Invalid amount of bits in the sample (should be one of 8, 16, 24 or 32).");
+ ERR_FAIL_V(ERR_INVALID_DATA);
}
/* Don't need anything else, continue */
@@ -185,7 +189,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
if (chunkID[0] == 'd' && chunkID[1] == 'a' && chunkID[2] == 't' && chunkID[3] == 'a' && !data_found) {
- /* IS FORMAT CHUNK */
+ /* IS DATA CHUNK */
data_found = true;
if (!format_found) {
@@ -201,7 +205,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
/*print_line("chunksize: "+itos(chunksize));
print_line("channels: "+itos(format_channels));
print_line("bits: "+itos(format_bits));
-*/
+ */
int len = frames;
if (format_channels == 2)
@@ -289,6 +293,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
bool is16 = format_bits != 8;
int rate = format_freq;
+ /*
print_line("Input Sample: ");
print_line("\tframes: " + itos(frames));
print_line("\tformat_channels: " + itos(format_channels));
@@ -297,18 +302,16 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
print_line("\tloop: " + itos(loop));
print_line("\tloop begin: " + itos(loop_begin));
print_line("\tloop end: " + itos(loop_end));
+ */
//apply frequency limit
bool limit_rate = p_options["force/max_rate"];
int limit_rate_hz = p_options["force/max_rate_hz"];
if (limit_rate && rate > limit_rate_hz && rate > 0 && frames > 0) {
- //resampleeee!!!
+ // resample!
int new_data_frames = (int)(frames * (float)limit_rate_hz / (float)rate);
- print_line("\tresampling ratio: " + rtos((float)limit_rate_hz / (float)rate));
- print_line("\tnew frames: " + itos(new_data_frames));
-
Vector<float> new_data;
new_data.resize(new_data_frames * format_channels);
for (int c = 0; c < format_channels; c++) {
@@ -488,8 +491,6 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
}
- //print_line("compressing ima-adpcm, resulting buffersize is "+itos(dst_data.size())+" from "+itos(data.size()));
-
} else {
dst_format = is16 ? AudioStreamSample::FORMAT_16_BITS : AudioStreamSample::FORMAT_8_BITS;