diff --git a/src/fbx/Fbx2Raw.cpp b/src/fbx/Fbx2Raw.cpp index 351bd85..6a7217f 100644 --- a/src/fbx/Fbx2Raw.cpp +++ b/src/fbx/Fbx2Raw.cpp @@ -459,7 +459,7 @@ static void ReadMesh( const RawMaterialType materialType = GetMaterialType(raw, textures, vertexTransparency, skinning.IsSkinned()); const int rawMaterialIndex = raw.AddMaterial( - materialId, materialName, materialType, textures, rawMatProps, userProperties); + materialId, materialName, materialType, textures, rawMatProps, userProperties, false ); raw.AddTriangle( rawVertexIndices[0], diff --git a/src/gltf/Raw2Gltf.cpp b/src/gltf/Raw2Gltf.cpp index 0e2c592..8ac6a1d 100644 --- a/src/gltf/Raw2Gltf.cpp +++ b/src/gltf/Raw2Gltf.cpp @@ -341,12 +341,12 @@ ModelData* Raw2Gltf( }, false); - if (aoMetRoughTex != nullptr) { - // if we successfully built a texture, factors are just multiplicative identity - metallic = roughness = 1.0f; - } else { - // no shininess texture, - roughness = getRoughness(props->shininess); + if (aoMetRoughTex != nullptr) { + // if we successfully built a texture, factors are just multiplicative identity + metallic = roughness = 1.0f; + } else { + // no shininess texture, + roughness = getRoughness(props->shininess); } } else { @@ -392,9 +392,12 @@ ModelData* Raw2Gltf( occlusionTexture = simpleTex(RAW_TEXTURE_USAGE_OCCLUSION).get(); } + // Setting DoubleSided + const bool isDoubleSided = material.isDoubleSided; std::shared_ptr mData = gltf->materials.hold(new MaterialData( material.name, isTransparent, + isDoubleSided, material.info->shadingModel, normalTexture, occlusionTexture, diff --git a/src/gltf/properties/MaterialData.cpp b/src/gltf/properties/MaterialData.cpp index dd5621e..e67c215 100644 --- a/src/gltf/properties/MaterialData.cpp +++ b/src/gltf/properties/MaterialData.cpp @@ -73,6 +73,7 @@ void to_json(json& j, const PBRMetallicRoughness& d) { MaterialData::MaterialData( std::string name, bool isTransparent, + bool isDoubleSided, const RawShadingModel shadingModel, const TextureData* normalTexture, const TextureData* occlusionTexture, @@ -84,6 +85,7 @@ MaterialData::MaterialData( name(std::move(name)), shadingModel(shadingModel), isTransparent(isTransparent), + isDoubleSided(isDoubleSided), normalTexture(Tex::ref(normalTexture)), occlusionTexture(Tex::ref(occlusionTexture)), emissiveTexture(Tex::ref(emissiveTexture)), @@ -94,6 +96,7 @@ MaterialData::MaterialData( json MaterialData::serialize() const { json result = {{"name", name}, {"alphaMode", isTransparent ? "BLEND" : "OPAQUE"}, + {"doubleSided", isDoubleSided}, {"extras", {{"fromFBX", {{"shadingModel", Describe(shadingModel)}, diff --git a/src/gltf/properties/MaterialData.hpp b/src/gltf/properties/MaterialData.hpp index d7a2ae5..0b226c9 100644 --- a/src/gltf/properties/MaterialData.hpp +++ b/src/gltf/properties/MaterialData.hpp @@ -43,6 +43,7 @@ struct MaterialData : Holdable { MaterialData( std::string name, bool isTransparent, + bool isDoubleSided, RawShadingModel shadingModel, const TextureData* normalTexture, const TextureData* occlusionTexture, @@ -56,6 +57,7 @@ struct MaterialData : Holdable { const std::string name; const RawShadingModel shadingModel; const bool isTransparent; + const bool isDoubleSided; const std::unique_ptr normalTexture; const std::unique_ptr occlusionTexture; const std::unique_ptr emissiveTexture; diff --git a/src/raw/RawModel.cpp b/src/raw/RawModel.cpp index 84b8ae9..2b2675d 100644 --- a/src/raw/RawModel.cpp +++ b/src/raw/RawModel.cpp @@ -142,7 +142,8 @@ int RawModel::AddMaterial(const RawMaterial& material) { material.type, material.textures, material.info, - material.userProperties); + material.userProperties, + material.isDoubleSided); } int RawModel::AddMaterial( @@ -151,7 +152,8 @@ int RawModel::AddMaterial( const RawMaterialType materialType, const int textures[RAW_TEXTURE_USAGE_MAX], std::shared_ptr materialInfo, - const std::vector& userProperties) { + const std::vector& userProperties, + const bool isDoubleSided ) { for (size_t i = 0; i < materials.size(); i++) { if (materials[i].name != name) { continue; @@ -184,6 +186,7 @@ int RawModel::AddMaterial( material.type = materialType; material.info = materialInfo; material.userProperties = userProperties; + material.isDoubleSided = isDoubleSided; for (int i = 0; i < RAW_TEXTURE_USAGE_MAX; i++) { material.textures[i] = textures[i]; diff --git a/src/raw/RawModel.hpp b/src/raw/RawModel.hpp index 81452d6..d5fd147 100644 --- a/src/raw/RawModel.hpp +++ b/src/raw/RawModel.hpp @@ -258,6 +258,7 @@ struct RawMaterial { std::shared_ptr info; int textures[RAW_TEXTURE_USAGE_MAX]; std::vector userProperties; + bool isDoubleSided; }; enum RawLightType { @@ -370,7 +371,8 @@ class RawModel { const RawMaterialType materialType, const int textures[RAW_TEXTURE_USAGE_MAX], std::shared_ptr materialInfo, - const std::vector& userProperties); + const std::vector& userProperties, + const bool isDoubleSided ); int AddLight( const char* name, RawLightType lightType,