From 4f8ddffdf7723eea4651aa002e61e4de5578b0b5 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Mon, 6 Nov 2017 14:48:16 -0800 Subject: [PATCH] Better calculation of glTF opacity. At the glTF level, transparency is a scalar; we just throw away any color information in FBX TransparentColor. We still need to calculate our total opacity from it, however. This is the right formula, which additionally matches the deprecated (but still populated, by the Maya exporter) 'Opacity' property. --- src/Fbx2Raw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Fbx2Raw.cpp b/src/Fbx2Raw.cpp index fb33485..5593829 100644 --- a/src/Fbx2Raw.cpp +++ b/src/Fbx2Raw.cpp @@ -168,8 +168,8 @@ public: if (facTex) { fmt::printf("Warning: Mat [%s]: Can't handle texture for %s; discarding.\n", name, FbxSurfaceMaterial::sTransparencyFactor); } - // FBX color is RGB, so we supply the A channel from TransparencyFactor - res.colDiffuse[3] = 1.0 - transparency[3]; + // FBX color is RGB, so we calculate the A channel as the average of the FBX transparency color vector + res.colDiffuse[3] = 1.0 - (transparency[0] + transparency[1] + transparency[2])/3.0; return res; }