From 9d957a9dd72366743c6fb17a62914874143c36ea Mon Sep 17 00:00:00 2001 From: Mikulas Florek Date: Sun, 15 Dec 2024 00:19:31 +0100 Subject: [PATCH] model importer - fix color import --- src/renderer/editor/fbx_importer.cpp | 3 ++- src/renderer/editor/model_importer.cpp | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/renderer/editor/fbx_importer.cpp b/src/renderer/editor/fbx_importer.cpp index c7f60373e5..235e0ceb43 100644 --- a/src/renderer/editor/fbx_importer.cpp +++ b/src/renderer/editor/fbx_importer.cpp @@ -1143,7 +1143,7 @@ struct FBXImporter : ModelImporter { mat_idx = materials.size(); ImportMaterial& mat = m_materials.emplace(m_allocator); const ofbx::Color diffuse_color = fbx_mat->getDiffuseColor(); - mat.diffuse_color = { diffuse_color.r, diffuse_color.g, diffuse_color.b }; + mat.diffuse_color = { powf(diffuse_color.r, 2.2f), powf(diffuse_color.g, 2.2f), powf(diffuse_color.b, 2.2f) }; materials.push(fbx_mat); } @@ -1235,6 +1235,7 @@ struct FBXImporter : ModelImporter { mat.name = name; } + // TODO move this to modelimporter? // gather textures // we don't support dds, but try it as last option, so user can get error message with filepath const char* exts[] = { "png", "jpg", "jpeg", "tga", "bmp", "dds" }; diff --git a/src/renderer/editor/model_importer.cpp b/src/renderer/editor/model_importer.cpp index 5a2fa40b96..0f8eed269b 100644 --- a/src/renderer/editor/model_importer.cpp +++ b/src/renderer/editor/model_importer.cpp @@ -628,9 +628,9 @@ bool ModelImporter::writeMaterials(const Path& src, const ModelMeta& meta, bool if (!material.textures[0].import && !meta.ignore_material_colors) { const Vec3 color = material.diffuse_color; - blob << "uniform \"Material color\", {" << powf(color.x, 2.2f) - << "," << powf(color.x, 2.2f) - << "," << powf(color.z, 2.2f) + blob << "uniform \"Material color\", {" << color.x + << "," << color.y + << "," << color.z << ",1}\n"; }