Skip to content

Conversation

@tychedelia
Copy link
Member

Changes MaterialKey to support batching for things beyond StandardMaterial. We are still implementing the ColorMaterial variant with StandardMaterial, but could choose to do so differently later.

Instead of spawning with a hard-coded MeshMaterial3d, we instead spawn an UntypedHandle and then downcast and attach the concrete material handle to the entity in a later system. This is the pattern we'll also use for custom user materials later. In other words, the core flush system now is type erased over the actual type of material.

This is mostly framing for follow up PRs.

@tychedelia tychedelia requested a review from catilac February 12, 2026 20:34
Copy link
Contributor

@catilac catilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Noting the pattern using TypeErasure.
I left one question

Comment on lines +58 to +65
pub(crate) fn add_standard_materials(
mut commands: Commands,
meshes: Query<(Entity, &UntypedMaterial)>,
) {
for (entity, handle) in meshes.iter() {
let handle = handle.deref().clone();
if let Ok(handle) = handle.try_typed::<StandardMaterial>() {
commands.entity(entity).insert(MeshMaterial3d(handle));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we want to support MeshMaterial2d, how would this look? For now we don't need to worry because we're focused on 3D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we just implement 2d via 3d, but this would allow us to switch to that later if we wanted, or vector graphics, or whatever.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, thanks!

@catilac catilac merged commit f411d2d into processing:main Feb 12, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants