diff --git a/src/Raw2Gltf.cpp b/src/Raw2Gltf.cpp index 919803e..40739d4 100644 --- a/src/Raw2Gltf.cpp +++ b/src/Raw2Gltf.cpp @@ -751,7 +751,8 @@ ModelData *Raw2Gltf( std::shared_ptr mData = gltf->materials.hold( new MaterialData( - material.name, isTransparent, normalTexture, occlusionTexture, emissiveTexture, + material.name, isTransparent, material.info->shadingModel, + normalTexture, occlusionTexture, emissiveTexture, emissiveFactor * emissiveIntensity, khrCmnUnlitMat, pbrMetRough)); materialsByName[materialHash(material)] = mData; } diff --git a/src/glTF/MaterialData.cpp b/src/glTF/MaterialData.cpp index 3fbad6e..4a28d26 100644 --- a/src/glTF/MaterialData.cpp +++ b/src/glTF/MaterialData.cpp @@ -79,13 +79,14 @@ void to_json(json &j, const PBRMetallicRoughness &d) } MaterialData::MaterialData( - std::string name, bool isTransparent, const TextureData *normalTexture, - const TextureData *occlusionTexture, + std::string name, bool isTransparent, const RawShadingModel shadingModel, + const TextureData *normalTexture, const TextureData *occlusionTexture, const TextureData *emissiveTexture, const Vec3f & emissiveFactor, std::shared_ptr const khrCmnConstantMaterial, std::shared_ptr const pbrMetallicRoughness) : Holdable(), name(std::move(name)), + shadingModel(shadingModel), isTransparent(isTransparent), normalTexture(Tex::ref(normalTexture)), occlusionTexture(Tex::ref(occlusionTexture)), @@ -98,7 +99,13 @@ json MaterialData::serialize() const { json result = { { "name", name }, - { "alphaMode", isTransparent ? "BLEND" : "OPAQUE" } + { "alphaMode", isTransparent ? "BLEND" : "OPAQUE" }, + { "extras", { + { "fromFBX", { + { "shadingModel", Describe(shadingModel) }, + { "isTruePBR", shadingModel == RAW_SHADING_MODEL_PBR_MET_ROUGH } + }} + }} }; if (normalTexture != nullptr) { diff --git a/src/glTF/MaterialData.h b/src/glTF/MaterialData.h index 4ff4f1a..170c093 100644 --- a/src/glTF/MaterialData.h +++ b/src/glTF/MaterialData.h @@ -44,8 +44,8 @@ struct PBRMetallicRoughness struct MaterialData : Holdable { MaterialData( - std::string name, bool isTransparent, const TextureData *normalTexture, - const TextureData *occlusionTexture, + std::string name, bool isTransparent, RawShadingModel shadingModel, + const TextureData *normalTexture, const TextureData *occlusionTexture, const TextureData *emissiveTexture, const Vec3f &emissiveFactor, std::shared_ptr const khrCmnConstantMaterial, std::shared_ptr const pbrMetallicRoughness); @@ -53,6 +53,7 @@ struct MaterialData : Holdable json serialize() const override; const std::string name; + const RawShadingModel shadingModel; const bool isTransparent; const std::unique_ptr normalTexture; const std::unique_ptr occlusionTexture;