diff --git a/src/Nazara/Graphics/Graphics.cpp b/src/Nazara/Graphics/Graphics.cpp index df5af50d5..62cb50094 100644 --- a/src/Nazara/Graphics/Graphics.cpp +++ b/src/Nazara/Graphics/Graphics.cpp @@ -315,8 +315,10 @@ namespace Nz m_defaultMaterials.basicTransparent = m_defaultMaterials.basicMaterial->Instantiate(); m_defaultMaterials.basicTransparent->DisablePass(depthPassIndex); m_defaultMaterials.basicTransparent->DisablePass(shadowPassIndex); + m_defaultMaterials.basicTransparent->UpdatePassFlags(forwardPassIndex, MaterialPassFlag::SortByDistance); m_defaultMaterials.basicTransparent->UpdatePassStates(forwardPassIndex, [](RenderStates& renderStates) { + renderStates.depthBuffer = true; renderStates.depthWrite = false; renderStates.blending = true; renderStates.blend.modeColor = BlendEquation::Add; diff --git a/src/Nazara/Graphics/TextSprite.cpp b/src/Nazara/Graphics/TextSprite.cpp index 7787c63b4..2d8cf1a84 100644 --- a/src/Nazara/Graphics/TextSprite.cpp +++ b/src/Nazara/Graphics/TextSprite.cpp @@ -19,7 +19,7 @@ namespace Nz m_material(std::move(material)) { if (!m_material) - m_material = Graphics::Instance()->GetDefaultMaterials().basicTransparent->Clone(); + m_material = Graphics::Instance()->GetDefaultMaterials().basicTransparent; } void TextSprite::BuildElement(ElementRendererRegistry& registry, const ElementData& elementData, std::size_t passIndex, std::vector& elements) const @@ -44,7 +44,7 @@ namespace Nz RenderIndices& indices = pair.second; if (indices.count > 0) - elements.emplace_back(registry.AllocateElement(GetRenderLayer(), m_material, passFlags, renderPipeline, *elementData.worldInstance, vertexDeclaration, key.texture->shared_from_this(), indices.count, &m_vertices[indices.first * 4], *elementData.scissorBox)); + elements.emplace_back(registry.AllocateElement(GetRenderLayer() + key.renderOrder, m_material, passFlags, renderPipeline, *elementData.worldInstance, vertexDeclaration, key.texture->shared_from_this(), indices.count, &m_vertices[indices.first * 4], *elementData.scissorBox)); } } diff --git a/src/Nazara/Utility/SimpleTextDrawer.cpp b/src/Nazara/Utility/SimpleTextDrawer.cpp index fa9b26f6e..66b7fbc2a 100644 --- a/src/Nazara/Utility/SimpleTextDrawer.cpp +++ b/src/Nazara/Utility/SimpleTextDrawer.cpp @@ -226,8 +226,10 @@ namespace Nz Glyph glyph; if (!whitespace) { + int glyphRenderOrder = (m_outlineThickness > 0.f) ? 1 : 0; + int iAdvance; - if (!GenerateGlyph(glyph, character, 0.f, true, m_color, 0, &iAdvance)) + if (!GenerateGlyph(glyph, character, 0.f, true, m_color, glyphRenderOrder, &iAdvance)) continue; // Glyph failed to load, just skip it (can't do much) advance += float(iAdvance); @@ -235,7 +237,7 @@ namespace Nz if (m_outlineThickness > 0.f) { Glyph outlineGlyph; - if (GenerateGlyph(outlineGlyph, character, m_outlineThickness, false, m_outlineColor, -1, nullptr)) + if (GenerateGlyph(outlineGlyph, character, m_outlineThickness, false, m_outlineColor, glyphRenderOrder - 1, nullptr)) m_glyphs.push_back(outlineGlyph); } }