From 3c075532f8cd3670eb51766f49e1a690ed813e2c Mon Sep 17 00:00:00 2001 From: samcake Date: Tue, 22 Mar 2016 15:14:01 -0700 Subject: [PATCH] Good to go for merge --- .../src/model-networking/ModelCache.cpp | 7 ++----- .../src/model-networking/ModelCache.h | 2 -- libraries/model/src/model/Material.cpp | 18 +----------------- libraries/model/src/model/Material.h | 7 ++++--- libraries/model/src/model/Material.slh | 8 ++++---- 5 files changed, 11 insertions(+), 31 deletions(-) diff --git a/libraries/model-networking/src/model-networking/ModelCache.cpp b/libraries/model-networking/src/model-networking/ModelCache.cpp index 2b142d95d5..5eb961ef98 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.cpp +++ b/libraries/model-networking/src/model-networking/ModelCache.cpp @@ -151,13 +151,11 @@ bool NetworkGeometry::isLoadedWithTextures() const { (material->lightmapTexture && !material->lightmapTexture->isLoaded())) { return false; } - if (/*material->useAlbedoMapOpacity && */ material->albedoTexture && material->albedoTexture->getGPUTexture()) { + if (material->albedoTexture && material->albedoTexture->getGPUTexture()) { + // Reassign the texture to make sure that itsalbedo alpha channel material key is detected correctly material->_material->setTextureMap(model::MaterialKey::ALBEDO_MAP, material->_material->getTextureMap(model::MaterialKey::ALBEDO_MAP)); - // Reset the materialKey transparentTexture key only, as it is albedoTexture-dependent const auto& usage = material->albedoTexture->getGPUTexture()->getUsage(); bool isTransparentTexture = usage.isAlpha() && !usage.isAlphaMask(); - // material->_material->setTransparentTexture(isTransparentTexture); - // FIXME: Materials with *some* transparent textures seem to give all *other* textures alphas of 0. _hasTransparentTextures = isTransparentTexture && _hasTransparentTextures; } } @@ -385,7 +383,6 @@ static NetworkMaterial* buildNetworkMaterial(NetworkGeometry* geometry, const FB if (!material.opacityTexture.filename.isEmpty()) { if (material.albedoTexture.filename == material.opacityTexture.filename) { // Best case scenario, just indicating that the albedo map contains transparency - networkMaterial->useAlbedoMapOpacity; albedoMap->setUseAlphaChannel(true); } else { // Opacity Map is different from the Abledo map, not supported diff --git a/libraries/model-networking/src/model-networking/ModelCache.h b/libraries/model-networking/src/model-networking/ModelCache.h index b172bb70b4..1c76a0b878 100644 --- a/libraries/model-networking/src/model-networking/ModelCache.h +++ b/libraries/model-networking/src/model-networking/ModelCache.h @@ -199,8 +199,6 @@ public: QSharedPointer occlusionTexture; QString lightmapTextureName; QSharedPointer lightmapTexture; - bool useAlbedoMapOpacity{ false }; - }; diff --git a/libraries/model/src/model/Material.cpp b/libraries/model/src/model/Material.cpp index eaabda8f07..f1e6b8c2ef 100755 --- a/libraries/model/src/model/Material.cpp +++ b/libraries/model/src/model/Material.cpp @@ -91,23 +91,7 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur if (textureMap->getTextureView().isValid()) { auto usage = textureMap->getTextureView()._texture->getUsage(); if (usage.isAlpha()) { - // Texture has alpha, is nut just a mask or a true transparent channel - if (usage.isAlphaMask()) { - _key.setOpacityMaskMap(true); - _key.setTranslucentMap(false); - } else { - _key.setOpacityMaskMap(false); - _key.setTranslucentMap(true); - } - } - } - } - } else { - if (textureMap->isDefined()) { - if (textureMap->getTextureView().isValid()) { - auto usage = textureMap->getTextureView()._texture->getUsage(); - if (usage.isAlpha()) { - // Texture has alpha, is nut just a mask or a true transparent channel + // Texture has alpha, is not just a mask or a true transparent channel if (usage.isAlphaMask()) { _key.setOpacityMaskMap(true); _key.setTranslucentMap(false); diff --git a/libraries/model/src/model/Material.h b/libraries/model/src/model/Material.h index 2527c8e1e1..5a7b919994 100755 --- a/libraries/model/src/model/Material.h +++ b/libraries/model/src/model/Material.h @@ -32,11 +32,12 @@ public: METALLIC_VAL_BIT, GLOSSY_VAL_BIT, OPACITY_VAL_BIT, - - EMISSIVE_MAP_BIT, - ALBEDO_MAP_BIT, OPACITY_MASK_MAP_BIT, // OPacity Map and Opacity MASK map are mutually exclusive OPACITY_TRANSLUCENT_MAP_BIT, + + // THe map bits must be in the smae sequence as the enum names for the map channels + EMISSIVE_MAP_BIT, + ALBEDO_MAP_BIT, METALLIC_MAP_BIT, ROUGHNESS_MAP_BIT, NORMAL_MAP_BIT, diff --git a/libraries/model/src/model/Material.slh b/libraries/model/src/model/Material.slh index a5b58e2aa0..28f9769a8b 100644 --- a/libraries/model/src/model/Material.slh +++ b/libraries/model/src/model/Material.slh @@ -44,11 +44,11 @@ const int ALBEDO_VAL_BIT = 0x00000002; const int METALLIC_VAL_BIT = 0x00000004; const int GLOSSY_VAL_BIT = 0x00000008; const int OPACITY_VAL_BIT = 0x00000010; +const int OPACITY_MASK_MAP_BIT = 0x00000020; +const int OPACITY_TRANSLUCENT_MAP_BIT = 0x00000040; -const int EMISSIVE_MAP_BIT = 0x00000020; -const int ALBEDO_MAP_BIT = 0x00000040; -const int OPACITY_MASK_MAP_BIT = 0x00000080; -const int OPACITY_TRANSLUCENT_MAP_BIT = 0x00000100; +const int EMISSIVE_MAP_BIT = 0x00000080; +const int ALBEDO_MAP_BIT = 0x00000100; const int METALLIC_MAP_BIT = 0x00000200; const int ROUGHNESS_MAP_BIT = 0x00000400; const int NORMAL_MAP_BIT = 0x00000800;