From 6df800d2b656ec828950a921f8ea0c1f7685d4e4 Mon Sep 17 00:00:00 2001 From: Selmar Kok Date: Mon, 19 Aug 2019 11:05:28 +0200 Subject: [PATCH 1/2] [emissiveFactor] fix inconsistency with baseColorFactor where default values were set only for baseColorFactor and not emissiveFactor --- tiny_gltf.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 26e72b3..7622b6d 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -3743,8 +3743,22 @@ static bool ParsePbrMetallicRoughness(PbrMetallicRoughness *pbr, static bool ParseMaterial(Material *material, std::string *err, const json &o) { ParseStringProperty(&material->name, err, o, "name", /* required */ false); - ParseNumberArrayProperty(&material->emissiveFactor, err, o, "emissiveFactor", - /* required */ false); + if(ParseNumberArrayProperty(&material->emissiveFactor, err, o, "emissiveFactor", + /* required */ false)) { + if (material->emissiveFactor.size() != 3) { + if (err) { + (*err) += + "Array length of `emissiveFactor` parameter in " + "material must be 3, but got " + + std::to_string(material->emissiveFactor.size()) + "\n"; + } + return false; + } + } + else { + // fill with default values + material->emissiveFactor = {1.0, 1.0, 1.0}; + } ParseStringProperty(&material->alphaMode, err, o, "alphaMode", /* required */ false); From 6dba6c6aacc1f21529127610d255457aa23bde5d Mon Sep 17 00:00:00 2001 From: Selmar Kok Date: Mon, 19 Aug 2019 11:23:31 +0200 Subject: [PATCH 2/2] [emissiveFactor] correct default values --- tiny_gltf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tiny_gltf.h b/tiny_gltf.h index 7622b6d..a18c73c 100644 --- a/tiny_gltf.h +++ b/tiny_gltf.h @@ -3757,7 +3757,7 @@ static bool ParseMaterial(Material *material, std::string *err, const json &o) { } else { // fill with default values - material->emissiveFactor = {1.0, 1.0, 1.0}; + material->emissiveFactor = {0.0, 0.0, 0.0}; } ParseStringProperty(&material->alphaMode, err, o, "alphaMode",