From 56de0f8d568677211914b5732fe52f374c9a7fe9 Mon Sep 17 00:00:00 2001 From: ksuprynowicz Date: Tue, 10 Jan 2023 00:08:45 +0100 Subject: [PATCH] Fix material colors for glTF MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Julian Groß --- libraries/model-serializers/src/GLTFSerializer.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/model-serializers/src/GLTFSerializer.cpp b/libraries/model-serializers/src/GLTFSerializer.cpp index 2304440a9f..0ad022d7cd 100755 --- a/libraries/model-serializers/src/GLTFSerializer.cpp +++ b/libraries/model-serializers/src/GLTFSerializer.cpp @@ -1886,7 +1886,8 @@ void GLTFSerializer::setHFMMaterial(HFMMaterial& hfmMat, const GLTFMaterial& mat } if (material.defined["emissiveFactor"] && material.emissiveFactor.size() == 3) { - glm::vec3 emissive = glm::vec3(material.emissiveFactor[0], material.emissiveFactor[1], material.emissiveFactor[2]); + glm::vec3 emissiveLinear = glm::vec3(material.emissiveFactor[0], material.emissiveFactor[1], material.emissiveFactor[2]); + glm::vec3 emissive = ColorUtils::tosRGBVec3(emissiveLinear); hfmMat._material->setEmissive(emissive); } @@ -1930,9 +1931,9 @@ void GLTFSerializer::setHFMMaterial(HFMMaterial& hfmMat, const GLTFMaterial& mat } if (material.pbrMetallicRoughness.defined["baseColorFactor"] && material.pbrMetallicRoughness.baseColorFactor.size() == 4) { - glm::vec3 dcolor = - glm::vec3(material.pbrMetallicRoughness.baseColorFactor[0], material.pbrMetallicRoughness.baseColorFactor[1], - material.pbrMetallicRoughness.baseColorFactor[2]); + glm::vec3 lcolor = glm::vec3(material.pbrMetallicRoughness.baseColorFactor[0], material.pbrMetallicRoughness.baseColorFactor[1], + material.pbrMetallicRoughness.baseColorFactor[2]); + glm::vec3 dcolor = ColorUtils::tosRGBVec3(lcolor); hfmMat.diffuseColor = dcolor; hfmMat._material->setAlbedo(dcolor); hfmMat._material->setOpacity(material.pbrMetallicRoughness.baseColorFactor[3]);