Text2dShadow sometimes renders in front of its text
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start by reproducing the provided example in the Bevy 2D text rendering pipeline, focusing on Text2dShadow, AlphaMode2d, and the RenderSystems::Queue ordering described in the workaround. Locate where shadow and text draw commands are queued and compare their ordering when an unrelated mesh changes visibility. Done means the reproduction consistently renders the shadow behind the text across the affected platform or build configurations without relying on the workaround.
Written by the indexing model from the issue text.
Description
Bevy version and features
- Bevy 0.20.1
- Bevy 5c485c424 (latest main)
Default features
What you did
Repeatedly include/exclude another (unrelated) mesh from rendering. Visibility::Hidden works, but for some reason moving it out of view produces more noticeable effects.
use bevy::{prelude::*, sprite::Text2dShadow, sprite_render::AlphaMode2d};
fn main() {
App::new()
.insert_resource(ClearColor(Color::WHITE))
.add_plugins(DefaultPlugins)
.add_systems(Startup, startup)
.add_systems(Update, update)
.run();
}
fn startup(
mut commands: Commands,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<ColorMaterial>>,
) {
commands.spawn(Camera2d);
commands.spawn((
Text2d::new("Red text with blue shadow"),
TextColor(Color::srgba(1.0, 0.0, 0.0, 1.0)),
TextFont::from_font_size(64.0),
Text2dShadow {
color: Color::srgba(0.0, 0.0, 1.0, 1.0),
offset: Vec2::ZERO,
},
));
commands.spawn((
Mesh2d(meshes.add(Rectangle::new(64.0, 64.0))),
MeshMaterial2d(materials.add(ColorMaterial {
color: Color::srgba(0.9, 0.9, 0.9, 1.0),
alpha_mode: AlphaMode2d::Blend, // this matters
..Default::default()
})),
Transform::from_xyz(0.0, 96.0, 0.0),
));
}
fn update(time: Res<Time>, mut mesh_transform: Single<&mut Transform, With<Mesh2d>>) {
**mesh_transform = if (time.elapsed().as_millis() / 250) % 2 == 0 {
// Move the rectangle out of frame.
// `Visibility::Hidden` also works but seems to only flicker briefly.
Transform::from_xyz(0.0, 99999.0, 0.0)
} else {
Transform::from_xyz(0.0, 96.0, 0.0)
};
}
This seems to be systems-ordering dependent, so it may not always be easy to reproduce. If the above works as expected, perhaps try a web build.
What went wrong
The blue text shadow sometimes renders in front of the red text, meaning its drawn later.
Additional information
Workaround:
impl Plugin for RenderingPlugin {
fn build(&self, app: &mut App) {
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
render_app.add_systems(
Render,
(|| {})
.in_set(RenderSystems::Queue)
.after(queue_material2d_meshes)
.before(queue_sprites),
);
}
}
}
- Dominant language
- Rust
- Stars
- 50k
- Forks
- 5.1k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 129
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from bevyengine/bevy
-
C-Bug S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bevyengine/bevy#26718 ·
Maintainers usually reply within 2 days
-
C-Bug S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
bevyengine/bevy#26689 ·
Maintainers usually reply within 2 days
-
Volumetric fog: a `FogVolume` with `Visibility::Hidden` is still renderedPossibly taken @adityawrk claimed this 2 days ago. OpenC-Bug S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
bevyengine/bevy#26688 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
bevyengine/bevy#26684 ·
Maintainers usually reply within 2 days
-
Create a bevy_fuzzy examplePossibly taken @Tatsuya0330 claimed this 1 day ago. OpenA-UI C-Examples C-Feature D-Straightforward S-Needs-Triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
bevyengine/bevy#26676 ·
Maintainers usually reply within 2 days
Similar issues
-
area:ui effort:medium enhancement P7 source:agent
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
documentation priority: low tech-debt
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
nledford/Ladderback#1823 ·
Maintainers usually reply within 1 day
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Possibly taken @ealwanlee claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
psmux/psmux-plugins#47 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 87/100
Maintainers usually reply within 1 day