Add KHR_materials_transmission during import
parent
197bf1e617
commit
2b097c1e73
|
@ -48,6 +48,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* KHR_lights_punctual full
|
* KHR_lights_punctual full
|
||||||
* KHR_materials_sheen full
|
* KHR_materials_sheen full
|
||||||
* KHR_materials_clearcoat full
|
* KHR_materials_clearcoat full
|
||||||
|
* KHR_materials_transmission full
|
||||||
*/
|
*/
|
||||||
#ifndef GLTF2ASSET_H_INC
|
#ifndef GLTF2ASSET_H_INC
|
||||||
#define GLTF2ASSET_H_INC
|
#define GLTF2ASSET_H_INC
|
||||||
|
@ -739,6 +740,11 @@ struct MaterialClearcoat {
|
||||||
NormalTextureInfo clearcoatNormalTexture;
|
NormalTextureInfo clearcoatNormalTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct MaterialTransmission {
|
||||||
|
TextureInfo transmissionTexture;
|
||||||
|
float transmissionFactor = 0.f;
|
||||||
|
};
|
||||||
|
|
||||||
//! The material appearance of a primitive.
|
//! The material appearance of a primitive.
|
||||||
struct Material : public Object {
|
struct Material : public Object {
|
||||||
//PBR metallic roughness properties
|
//PBR metallic roughness properties
|
||||||
|
@ -762,6 +768,9 @@ struct Material : public Object {
|
||||||
//extension: KHR_materials_clearcoat
|
//extension: KHR_materials_clearcoat
|
||||||
Nullable<MaterialClearcoat> materialClearcoat;
|
Nullable<MaterialClearcoat> materialClearcoat;
|
||||||
|
|
||||||
|
//extension: KHR_materials_transmission
|
||||||
|
Nullable<MaterialTransmission> materialTransmission;
|
||||||
|
|
||||||
//extension: KHR_materials_unlit
|
//extension: KHR_materials_unlit
|
||||||
bool unlit;
|
bool unlit;
|
||||||
|
|
||||||
|
@ -1082,6 +1091,7 @@ public:
|
||||||
bool KHR_texture_transform;
|
bool KHR_texture_transform;
|
||||||
bool KHR_materials_sheen;
|
bool KHR_materials_sheen;
|
||||||
bool KHR_materials_clearcoat;
|
bool KHR_materials_clearcoat;
|
||||||
|
bool KHR_materials_transmission;
|
||||||
} extensionsUsed;
|
} extensionsUsed;
|
||||||
|
|
||||||
//! Keeps info about the required extensions
|
//! Keeps info about the required extensions
|
||||||
|
|
|
@ -1069,6 +1069,17 @@ inline void Material::Read(Value &material, Asset &r) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (r.extensionsUsed.KHR_materials_transmission) {
|
||||||
|
if (Value *curMaterialTransmission = FindObject(*extensions, "KHR_materials_transmission")) {
|
||||||
|
MaterialTransmission transmission;
|
||||||
|
|
||||||
|
ReadMember(*curMaterialTransmission, "transmissionFactor", transmission.transmissionFactor);
|
||||||
|
ReadTextureProperty(r, *curMaterialTransmission, "transmissionTexture", transmission.transmissionTexture);
|
||||||
|
|
||||||
|
this->materialTransmission = Nullable<MaterialTransmission>(transmission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
|
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1766,6 +1777,7 @@ inline void Asset::ReadExtensionsUsed(Document &doc) {
|
||||||
CHECK_EXT(KHR_texture_transform);
|
CHECK_EXT(KHR_texture_transform);
|
||||||
CHECK_EXT(KHR_materials_sheen);
|
CHECK_EXT(KHR_materials_sheen);
|
||||||
CHECK_EXT(KHR_materials_clearcoat);
|
CHECK_EXT(KHR_materials_clearcoat);
|
||||||
|
CHECK_EXT(KHR_materials_transmission);
|
||||||
|
|
||||||
#undef CHECK_EXT
|
#undef CHECK_EXT
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,6 +301,14 @@ static aiMaterial *ImportMaterial(std::vector<int> &embeddedTexIdxs, Asset &r, M
|
||||||
SetMaterialTextureProperty(embeddedTexIdxs, r, clearcoat.clearcoatRoughnessTexture, aimat, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE);
|
SetMaterialTextureProperty(embeddedTexIdxs, r, clearcoat.clearcoatRoughnessTexture, aimat, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE);
|
||||||
SetMaterialTextureProperty(embeddedTexIdxs, r, clearcoat.clearcoatNormalTexture, aimat, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE);
|
SetMaterialTextureProperty(embeddedTexIdxs, r, clearcoat.clearcoatNormalTexture, aimat, AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE);
|
||||||
}
|
}
|
||||||
|
//KHR_materials_transmission
|
||||||
|
if (mat.materialTransmission.isPresent) {
|
||||||
|
MaterialTransmission &transmission = mat.materialTransmission.value;
|
||||||
|
|
||||||
|
aimat->AddProperty(&mat.materialTransmission.isPresent, 1, AI_MATKEY_GLTF_MATERIAL_TRANSMISSION);
|
||||||
|
aimat->AddProperty(&transmission.transmissionFactor, 1, AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR);
|
||||||
|
SetMaterialTextureProperty(embeddedTexIdxs, r, transmission.transmissionTexture, aimat, AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE);
|
||||||
|
}
|
||||||
|
|
||||||
return aimat;
|
return aimat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE aiTextureType_UNKNOWN, 3
|
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_TEXTURE aiTextureType_UNKNOWN, 3
|
||||||
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 4
|
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_ROUGHNESS_TEXTURE aiTextureType_UNKNOWN, 4
|
||||||
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE aiTextureType_NORMALS, 1
|
#define AI_MATKEY_GLTF_MATERIAL_CLEARCOAT_NORMAL_TEXTURE aiTextureType_NORMALS, 1
|
||||||
|
#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION "$mat.gltf.materialTransmission", 0, 0
|
||||||
|
#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_FACTOR "$mat.gltf.materialTransmission.transmissionFactor", 0, 0
|
||||||
|
#define AI_MATKEY_GLTF_MATERIAL_TRANSMISSION_TEXTURE aiTextureType_UNKNOWN, 5
|
||||||
|
|
||||||
#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
|
#define _AI_MATKEY_GLTF_TEXTURE_TEXCOORD_BASE "$tex.file.texCoord"
|
||||||
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
|
#define _AI_MATKEY_GLTF_MAPPINGNAME_BASE "$tex.mappingname"
|
||||||
|
|
Loading…
Reference in New Issue