Drawable Renderer (#1570), Fix color normalization problems, don't produce zero-alpha drawables

This commit is contained in:
Tim Sylvester
2023-05-16 09:59:12 -07:00
committed by Bart Louwers
parent 1fa3502048
commit 76658d8717
5 changed files with 17 additions and 16 deletions

View File

@@ -82,7 +82,7 @@ gfx::UniformBufferArray& DrawableGL::mutableUniformBuffers() {
void DrawableGL::resetColor(const Color& newColor) {
if (const auto& colorAttr = impl->vertexAttributes.get("a_color")) {
colorAttr->clear();
colorAttr->set(0, colorAttrValue(newColor));
colorAttr->set(0, Drawable::colorAttrRGBA(newColor));
}
}

View File

@@ -30,12 +30,12 @@ void DrawableGLBuilder::init() {
}
if (impl->colors.empty()) {
colorAttr->set(0, DrawableGL::colorAttrValue(getColor()));
colorAttr->set(0, gfx::Drawable::colorAttrRGBA(getColor()));
} else {
std::size_t index = 0;
colorAttr->reserve(impl->colors.size());
for (const auto& color : impl->colors) {
colorAttr->set(index++, DrawableGL::colorAttrValue(color));
colorAttr->set(index++, gfx::Drawable::colorAttrRGBA(color));
}
}
}

View File

@@ -343,21 +343,21 @@ void RenderFillLayer::update(const int32_t layerIndex,
const auto& evaluated = getEvaluated<FillLayerProperties>(renderData->layerProperties);
const auto evalColor = evaluated.get<FillColor>().constantOr(Color());
const auto fillOpacity = evaluated.get<FillOpacity>().constantOr(1);
// const auto fillColor = evalColor * (fillOpacity > 0.0f ? fillOpacity : 1.0f);
const auto fillColor = evalColor * (fillOpacity > 0.0f ? fillOpacity : 1.0f);
const auto fillRenderPass = (evalColor.a >= 1.0f && fillOpacity >= 1.0f
const auto fillRenderPass = (fillColor.a >= 1.0f
/* && parameters.currentLayer >= parameters.opaquePassCutoff*/)
? RenderPass::Opaque
: RenderPass::Translucent;
if (fillRenderPass != renderPass) {
if (fillRenderPass != renderPass || fillColor.a <= 0.0f) {
removeTile();
continue;
}
vertexAttrs.clear();
if (auto& attr = vertexAttrs.getOrAdd("a_color")) {
attr->set(0, util::cast<float>(evalColor.toArray()));
attr->set(0, gfx::Drawable::colorAttrRGBA(evalColor));
}
if (auto& attr = vertexAttrs.getOrAdd("a_opacity")) {
attr->set<gfx::VertexAttribute::float2>(0, {fillOpacity, fillOpacity});