Merge pull request #14801 from SamGondelman/transparent

Case 20867: Fix translucent textures not getting reset
This commit is contained in:
Sam Gateau 2019-01-30 08:54:48 -08:00 committed by GitHub
commit d418fa282a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 14 deletions

View file

@ -53,7 +53,7 @@ bool ShapeEntityRenderer::needsRenderUpdate() const {
}
auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.needsUpdate()) {
if (mat != _materials.end() && (mat->second.needsUpdate() || mat->second.areTexturesLoading())) {
return true;
}
@ -188,7 +188,7 @@ bool ShapeEntityRenderer::useMaterialPipeline(const graphics::MultiMaterial& mat
ShapeKey ShapeEntityRenderer::getShapeKey() {
auto mat = _materials.find("0");
if (mat != _materials.end() && mat->second.needsUpdate()) {
if (mat != _materials.end() && (mat->second.needsUpdate() || mat->second.areTexturesLoading())) {
RenderPipelines::updateMultiMaterial(mat->second);
}

View file

@ -409,11 +409,11 @@ void Geometry::setTextures(const QVariantMap& textureMap) {
material->setTextures(textureMap);
_areTexturesLoaded = false;
// If we only use cached textures, they should all be loaded
areTexturesLoaded();
}
}
// If we only use cached textures, they should all be loaded
areTexturesLoaded();
} else {
qCWarning(modelnetworking) << "Ignoring setTextures(); geometry not ready";
}
@ -422,10 +422,7 @@ void Geometry::setTextures(const QVariantMap& textureMap) {
bool Geometry::areTexturesLoaded() const {
if (!_areTexturesLoaded) {
for (auto& material : _materials) {
// Check if material textures are loaded
bool materialMissingTexture = material->isMissingTexture();
if (materialMissingTexture) {
if (material->isMissingTexture()) {
return false;
}

View file

@ -83,7 +83,7 @@ void MeshPartPayload::updateKey(const render::ItemKey& key) {
ItemKey::Builder builder(key);
builder.withTypeShape();
if (_drawMaterials.needsUpdate()) {
if (_drawMaterials.needsUpdate() || _drawMaterials.areTexturesLoading()) {
RenderPipelines::updateMultiMaterial(_drawMaterials);
}
@ -329,7 +329,7 @@ void ModelMeshPartPayload::updateKey(const render::ItemKey& key) {
builder.withDeformed();
}
if (_drawMaterials.needsUpdate()) {
if (_drawMaterials.needsUpdate() || _drawMaterials.areTexturesLoading()) {
RenderPipelines::updateMultiMaterial(_drawMaterials);
}
@ -347,7 +347,7 @@ void ModelMeshPartPayload::setShapeKey(bool invalidateShapeKey, PrimitiveMode pr
return;
}
if (_drawMaterials.needsUpdate()) {
if (_drawMaterials.needsUpdate() || _drawMaterials.areTexturesLoading()) {
RenderPipelines::updateMultiMaterial(_drawMaterials);
}

View file

@ -482,6 +482,7 @@ void RenderPipelines::updateMultiMaterial(graphics::MultiMaterial& multiMaterial
auto itr = textureMaps.find(graphics::MaterialKey::ALBEDO_MAP);
if (itr != textureMaps.end()) {
if (itr->second->isDefined()) {
material->resetOpacityMap();
drawMaterialTextures->setTexture(gr::Texture::MaterialAlbedo, itr->second->getTextureView());
wasSet = true;
} else {
@ -492,8 +493,8 @@ void RenderPipelines::updateMultiMaterial(graphics::MultiMaterial& multiMaterial
forceDefault = true;
}
schemaKey.setAlbedoMap(true);
schemaKey.setOpacityMaskMap(materialKey.isOpacityMaskMap());
schemaKey.setTranslucentMap(materialKey.isTranslucentMap());
schemaKey.setOpacityMaskMap(material->getKey().isOpacityMaskMap());
schemaKey.setTranslucentMap(material->getKey().isTranslucentMap());
}
break;
case graphics::MaterialKey::METALLIC_MAP_BIT: