Merge branch 'master' into qt-5.11

pull/1966/head
Alexander Gessler 2018-05-19 00:45:17 +02:00 committed by GitHub
commit a7ce5e838e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 0 deletions

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* glTF Extensions Support: * glTF Extensions Support:
* KHR_materials_pbrSpecularGlossiness full * KHR_materials_pbrSpecularGlossiness full
* KHR_materials_unlit full
*/ */
#ifndef GLTF2ASSET_H_INC #ifndef GLTF2ASSET_H_INC
#define GLTF2ASSET_H_INC #define GLTF2ASSET_H_INC
@ -741,6 +742,9 @@ namespace glTF2
//extension: KHR_materials_pbrSpecularGlossiness //extension: KHR_materials_pbrSpecularGlossiness
Nullable<PbrSpecularGlossiness> pbrSpecularGlossiness; Nullable<PbrSpecularGlossiness> pbrSpecularGlossiness;
//extension: KHR_materials_unlit
bool unlit;
Material() { SetDefaults(); } Material() { SetDefaults(); }
void Read(Value& obj, Asset& r); void Read(Value& obj, Asset& r);
void SetDefaults(); void SetDefaults();
@ -1037,6 +1041,7 @@ namespace glTF2
struct Extensions struct Extensions
{ {
bool KHR_materials_pbrSpecularGlossiness; bool KHR_materials_pbrSpecularGlossiness;
bool KHR_materials_unlit;
} extensionsUsed; } extensionsUsed;

View File

@ -860,6 +860,8 @@ inline void Material::Read(Value& material, Asset& r)
this->pbrSpecularGlossiness = Nullable<PbrSpecularGlossiness>(pbrSG); this->pbrSpecularGlossiness = Nullable<PbrSpecularGlossiness>(pbrSG);
} }
} }
unlit = nullptr != FindObject(*extensions, "KHR_materials_unlit");
} }
} }
@ -882,6 +884,7 @@ inline void Material::SetDefaults()
alphaMode = "OPAQUE"; alphaMode = "OPAQUE";
alphaCutoff = 0.5; alphaCutoff = 0.5;
doubleSided = false; doubleSided = false;
unlit = false;
} }
inline void PbrSpecularGlossiness::SetDefaults() inline void PbrSpecularGlossiness::SetDefaults()
@ -1253,6 +1256,7 @@ inline void Asset::ReadExtensionsUsed(Document& doc)
if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true; if (exts.find(#EXT) != exts.end()) extensionsUsed.EXT = true;
CHECK_EXT(KHR_materials_pbrSpecularGlossiness); CHECK_EXT(KHR_materials_pbrSpecularGlossiness);
CHECK_EXT(KHR_materials_unlit);
#undef CHECK_EXT #undef CHECK_EXT
} }

View File

@ -45,6 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* glTF Extensions Support: * glTF Extensions Support:
* KHR_materials_pbrSpecularGlossiness: full * KHR_materials_pbrSpecularGlossiness: full
* KHR_materials_unlit: full
*/ */
#ifndef GLTF2ASSETWRITER_H_INC #ifndef GLTF2ASSETWRITER_H_INC
#define GLTF2ASSETWRITER_H_INC #define GLTF2ASSETWRITER_H_INC

View File

@ -343,6 +343,12 @@ namespace glTF2 {
} }
} }
if (m.unlit) {
Value unlit;
unlit.SetObject();
exts.AddMember("KHR_materials_unlit", unlit, w.mAl);
}
if (!exts.ObjectEmpty()) { if (!exts.ObjectEmpty()) {
obj.AddMember("extensions", exts, w.mAl); obj.AddMember("extensions", exts, w.mAl);
} }
@ -683,6 +689,10 @@ namespace glTF2 {
if (this->mAsset.extensionsUsed.KHR_materials_pbrSpecularGlossiness) { if (this->mAsset.extensionsUsed.KHR_materials_pbrSpecularGlossiness) {
exts.PushBack(StringRef("KHR_materials_pbrSpecularGlossiness"), mAl); exts.PushBack(StringRef("KHR_materials_pbrSpecularGlossiness"), mAl);
} }
if (this->mAsset.extensionsUsed.KHR_materials_unlit) {
exts.PushBack(StringRef("KHR_materials_unlit"), mAl);
}
} }
if (!exts.Empty()) if (!exts.Empty())

View File

@ -526,6 +526,12 @@ void glTF2Exporter::ExportMaterials()
m->pbrSpecularGlossiness = Nullable<PbrSpecularGlossiness>(pbrSG); m->pbrSpecularGlossiness = Nullable<PbrSpecularGlossiness>(pbrSG);
} }
bool unlit;
if (mat->Get(AI_MATKEY_GLTF_UNLIT, unlit) == AI_SUCCESS && unlit) {
mAsset->extensionsUsed.KHR_materials_unlit = true;
m->unlit = true;
}
} }
} }

View File

@ -281,6 +281,9 @@ static aiMaterial* ImportMaterial(std::vector<int>& embeddedTexIdxs, Asset& r, M
SetMaterialTextureProperty(embeddedTexIdxs, r, pbrSG.specularGlossinessTexture, aimat, aiTextureType_SPECULAR); SetMaterialTextureProperty(embeddedTexIdxs, r, pbrSG.specularGlossinessTexture, aimat, aiTextureType_SPECULAR);
} }
if (mat.unlit) {
aimat->AddProperty(&mat.unlit, 1, AI_MATKEY_GLTF_UNLIT);
}
return aimat; return aimat;
} }

View File

@ -56,6 +56,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0 #define AI_MATKEY_GLTF_ALPHACUTOFF "$mat.gltf.alphaCutoff", 0, 0
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0 #define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS "$mat.gltf.pbrSpecularGlossiness", 0, 0
#define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0 #define AI_MATKEY_GLTF_PBRSPECULARGLOSSINESS_GLOSSINESS_FACTOR "$mat.gltf.pbrMetallicRoughness.glossinessFactor", 0, 0
#define AI_MATKEY_GLTF_UNLIT "$mat.gltf.unlit", 0, 0
#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"