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) {
_hasTransparentTextures = true;
_hasTransparentTextures = false;
for (auto&& material : _materials) {
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));
const auto& usage = material->albedoTexture->getGPUTexture()->getUsage();
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;
}
void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textureMap) {
if (textureMap) {
_key.setMapChannel(channel, (true));
@ -90,26 +89,21 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
_key.setOpacityMaskMap(false);
_key.setTranslucentMap(false);
if (textureMap->useAlphaChannel()) {
if (textureMap->isDefined()) {
if (textureMap->getTextureView().isValid()) {
auto usage = textureMap->getTextureView()._texture->getUsage();
if (usage.isAlpha()) {
// Texture has alpha, is not just a mask or a true transparent channel
if (usage.isAlphaMask()) {
_key.setOpacityMaskMap(true);
_key.setTranslucentMap(false);
} else {
_key.setOpacityMaskMap(false);
_key.setTranslucentMap(true);
}
}
if (textureMap->useAlphaChannel() && textureMap->isDefined() && textureMap->getTextureView().isValid()) {
auto usage = textureMap->getTextureView()._texture->getUsage();
if (usage.isAlpha()) {
// Texture has alpha, is not just a mask or a true transparent channel
if (usage.isAlphaMask()) {
_key.setOpacityMaskMap(true);
_key.setTranslucentMap(false);
} else {
_key.setOpacityMaskMap(false);
_key.setTranslucentMap(true);
}
}
}
}
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
_textureMaps[channel] = textureMap;
} else {
_key.setMapChannel(channel, (false));
@ -119,9 +113,11 @@ void Material::setTextureMap(MapChannel channel, const TextureMapPointer& textur
_key.setTranslucentMap(false);
}
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
_textureMaps.erase(channel);
}
_schemaBuffer.edit<Schema>()._key = (uint32)_key._flags.to_ulong();
}
@ -132,4 +128,4 @@ const TextureMapPointer Material::getTextureMap(MapChannel channel) const {
} else {
return TextureMapPointer();
}
}
}

View file

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