Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAras Pranckevicius <aras@nesnausk.org>2022-09-13 13:28:57 +0300
committerAras Pranckevicius <aras@nesnausk.org>2022-09-13 15:01:29 +0300
commita99a62231e040a15c93add9ffa582ec9e1d9c4f1 (patch)
tree4eefa8527eb047ae20336e5fdd1a8b8b48e2678c /source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
parent3839a4dd84877988bcb6023d1757d6fe36786d19 (diff)
obj: implement support for PBR .mtl extensions
Implement import & export support for "PBR extensions" in .mtl files (T101029, also fixes T86736). Newly supported parameters: - Roughness (Pr, map_Pr) - Metallic (Pm, map_Pm) - Sheen (Ps, map_Ps) - Clearcoat thickness (Pc) and roughness (Pcr) - Anisotropy (aniso) and rotation (anisor) - Transmittance (Tf / Kt) Exporter has an option to enable these additional PBR parameters export; defaults to off since not all software understands that. Exporter UI tweaked and all material-related options were put into their own separate box. Added/extended test files in Subversion repository for test coverage.
Diffstat (limited to 'source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc')
-rw-r--r--source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index cc98dbdbf92..f92f9894f75 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -617,6 +617,15 @@ static MTLTexMapType mtl_line_start_to_texture_type(const char *&p, const char *
parse_keyword(p, end, "map_bump")) {
return MTLTexMapType::Normal;
}
+ if (parse_keyword(p, end, "map_Pr")) {
+ return MTLTexMapType::Roughness;
+ }
+ if (parse_keyword(p, end, "map_Pm")) {
+ return MTLTexMapType::Metallic;
+ }
+ if (parse_keyword(p, end, "map_Ps")) {
+ return MTLTexMapType::Sheen;
+ }
return MTLTexMapType::Count;
}
@@ -806,6 +815,30 @@ void MTLParser::parse_and_store(Map<string, std::unique_ptr<MTLMaterial>> &r_mat
parse_float(p, end, 1.0f, val);
material->illum_mode = val;
}
+ else if (parse_keyword(p, end, "Pr")) {
+ parse_float(p, end, 0.5f, material->roughness);
+ }
+ else if (parse_keyword(p, end, "Pm")) {
+ parse_float(p, end, 0.0f, material->metallic);
+ }
+ else if (parse_keyword(p, end, "Ps")) {
+ parse_float(p, end, 0.0f, material->sheen);
+ }
+ else if (parse_keyword(p, end, "Pc")) {
+ parse_float(p, end, 0.0f, material->cc_thickness);
+ }
+ else if (parse_keyword(p, end, "Pcr")) {
+ parse_float(p, end, 0.0f, material->cc_roughness);
+ }
+ else if (parse_keyword(p, end, "aniso")) {
+ parse_float(p, end, 0.0f, material->aniso);
+ }
+ else if (parse_keyword(p, end, "anisor")) {
+ parse_float(p, end, 0.0f, material->aniso_rot);
+ }
+ else if (parse_keyword(p, end, "Kt") || parse_keyword(p, end, "Tf")) {
+ parse_floats(p, end, 0.0f, material->transmit_color, 3);
+ }
else {
parse_texture_map(p, end, material, mtl_dir_path_);
}