From 46f6234af547f6ce4b0b7e01997d1fa28b8204e7 Mon Sep 17 00:00:00 2001 From: Par Winzell Date: Fri, 29 Mar 2019 10:29:59 -0700 Subject: [PATCH] Fix previous fix. --- src/gltf/Raw2Gltf.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/gltf/Raw2Gltf.cpp b/src/gltf/Raw2Gltf.cpp index fb195da..be1af20 100644 --- a/src/gltf/Raw2Gltf.cpp +++ b/src/gltf/Raw2Gltf.cpp @@ -266,13 +266,17 @@ ModelData* Raw2Gltf( bool hasMetallicMap = material.textures[RAW_TEXTURE_USAGE_METALLIC] >= 0; bool hasRoughnessMap = material.textures[RAW_TEXTURE_USAGE_ROUGHNESS] >= 0; bool hasOcclusionMap = material.textures[RAW_TEXTURE_USAGE_OCCLUSION] >= 0; - aoMetRoughTex = hasMetallicMap - ? simpleTex(RAW_TEXTURE_USAGE_METALLIC) - : (hasRoughnessMap - ? simpleTex(RAW_TEXTURE_USAGE_ROUGHNESS) - : (hasOcclusionMap ? simpleTex(RAW_TEXTURE_USAGE_OCCLUSION) : nullptr)); - if (aoMetRoughTex == nullptr) { - // merge occlusion into the red channel, metallic into blue channel, and + bool atLeastTwoMaps = hasMetallicMap ? (hasRoughnessMap || hasOcclusionMap) + : (hasRoughnessMap && hasMetallicMap); + if (!atLeastTwoMaps) { + // this handles the case of 0 or 1 maps supplied + aoMetRoughTex = hasMetallicMap + ? simpleTex(RAW_TEXTURE_USAGE_METALLIC) + : (hasRoughnessMap + ? simpleTex(RAW_TEXTURE_USAGE_ROUGHNESS) + : (hasOcclusionMap ? simpleTex(RAW_TEXTURE_USAGE_OCCLUSION) : nullptr)); + } else { + // otherwise merge occlusion into the red channel, metallic into blue channel, and // roughness into the green, of a new combinatory texture aoMetRoughTex = textureBuilder.combine( {