fixing repported issues during review

This commit is contained in:
samcake 2016-03-23 15:59:57 -07:00
parent 7d99183474
commit 1e46b0803c
3 changed files with 17 additions and 21 deletions

View file

@ -139,7 +139,7 @@ bool NetworkGeometry::isLoadedWithTextures() const {
} }
if (!_isLoadedWithTextures) { if (!_isLoadedWithTextures) {
_hasTransparentTextures = true; _hasTransparentTextures = false;
for (auto&& material : _materials) { for (auto&& material : _materials) {
if ((material->albedoTexture && !material->albedoTexture->isLoaded()) || if ((material->albedoTexture && !material->albedoTexture->isLoaded()) ||
@ -156,7 +156,7 @@ bool NetworkGeometry::isLoadedWithTextures() const {
material->_material->setTextureMap(model::MaterialKey::ALBEDO_MAP, material->_material->getTextureMap(model::MaterialKey::ALBEDO_MAP)); material->_material->setTextureMap(model::MaterialKey::ALBEDO_MAP, material->_material->getTextureMap(model::MaterialKey::ALBEDO_MAP));
const auto& usage = material->albedoTexture->getGPUTexture()->getUsage(); const auto& usage = material->albedoTexture->getGPUTexture()->getUsage();
bool isTransparentTexture = usage.isAlpha() && !usage.isAlphaMask(); bool isTransparentTexture = usage.isAlpha() && !usage.isAlphaMask();
_hasTransparentTextures = isTransparentTexture && _hasTransparentTextures; _hasTransparentTextures |= isTransparentTexture;
} }
} }

View file

@ -80,7 +80,6 @@ void Material::setMetallic(float metallic) {
_schemaBuffer.edit<Schema>()._metallic = metallic; _schemaBuffer.edit<Schema>()._metallic = metallic;
} }
void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textureMap) { void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textureMap) {
if (textureMap) { if (textureMap) {
_key.setMapChannel(channel, (true)); _key.setMapChannel(channel, (true));
@ -90,9 +89,7 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
_key.setOpacityMaskMap(false); _key.setOpacityMaskMap(false);
_key.setTranslucentMap(false); _key.setTranslucentMap(false);
if (textureMap->useAlphaChannel()) { if (textureMap->useAlphaChannel() && textureMap->isDefined() && textureMap->getTextureView().isValid()) {
if (textureMap->isDefined()) {
if (textureMap->getTextureView().isValid()) {
auto usage = textureMap->getTextureView()._texture->getUsage(); auto usage = textureMap->getTextureView()._texture->getUsage();
if (usage.isAlpha()) { if (usage.isAlpha()) {
// Texture has alpha, is not just a mask or a true transparent channel // Texture has alpha, is not just a mask or a true transparent channel
@ -106,10 +103,7 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
} }
} }
} }
}
}
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
_textureMaps[channel] = textureMap; _textureMaps[channel] = textureMap;
} else { } else {
_key.setMapChannel(channel, (false)); _key.setMapChannel(channel, (false));
@ -119,9 +113,11 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
_key.setTranslucentMap(false); _key.setTranslucentMap(false);
} }
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
_textureMaps.erase(channel); _textureMaps.erase(channel);
} }
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
} }

View file

@ -81,7 +81,7 @@ ItemKey MeshPartPayload::getKey() const {
if (_drawMaterial) { if (_drawMaterial) {
auto matKey = _drawMaterial->getKey(); auto matKey = _drawMaterial->getKey();
if (matKey.isTranslucentFactor() || matKey.isTranslucentMap()) { if (matKey.isTranslucent()) {
builder.withTransparent(); builder.withTransparent();
} }
} }