Skip to content

armgit / raea

Public Imported from GitHub
0

Render Anything Engine: tell your AI what to make. Videos, motion graphics, 3D and games as React and TypeScript, rendered on your own GPU. Rust + Bevy, macOS, Linux and Windows.

FC2a: one reader for the component a part holds its own Material by (3D, 2D or a sprite's)

shinyobjectz5acc123835af
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index 2a443679..bbcc02fb 100644
--- a/docs/bevy-parity.md
+++ b/docs/bevy-parity.md
@@ -191,16 +191,16 @@ doesn't pay.
| shader/shader_material_screenspace_texture | 60 | 0.998929 | 2 | 1 / 1 | 449 / 521 | 7 / 9 | 2 / 3 | 3.42 / 1.81 = 1.81 + 0 | yes | |
| shader/shader_material_2d | 10 | 1.000000 | 0 | 0 / 0 | 447 / 519 | 6 / 8 | 1 / 1 | 44.328 / 2.569 = 2.569 + 0 | yes | |
| shader/fallback_image | 10 | 1.000000 | 0 | 0 / 0 | 447 / 519 | 6 / 8 | 1 / 2 | 46.39 / 2.292 = 2.292 + 0 | yes | |
-| shader/storage_buffer | 30 | 0.999999 | 0 | 0 / 0 | 538 / 973 | 6 / 8 | 1 / 92 | 18.943 / 1.755 = 1.755 + 0 | yes | |
-| shader/storage_buffer | 60 | 0.999999 | 0 | 0 / 0 | 538 / 973 | 6 / 8 | 1 / 92 | 3.51 / 1.665 = 1.665 + 0 | yes | |
| shader/array_texture | 100 | 1.000000 | 0 | 0 / 0 | 458 / 542 | 6 / 8 | 1 / 12 | 3.291 / 1.574 = 1.574 + 0 | yes | |
| shader/array_texture | 30 | 1.000000 | 0 | 0 / 0 | 458 / 542 | 6 / 8 | 1 / 12 | 19.391 / 1.975 = 1.975 + 0 | yes | |
-| shader/sprite_material | 110 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.45 / 1.676 = 1.676 + 0 | yes | |
-| shader/sprite_material | 130 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.375 / 1.573 = 1.573 + 0 | yes | |
-| shader/sprite_material | 29 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 18.236 / 2.007 = 2.007 + 0 | yes | |
-| shader/sprite_material | 40 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 3.11 / 1.629 = 1.629 + 0 | yes | |
-| shader/sprite_material | 70 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.606 / 1.505 = 1.505 + 0 | yes | |
-| shader/sprite_material | 95 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.456 / 1.656 = 1.656 + 0 | yes | |
+| shader/storage_buffer | 30 | 0.999999 | 0 | 0 / 0 | 538 / 973 | 6 / 8 | 1 / 92 | 19.664 / 2.053 = 2.053 + 0 | yes | |
+| shader/storage_buffer | 60 | 0.999999 | 0 | 0 / 0 | 538 / 973 | 6 / 8 | 1 / 92 | 3.572 / 1.798 = 1.798 + 0 | yes | |
+| shader/sprite_material | 110 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.304 / 1.727 = 1.727 + 0 | yes | |
+| shader/sprite_material | 130 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.359 / 1.654 = 1.654 + 0 | yes | |
+| shader/sprite_material | 29 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 19.17 / 1.813 = 1.813 + 0 | yes | |
+| shader/sprite_material | 40 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.813 / 1.612 = 1.612 + 0 | yes | |
+| shader/sprite_material | 70 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.645 / 1.691 = 1.691 + 0 | yes | |
+| shader/sprite_material | 95 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.425 / 1.391 = 1.391 + 0 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index 085ed50c..10320133 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -178,13 +178,13 @@
{"example":"shader/shader_material_screenspace_texture","frame":60,"ssim":0.998929,"tile":2,"bevy":{"batch_keys":1,"entities":449,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":60,"frame_ms":3.42,"materials":2,"mesh_entities":2,"meshes":7,"other_material":1,"visible":2},"raea":{"frame":69,"entities":521,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":1,"other_material":1,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.81,"step_ms":null,"cost_ms":1.81},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/shader_material_2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":44.328,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":519,"mesh_entities":0,"visible":0,"meshes":8,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.569,"step_ms":null,"cost_ms":2.569},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/fallback_image","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":10,"frame_ms":46.39,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":17,"entities":519,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":2.292,"step_ms":null,"cost_ms":2.292},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/storage_buffer","frame":30,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":0,"entities":538,"extents":["0.1500 0.1500 0.1500"],"frame":30,"frame_ms":18.943,"materials":1,"mesh_entities":91,"meshes":6,"other_material":91,"visible":91},"raea":{"frame":37,"entities":973,"mesh_entities":91,"visible":91,"meshes":8,"materials":92,"batch_keys":0,"other_material":91,"extents":["0.1500 0.1500 0.1500"],"frame_ms":1.755,"step_ms":null,"cost_ms":1.755},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/storage_buffer","frame":60,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":0,"entities":538,"extents":["0.1500 0.1500 0.1500"],"frame":60,"frame_ms":3.51,"materials":1,"mesh_entities":91,"meshes":6,"other_material":91,"visible":91},"raea":{"frame":67,"entities":973,"mesh_entities":91,"visible":91,"meshes":8,"materials":92,"batch_keys":0,"other_material":91,"extents":["0.1500 0.1500 0.1500"],"frame_ms":1.665,"step_ms":null,"cost_ms":1.665},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/array_texture","frame":100,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":458,"extents":["0.5000 0.5000 0.5000"],"frame":100,"frame_ms":3.291,"materials":1,"mesh_entities":11,"meshes":6,"other_material":11,"visible":11},"raea":{"frame":109,"entities":542,"mesh_entities":11,"visible":11,"meshes":8,"materials":12,"batch_keys":0,"other_material":11,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.574,"step_ms":null,"cost_ms":1.574},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/array_texture","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":458,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":19.391,"materials":1,"mesh_entities":11,"meshes":6,"other_material":11,"visible":11},"raea":{"frame":39,"entities":542,"mesh_entities":11,"visible":11,"meshes":8,"materials":12,"batch_keys":0,"other_material":11,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.975,"step_ms":null,"cost_ms":1.975},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":110,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":110,"frame_ms":2.45,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":117,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.676,"step_ms":null,"cost_ms":1.676},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":130,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":130,"frame_ms":2.375,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":137,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.573,"step_ms":null,"cost_ms":1.573},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":29,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":29,"frame_ms":18.236,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":36,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.007,"step_ms":null,"cost_ms":2.007},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":40,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":40,"frame_ms":3.11,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":47,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.629,"step_ms":null,"cost_ms":1.629},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":70,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":70,"frame_ms":2.606,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":77,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.505,"step_ms":null,"cost_ms":1.505},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":95,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":95,"frame_ms":2.456,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":102,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.656,"step_ms":null,"cost_ms":1.656},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/storage_buffer","frame":30,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":0,"entities":538,"extents":["0.1500 0.1500 0.1500"],"frame":30,"frame_ms":19.664,"materials":1,"mesh_entities":91,"meshes":6,"other_material":91,"visible":91},"raea":{"frame":37,"entities":973,"mesh_entities":91,"visible":91,"meshes":8,"materials":92,"batch_keys":0,"other_material":91,"extents":["0.1500 0.1500 0.1500"],"frame_ms":2.053,"step_ms":null,"cost_ms":2.053},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/storage_buffer","frame":60,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":0,"entities":538,"extents":["0.1500 0.1500 0.1500"],"frame":60,"frame_ms":3.572,"materials":1,"mesh_entities":91,"meshes":6,"other_material":91,"visible":91},"raea":{"frame":67,"entities":973,"mesh_entities":91,"visible":91,"meshes":8,"materials":92,"batch_keys":0,"other_material":91,"extents":["0.1500 0.1500 0.1500"],"frame_ms":1.798,"step_ms":null,"cost_ms":1.798},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":110,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":110,"frame_ms":2.304,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":117,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.727,"step_ms":null,"cost_ms":1.727},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":130,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":130,"frame_ms":2.359,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":137,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.654,"step_ms":null,"cost_ms":1.654},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":29,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":29,"frame_ms":19.17,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":36,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.813,"step_ms":null,"cost_ms":1.813},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":40,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":40,"frame_ms":2.813,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":47,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.612,"step_ms":null,"cost_ms":1.612},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":70,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":70,"frame_ms":2.645,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":77,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.691,"step_ms":null,"cost_ms":1.691},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":95,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":95,"frame_ms":2.425,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":102,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.391,"step_ms":null,"cost_ms":1.391},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
diff --git a/systems/shader/src/own_live.rs b/systems/shader/src/own_live.rs
index 7b3bf55e..b78481ba 100644
--- a/systems/shader/src/own_live.rs
+++ b/systems/shader/src/own_live.rs
@@ -63,11 +63,16 @@ pub fn settle(world: &mut World, e: Entity) -> Result<(), String> {
}
}
+/// The part's own Material, if it holds it as `C` (a 3D, 2D or sprite's).
+fn handle<C: Component + std::ops::Deref<Target = Handle<OwnMaterial>>>(world: &World, e: Entity) -> Option<Handle<OwnMaterial>> {
+ world.get::<C>(e).map(|m| (**m).clone())
+}
+
/// An `own:uniforms` component row: the frame's {uniforms, buffers} packed into the part's own Material (3D, 2D or a
/// sprite's) and its storage buffers.
pub fn patch(world: &mut World, e: Entity, v: &Value) -> Result<(), String> {
- let h = world.get::<MeshMaterial3d<OwnMaterial>>(e).map(|m| m.0.clone());
- let h = h.or_else(|| world.get::<MeshMaterial2d<OwnMaterial>>(e).map(|m| m.0.clone())).or_else(|| world.get::<SpriteMaterial<OwnMaterial>>(e).map(|m| m.0.clone()));
+ let h = [handle::<MeshMaterial3d<OwnMaterial>>(world, e), handle::<MeshMaterial2d<OwnMaterial>>(world, e), handle::<SpriteMaterial<OwnMaterial>>(world, e)];
+ let h = h.into_iter().flatten().next();
// a row applied before the part's Material is put on (shade_rows runs after the rows): kept for `put`
let Some(h) = h else {
world.entity_mut(e).insert(Pending(v.clone()));