From b7b17b03ec57ed81a9203ec9c3b40766b3eec22e Mon Sep 17 00:00:00 2001 From: jamesgk Date: Wed, 26 Jul 2017 14:39:35 -0700 Subject: [PATCH] glTF2: use opacity for diffuse alpha + alphaMode The "transparency" attribute is unused in glTF2. --- code/glTF2AssetWriter.inl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/code/glTF2AssetWriter.inl b/code/glTF2AssetWriter.inl index 03e73eb27..646b31ec5 100644 --- a/code/glTF2AssetWriter.inl +++ b/code/glTF2AssetWriter.inl @@ -212,17 +212,20 @@ namespace glTF2 { inline void Write(Value& obj, Material& m, AssetWriter& w) { + if (m.transparent) { + obj.AddMember("alphaMode", "BLEND", w.mAl); + } + Value v; v.SetObject(); { + if (m.transparent && !m.diffuse.texture) { + m.diffuse.color[3] = m.transparency; + } WriteColorOrTex(v, m.ambient, m.ambient.texture ? "ambientTexture" : "ambientFactor", w.mAl); WriteColorOrTex(v, m.diffuse, m.diffuse.texture ? "diffuseTexture" : "diffuseFactor", w.mAl); WriteColorOrTex(v, m.specular, m.specular.texture ? "specularTexture" : "specularFactor", w.mAl); WriteColorOrTex(v, m.emission, m.emission.texture ? "emissionTexture" : "emissionFactor", w.mAl); - - if (m.transparent) - v.AddMember("transparency", m.transparency, w.mAl); - v.AddMember("shininessFactor", m.shininess, w.mAl); } v.AddMember("type", "commonPhong", w.mAl);