Skip to content

Commit 3552537

Browse files
authored
Fix that transparent text still draws a text shadow (luanti-org#13649)
Makes fade out animations of text more pleasant to look at.
1 parent f41e9e3 commit 3552537

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/irrlicht_changes/CGUITTFont.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,13 +678,6 @@ void CGUITTFont::draw(const EnrichedString &text, const core::rect<s32>& positio
678678
CGUITTGlyphPage* page = it->second;
679679
++it;
680680

681-
if (shadow_offset) {
682-
for (size_t i = 0; i < page->render_positions.size(); ++i)
683-
page->render_positions[i] += core::vector2di(shadow_offset, shadow_offset);
684-
Driver->draw2DImageBatch(page->texture, page->render_positions, page->render_source_rects, clip, video::SColor(shadow_alpha,0,0,0), true);
685-
for (size_t i = 0; i < page->render_positions.size(); ++i)
686-
page->render_positions[i] -= core::vector2di(shadow_offset, shadow_offset);
687-
}
688681
// render runs of matching color in batch
689682
size_t ibegin;
690683
video::SColor colprev;
@@ -700,6 +693,19 @@ void CGUITTFont::draw(const EnrichedString &text, const core::rect<s32>& positio
700693

701694
if (!use_transparency)
702695
colprev.color |= 0xff000000;
696+
697+
if (shadow_offset) {
698+
for (size_t i = 0; i < tmp_positions.size(); ++i)
699+
tmp_positions[i] += core::vector2di(shadow_offset, shadow_offset);
700+
701+
u32 new_shadow_alpha = core::clamp(core::round32(shadow_alpha * colprev.getAlpha() / 255.0f), 0, 255);
702+
video::SColor shadow_color = video::SColor(new_shadow_alpha, 0, 0, 0);
703+
Driver->draw2DImageBatch(page->texture, tmp_positions, tmp_source_rects, clip, shadow_color, true);
704+
705+
for (size_t i = 0; i < tmp_positions.size(); ++i)
706+
tmp_positions[i] -= core::vector2di(shadow_offset, shadow_offset);
707+
}
708+
703709
Driver->draw2DImageBatch(page->texture, tmp_positions, tmp_source_rects, clip, colprev, true);
704710
}
705711
}

0 commit comments

Comments
 (0)