From f7b5f18b3f59d8152b53c5bcee3697a2e4e30b00 Mon Sep 17 00:00:00 2001 From: shinyobjectz Date: Sun, 8 Nov 2026 18:19:55 -0800 Subject: [PATCH] Bevy's own Text2d inside a Canvas3D and TextureAtlasBuilder; Bevy parity for 2d/text2d (exact), 2d/texture_atlas and 2d/rotation A inside a is now Bevy's Text2d (raea-sys-sprite text2d.rs, sent as a Shape2D row with its `text` spec): bevy_text lays it out and rasterises it and bevy_sprite_render orders it with the sprites by z, so TextBounds (`bounds`), FontSmoothing::None (`font_smoothing`), Text2dShadow (`shadow`), LineBreak, its s, a z under a sprite and a scaled quad's pixelated look are Bevy's. After the Canvas3D it is the page's Text, as before; the page refuses bounds, shadow and "None", which it can't draw. 2d/text2d is exact at frames 10 and 60 (SSIM 1.000000, tile 0); with FontSmoothing::None taken out it fails (tile 40, 5308 px off in that block). TextureAtlasBuilder (raea/sprite, raea/image): pictures packed by Bevy's own builder in the order added (padding, sampler), a sprite showing the whole atlas or one picture (sources.handle(texture), the row's atlas_pick, which sync_2d no longer resets to a sheet's cell). 2d/texture_atlas lists textures/rpg in load_folder's order and passes at 0.998551; its packed atlases match Bevy's. 2d/rotation: the port took the direction to the ship as -at, so the enemy straight above had x = -0 and copysign turned it the other way; player - enemy (0 - 0 = +0) as Bevy subtracts. Passes at 0.999751, its turning enemies within 8 grey of Bevy's at frames 10 and 60 (the bar alone passed a 10 degree a second error). All 2D ports and shader/pipeline_constants rerun: 155 ported, 155 passing. skills/ pins raea-skills f81678f (#9), whose generated sdk.md lists TextureAtlasBuilder. --- bench/bevy-parity/examples.list | 3 + bench/bevy-parity/runs.tsv | 3 + docs/bevy-parity.md | 58 +++-- docs/bevy-parity/results.jsonl | 56 +++-- runtime/look/src/parts.rs | 13 +- runtime/scene2d/src/lib.rs | 17 ++ sdk/raea/bench/bevy-parity/2d/2d_shapes.tsx | 3 +- sdk/raea/bench/bevy-parity/2d/rotation.tsx | 79 +++++++ sdk/raea/bench/bevy-parity/2d/text2d.tsx | 71 ++++++ .../bench/bevy-parity/2d/texture_atlas.tsx | 223 ++++++++++++++++++ sdk/raea/src/image.ts | 1 + sdk/raea/src/sprite.ts | 1 + sdk/render/src/3d/atlas.ts | 57 +++++ sdk/render/src/3d/sprite.tsx | 4 + sdk/render/src/bevy3d/text2d.tsx | 90 +++++++ sdk/render/src/bevy3d/ui.tsx | 26 +- skills | 2 +- systems/sprite/src/atlas.rs | 71 ++++++ systems/sprite/src/lib.rs | 23 +- systems/sprite/src/text2d.rs | 106 +++++++++ 20 files changed, 833 insertions(+), 74 deletions(-) create mode 100644 sdk/raea/bench/bevy-parity/2d/rotation.tsx create mode 100644 sdk/raea/bench/bevy-parity/2d/text2d.tsx create mode 100644 sdk/raea/bench/bevy-parity/2d/texture_atlas.tsx create mode 100644 sdk/render/src/3d/atlas.ts create mode 100644 sdk/render/src/bevy3d/text2d.tsx create mode 100644 systems/sprite/src/atlas.rs create mode 100644 systems/sprite/src/text2d.rs diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list index 952e2a78..0d42852c 100644 --- a/bench/bevy-parity/examples.list +++ b/bench/bevy-parity/examples.list @@ -152,3 +152,6 @@ shader_advanced/render_depth_to_texture shader_advanced/specialized_mesh_pipeline shader_advanced/texture_binding_array 2d/2d_shapes +2d/rotation +2d/text2d +2d/texture_atlas diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv index 7cd421b0..cd85ab98 100644 --- a/bench/bevy-parity/runs.tsv +++ b/bench/bevy-parity/runs.tsv @@ -151,3 +151,6 @@ shader_advanced/render_depth_to_texture - 5,10,30,60 shader_advanced/specialized_mesh_pipeline - 5,10 shader_advanced/texture_binding_array - 5,10 2d/2d_shapes - 5,10 +2d/rotation - 10,60 +2d/texture_atlas - 10,30 +2d/text2d - 10,60 diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md index 2c0ad37c..ba73a6ab 100644 --- a/docs/bevy-parity.md +++ b/docs/bevy-parity.md @@ -4,7 +4,7 @@ Bevy v0.20.0's examples against their raea TSX ports (docs/control.feature FC0a) don't edit. An example passes when every probed frame passes pixels (SSIM 0.98 and no 32 px tile off by more than 24 of 255) and cost (batch keys and frame time at most 1.25x the example's). Wall time is one machine's, measured in the same run. -Examples: **438**, ported **152**, passing **152**, excluded **17** (docs/bevy-parity/excluded.tsv), left **269**. +Examples: **438**, ported **155**, passing **155**, excluded **17** (docs/bevy-parity/excluded.tsv), left **266**. raea's frame ms is its update's plus the time React takes to step a frame for its 3D (step), which the example doesn't pay. @@ -30,14 +30,8 @@ doesn't pay. | 3d/orthographic | 10 | 0.999503 | 0 | 5 / 2 | 446 / 536 | 10 / 9 | 6 / 3 | 22.593 / 1.246 = 1.246 + 0 | yes | | | 3d/parenting | 30 | 0.999969 | 0 | 1 / 1 | 443 / 533 | 6 / 8 | 2 / 2 | 10.004 / 1.028 = 1.028 + 0 | yes | | | 3d/parenting | 60 | 0.999968 | 0 | 1 / 1 | 443 / 533 | 6 / 8 | 2 / 2 | 2.302 / 0.72 = 0.72 + 0 | yes | | -| 2d/mesh2d | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 6 / 8 | 1 / 1 | 22.081 / 1.376 = 1.376 + 0 | yes | | -| 2d/sprite | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 21.919 / 1.417 = 1.417 + 0 | yes | | | transforms/3d_rotation | 30 | 1.000000 | 0 | 1 / 1 | 442 / 532 | 6 / 8 | 2 / 2 | 9.171 / 0.812 = 0.812 + 0 | yes | | | transforms/3d_rotation | 60 | 1.000000 | 0 | 1 / 1 | 442 / 532 | 6 / 8 | 2 / 2 | 1.402 / 0.778 = 0.778 + 0 | yes | | -| 2d/sprite_flipping | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 22.732 / 1.354 = 1.354 + 0 | yes | | -| 2d/move_sprite | 120 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 1.013 / 0.826 = 0.826 + 0 | yes | | -| 2d/move_sprite | 30 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 9.027 / 0.869 = 0.869 + 0 | yes | | -| 2d/transparency_2d | 10 | 1.000000 | 0 | 0 / 0 | 443 / 533 | 5 / 7 | 1 / 1 | 36.512 / 2.591 = 2.591 + 0 | yes | | | transforms/translation | 180 | 1.000000 | 0 | 1 / 1 | 442 / 532 | 6 / 8 | 2 / 2 | 1.326 / 0.644 = 0.644 + 0 | yes | | | transforms/translation | 60 | 1.000000 | 0 | 1 / 1 | 442 / 532 | 6 / 8 | 2 / 2 | 6.107 / 1.282 = 1.282 + 0 | yes | | | transforms/scale | 300 | 1.000000 | 0 | 1 / 1 | 442 / 532 | 6 / 8 | 2 / 2 | 2.444 / 1.425 = 1.425 + 0 | yes | | @@ -45,8 +39,6 @@ doesn't pay. | 3d/texture | 10 | 0.999547 | 1 | 3 / 3 | 443 / 534 | 6 / 8 | 4 / 4 | 30.809 / 2.073 = 2.073 + 0 | yes | | | shader/animate_shader | 30 | 1.000000 | 0 | 0 / 0 | 447 / 534 | 6 / 8 | 1 / 2 | 11.925 / 1.499 = 1.499 + 0 | yes | | | shader/animate_shader | 60 | 1.000000 | 0 | 0 / 0 | 447 / 534 | 6 / 8 | 1 / 2 | 2.271 / 1.532 = 1.532 + 0 | yes | | -| 2d/sprite_sheet | 30 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 11.283 / 1.703 = 1.703 + 0 | yes | | -| 2d/sprite_sheet | 60 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 1.822 / 1.512 = 1.512 + 0 | yes | | | 3d/pbr | 30 | 0.997686 | 8 | 56 / 56 | 499 / 587 | 6 / 8 | 57 / 57 | 13.595 / 1.618 = 1.618 + 0 | yes | | | 3d/pbr | 60 | 0.997686 | 8 | 56 / 56 | 499 / 587 | 6 / 8 | 57 / 57 | 2.661 / 1.576 = 1.576 + 0 | yes | | | 3d/animated_material | 30 | 0.999898 | 0 | 9 / 9 | 449 / 539 | 6 / 8 | 10 / 19 | 13.456 / 1.416 = 1.416 + 0 | yes | | @@ -54,11 +46,6 @@ doesn't pay. | camera/pan_camera_controller | 10 | 0.998512 | 10 | 0 / 0 | 446 / 531 | 5 / 7 | 1 / 1 | 28.94 / 1.995 = 1.995 + 0 | yes | | | camera/camera_orbit | 10 | 0.999220 | 8 | 2 / 2 | 445 / 533 | 7 / 9 | 3 / 3 | 32.824 / 2.385 = 2.385 + 0 | yes | | | camera/projection_zoom | 30 | 0.998025 | 8 | 2 / 2 | 473 / 563 | 7 / 9 | 3 / 3 | 13.696 / 1.668 = 1.668 + 0 | yes | | -| 2d/sprite_animation | 12 | 0.999303 | 8 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 25.214 / 1.997 = 1.997 + 0 | yes | | -| 2d/sprite_animation | 30 | 0.999303 | 8 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 2.08 / 1.632 = 1.632 + 0 | yes | | -| 2d/sprite_animation | 60 | 0.999303 | 8 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 1.946 / 1.564 = 1.564 + 0 | yes | | -| 2d/sprite_tile | 30 | 1.000000 | 0 | 0 / 0 | 442 / 531 | 5 / 7 | 1 / 1 | 10.888 / 1.685 = 1.685 + 0 | yes | | -| 2d/sprite_tile | 300 | 1.000000 | 0 | 0 / 0 | 442 / 531 | 5 / 7 | 1 / 1 | 1.716 / 1.576 = 1.576 + 0 | yes | | | 3d/vertex_colors | 10 | 0.999019 | 0 | 2 / 2 | 443 / 533 | 7 / 9 | 3 / 3 | 34.667 / 2.826 = 2.826 + 0 | yes | | | 3d/spherical_area_lights | 10 | 0.999749 | 0 | 7 / 2 | 453 / 543 | 7 / 9 | 8 / 3 | 30.371 / 2.023 = 2.023 + 0 | yes | | | 3d/fog_volumes | 10 | 0.995718 | 14 | 0 / 0 | 442 / 531 | 5 / 7 | 1 / 1 | 30.049 / 2.6 = 2.6 + 0 | yes | | @@ -85,14 +72,10 @@ doesn't pay. | 3d/3d_viewport_to_world | 5 | 0.998921 | 1 | 1 / 1 | 442 / 532 | 6 / 8 | 2 / 2 | 40.172 / 2.923 = 2.923 + 0 | yes | | | 3d/atmospheric_fog | 10 | 0.998695 | 9 | 2 / 2 | 449 / 541 | 7 / 9 | 3 / 3 | 3.156 / 2.45 = 2.45 + 0 | yes | | | 3d/atmospheric_fog | 5 | 0.998695 | 9 | 2 / 2 | 449 / 541 | 7 / 9 | 3 / 3 | 43.278 / 2.962 = 2.962 + 0 | yes | | -| 2d/rotate_to_cursor | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 1.443 / 2.227 = 2.227 + 0 | yes | | -| 2d/rotate_to_cursor | 5 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 38.032 / 2.575 = 2.575 + 0 | yes | | | movement/smooth_follow | 120 | 0.998129 | 0 | 3 / 3 | 448 / 534 | 8 / 9 | 4 / 4 | 2.342 / 2.208 = 2.208 + 0 | yes | | | movement/smooth_follow | 30 | 0.998157 | 0 | 3 / 3 | 448 / 534 | 8 / 9 | 4 / 4 | 10.266 / 1.797 = 1.797 + 0 | yes | | | 3d/mesh_ray_cast | 300 | 0.999964 | 0 | 1 / 1 | 447 / 801 | 6 / 8 | 2 / 2 | 3.132 / 1.233 = 1.233 + 0 | yes | | | 3d/mesh_ray_cast | 900 | 0.999766 | 1 | 1 / 1 | 447 / 801 | 6 / 8 | 2 / 2 | 1.805 / 1.146 = 1.146 + 0 | yes | | -| 2d/mesh2d_alpha_mode | 10 | 1.000000 | 0 | 0 / 0 | 446 / 536 | 6 / 13 | 1 / 1 | 1.676 / 1.503 = 1.503 + 0 | yes | | -| 2d/mesh2d_alpha_mode | 5 | 1.000000 | 0 | 0 / 0 | 446 / 536 | 6 / 13 | 1 / 1 | 34.099 / 2.352 = 2.352 + 0 | yes | | | 3d/lightmaps | 10 | 1.000000 | 0 | 6 / 6 | 453 / 543 | 11 / 13 | 6 / 10 | 2.099 / 2.391 = 2.391 + 0 | yes | | | 3d/lightmaps | 5 | 1.000000 | 0 | 6 / 6 | 453 / 543 | 11 / 13 | 6 / 10 | 42.641 / 2.697 = 2.697 + 0 | yes | | | ui/styling/transparency_ui | 10 | 0.999725 | 3 | 0 / 0 | 445 / 529 | 5 / 7 | 1 / 1 | 1.536 / 0.803 = 0.803 + 0 | yes | | @@ -113,8 +96,6 @@ doesn't pay. | ui/scroll_and_overflow/overflow | 5 | 0.998778 | 4 | 0 / 0 | 461 / 529 | 5 / 7 | 1 / 1 | 38.475 / 2.342 = 2.342 + 0 | yes | | | ui/images/ui_texture_atlas | 10 | 0.999781 | 5 | 0 / 0 | 445 / 529 | 5 / 7 | 1 / 1 | 1.724 / 1.193 = 1.193 + 0 | yes | | | ui/images/ui_texture_atlas | 5 | 0.999781 | 5 | 0 / 0 | 445 / 529 | 5 / 7 | 1 / 1 | 39.872 / 2.759 = 2.759 + 0 | yes | | -| 2d/mesh2d_vertex_color_texture | 10 | 1.000000 | 0 | 0 / 0 | 442 / 532 | 6 / 9 | 1 / 1 | 24.26 / 1.537 = 1.537 + 0 | yes | | -| 2d/mesh2d_repeated_texture | 10 | 0.999749 | 6 | 0 / 0 | 437 / 533 | 8 / 10 | 1 / 1 | 14.693 / 1.619 = 1.619 + 0 | yes | | | ui/layout/flex_layout | 10 | 0.992175 | 8 | 0 / 0 | 602 / 529 | 5 / 7 | 1 / 1 | 22.579 / 1.108 = 1.108 + 0 | yes | | | ui/scroll_and_overflow/overflow_clip_margin | 10 | 0.997330 | 7 | 0 / 0 | 465 / 529 | 5 / 7 | 1 / 1 | 21.59 / 0.867 = 0.867 + 0 | yes | | | ui/images/ui_texture_slice | 10 | 0.998933 | 8 | 0 / 0 | 447 / 529 | 5 / 7 | 1 / 1 | 21.761 / 0.952 = 0.952 + 0 | yes | | @@ -184,9 +165,6 @@ doesn't pay. | 3d/fog | 120 | 0.996932 | 8 | 56 / 53 | 498 / 588 | 61 / 60 | 4 / 4 | 3.061 / 2.105 = 2.105 + 0 | yes | | | 3d/3d_shapes | 10 | 0.998884 | 8 | 27 / 27 | 478 / 611 | 32 / 34 | 3 / 28 | 28.266 / 2.438 = 2.438 + 0 | yes | | | 3d/3d_shapes | 120 | 0.998883 | 8 | 27 / 27 | 478 / 611 | 32 / 34 | 3 / 28 | 2.935 / 1.717 = 1.717 + 0 | yes | | -| 2d/sprite_scale | 10 | 0.992293 | 11 | 0 / 0 | 486 / 553 | 5 / 7 | 1 / 1 | 21.618 / 1.53 = 1.53 + 0 | yes | | -| 2d/sprite_scale | 60 | 0.992293 | 11 | 0 / 0 | 486 / 553 | 5 / 7 | 1 / 1 | 1.368 / 1.296 = 1.296 + 0 | yes | | -| 2d/sprite_slice | 10 | 0.997293 | 11 | 0 / 0 | 464 / 542 | 5 / 7 | 1 / 1 | 21.287 / 1.576 = 1.576 + 0 | yes | | | shader/shader_material | 30 | 1.000000 | 0 | 0 / 0 | 447 / 534 | 6 / 8 | 1 / 2 | 8.624 / 0.894 = 0.894 + 0 | yes | | | shader/shader_defs | 10 | 1.000000 | 0 | 0 / 0 | 448 / 535 | 7 / 8 | 1 / 3 | 21.776 / 0.953 = 0.953 + 0 | yes | | | shader/shader_material_screenspace_texture | 10 | 0.999172 | 0 | 1 / 1 | 449 / 536 | 7 / 9 | 2 / 3 | 24.327 / 1.722 = 1.722 + 0 | yes | | @@ -211,7 +189,6 @@ doesn't pay. | shader/shader_material_2d_bindless | 10 | 1.000000 | 0 | 0 / 0 | 450 / 536 | 6 / 11 | 1 / 1 | 20.677 / 1.258 = 1.258 + 0 | yes | | | shader/extended_material_bindless | 30 | 1.000000 | 0 | 0 / 0 | 448 / 532 | 6 / 8 | 1 / 2 | 9.535 / 0.67 = 0.67 + 0 | yes | | | shader/extended_material_bindless | 60 | 1.000000 | 0 | 0 / 0 | 448 / 532 | 6 / 8 | 1 / 2 | 1.51 / 0.598 = 0.598 + 0 | yes | | -| shader/pipeline_constants | 10 | 0.999666 | 2 | 0 / 0 | 452 / 535 | 6 / 10 | 1 / 1 | 28.905 / 1.194 = 1.194 + 0 | yes | | | shader/compute_shader_game_of_life | 10 | 1.000000 | 0 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 21.694 / 2.024 = 1.751 + 0.273 | yes | | | shader/compute_shader_game_of_life | 11 | 1.000000 | 0 | 0 / 0 | 445 / 532 | 5 / 7 | 1 / 1 | 1.418 / 1.915 = 1.682 + 0.233 | yes | | | shader/compute_shader_game_of_life | 30 | 1.000000 | 0 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 1.361 / 0.958 = 0.787 + 0.171 | yes | | @@ -257,8 +234,37 @@ doesn't pay. | shader_advanced/specialized_mesh_pipeline | 5 | 1.000000 | 0 | 0 / 0 | 445 / 538 | 9 / 9 | 1 / 1 | 39.37 / 2.608 = 2.608 + 0 | yes | | | shader_advanced/texture_binding_array | 10 | 1.000000 | 0 | 0 / 0 | 447 / 535 | 6 / 8 | 1 / 2 | 1.886 / 1.076 = 1.076 + 0 | yes | | | shader_advanced/texture_binding_array | 5 | 1.000000 | 0 | 0 / 0 | 447 / 535 | 6 / 8 | 1 / 2 | 37.298 / 2.566 = 2.566 + 0 | yes | | -| 2d/2d_shapes | 10 | 0.999866 | 6 | 0 / 0 | 530 / 552 | 27 / 29 | 1 / 1 | 1.786 / 1.512 = 1.512 + 0 | yes | | -| 2d/2d_shapes | 5 | 0.999866 | 6 | 0 / 0 | 530 / 552 | 27 / 29 | 1 / 1 | 40.538 / 2.501 = 2.501 + 0 | yes | | +| 2d/mesh2d | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 6 / 8 | 1 / 1 | 26.165 / 1.485 = 1.485 + 0 | yes | | +| 2d/sprite | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 28.313 / 2.447 = 2.447 + 0 | yes | | +| 2d/sprite_flipping | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 27.5 / 1.78 = 1.78 + 0 | yes | | +| 2d/move_sprite | 120 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 1.608 / 1.381 = 1.381 + 0 | yes | | +| 2d/move_sprite | 30 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 10.167 / 1.189 = 1.189 + 0 | yes | | +| 2d/transparency_2d | 10 | 1.000000 | 0 | 0 / 0 | 443 / 533 | 5 / 7 | 1 / 1 | 29.403 / 2.851 = 2.851 + 0 | yes | | +| 2d/sprite_sheet | 30 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 10.381 / 1.563 = 1.563 + 0 | yes | | +| 2d/sprite_sheet | 60 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 2.017 / 1.456 = 1.456 + 0 | yes | | +| 2d/sprite_animation | 12 | 0.999303 | 8 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 23.043 / 1.61 = 1.61 + 0 | yes | | +| 2d/sprite_animation | 30 | 0.999303 | 8 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 1.849 / 1.355 = 1.355 + 0 | yes | | +| 2d/sprite_animation | 60 | 0.999303 | 8 | 0 / 0 | 443 / 532 | 5 / 7 | 1 / 1 | 1.706 / 0.77 = 0.77 + 0 | yes | | +| 2d/sprite_tile | 30 | 1.000000 | 0 | 0 / 0 | 442 / 531 | 5 / 7 | 1 / 1 | 8.954 / 1.457 = 1.457 + 0 | yes | | +| 2d/sprite_tile | 300 | 1.000000 | 0 | 0 / 0 | 442 / 531 | 5 / 7 | 1 / 1 | 1.324 / 0.888 = 0.888 + 0 | yes | | +| 2d/rotate_to_cursor | 10 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 2.089 / 1.476 = 1.476 + 0 | yes | | +| 2d/rotate_to_cursor | 5 | 1.000000 | 0 | 0 / 0 | 441 / 531 | 5 / 7 | 1 / 1 | 43.695 / 2.517 = 2.517 + 0 | yes | | +| 2d/mesh2d_alpha_mode | 10 | 1.000000 | 0 | 0 / 0 | 446 / 536 | 6 / 13 | 1 / 1 | 2.964 / 2.391 = 2.391 + 0 | yes | | +| 2d/mesh2d_alpha_mode | 5 | 1.000000 | 0 | 0 / 0 | 446 / 536 | 6 / 13 | 1 / 1 | 45.605 / 3.875 = 3.875 + 0 | yes | | +| 2d/mesh2d_vertex_color_texture | 10 | 1.000000 | 0 | 0 / 0 | 442 / 532 | 6 / 9 | 1 / 1 | 25.697 / 2.621 = 2.621 + 0 | yes | | +| 2d/mesh2d_repeated_texture | 10 | 0.999749 | 6 | 0 / 0 | 437 / 533 | 8 / 10 | 1 / 1 | 18.705 / 1.848 = 1.848 + 0 | yes | | +| 2d/sprite_scale | 10 | 0.992293 | 11 | 0 / 0 | 486 / 553 | 5 / 7 | 1 / 1 | 24.227 / 1.982 = 1.982 + 0 | yes | | +| 2d/sprite_scale | 60 | 0.992293 | 11 | 0 / 0 | 486 / 553 | 5 / 7 | 1 / 1 | 1.751 / 1.391 = 1.391 + 0 | yes | | +| 2d/sprite_slice | 10 | 0.997293 | 11 | 0 / 0 | 464 / 542 | 5 / 7 | 1 / 1 | 24.925 / 1.495 = 1.495 + 0 | yes | | +| shader/pipeline_constants | 10 | 0.999666 | 2 | 0 / 0 | 452 / 535 | 6 / 10 | 1 / 1 | 26.406 / 1.819 = 1.819 + 0 | yes | | +| 2d/2d_shapes | 10 | 0.999866 | 6 | 0 / 0 | 530 / 552 | 27 / 29 | 1 / 1 | 2.158 / 1.279 = 1.279 + 0 | yes | | +| 2d/2d_shapes | 5 | 0.999866 | 6 | 0 / 0 | 530 / 552 | 27 / 29 | 1 / 1 | 55.532 / 2.607 = 2.607 + 0 | yes | | +| 2d/rotation | 10 | 0.999751 | 5 | 0 / 0 | 446 / 535 | 5 / 7 | 1 / 1 | 21.618 / 1.46 = 1.46 + 0 | yes | | +| 2d/rotation | 60 | 0.999751 | 5 | 0 / 0 | 446 / 535 | 5 / 7 | 1 / 1 | 1.053 / 0.712 = 0.712 + 0 | yes | | +| 2d/text2d | 10 | 1.000000 | 0 | 0 / 0 | 461 / 552 | 5 / 10 | 1 / 1 | 20.82 / 1.394 = 1.394 + 0 | yes | | +| 2d/text2d | 60 | 1.000000 | 0 | 0 / 0 | 461 / 552 | 5 / 10 | 1 / 1 | 1.055 / 0.751 = 0.751 + 0 | yes | | +| 2d/texture_atlas | 10 | 0.998551 | 14 | 0 / 0 | 457 / 544 | 5 / 7 | 1 / 1 | 27.71 / 1.438 = 1.438 + 0 | yes | | +| 2d/texture_atlas | 30 | 0.998551 | 14 | 0 / 0 | 457 / 544 | 5 / 7 | 1 / 1 | 1.238 / 1.969 = 1.969 + 0 | yes | | ## Excluded diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl index 43cfadff..060a7ee9 100644 --- a/docs/bevy-parity/results.jsonl +++ b/docs/bevy-parity/results.jsonl @@ -17,14 +17,8 @@ {"example":"3d/orthographic","frame":10,"ssim":0.999503,"tile":0,"bevy":{"batch_keys":5,"entities":446,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":22.593,"materials":6,"mesh_entities":5,"meshes":10,"other_material":0,"visible":5},"raea":{"frame":17,"entities":536,"mesh_entities":5,"visible":5,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":1.246,"step_ms":null,"cost_ms":1.246},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/parenting","frame":30,"ssim":0.999969,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["1.0000 1.0000 1.0000"],"frame":30,"frame_ms":10.004,"materials":2,"mesh_entities":2,"meshes":6,"other_material":0,"visible":2},"raea":{"frame":37,"entities":533,"mesh_entities":2,"visible":2,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["1.0000 1.0000 1.0000"],"frame_ms":1.028,"step_ms":null,"cost_ms":1.028},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/parenting","frame":60,"ssim":0.999968,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["1.0000 1.0000 1.0000"],"frame":60,"frame_ms":2.302,"materials":2,"mesh_entities":2,"meshes":6,"other_material":0,"visible":2},"raea":{"frame":67,"entities":533,"mesh_entities":2,"visible":2,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.72,"step_ms":null,"cost_ms":0.72},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/mesh2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":22.081,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":8,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.376,"step_ms":null,"cost_ms":1.376},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":21.919,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.417,"step_ms":null,"cost_ms":1.417},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"transforms/3d_rotation","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":9.171,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":37,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.812,"step_ms":null,"cost_ms":0.812},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"transforms/3d_rotation","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":1.402,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.778,"step_ms":null,"cost_ms":0.778},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_flipping","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":22.732,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.354,"step_ms":null,"cost_ms":1.354},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/move_sprite","frame":120,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":120,"frame_ms":1.013,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":127,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.826,"step_ms":null,"cost_ms":0.826},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/move_sprite","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":9.027,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.869,"step_ms":null,"cost_ms":0.869},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/transparency_2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":10,"frame_ms":36.512,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":533,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.591,"step_ms":null,"cost_ms":2.591},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"transforms/translation","frame":180,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":180,"frame_ms":1.326,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":187,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.644,"step_ms":null,"cost_ms":0.644},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"transforms/translation","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":6.107,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.282,"step_ms":null,"cost_ms":1.282},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"transforms/scale","frame":300,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":1,"entities":442,"extents":["0.5000 0.5000 0.5000"],"frame":300,"frame_ms":2.444,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":307,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.425,"step_ms":null,"cost_ms":1.425},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -32,8 +26,6 @@ {"example":"3d/texture","frame":10,"ssim":0.999547,"tile":1,"bevy":{"batch_keys":3,"entities":443,"extents":["4.0000 1.0000 0.0000"],"frame":10,"frame_ms":30.809,"materials":4,"mesh_entities":3,"meshes":6,"other_material":0,"visible":3},"raea":{"frame":17,"entities":534,"mesh_entities":3,"visible":3,"meshes":8,"materials":4,"batch_keys":3,"other_material":0,"extents":["4.0000 0.0000 1.0000"],"frame_ms":2.073,"step_ms":null,"cost_ms":2.073},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/animate_shader","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":11.925,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":37,"entities":534,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.499,"step_ms":null,"cost_ms":1.499},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/animate_shader","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":2.271,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":67,"entities":534,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.532,"step_ms":null,"cost_ms":1.532},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_sheet","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":11.283,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.703,"step_ms":null,"cost_ms":1.703},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_sheet","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":60,"frame_ms":1.822,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.512,"step_ms":null,"cost_ms":1.512},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/pbr","frame":30,"ssim":0.997686,"tile":8,"bevy":{"batch_keys":56,"entities":499,"extents":["0.4475 0.4500 0.4500"],"frame":30,"frame_ms":13.595,"materials":57,"mesh_entities":56,"meshes":6,"other_material":0,"visible":56},"raea":{"frame":37,"entities":587,"mesh_entities":56,"visible":56,"meshes":8,"materials":57,"batch_keys":56,"other_material":0,"extents":["0.4475 0.4500 0.4500"],"frame_ms":1.618,"step_ms":null,"cost_ms":1.618},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/pbr","frame":60,"ssim":0.997686,"tile":8,"bevy":{"batch_keys":56,"entities":499,"extents":["0.4475 0.4500 0.4500"],"frame":60,"frame_ms":2.661,"materials":57,"mesh_entities":56,"meshes":6,"other_material":0,"visible":56},"raea":{"frame":67,"entities":587,"mesh_entities":56,"visible":56,"meshes":8,"materials":57,"batch_keys":56,"other_material":0,"extents":["0.4475 0.4500 0.4500"],"frame_ms":1.576,"step_ms":null,"cost_ms":1.576},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/animated_material","frame":30,"ssim":0.999898,"tile":0,"bevy":{"batch_keys":9,"entities":449,"extents":["0.2500 0.2500 0.2500"],"frame":30,"frame_ms":13.456,"materials":10,"mesh_entities":9,"meshes":6,"other_material":0,"visible":9},"raea":{"frame":37,"entities":539,"mesh_entities":9,"visible":9,"meshes":8,"materials":19,"batch_keys":9,"other_material":0,"extents":["0.2500 0.2500 0.2500"],"frame_ms":1.416,"step_ms":null,"cost_ms":1.416},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -41,11 +33,6 @@ {"example":"camera/pan_camera_controller","frame":10,"ssim":0.998512,"tile":10,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":28.94,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.995,"step_ms":null,"cost_ms":1.995},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"camera/camera_orbit","frame":10,"ssim":0.999220,"tile":8,"bevy":{"batch_keys":2,"entities":445,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":32.824,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":533,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":2.385,"step_ms":null,"cost_ms":2.385},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"camera/projection_zoom","frame":30,"ssim":0.998025,"tile":8,"bevy":{"batch_keys":2,"entities":473,"extents":["12.5927 39.5145 77.3599","2.5000 0.0000 2.5000"],"frame":30,"frame_ms":13.696,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":41,"entities":563,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["12.5927 39.5145 77.3599","2.5000 0.0000 2.5000"],"frame_ms":1.668,"step_ms":null,"cost_ms":1.668},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_animation","frame":12,"ssim":0.999303,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":12,"frame_ms":25.214,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":19,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.997,"step_ms":null,"cost_ms":1.997},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_animation","frame":30,"ssim":0.999303,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":30,"frame_ms":2.08,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.632,"step_ms":null,"cost_ms":1.632},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_animation","frame":60,"ssim":0.999303,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":60,"frame_ms":1.946,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.564,"step_ms":null,"cost_ms":1.564},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_tile","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":30,"frame_ms":10.888,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.685,"step_ms":null,"cost_ms":1.685},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_tile","frame":300,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":300,"frame_ms":1.716,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":307,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.576,"step_ms":null,"cost_ms":1.576},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/vertex_colors","frame":10,"ssim":0.999019,"tile":0,"bevy":{"batch_keys":2,"entities":443,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":34.667,"materials":3,"mesh_entities":2,"meshes":7,"other_material":0,"visible":2},"raea":{"frame":17,"entities":533,"mesh_entities":2,"visible":2,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame_ms":2.826,"step_ms":null,"cost_ms":2.826},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/spherical_area_lights","frame":10,"ssim":0.999749,"tile":0,"bevy":{"batch_keys":7,"entities":453,"extents":["1.0000 1.0000 1.0000","50.0000 0.0000 50.0000"],"frame":10,"frame_ms":30.371,"materials":8,"mesh_entities":7,"meshes":7,"other_material":0,"visible":7},"raea":{"frame":17,"entities":543,"mesh_entities":7,"visible":7,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 1.0000 1.0000","50.0000 0.0000 50.0000"],"frame_ms":2.023,"step_ms":null,"cost_ms":2.023},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/fog_volumes","frame":10,"ssim":0.995718,"tile":14,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":30.049,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.6,"step_ms":null,"cost_ms":2.6},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -72,14 +59,10 @@ {"example":"3d/3d_viewport_to_world","frame":5,"ssim":0.998921,"tile":1,"bevy":{"batch_keys":1,"entities":442,"extents":["10.0000 0.0000 10.0000"],"frame":5,"frame_ms":40.172,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":12,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["10.0000 0.0000 10.0000"],"frame_ms":2.923,"step_ms":null,"cost_ms":2.923},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/atmospheric_fog","frame":10,"ssim":0.998695,"tile":9,"bevy":{"batch_keys":2,"entities":449,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame":10,"frame_ms":3.156,"materials":3,"mesh_entities":3,"meshes":7,"other_material":0,"visible":3},"raea":{"frame":20,"entities":541,"mesh_entities":3,"visible":3,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame_ms":2.45,"step_ms":null,"cost_ms":2.45},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/atmospheric_fog","frame":5,"ssim":0.998695,"tile":9,"bevy":{"batch_keys":2,"entities":449,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame":5,"frame_ms":43.278,"materials":3,"mesh_entities":3,"meshes":7,"other_material":0,"visible":3},"raea":{"frame":15,"entities":541,"mesh_entities":3,"visible":3,"meshes":9,"materials":3,"batch_keys":2,"other_material":0,"extents":["1.0000 0.1674 1.0026","1.0000 0.5000 0.5000"],"frame_ms":2.962,"step_ms":null,"cost_ms":2.962},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/rotate_to_cursor","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":1.443,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.227,"step_ms":null,"cost_ms":2.227},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/rotate_to_cursor","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":5,"frame_ms":38.032,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.575,"step_ms":null,"cost_ms":2.575},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"movement/smooth_follow","frame":120,"ssim":0.998129,"tile":0,"bevy":{"batch_keys":3,"entities":448,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame":120,"frame_ms":2.342,"materials":4,"mesh_entities":3,"meshes":8,"other_material":0,"visible":3},"raea":{"frame":127,"entities":534,"mesh_entities":3,"visible":3,"meshes":9,"materials":4,"batch_keys":3,"other_material":0,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame_ms":2.208,"step_ms":null,"cost_ms":2.208},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"movement/smooth_follow","frame":30,"ssim":0.998157,"tile":0,"bevy":{"batch_keys":3,"entities":448,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame":30,"frame_ms":10.266,"materials":4,"mesh_entities":3,"meshes":8,"other_material":0,"visible":3},"raea":{"frame":37,"entities":534,"mesh_entities":3,"visible":3,"meshes":9,"materials":4,"batch_keys":3,"other_material":0,"extents":["0.2983 0.3000 0.3000","6.0000 0.0000 6.0000"],"frame_ms":1.797,"step_ms":null,"cost_ms":1.797},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/mesh_ray_cast","frame":300,"ssim":0.999964,"tile":0,"bevy":{"batch_keys":1,"entities":447,"extents":["0.5000 0.0000 0.5000"],"frame":300,"frame_ms":3.132,"materials":2,"mesh_entities":6,"meshes":6,"other_material":0,"visible":6},"raea":{"frame":307,"entities":801,"mesh_entities":6,"visible":6,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.0000 0.5000"],"frame_ms":1.233,"step_ms":null,"cost_ms":1.233},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/mesh_ray_cast","frame":900,"ssim":0.999766,"tile":1,"bevy":{"batch_keys":1,"entities":447,"extents":["0.5000 0.0000 0.5000"],"frame":900,"frame_ms":1.805,"materials":2,"mesh_entities":6,"meshes":6,"other_material":0,"visible":6},"raea":{"frame":907,"entities":801,"mesh_entities":6,"visible":6,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.0000 0.5000"],"frame_ms":1.146,"step_ms":null,"cost_ms":1.146},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/mesh2d_alpha_mode","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":1.676,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":536,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.503,"step_ms":null,"cost_ms":1.503},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/mesh2d_alpha_mode","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":5,"frame_ms":34.099,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":12,"entities":536,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.352,"step_ms":null,"cost_ms":2.352},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/lightmaps","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":6,"entities":453,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame":10,"frame_ms":2.099,"materials":6,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":20,"entities":543,"mesh_entities":6,"visible":6,"meshes":13,"materials":10,"batch_keys":6,"other_material":0,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame_ms":2.391,"step_ms":null,"cost_ms":2.391},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/lightmaps","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":6,"entities":453,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame":5,"frame_ms":42.641,"materials":6,"mesh_entities":6,"meshes":11,"other_material":0,"visible":6},"raea":{"frame":15,"entities":543,"mesh_entities":6,"visible":6,"meshes":13,"materials":10,"batch_keys":6,"other_material":0,"extents":["0.0001 274.4000 279.6000","102.6464 82.5000 102.6464","103.2390 165.0000 103.2390","278.0000 274.4000 279.6001","3.2000 274.4000 279.6000","65.0000 0.0000 52.5000"],"frame_ms":2.697,"step_ms":null,"cost_ms":2.697},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"ui/styling/transparency_ui","frame":10,"ssim":0.999725,"tile":3,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":10,"frame_ms":1.536,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.803,"step_ms":null,"cost_ms":0.803},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -100,8 +83,6 @@ {"example":"ui/scroll_and_overflow/overflow","frame":5,"ssim":0.998778,"tile":4,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":5,"frame_ms":38.475,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.342,"step_ms":null,"cost_ms":2.342},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"ui/images/ui_texture_atlas","frame":10,"ssim":0.999781,"tile":5,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":10,"frame_ms":1.724,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.193,"step_ms":null,"cost_ms":1.193},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"ui/images/ui_texture_atlas","frame":5,"ssim":0.999781,"tile":5,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":5,"frame_ms":39.872,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.759,"step_ms":null,"cost_ms":2.759},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/mesh2d_vertex_color_texture","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":24.26,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":532,"mesh_entities":0,"visible":0,"meshes":9,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.537,"step_ms":null,"cost_ms":1.537},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/mesh2d_repeated_texture","frame":10,"ssim":0.999749,"tile":6,"bevy":{"batch_keys":0,"entities":437,"extents":[],"frame":10,"frame_ms":14.693,"materials":1,"mesh_entities":0,"meshes":8,"other_material":0,"visible":0},"raea":{"frame":17,"entities":533,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.619,"step_ms":null,"cost_ms":1.619},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"ui/layout/flex_layout","frame":10,"ssim":0.992175,"tile":8,"bevy":{"batch_keys":0,"entities":602,"extents":[],"frame":10,"frame_ms":22.579,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.108,"step_ms":null,"cost_ms":1.108},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"ui/scroll_and_overflow/overflow_clip_margin","frame":10,"ssim":0.997330,"tile":7,"bevy":{"batch_keys":0,"entities":465,"extents":[],"frame":10,"frame_ms":21.59,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.867,"step_ms":null,"cost_ms":0.867},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"ui/images/ui_texture_slice","frame":10,"ssim":0.998933,"tile":8,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":21.761,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":529,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.952,"step_ms":null,"cost_ms":0.952},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -171,9 +152,6 @@ {"example":"3d/fog","frame":120,"ssim":0.996932,"tile":8,"bevy":{"batch_keys":56,"entities":498,"extents":["0.5000 1.5000 0.5000","3.0000 0.2500 3.0000","3.5000 0.2500 3.5000","4.0000 0.2500 4.0000","4.5000 0.2500 4.5000","5.0000 0.2500 5.0000","5.5000 0.2500 5.5000","6.0000 0.2500 6.0000"],"frame":120,"frame_ms":3.061,"materials":4,"mesh_entities":56,"meshes":61,"other_material":0,"visible":56},"raea":{"frame":127,"entities":588,"mesh_entities":56,"visible":56,"meshes":60,"materials":4,"batch_keys":53,"other_material":0,"extents":["0.4972 0.5000 0.5000","0.5000 1.5000 0.5000","3.0000 0.2500 3.0000","3.5000 0.2500 3.5000","4.0000 0.2500 4.0000","4.5000 0.2500 4.5000","5.0000 0.2500 5.0000","5.5000 0.2500 5.5000"],"frame_ms":2.105,"step_ms":null,"cost_ms":2.105},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/3d_shapes","frame":10,"ssim":0.998884,"tile":8,"bevy":{"batch_keys":27,"entities":478,"extents":["0.4972 0.5000 0.5000","0.5000 0.0000 0.0000","0.5000 0.2500 0.0000","0.5000 0.2500 0.5000","0.5000 0.5000 0.5000","0.5000 1.0000 0.5000","1.0000 0.2500 1.0000","25.0000 0.0000 25.0000"],"frame":10,"frame_ms":28.266,"materials":3,"mesh_entities":27,"meshes":32,"other_material":0,"visible":27},"raea":{"frame":17,"entities":611,"mesh_entities":27,"visible":27,"meshes":34,"materials":28,"batch_keys":27,"other_material":0,"extents":["0.4972 0.5000 0.5000","0.4976 0.9976 0.5000","0.5000 0.0000 0.0000","0.5000 0.2500 0.0000","0.5000 0.2500 0.5000","0.5000 0.5000 0.5000","0.5000 1.0000 0.5000","1.0000 0.2500 1.0000"],"frame_ms":2.438,"step_ms":null,"cost_ms":2.438},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"3d/3d_shapes","frame":120,"ssim":0.998883,"tile":8,"bevy":{"batch_keys":27,"entities":478,"extents":["0.4972 0.5000 0.5000","0.5000 0.0000 0.0000","0.5000 0.2500 0.0000","0.5000 0.2500 0.5000","0.5000 0.5000 0.5000","0.5000 1.0000 0.5000","1.0000 0.2500 1.0000","25.0000 0.0000 25.0000"],"frame":120,"frame_ms":2.935,"materials":3,"mesh_entities":27,"meshes":32,"other_material":0,"visible":27},"raea":{"frame":127,"entities":611,"mesh_entities":27,"visible":27,"meshes":34,"materials":28,"batch_keys":27,"other_material":0,"extents":["0.4972 0.5000 0.5000","0.4976 0.9976 0.5000","0.5000 0.0000 0.0000","0.5000 0.2500 0.0000","0.5000 0.2500 0.5000","0.5000 0.5000 0.5000","0.5000 1.0000 0.5000","1.0000 0.2500 1.0000"],"frame_ms":1.717,"step_ms":null,"cost_ms":1.717},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_scale","frame":10,"ssim":0.992293,"tile":11,"bevy":{"batch_keys":0,"entities":486,"extents":[],"frame":10,"frame_ms":21.618,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":553,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.53,"step_ms":null,"cost_ms":1.53},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_scale","frame":60,"ssim":0.992293,"tile":11,"bevy":{"batch_keys":0,"entities":486,"extents":[],"frame":60,"frame_ms":1.368,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":553,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.296,"step_ms":null,"cost_ms":1.296},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/sprite_slice","frame":10,"ssim":0.997293,"tile":11,"bevy":{"batch_keys":0,"entities":464,"extents":[],"frame":10,"frame_ms":21.287,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":542,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.576,"step_ms":null,"cost_ms":1.576},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/shader_material","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":8.624,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":38,"entities":534,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.894,"step_ms":null,"cost_ms":0.894},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/shader_defs","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["0.5000 0.5000 0.5000"],"frame":10,"frame_ms":21.776,"materials":1,"mesh_entities":2,"meshes":7,"other_material":2,"visible":2},"raea":{"frame":17,"entities":535,"mesh_entities":2,"visible":2,"meshes":8,"materials":3,"batch_keys":0,"other_material":2,"extents":["0.5000 0.5000 0.5000"],"frame_ms":0.953,"step_ms":null,"cost_ms":0.953},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/shader_material_screenspace_texture","frame":10,"ssim":0.999172,"tile":0,"bevy":{"batch_keys":1,"entities":449,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":24.327,"materials":2,"mesh_entities":2,"meshes":7,"other_material":1,"visible":2},"raea":{"frame":18,"entities":536,"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.722,"step_ms":null,"cost_ms":1.722},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -198,7 +176,6 @@ {"example":"shader/shader_material_2d_bindless","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":450,"extents":[],"frame":10,"frame_ms":20.677,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":536,"mesh_entities":0,"visible":0,"meshes":11,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.258,"step_ms":null,"cost_ms":1.258},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/extended_material_bindless","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["1.0000 1.0000 1.0000"],"frame":30,"frame_ms":9.535,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":39,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.67,"step_ms":null,"cost_ms":0.67},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/extended_material_bindless","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":448,"extents":["1.0000 1.0000 1.0000"],"frame":60,"frame_ms":1.51,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":69,"entities":532,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["1.0000 1.0000 1.0000"],"frame_ms":0.598,"step_ms":null,"cost_ms":0.598},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"shader/pipeline_constants","frame":10,"ssim":0.999666,"tile":2,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":10,"frame_ms":28.905,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":535,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.194,"step_ms":null,"cost_ms":1.194},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/compute_shader_game_of_life","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":10,"frame_ms":21.694,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.751,"step_ms":0.273,"cost_ms":2.024},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/compute_shader_game_of_life","frame":11,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":445,"extents":[],"frame":11,"frame_ms":1.418,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":18,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.682,"step_ms":0.233,"cost_ms":1.915},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader/compute_shader_game_of_life","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":30,"frame_ms":1.361,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.787,"step_ms":0.171,"cost_ms":0.958},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} @@ -244,5 +221,34 @@ {"example":"shader_advanced/specialized_mesh_pipeline","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":445,"extents":["0.2500 0.2500 0.0000","0.5000 0.3750 0.0000"],"frame":5,"frame_ms":39.37,"materials":1,"mesh_entities":4,"meshes":9,"other_material":4,"visible":4},"raea":{"frame":12,"entities":538,"mesh_entities":4,"visible":4,"meshes":9,"materials":1,"batch_keys":0,"other_material":4,"extents":["0.2500 0.2500 0.0000","0.5000 0.3750 0.0000"],"frame_ms":2.608,"step_ms":null,"cost_ms":2.608},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader_advanced/texture_binding_array","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":10,"frame_ms":1.886,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":18,"entities":535,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":0,"other_material":1,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.076,"step_ms":null,"cost_ms":1.076},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} {"example":"shader_advanced/texture_binding_array","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":5,"frame_ms":37.298,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":13,"entities":535,"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.566,"step_ms":null,"cost_ms":2.566},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/2d_shapes","frame":10,"ssim":0.999866,"tile":6,"bevy":{"batch_keys":0,"entities":530,"extents":[],"frame":10,"frame_ms":1.786,"materials":1,"mesh_entities":0,"meshes":27,"other_material":0,"visible":0},"raea":{"frame":17,"entities":552,"mesh_entities":0,"visible":0,"meshes":29,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.512,"step_ms":null,"cost_ms":1.512},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} -{"example":"2d/2d_shapes","frame":5,"ssim":0.999866,"tile":6,"bevy":{"batch_keys":0,"entities":530,"extents":[],"frame":5,"frame_ms":40.538,"materials":1,"mesh_entities":0,"meshes":27,"other_material":0,"visible":0},"raea":{"frame":12,"entities":552,"mesh_entities":0,"visible":0,"meshes":29,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.501,"step_ms":null,"cost_ms":2.501},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/mesh2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":26.165,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":8,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.485,"step_ms":null,"cost_ms":1.485},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":28.313,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.447,"step_ms":null,"cost_ms":2.447},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_flipping","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":27.5,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.78,"step_ms":null,"cost_ms":1.78},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/move_sprite","frame":120,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":120,"frame_ms":1.608,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":127,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.381,"step_ms":null,"cost_ms":1.381},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/move_sprite","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":10.167,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.189,"step_ms":null,"cost_ms":1.189},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/transparency_2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":10,"frame_ms":29.403,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":533,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.851,"step_ms":null,"cost_ms":2.851},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_sheet","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":30,"frame_ms":10.381,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.563,"step_ms":null,"cost_ms":1.563},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_sheet","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":60,"frame_ms":2.017,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.456,"step_ms":null,"cost_ms":1.456},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_animation","frame":12,"ssim":0.999303,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":12,"frame_ms":23.043,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":19,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.61,"step_ms":null,"cost_ms":1.61},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_animation","frame":30,"ssim":0.999303,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":30,"frame_ms":1.849,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.355,"step_ms":null,"cost_ms":1.355},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_animation","frame":60,"ssim":0.999303,"tile":8,"bevy":{"batch_keys":0,"entities":443,"extents":[],"frame":60,"frame_ms":1.706,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":532,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.77,"step_ms":null,"cost_ms":0.77},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_tile","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":30,"frame_ms":8.954,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.457,"step_ms":null,"cost_ms":1.457},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_tile","frame":300,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":300,"frame_ms":1.324,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":307,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.888,"step_ms":null,"cost_ms":0.888},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/rotate_to_cursor","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":10,"frame_ms":2.089,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.476,"step_ms":null,"cost_ms":1.476},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/rotate_to_cursor","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":441,"extents":[],"frame":5,"frame_ms":43.695,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":12,"entities":531,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.517,"step_ms":null,"cost_ms":2.517},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/mesh2d_alpha_mode","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":2.964,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":536,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.391,"step_ms":null,"cost_ms":2.391},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/mesh2d_alpha_mode","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":5,"frame_ms":45.605,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":12,"entities":536,"mesh_entities":0,"visible":0,"meshes":13,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":3.875,"step_ms":null,"cost_ms":3.875},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/mesh2d_vertex_color_texture","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":442,"extents":[],"frame":10,"frame_ms":25.697,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":532,"mesh_entities":0,"visible":0,"meshes":9,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.621,"step_ms":null,"cost_ms":2.621},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/mesh2d_repeated_texture","frame":10,"ssim":0.999749,"tile":6,"bevy":{"batch_keys":0,"entities":437,"extents":[],"frame":10,"frame_ms":18.705,"materials":1,"mesh_entities":0,"meshes":8,"other_material":0,"visible":0},"raea":{"frame":17,"entities":533,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.848,"step_ms":null,"cost_ms":1.848},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_scale","frame":10,"ssim":0.992293,"tile":11,"bevy":{"batch_keys":0,"entities":486,"extents":[],"frame":10,"frame_ms":24.227,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":553,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.982,"step_ms":null,"cost_ms":1.982},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/sprite_scale","frame":60,"ssim":0.992293,"tile":11,"bevy":{"batch_keys":0,"entities":486,"extents":[],"frame":60,"frame_ms":1.751,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":553,"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":""} +{"example":"2d/sprite_slice","frame":10,"ssim":0.997293,"tile":11,"bevy":{"batch_keys":0,"entities":464,"extents":[],"frame":10,"frame_ms":24.925,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":542,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.495,"step_ms":null,"cost_ms":1.495},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"shader/pipeline_constants","frame":10,"ssim":0.999666,"tile":2,"bevy":{"batch_keys":0,"entities":452,"extents":[],"frame":10,"frame_ms":26.406,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":535,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.819,"step_ms":null,"cost_ms":1.819},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/2d_shapes","frame":10,"ssim":0.999866,"tile":6,"bevy":{"batch_keys":0,"entities":530,"extents":[],"frame":10,"frame_ms":2.158,"materials":1,"mesh_entities":0,"meshes":27,"other_material":0,"visible":0},"raea":{"frame":17,"entities":552,"mesh_entities":0,"visible":0,"meshes":29,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.279,"step_ms":null,"cost_ms":1.279},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/2d_shapes","frame":5,"ssim":0.999866,"tile":6,"bevy":{"batch_keys":0,"entities":530,"extents":[],"frame":5,"frame_ms":55.532,"materials":1,"mesh_entities":0,"meshes":27,"other_material":0,"visible":0},"raea":{"frame":12,"entities":552,"mesh_entities":0,"visible":0,"meshes":29,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.607,"step_ms":null,"cost_ms":2.607},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/rotation","frame":10,"ssim":0.999751,"tile":5,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":10,"frame_ms":21.618,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":535,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.46,"step_ms":null,"cost_ms":1.46},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/rotation","frame":60,"ssim":0.999751,"tile":5,"bevy":{"batch_keys":0,"entities":446,"extents":[],"frame":60,"frame_ms":1.053,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":535,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.712,"step_ms":null,"cost_ms":0.712},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/text2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":10,"frame_ms":20.82,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":552,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.394,"step_ms":null,"cost_ms":1.394},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/text2d","frame":60,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":461,"extents":[],"frame":60,"frame_ms":1.055,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":67,"entities":552,"mesh_entities":0,"visible":0,"meshes":10,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":0.751,"step_ms":null,"cost_ms":0.751},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/texture_atlas","frame":10,"ssim":0.998551,"tile":14,"bevy":{"batch_keys":0,"entities":457,"extents":[],"frame":10,"frame_ms":27.71,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":544,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.438,"step_ms":null,"cost_ms":1.438},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} +{"example":"2d/texture_atlas","frame":30,"ssim":0.998551,"tile":14,"bevy":{"batch_keys":0,"entities":457,"extents":[],"frame":30,"frame_ms":1.238,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":37,"entities":544,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.969,"step_ms":null,"cost_ms":1.969},"pixels":true,"draws":true,"time":true,"pass":true,"why":""} diff --git a/runtime/look/src/parts.rs b/runtime/look/src/parts.rs index 06e9b3f2..b48d845a 100644 --- a/runtime/look/src/parts.rs +++ b/runtime/look/src/parts.rs @@ -95,7 +95,16 @@ pub fn keyed_strings(p: &mut Program, row: &mut BTreeMap, id: &str, c p.keys.insert((id.to_string(), format!("{col}_k")), ks.iter().enumerate().map(|(f, k)| (f as i64, *k, "step".to_string())).collect()); } -/// Each frame's `src` (a picture's path, found as staticFile's /media/ is, or a "render:NAME"), for keyed_strings. +/// Each frame's `src` (a picture's path, found as staticFile's /media/ is, or a "render:NAME"; an "atlas:" its +/// textures each found so), for keyed_strings. pub fn srcs_of(its: &[Item]) -> Vec { - its.iter().map(|i| src_path(i.props.get("src").and_then(Value::as_str).unwrap_or(""))).collect() + its.iter().map(|i| i.props.get("src").and_then(Value::as_str).unwrap_or("")).map(|s| match s.strip_prefix("atlas:").and_then(|j| serde_json::from_str::(j).ok()) { + Some(mut a) => { + if let Some(Value::Array(t)) = a.get_mut("textures") { + t.iter_mut().for_each(|p| if let Some(s) = p.as_str() { *p = Value::String(src_path(s)) }); + } + format!("atlas:{a}") + } + None => src_path(s), + }).collect() } diff --git a/runtime/scene2d/src/lib.rs b/runtime/scene2d/src/lib.rs index 615c824f..49c92b93 100644 --- a/runtime/scene2d/src/lib.rs +++ b/runtime/scene2d/src/lib.rs @@ -49,6 +49,8 @@ pub fn sprites(tracks: &[Track], p: &mut Program) { } } sheet(p, &mut row, &id, &its); + // one picture of an atlas (TextureAtlasBuilder): its index in the atlas's list (raea-sys-sprite's atlas.rs) + if let Some(i) = num(first, "atlasPick") { row.insert("atlas_pick".into(), V::N(i)); } // as JSON: the picture's sampler (Bevy's load_with_settings, raea-sys-sampler's), Bevy's SpriteImageMode as given // and its (Bevy's SpriteMaterial, systems/sprite) for (prop, col) in [("sampler", "texture_sampler"), ("image_mode", "image_mode"), ("shader", "shader")] { @@ -76,6 +78,8 @@ pub fn shapes(tracks: &[Track], p: &mut Program) { let mut row = BTreeMap::new(); row.insert("id".into(), V::S(id.clone())); let first = &its[0].props; + // a native : its spec, each font file found as staticFile's /media/ is (raea-sys-sprite's text2d.rs) + if let Some(spec) = first.get("text") { row.insert("text".into(), V::S(text_spec(spec))); } row.insert("shape".into(), V::S(first.get("shape").and_then(Value::as_str).unwrap_or("rect").to_string())); let size = first.get("size").and_then(Value::as_array); let at = |i: usize| size.and_then(|a| a.get(i)).and_then(Value::as_f64).unwrap_or(100.0); @@ -98,3 +102,16 @@ pub fn shapes(tracks: &[Track], p: &mut Program) { own_uniforms(p, &id, &its, |it| it.props.get("shader")); } } + +/// A 's spec with each section's font file found. +fn text_spec(spec: &Value) -> String { + let mut spec = spec.clone(); + if let Some(Value::Array(sections)) = spec.get_mut("sections") { + for s in sections.iter_mut() { + if let Some(f) = s.get("font").and_then(Value::as_str).map(src_path) { + s["font"] = Value::String(f); + } + } + } + spec.to_string() +} diff --git a/sdk/raea/bench/bevy-parity/2d/2d_shapes.tsx b/sdk/raea/bench/bevy-parity/2d/2d_shapes.tsx index 660fd8d8..0e472cff 100644 --- a/sdk/raea/bench/bevy-parity/2d/2d_shapes.tsx +++ b/sdk/raea/bench/bevy-parity/2d/2d_shapes.tsx @@ -5,6 +5,7 @@ // twelve would be, coloured by i / 12. In the bottom left the ROTATE and WIREFRAME feathers checkboxes, unchecked, // under helpers/theme.rs basic_example_theme(WHITE), so nothing turns and no wireframe draws; Bevy's default 1280 x 720 // window and clear colour. +import type { ReactElement } from "react"; import { AbsoluteFill, Composition, registerRoot } from "raea"; import { Canvas3D } from "raea/3d"; import { Hsla, Srgba } from "raea/color"; @@ -46,7 +47,7 @@ const RINGS = [ ]; /** a row of shapes spread over X_EXTENT at height y, `n` places wide, each coloured by its place */ -function row(shapes: JSX.Element[], n: number, y: number) { +function row(shapes: ReactElement[], n: number, y: number) { return shapes.map((shape, i) => ( {shape} diff --git a/sdk/raea/bench/bevy-parity/2d/rotation.tsx b/sdk/raea/bench/bevy-parity/2d/rotation.tsx new file mode 100644 index 00000000..07558147 --- /dev/null +++ b/sdk/raea/bench/bevy-parity/2d/rotation.tsx @@ -0,0 +1,79 @@ +// Bevy v0.20.0 examples/2d/rotation.rs in raea's TSX (docs/control.feature FC2): the ship +// (textures/simplespace/ship_C.png) at the origin, which moves only under the arrow keys, so it stays there; two +// enemy_A sprites at (-300, 0) and (0, -160) snapped each fixed update to face it (Quat::from_rotation_arc from +Y), and +// two enemy_B at (300, 0) and (0, 160) turning towards it at 45 and 90 degrees a second; "Up Arrow: Move Forward\nLeft +// / Right Arrow: Turn" 12 px from the top left. FixedUpdate at 60 Hz under the harness's 60 fps clock runs once each +// frame after the first, its delta 16_666_667 ns as f32 seconds; the turns are glam's in f32. +import { AbsoluteFill, Composition, registerRoot, staticFile, useCurrentFrame } from "raea"; +import { Canvas3D, Sprite } from "raea/3d"; +import { Quat } from "raea/transform"; +import { Text, px } from "raea/ui"; + +const f = Math.fround; +const DT = f(16_666_667e-9); +const EPSILON = 1.1920929e-7; +type V2 = [number, number]; + +const mul = (a: Quat, b: Quat): Quat => Quat.mul(a, b).map(f) as Quat; +const rotZ = (a: number): Quat => [0, 0, f(Math.sin(f(a * 0.5))), f(Math.cos(f(a * 0.5)))]; +/** glam's Quat * Vec3 for a vector in the plane, its x and y */ +function turn(q: Quat, v: V2): V2 { + const [x, y, z, w] = q; + const b2 = f(f(f(x * x) + f(y * y)) + f(z * z)); + const s = f(f(w * w) - b2), d = f(f(f(v[0] * x) + f(v[1] * y)) * 2), w2 = f(w * 2); + // rhs * s + b * d + b.cross(rhs) * w2, rhs = (v.x, v.y, 0): b x rhs = (-z v.y, z v.x, x v.y - y v.x) + return [f(f(f(v[0] * s) + f(x * d)) + f(f(-z * v[1]) * w2)), f(f(f(v[1] * s) + f(y * d)) + f(f(z * v[0]) * w2))]; +} +const norm = (v: V2): V2 => { + const l = f(Math.sqrt(f(f(v[0] * v[0]) + f(v[1] * v[1])))); + return [f(v[0] / l), f(v[1] / l)]; +}; +const dot = (a: V2, b: V2) => f(f(a[0] * b[0]) + f(a[1] * b[1])); + +/** snap_to_player_system: Quat::from_rotation_arc(Vec3::Y, towards the origin) */ +function snapped(at: V2): Quat { + const to = norm([0 - at[0], 0 - at[1]]); + const d = to[1]; + if (d > 1 - 2 * EPSILON) return [0, 0, 0, 1]; + // Y x to = (0, 0, -to.x), w = 1 + dot, normalised + const q: Quat = [0, 0, f(-to[0]), f(1 + d)]; + const l = f(Math.sqrt(f(f(q[2] * q[2]) + f(q[3] * q[3])))); + return [0, 0, f(q[2] / l), f(q[3] / l)]; +} + +/** rotate_to_player_system over `steps` fixed updates, for an enemy at `at` turning `speed` radians a second */ +function turned(at: V2, speed: number, steps: number): Quat { + let q: Quat = [0, 0, 0, 1]; + // player - enemy, as Bevy subtracts: 0 - 0 is +0 (-at's -0 flipped copysign for the enemy straight above, which + // then turned the other way round) + const to = norm([0 - at[0], 0 - at[1]]); + for (let n = 0; n < steps; n++) { + const fwd = dot(turn(q, [0, 1]), to); + if (Math.abs(f(fwd - 1)) < EPSILON) continue; + const r = dot(turn(q, [1, 0]), to); + // -f32::copysign(1, r): -0 counts as negative + const sign = r < 0 || Object.is(r, -0) ? 1 : -1; + const max = f(Math.acos(Math.min(1, Math.max(-1, fwd)))); + q = mul(rotZ(f(sign * Math.min(f(speed * DT), max))), q); + } + return q; +} + +const rad = (deg: number) => f((deg * Math.PI) / 180); + +function Shot() { + const steps = useCurrentFrame(); + const at = (p: V2) => ({ x: 640 + p[0], y: 360 - p[1] }); + return ( + + + + {([[-300, 0], [0, -160]] as V2[]).map((p) => )} + {([[[300, 0], 45], [[0, 160], 90]] as [V2, number][]).map(([p, deg]) => )} + + {"Up Arrow: Move Forward\nLeft / Right Arrow: Turn"} + + ); +} + +registerRoot(() => ); diff --git a/sdk/raea/bench/bevy-parity/2d/text2d.tsx b/sdk/raea/bench/bevy-parity/2d/text2d.tsx new file mode 100644 index 00000000..8ef404b5 --- /dev/null +++ b/sdk/raea/bench/bevy-parity/2d/text2d.tsx @@ -0,0 +1,71 @@ +// Bevy v0.20.0 examples/2d/text2d.rs in raea's TSX (docs/control.feature FC2): Bevy's own Text2d inside the Canvas3D. +// " translation ", " rotation " and " scale " in FiraSans-Bold at 50 px, centred, on a half-black background with +// Text2dShadow's default, moving on a circle of 100 px about (-400, 0), turning by cos(t) and scaled by +// (sin(t) + 1.1) * 2 at (400, 0), t the elapsed seconds (a 1/60 s Duration a frame, as f32); two 300 x 200 boxes +// (srgb 0.25, 0.25, 0.55) at (0, -250) and (320, -250), each with 35 px text wrapped in its TextBounds, Unicode +// (WordBoundary, underlined) and AnyCharacter linebreaks, one above the box (z 1) with a shadow of the box's colour +// darker(0.05); FontSmoothing::None text at (-400, -250), centred; a 10 x 10 LIGHT_CYAN sprite at (0, 250) over four +// " Anchor" texts at z -1, one at each corner Anchor, on WHITE.darker(0.8), with a "::" span (LIGHT_GREY on DARK_BLUE) +// and the anchor's Debug in its colour on that colour darker(0.3). Camera2d, Bevy's default clear colour and +// 1280 x 720 window. +import { AbsoluteFill, Composition, registerRoot, staticFile, useCurrentFrame } from "raea"; +import { Canvas3D } from "raea/3d"; +import { Shape2D } from "raea/sprite"; +import { Srgba } from "raea/color"; +import { Quat, Transform } from "raea/transform"; +import { Text2d, TextSpan } from "raea/ui"; + +const f = Math.fround; +const FONT = staticFile("fonts/FiraSans-Bold.ttf"); +const HALF_BLACK = new Srgba(0, 0, 0, 0.5); +const BOX = new Srgba(0.25, 0.25, 0.55, 1); +const BOX_RGB: [number, number, number] = [0.25, 0.25, 0.55]; +const BOX_SHADOW = BOX.darker(0.05); +const WHITE_DARKER = new Srgba(1, 1, 1, 1).darker(0.8); +const LIGHT_GREY = new Srgba(0.827, 0.827, 0.827, 1); +const DARK_BLUE = new Srgba(0, 0, 0.545, 1); +// Bevy's Anchor constants with their Debug, and the colour each is shown in +const ANCHORS: [[number, number], string, Srgba][] = [ + [[-0.5, 0.5], "Anchor(Vec2(-0.5, 0.5))", new Srgba(1, 0.627, 0.478, 1)], + [[0.5, 0.5], "Anchor(Vec2(0.5, 0.5))", new Srgba(0.565, 0.933, 0.565, 1)], + [[0.5, -0.5], "Anchor(Vec2(0.5, -0.5))", new Srgba(0.678, 0.847, 0.902, 1)], + [[-0.5, -0.5], "Anchor(Vec2(-0.5, -0.5))", new Srgba(1, 1, 0.878, 1)], +]; + +function Shot() { + // Time::elapsed_secs: f frames of Bevy's 1/60 s Duration, as f32 + const t = f((useCurrentFrame() * 16_666_667) / 1e9); + const s = f(f(f(Math.sin(t)) + 1.1) * 2); + const big = { font: FONT, font_size: 50, justify: "Center" as const, text_background_color: HALF_BLACK, shadow: true as const }; + const small = { font: FONT, font_size: 35 }; + return ( + + + translation + rotation + scale + + + {"this text wraps in the box\n(Unicode linebreaks)"} + + + + {"this text wraps in the box\n(AnyCharacter linebreaks)"} + + + {"This text has\nFontSmoothing::None\nAnd Justify::Center"} + + + {ANCHORS.map(([anchor, name, color]) => ( + + {" Anchor"} + :: + {`${name} `} + + ))} + + + ); +} + +registerRoot(() => ); diff --git a/sdk/raea/bench/bevy-parity/2d/texture_atlas.tsx b/sdk/raea/bench/bevy-parity/2d/texture_atlas.tsx new file mode 100644 index 00000000..366af42d --- /dev/null +++ b/sdk/raea/bench/bevy-parity/2d/texture_atlas.tsx @@ -0,0 +1,223 @@ +// Bevy v0.20.0 examples/2d/texture_atlas.rs in raea's TSX (docs/control.feature FC2): every picture of +// textures/rpg, as asset_server.load_folder gives them (depth first, each folder in its read_dir order, listed below +// as this checkout's file system orders them), packed four times by Bevy's TextureAtlasBuilder: with no padding and +// with 6 x 6 px, each sampled linear and nearest. The linear atlases drawn whole at (-250, -160) and (250, -160), +// half size; the vendor picked from each atlas at (x, 80), three times its size, x -350, -150, 150 and 350; Text2d +// labels in FiraSans-Bold, 42 px at y 250 and 25 px 110 above each vendor, centred. Camera2d, Bevy's default clear +// colour and 1280 x 720 window (ImagePlugin::default_nearest, which every picture drawn here overrides). +import { AbsoluteFill, Composition, registerRoot, staticFile } from "raea"; +import { Canvas3D, Sprite } from "raea/3d"; +import { TextureAtlasBuilder } from "raea/sprite"; +import { Transform } from "raea/transform"; +import { Text2d } from "raea/ui"; + +const RPG = [ + "textures/rpg/ui/generic-rpg-ui-inventario.png", + "textures/rpg/ui/generic-rpg-ui-text-box.png", + "textures/rpg/ui/generic-rpg-ui-inventario01.png", + "textures/rpg/ui/generic-rpg-ui-inventario03.png", + "textures/rpg/ui/generic-rpg-ui-inventario02.png", + "textures/rpg/ui/generic-rpg-ui-inventario04.png", + "textures/rpg/mobs/worm-run-idle.png", + "textures/rpg/mobs/slime-blue.png", + "textures/rpg/mobs/boss_bee.png", + "textures/rpg/mobs/fox-run.png", + "textures/rpg/mobs/slime-green.png", + "textures/rpg/mobs/slime-orange.png", + "textures/rpg/mobs/kobold-idle.png", + "textures/rpg/props/generic-rpg-board02.png", + "textures/rpg/props/generic-rpg-barrel02.png", + "textures/rpg/props/generic-rpg-grass02.png", + "textures/rpg/props/generic-rpg-barrel03.png", + "textures/rpg/props/generic-rpg-board03.png", + "textures/rpg/props/generic-rpg-treasure-closed.png", + "textures/rpg/props/generic-rpg-board01.png", + "textures/rpg/props/generic-rpg-barrel01.png", + "textures/rpg/props/generic-rpg-grass01.png", + "textures/rpg/props/generic-rpg-board04.png", + "textures/rpg/props/generic-rpg-flowers.png", + "textures/rpg/props/generic-rpg-fence-raw03.png", + "textures/rpg/props/generic-rpg-fence-raw17.png", + "textures/rpg/props/generic-rpg-rock01.png", + "textures/rpg/props/generic-rpg-loot01.png", + "textures/rpg/props/generic-rpg-fence-raw16.png", + "textures/rpg/props/generic-rpg-fence-raw02.png", + "textures/rpg/props/generic-rpg-fence-raw14.png", + "textures/rpg/props/generic-rpg-loot03.png", + "textures/rpg/props/generic-rpg-rock03.png", + "textures/rpg/props/generic-rpg-rock02.png", + "textures/rpg/props/generic-rpg-loot02.png", + "textures/rpg/props/generic-rpg-fence-raw01.png", + "textures/rpg/props/generic-rpg-fence-raw15.png", + "textures/rpg/props/generic-rpg-fence-raw11.png", + "textures/rpg/props/generic-rpg-fence-raw05.png", + "textures/rpg/props/generic-rpg-rock06.png", + "textures/rpg/props/generic-rpg-rod.png", + "textures/rpg/props/generic-rpg-fence-raw04.png", + "textures/rpg/props/generic-rpg-fence-raw10.png", + "textures/rpg/props/generic-rpg-bridge.png", + "textures/rpg/props/generic-rpg-fence-raw06.png", + "textures/rpg/props/generic-rpg-fence-raw12.png", + "textures/rpg/props/generic-rpg-loot05.png", + "textures/rpg/props/generic-rpg-rock05.png", + "textures/rpg/props/generic-rpg-fence08.png", + "textures/rpg/props/generic-rpg-fence09.png", + "textures/rpg/props/generic-rpg-rock04.png", + "textures/rpg/props/generic-rpg-loot04.png", + "textures/rpg/props/generic-rpg-fence-raw13.png", + "textures/rpg/props/generic-rpg-fence-raw07.png", + "textures/rpg/props/generic-rpg-fence-raw22.png", + "textures/rpg/props/generic-rpg-fence04.png", + "textures/rpg/props/generic-rpg-fence10.png", + "textures/rpg/props/generic-rpg-fence11.png", + "textures/rpg/props/generic-rpg-fence05.png", + "textures/rpg/props/generic-rpg-flower01.png", + "textures/rpg/props/generic-rpg-fence-raw23.png", + "textures/rpg/props/generic-rpg-fence-raw21.png", + "textures/rpg/props/generic-rpg-fence-raw09.png", + "textures/rpg/props/generic-rpg-flower03.png", + "textures/rpg/props/generic-rpg-fence-complete.png", + "textures/rpg/props/generic-rpg-fence13.png", + "textures/rpg/props/generic-rpg-fence07.png", + "textures/rpg/props/generic-rpg-fence06.png", + "textures/rpg/props/generic-rpg-fence12.png", + "textures/rpg/props/generic-rpg-flower02.png", + "textures/rpg/props/generic-rpg-fence-raw08.png", + "textures/rpg/props/generic-rpg-fence-raw20.png", + "textures/rpg/props/generic-rpg-tree02.png", + "textures/rpg/props/generic-rpg-fence-raw18.png", + "textures/rpg/props/generic-rpg-fence-raw24.png", + "textures/rpg/props/generic-rpg-fence02.png", + "textures/rpg/props/generic-rpg-fence03.png", + "textures/rpg/props/generic-rpg-fence-raw25.png", + "textures/rpg/props/generic-rpg-fence-raw19.png", + "textures/rpg/props/generic-rpg-tree01.png", + "textures/rpg/props/generic-rpg-house-inn.png", + "textures/rpg/props/generic-rpg-fence01.png", + "textures/rpg/props/generic-rpg-fence14.png", + "textures/rpg/props/generic-rpg-crate02.png", + "textures/rpg/props/generic-rpg-crate03.png", + "textures/rpg/props/generic-rpg-crate01.png", + "textures/rpg/props/generic-rpg-fish04.png", + "textures/rpg/props/generic-rpg-mini-lake.png", + "textures/rpg/props/generic-rpg-fish01.png", + "textures/rpg/props/generic-rpg-fish02.png", + "textures/rpg/props/generic-rpg-fish03.png", + "textures/rpg/props/generic-rpg-trasure-open.png", + "textures/rpg/tiles/generic-rpg-tile35.png", + "textures/rpg/tiles/generic-rpg-tile21.png", + "textures/rpg/tiles/generic-rpg-tile09.png", + "textures/rpg/tiles/generic-rpg-tile08.png", + "textures/rpg/tiles/generic-rpg-tile20.png", + "textures/rpg/tiles/generic-rpg-tile34.png", + "textures/rpg/tiles/generic-rpg-tile22.png", + "textures/rpg/tiles/generic-rpg-tile37.png", + "textures/rpg/tiles/generic-rpg-tile23.png", + "textures/rpg/tiles/generic-rpg-tile27.png", + "textures/rpg/tiles/generic-rpg-tile33.png", + "textures/rpg/tiles/generic-rpg-tile32.png", + "textures/rpg/tiles/generic-rpg-tile26.png", + "textures/rpg/tiles/generic-rpg-tile18.png", + "textures/rpg/tiles/generic-rpg-tile30.png", + "textures/rpg/tiles/generic-rpg-tile24.png", + "textures/rpg/tiles/generic-rpg-tile25.png", + "textures/rpg/tiles/generic-rpg-tile31.png", + "textures/rpg/tiles/generic-rpg-tile19.png", + "textures/rpg/tiles/generic-rpg-tile56.png", + "textures/rpg/tiles/generic-rpg-tile42.png", + "textures/rpg/tiles/generic-rpg-tile43.png", + "textures/rpg/tiles/generic-rpg-tile57.png", + "textures/rpg/tiles/generic-rpg-tile41.png", + "textures/rpg/tiles/generic-rpg-tile55.png", + "textures/rpg/tiles/generic-rpg-tile69.png", + "textures/rpg/tiles/generic-rpg-tile68.png", + "textures/rpg/tiles/generic-rpg-tile54.png", + "textures/rpg/tiles/generic-rpg-tile40.png", + "textures/rpg/tiles/generic-rpg-tile44.png", + "textures/rpg/tiles/generic-rpg-tile50.png", + "textures/rpg/tiles/generic-rpg-tile51.png", + "textures/rpg/tiles/generic-rpg-tile45.png", + "textures/rpg/tiles/generic-rpg-tile53.png", + "textures/rpg/tiles/generic-rpg-tile47.png", + "textures/rpg/tiles/generic-rpg-tile46.png", + "textures/rpg/tiles/generic-rpg-tile52.png", + "textures/rpg/tiles/generic-rpg-tile63.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall01.png", + "textures/rpg/tiles/generic-rpg-tile62.png", + "textures/rpg/tiles/generic-rpg-tile60.png", + "textures/rpg/tiles/generic-rpg-tile48.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall02.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall03.png", + "textures/rpg/tiles/generic-rpg-tile49.png", + "textures/rpg/tiles/generic-rpg-tile61.png", + "textures/rpg/tiles/generic-rpg-tile59.png", + "textures/rpg/tiles/generic-rpg-tile65.png", + "textures/rpg/tiles/generic-rpg-tile71.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall07.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall06.png", + "textures/rpg/tiles/generic-rpg-tile70.png", + "textures/rpg/tiles/generic-rpg-tile64.png", + "textures/rpg/tiles/generic-rpg-tile58.png", + "textures/rpg/tiles/generic-rpg-tile66.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall04.png", + "textures/rpg/tiles/generic-rpg-tile-waterfall05.png", + "textures/rpg/tiles/generic-rpg-tile67.png", + "textures/rpg/tiles/generic-rpg-tile14.png", + "textures/rpg/tiles/generic-rpg-tile28.png", + "textures/rpg/tiles/generic-rpg-tile29.png", + "textures/rpg/tiles/generic-rpg-tile01.png", + "textures/rpg/tiles/generic-rpg-tile15.png", + "textures/rpg/tiles/generic-rpg-tile03.png", + "textures/rpg/tiles/generic-rpg-tile17.png", + "textures/rpg/tiles/generic-rpg-tile16.png", + "textures/rpg/tiles/generic-rpg-tile02.png", + "textures/rpg/tiles/generic-rpg-tile06.png", + "textures/rpg/tiles/generic-rpg-tile12.png", + "textures/rpg/tiles/generic-rpg-tile13.png", + "textures/rpg/tiles/generic-rpg-tile07.png", + "textures/rpg/tiles/generic-rpg-tile39.png", + "textures/rpg/tiles/generic-rpg-tile11.png", + "textures/rpg/tiles/generic-rpg-tile05.png", + "textures/rpg/tiles/generic-rpg-tile04.png", + "textures/rpg/tiles/generic-rpg-tile10.png", + "textures/rpg/tiles/generic-rpg-tile38.png", + "textures/rpg/tiles/generic-rpg-Slice.png", + "textures/rpg/chars/sensei/sensei.png", + "textures/rpg/chars/mani/mani-idle-run.png", + "textures/rpg/chars/hat-guy/hat-guy.png", + "textures/rpg/chars/vendor/generic-rpg-vendor.png", + "textures/rpg/chars/gabe/gabe-idle-run.png", +].map((p) => staticFile(p)); +const VENDOR = staticFile("textures/rpg/chars/vendor/generic-rpg-vendor.png"); +const FONT = staticFile("fonts/FiraSans-Bold.ttf"); + +function atlas(padding: [number, number], filter: "linear" | "nearest") { + const b = new TextureAtlasBuilder().padding(padding); + RPG.forEach((p) => b.addTexture(p)); + return b.build({ sampler: { filter } }); +} +const linear = atlas([0, 0], "linear"); +const nearest = atlas([0, 0], "nearest"); +const linearPadded = atlas([6, 6], "linear"); +const nearestPadded = atlas([6, 6], "nearest"); +const CONFIGS = [["Linear", linear, -350], ["Nearest", nearest, -150], ["Linear", linearPadded, 150], ["Nearest", nearestPadded, 350]] as const; +const BASE_Y = 80; + +function Shot() { + return ( + + + + + {CONFIGS.map(([, a, x]) => )} + No padding + Padding + {CONFIGS.map(([label, , x]) => ( + {label} + ))} + + + ); +} + +registerRoot(() => ); diff --git a/sdk/raea/src/image.ts b/sdk/raea/src/image.ts index 3409bdda..050a5fa8 100644 --- a/sdk/raea/src/image.ts +++ b/sdk/raea/src/image.ts @@ -3,3 +3,4 @@ // raea/image (bevy_image): pictures, on the page and in the world. export { Img, type ImgProps } from "@raea/video/media"; export { ImagePlane, Plate, type ImagePlaneProps, type PlateProps } from "./3d"; +export { TextureAtlasBuilder, type BuiltAtlas, type AtlasSprite } from "@raea/render/3d/atlas"; diff --git a/sdk/raea/src/sprite.ts b/sdk/raea/src/sprite.ts index 13365d8d..443f730e 100644 --- a/sdk/raea/src/sprite.ts +++ b/sdk/raea/src/sprite.ts @@ -1,4 +1,5 @@ // docs/sdk.feature S1b: a Bevy-named entry point. // raea/sprite (bevy_sprite): 2D pictures and flat shapes over the 3D, drawn by a 2D camera of their own (S3c). export { Sprite, Shape2D, type SpriteProps, type Shape2DProps, type Place2dProps, type AlphaMode2d, type SpriteImageMode } from "@raea/render/3d/sprite"; +export { TextureAtlasBuilder, type BuiltAtlas, type AtlasSprite } from "@raea/render/3d/atlas"; export { Mesh2d, Circle, Rectangle, Ellipse, RegularPolygon, CircularSector, CircularSegment, Annulus, Capsule2d, Rhombus, Triangle2d, Segment2d, Polyline2d, ConvexPolygon, ColorMaterial, type RingProps, type ArcProps, type AnnulusProps, type Capsule2dProps, type RhombusProps, type VerticesProps, type Mesh2dProps, type CircleProps, type RectangleProps, type EllipseProps, type RegularPolygonProps, type ColorMaterialProps, type MeshAttributes } from "@raea/render/bevy3d"; diff --git a/sdk/render/src/3d/atlas.ts b/sdk/render/src/3d/atlas.ts new file mode 100644 index 00000000..c336df66 --- /dev/null +++ b/sdk/render/src/3d/atlas.ts @@ -0,0 +1,57 @@ +// bevy_image's TextureAtlasBuilder: pictures packed into one atlas, which raea-sys-sprite builds with Bevy's own +// builder (systems/sprite atlas.rs), each picture added in the order given (the packer's ties go by that order). +import { samplerSpec, type SamplerSpec } from "./materials"; + +/** What a takes to show a built atlas: the whole of it, or one of its pictures (`atlasPick`). */ +export interface AtlasSprite { + src: string; + sampler?: SamplerSpec; + atlasPick?: number; +} + +/** A built atlas: `image` the whole atlas as a sprite's picture, `sources.handle(texture)` one picture of it + * (TextureAtlasSources::handle). */ +export interface BuiltAtlas { + image: AtlasSprite; + sources: { handle(texture: string): AtlasSprite }; +} + +/** Pictures packed into one atlas, as Bevy's TextureAtlasBuilder: `padding([x, y])` px around each, `addTexture` in + * order, then `build({ sampler })` (the atlas's own sampler, Bevy's default otherwise). + * @bevy bevy_image::texture_atlas_builder::TextureAtlasBuilder + * @bevy bevy_image::texture_atlas::TextureAtlasSources */ +export class TextureAtlasBuilder { + private pad: [number, number] = [0, 0]; + private textures: string[] = []; + + padding(p: [number, number]): this { + if (!(Array.isArray(p) && p.length === 2 && p.every((n) => Number.isInteger(n) && n >= 0))) throw new TypeError(`TextureAtlasBuilder: padding is [x, y], whole px of 0 or more, got ${JSON.stringify(p)}`); + this.pad = p; + return this; + } + + addTexture(src: string): this { + if (typeof src !== "string" || src === "" || src.startsWith("render:") || src.startsWith("atlas:")) throw new TypeError(`TextureAtlasBuilder: a texture is a picture (staticFile("x.png")), got ${JSON.stringify(src)}`); + this.textures.push(src); + return this; + } + + build({ sampler }: { sampler?: SamplerSpec } = {}): BuiltAtlas { + if (this.textures.length === 0) throw new TypeError("TextureAtlasBuilder: add a texture before build()"); + if (sampler !== undefined) samplerSpec("TextureAtlasBuilder: sampler", sampler); + const textures = [...this.textures]; + // the sampler is in the key: one list packed twice with two samplers is two atlases, as in Bevy + const src = `atlas:${JSON.stringify({ textures, padding: this.pad, sampler: sampler ?? null })}`; + const image: AtlasSprite = sampler === undefined ? { src } : { src, sampler }; + return { + image, + sources: { + handle(texture: string) { + const i = textures.indexOf(texture); + if (i < 0) throw new RangeError(`TextureAtlasBuilder: ${texture} isn't in this atlas`); + return { ...image, atlasPick: i }; + }, + }, + }; + } +} diff --git a/sdk/render/src/3d/sprite.tsx b/sdk/render/src/3d/sprite.tsx index b9f1e782..341332c7 100644 --- a/sdk/render/src/3d/sprite.tsx +++ b/sdk/render/src/3d/sprite.tsx @@ -33,6 +33,9 @@ export interface SpriteProps extends Place2dProps { height?: number; /** a sprite sheet: the picture is `[columns, rows]` cells of equal size, read left to right, top to bottom */ grid?: [number, number]; + /** one picture of a built atlas (TextureAtlasBuilder's sources.handle gives it with its src): its index in the + * atlas's list */ + atlasPick?: number; /** with `grid`: which cell shows (0 is the top left); animate it to play the sheet: frame={Math.floor(f / 3)} */ frame?: number; flipX?: boolean; @@ -103,6 +106,7 @@ export function Sprite(props: SpriteProps) { checkImageMode(props.image_mode); } if (props.sampler !== undefined) samplerSpec("Sprite: sampler", props.sampler); + if (props.atlasPick !== undefined && !(Number.isInteger(props.atlasPick) && props.atlasPick >= 0 && props.src.startsWith("atlas:"))) throw new TypeError("Sprite: atlasPick is one picture of a built atlas: spread TextureAtlasBuilder's sources.handle(texture) into it"); check2d("Sprite", props); const id = useId(); const handled = Object.keys(props).some((k) => /^on[A-Z]/.test(k)); diff --git a/sdk/render/src/bevy3d/text2d.tsx b/sdk/render/src/bevy3d/text2d.tsx new file mode 100644 index 00000000..5a422666 --- /dev/null +++ b/sdk/render/src/bevy3d/text2d.tsx @@ -0,0 +1,90 @@ +// A inside a : Bevy's own Text2d (raea-sys-sprite's text2d.rs), laid out, rasterised and ordered +// among the sprites by bevy_text and bevy_sprite_render, so TextBounds, FontSmoothing::None, a Text2dShadow, its +// spans and a z under a sprite are Bevy's. Sent as a Shape2D row with its `text` spec. +import { Children, isValidElement, type ReactNode } from "react"; +import { node3d } from "../3d/core"; +import { LinearRgba, Srgba } from "./colors"; +import type { TextStyleProps, TextRunProps } from "./ui"; +import type { TransformValue } from "./core"; +import { useVideoConfig } from "@raea/app/clock"; + +/** bevy_sprite's Text2dShadow: the glyphs again `offset` px right and up (y up, as the 2D world), under the text; + * Text2dShadow::default() is { offset: [4, -4], color: black }. @bevy bevy_sprite::text2d::Text2dShadow */ +export interface Text2dShadow { + offset?: [number, number]; + color?: unknown; +} + +export interface Text2dProps extends TextStyleProps, TextRunProps { + /** its place in Bevy's 2D world: the frame's centre the origin, +Y up, a unit a pixel, turns counterclockwise */ + transform?: TransformValue; + /** how its lines line up with each other (TextLayout's Justify, Left by default) */ + justify?: "Left" | "Center" | "Right" | "Justified" | "Start" | "End"; + /** TextLayout's LineBreak (WordBoundary by default); inside a Canvas3D */ + linebreak?: "WordBoundary" | "AnyCharacter" | "WordOrCharacter" | "NoWrap"; + /** Bevy's Anchor, as its Vec2: which point of the block sits at its Transform, [-0.5, -0.5] its bottom left to + * [0.5, 0.5] its top right ([0, 0], the centre, by default; Anchor::TOP_CENTER is [0, 0.5]) */ + anchor?: [number, number]; + /** TextBounds: the box its lines wrap in, [width, height] px (either null, unbounded), the anchor then the box's + * point; inside a Canvas3D */ + bounds?: [number | null, number | null]; + /** Text2dShadow (true for its default); inside a Canvas3D */ + shadow?: Text2dShadow | true; + children?: ReactNode; +} + +type Rgba = [number, number, number, number]; + +function rgba(who: string, c: unknown): Rgba | null { + if (c === undefined) return null; + const s = c instanceof LinearRgba ? c.to_srgba() : c instanceof Srgba ? c : typeof c === "string" ? Srgba.hex(c) : undefined; + if (!s) throw new TypeError(`${who}: a colour is an Srgba, a LinearRgba or a CSS colour, got ${JSON.stringify(c)}`); + return [s.red, s.green, s.blue, s.alpha]; +} + +/** One section of the text: its string and its TextFont, colour, background and underline. */ +function sectionOf(who: string, text: string, p: TextStyleProps & TextRunProps) { + const font = p.font; + if (font !== undefined && typeof font !== "string") throw new TypeError(`${who}: inside a Canvas3D its font is a font file (staticFile("fonts/x.ttf")) or Bevy's default font, got ${JSON.stringify(font)}`); + const fs = p.font_size; + const size = fs === undefined ? 20 : typeof fs === "number" ? fs : "Px" in fs ? fs.Px : NaN; + if (!(Number.isFinite(size) && size > 0)) throw new TypeError(`${who}: inside a Canvas3D its font_size is px (a number or { Px }), got ${JSON.stringify(fs)}`); + if (p.font_smoothing !== undefined && p.font_smoothing !== "AntiAliased" && p.font_smoothing !== "None") throw new TypeError(`${who}: font_smoothing is "AntiAliased" or "None", got ${JSON.stringify(p.font_smoothing)}`); + return { text, font: font ?? null, size, weight: p.weight ?? null, color: rgba(who, p.color), background: rgba(who, p.text_background_color), underline: p.underline === true, smoothing: p.font_smoothing ?? "AntiAliased" }; +} + +/** The Text2d's sections: its own leading text, then each child in its own style (Bevy's defaults where + * left out, as a TextSpan's). `span` is ui.tsx's TextSpan, which marks a span child. */ +function sectionsOf(p: Text2dProps, span: unknown) { + let own = ""; + const spans: ReturnType[] = []; + for (const c of Children.toArray(p.children)) { + if (typeof c === "string" || typeof c === "number") { + if (spans.length) throw new TypeError("Text2d: inside a Canvas3D its own text comes before its s"); + own += String(c); + } else if (isValidElement(c) && c.type === span) { + const sp = c.props as TextStyleProps & TextRunProps & { children?: ReactNode }; + spans.push(sectionOf("TextSpan", Children.toArray(sp.children).map(String).join(""), sp)); + } else throw new TypeError("Text2d: inside a Canvas3D its children are text and s"); + } + return [sectionOf("Text2d", own, p), ...spans]; +} + +const JUSTIFY = ["Left", "Center", "Right", "Justified", "Start", "End"]; +const BREAKS = ["WordBoundary", "AnyCharacter", "WordOrCharacter", "NoWrap"]; + +/** Bevy's Text2d in the Canvas3D's 2D world: its place the frame's centre the origin, +Y up, a unit a pixel. */ +export function NativeText2d({ span, ...p }: Text2dProps & { span: unknown }) { + const { width, height } = useVideoConfig(); + if (p.justify !== undefined && !JUSTIFY.includes(p.justify)) throw new TypeError(`Text2d: justify is ${JUSTIFY.join(", ")}, got ${JSON.stringify(p.justify)}`); + if (p.linebreak !== undefined && !BREAKS.includes(p.linebreak)) throw new TypeError(`Text2d: linebreak is ${BREAKS.join(", ")}, got ${JSON.stringify(p.linebreak)}`); + const b = p.bounds; + if (b !== undefined && !(Array.isArray(b) && b.length === 2 && b.every((x) => x === null || (Number.isFinite(x) && x > 0)))) throw new TypeError(`Text2d: bounds is TextBounds' [width, height] in px (either null, unbounded), got ${JSON.stringify(b)}`); + const sh = p.shadow === true ? {} : p.shadow; + const shadow = sh && { offset: sh.offset ?? [4, -4], color: rgba("Text2d shadow", sh.color) ?? [0, 0, 0, 1] }; + const text = { sections: sectionsOf(p, span), justify: p.justify ?? "Left", linebreak: p.linebreak ?? "WordBoundary", bounds: b ?? null, anchor: p.anchor ?? [0, 0], shadow: shadow ?? null }; + const [tx, ty, tz] = p.transform?.translation ?? [0, 0, 0]; + const [sx, sy] = p.transform?.scale ?? [1, 1, 1]; + const quat = p.transform?.rotation; + return node3d("Shape2D", { text, x: width / 2 + tx, y: height / 2 - ty, z: tz, scale: [sx, sy], ...(quat ? { quat } : {}) }); +} diff --git a/sdk/render/src/bevy3d/ui.tsx b/sdk/render/src/bevy3d/ui.tsx index d9fc4c60..76e30a25 100644 --- a/sdk/render/src/bevy3d/ui.tsx +++ b/sdk/render/src/bevy3d/ui.tsx @@ -19,6 +19,7 @@ import { scrollCss, type IgnoreScroll } from "./ui-scroll"; import { useDebugAttr, type UiDebugOptions } from "./ui-debug"; import type { TransformValue } from "./core"; import { InCanvas3D, eulerOf } from "../3d/model"; +import { NativeText2d, type Text2dProps } from "./text2d"; import { useVideoConfig } from "@raea/app/clock"; type Color = Srgba | LinearRgba | string; @@ -258,6 +259,8 @@ export interface TextStyleProps { font_features?: Record; /** LetterSpacing: { Px } or { Rem } (of bevy_text's 20 px rem) after every glyph (none by default) */ letter_spacing?: { Px: number } | { Rem: number }; + /** TextFont's FontSmoothing: "None" draws the glyphs unantialiased (a inside a Canvas3D only) */ + font_smoothing?: "AntiAliased" | "None"; } /** bevy_text's FontVariationTag: the registered axes' OpenType tags. @bevy bevy_text::FontVariationTag */ @@ -374,9 +377,10 @@ const BREAK: Record, CSSProperties> = { /** Bevy's UI text: a Node whose content is its string and its children, in its TextFont, TextColor, * TextLayout and LineHeight (Bevy's defaults when left out). @bevy bevy_ui::widget::text::Text */ -export function Text({ children, font, font_size, weight, style, font_width, color, line_height, font_variations, font_features, letter_spacing, justify, linebreak, shadow, underline, strikethrough, underline_color, strikethrough_color, text_background_color, ...node }: TextProps) { +export function Text({ children, font, font_size, weight, style, font_width, color, line_height, font_variations, font_features, letter_spacing, justify, linebreak, shadow, underline, strikethrough, underline_color, strikethrough_color, text_background_color, font_smoothing, ...node }: TextProps) { const ui = useContext(InUi); const n = nodeCss("Text", node, ui?.back, useContext(UiScaleCx)); + if (font_smoothing === "None") throw new TypeError("Text: font_smoothing \"None\" is for a inside a Canvas3D (the page's text is always smoothed)"); const t = textCss("Text", { font, font_size, weight, style, font_width, color, line_height, font_variations, font_features, letter_spacing }, n.back); if (justify !== undefined && !["Left", "Center", "Right", "Justified", "Start", "End"].includes(justify)) throw new TypeError(`Text: justify is Left, Center, Right, Justified, Start or End, got ${JSON.stringify(justify)}`); if (linebreak !== undefined && !(linebreak in BREAK)) throw new TypeError(`Text: linebreak is WordBoundary, AnyCharacter, WordOrCharacter or NoWrap, got ${JSON.stringify(linebreak)}`); @@ -423,23 +427,15 @@ export function TextSpan({ children, underline, strikethrough, underline_color, } -export interface Text2dProps extends TextStyleProps, TextRunProps { - /** its place in Bevy's 2D world: the frame's centre the origin, +Y up, a unit a pixel, turns counterclockwise */ - transform?: TransformValue; - /** how its lines line up with each other (TextLayout's Justify, Left by default) */ - justify?: TextProps["justify"]; - /** Bevy's Anchor, as its Vec2: which point of the block sits at its Transform, [-0.5, -0.5] its bottom left to - * [0.5, 0.5] its top right ([0, 0], the centre, by default; Anchor::TOP_CENTER is [0, 0.5]) */ - anchor?: [number, number]; - children?: ReactNode; -} +export type { Text2dProps } from "./text2d"; /** Text in Bevy's 2D world, its block's centre at its Transform (Text2d; Bevy's Anchor::CENTER unless `anchor` says). bevy_text - * lays it out as a 's, so this is that Text, placed on the frame. Put it after the in the - * : it draws over the 2D and 3D parts, where Bevy orders it with the 2D ones by z. + * lays it out as a 's. Inside a it is Bevy's own Text2d (text2d.tsx), ordered with the 2D parts by z; + * after it, in the , it is that Text placed on the frame, over the 2D and 3D parts. * @bevy bevy_sprite::text2d::Text2d */ -export function Text2d({ transform, justify, anchor = [0, 0], children, ...text }: Text2dProps) { - if (useContext(InCanvas3D)) throw new TypeError("Text2d: put it after the , in the : inside a layered Canvas3D it would be read as a 3D part and not drawn"); +export function Text2d({ transform, justify, anchor = [0, 0], children, bounds, shadow, ...text }: Text2dProps) { + if (useContext(InCanvas3D)) return {children}; + if (bounds || shadow || text.font_smoothing === "None") throw new TypeError("Text2d: bounds, shadow and font_smoothing \"None\" are Bevy's own Text2d's: put it inside the "); if (!(Array.isArray(anchor) && anchor.length === 2 && anchor.every(Number.isFinite))) throw new TypeError(`Text2d: anchor is Bevy's Anchor as [x, y] (-0.5 to 0.5), got ${JSON.stringify(anchor)}`); const { width, height } = useVideoConfig(); const [tx, ty] = transform?.translation ?? [0, 0, 0]; diff --git a/skills b/skills index 004b8664..f81678fa 160000 --- a/skills +++ b/skills @@ -1 +1 @@ -Subproject commit 004b8664083c8fc5b3b07eea6b31bd41c7595f04 +Subproject commit f81678fa1391975f30983410305782779b6652c7 diff --git a/systems/sprite/src/atlas.rs b/systems/sprite/src/atlas.rs new file mode 100644 index 00000000..1091773a --- /dev/null +++ b/systems/sprite/src/atlas.rs @@ -0,0 +1,71 @@ +//! A texture atlas packed from pictures (raea/3d's TextureAtlasBuilder, Bevy's examples/2d/texture_atlas): the src +//! "atlas:" and its JSON, { textures: [picture, ...], padding: [x, y], sampler }, built once by Bevy's own +//! TextureAtlasBuilder, each picture added in its list's order (the packer's ties go by that order, as a LoadedFolder's +//! handles go to Bevy's). A sprite showing one of its pictures is the row's `atlas_pick`, its index in that list. + +use std::collections::HashMap; + +use bevy::image::{TextureAtlas, TextureAtlasBuilder, TextureAtlasLayout}; +use bevy::prelude::*; + +const PREFIX: &str = "atlas:"; + +#[derive(Clone)] +struct Built { + image: Handle, + size: UVec2, + layout: Handle, + /// each listed picture's index in the layout + picks: Vec, +} + +/// Atlases built so far, by their src: sprites naming one share its picture and layout. +#[derive(Resource, Default)] +struct Atlases(HashMap); + +/// Whether a sprite's src is an atlas. +pub fn is_atlas(src: &str) -> bool { + src.starts_with(PREFIX) +} + +/// The atlas a src names, packed now if it is new: its picture and that picture's size. `picture` decodes one listed +/// picture to straight RGBA8, as a sprite's own. +pub fn source(world: &mut World, src: &str, mut picture: impl FnMut(&str) -> Result<((u32, u32), Vec), String>) -> Result<(Handle, UVec2), String> { + if let Some(b) = world.get_resource_or_init::().0.get(src) { + return Ok((b.image.clone(), b.size)); + } + let spec: serde_json::Value = serde_json::from_str(&src[PREFIX.len()..]).map_err(|e| format!("atlas: {e}"))?; + let list = spec.get("textures").and_then(|t| t.as_array()).filter(|t| !t.is_empty()).ok_or("atlas: textures is a list of one or more pictures")?; + let pad: [u32; 2] = match spec.get("padding") { + Some(p) => serde_json::from_value(p.clone()).map_err(|e| format!("atlas: padding is [x, y]: {e}"))?, + None => [0, 0], + }; + let mut images = Vec::with_capacity(list.len()); + for p in list { + let p = p.as_str().ok_or_else(|| format!("atlas: a texture is a picture's path, got {p}"))?; + let ((w, h), rgba) = picture(p).map_err(|e| format!("atlas texture {p}: {e}"))?; + images.push(crate::sprite_image(w, h, rgba)); + } + let ids: Vec> = images.iter().map(|i| world.resource_mut::>().add(i.clone()).id()).collect(); + let mut builder = TextureAtlasBuilder::default(); + builder.padding(UVec2::from_array(pad)); + for (id, image) in ids.iter().zip(&images) { + builder.add_texture(Some(*id), image); + } + let (layout, sources, image) = builder.build().map_err(|e| format!("atlas: {e}"))?; + let mut picks = Vec::with_capacity(ids.len()); + for id in &ids { + picks.push(sources.texture_index(*id).ok_or("atlas: a texture left out of its layout")?); + } + let size = layout.size; + let built = Built { image: world.resource_mut::>().add(image), size, layout: world.resource_mut::>().add(layout), picks }; + world.resource_mut::().0.insert(src.to_string(), built.clone()); + Ok((built.image, built.size)) +} + +/// The cell of an atlas a sprite shows: its `pick` (a listed picture's index), or the whole atlas without one. +pub fn pick(world: &mut World, src: &str, pick: Option) -> Result, String> { + let (Some(i), Some(b)) = (pick, world.get_resource::().and_then(|a| a.0.get(src))) else { return Ok(None) }; + let index = *b.picks.get(i).ok_or_else(|| format!("atlas_pick {i}: the atlas has {} textures", b.picks.len()))?; + Ok(Some(TextureAtlas { layout: b.layout.clone(), index })) +} diff --git a/systems/sprite/src/lib.rs b/systems/sprite/src/lib.rs index 13cc2c84..52bbcb86 100644 --- a/systems/sprite/src/lib.rs +++ b/systems/sprite/src/lib.rs @@ -23,6 +23,9 @@ use raea_sys_frame::{FrameRows, RenderImages, num}; #[derive(Component)] pub struct Part2d; +pub mod atlas; +pub mod text2d; + /// The scene's 2D camera. #[derive(Component)] pub struct Camera2dOver; @@ -90,7 +93,10 @@ pub fn shape_image(w: u32, h: u32, rgba: Vec, v: &BTreeMap) -> Re /// A sprite's entity from its row and its picture (`size` in px). /// A sprite's picture and its size: a "render:NAME" (or "render:NAME:WxH") image as it is, from `render` (raea-runtime-plugins' /// fields::image), which a frame may switch to another by name (sync_2d); otherwise the picture `picture` decodes. -pub fn source(world: &mut World, src: &str, picture: impl FnOnce(&str) -> Result<((u32, u32), Vec), String>, render: impl FnOnce(&mut World, &serde_json::Value) -> Result, String>) -> Result<(Handle, UVec2), String> { +pub fn source(world: &mut World, src: &str, mut picture: impl FnMut(&str) -> Result<((u32, u32), Vec), String>, render: impl FnOnce(&mut World, &serde_json::Value) -> Result, String>) -> Result<(Handle, UVec2), String> { + if atlas::is_atlas(src) { + return atlas::source(world, src, picture); + } if let Some(name) = RenderImages::name(src) { let image = render(world, &serde_json::Value::String(src.into()))?; let (w, h) = world.get_resource::().and_then(|r| r.0.get(name)).map(|i| i.1).ok_or_else(|| format!("{src}: no render image"))?; @@ -111,10 +117,13 @@ pub fn spawn_sprite(world: &mut World, e: Entity, t: &Tup, image: Handle, img.sampler = ImageSampler::Descriptor(s.over(raea_sys_sampler::descriptor_of(&img.sampler))); } } - let texture_atlas = (cols > 1 || rows > 1).then(|| { + // a picture of an atlas (TextureAtlasBuilder): its `atlas_pick`, or the whole atlas + let src = match v.get("src") { Some(V::S(s)) => s.clone(), _ => String::new() }; + let picked = atlas::pick(world, &src, v.get("atlas_pick").map(|p| p.num().max(0.0) as usize))?; + let texture_atlas = picked.or_else(|| (cols > 1 || rows > 1).then(|| { let layout = world.resource_mut::>().add(TextureAtlasLayout::from_grid(UVec2::new(cw, ch), cols, rows, None, None)); TextureAtlas { layout, index: cell(v, cols * rows) } - }); + })); let custom_size = size_of(v, ch as f32 / cw as f32); // Bevy's SpriteImageMode::Tiled: the picture repeats across the sprite's size, every stretch_value x its own let (tile_x, tile_y) = (num(v, "tile_x", 0.0) > 0.5, num(v, "tile_y", 0.0) > 0.5); @@ -167,6 +176,11 @@ fn uv_of(v: &BTreeMap) -> bevy::math::Affine2 { /// `shader` (a in a Mesh2d, docs/control.feature FC2a), its own Material2d (raea-sys-shader's OwnMaterial). pub fn spawn_shape(world: &mut World, e: Entity, t: &Tup, texture: Option>) -> Result<(), String> { let v = &t.vals; + // a Text2d (its `text` spec): Bevy's own, placed as any 2D part + if let Some(V::S(spec)) = v.get("text") { + world.entity_mut(e).insert((place_of(v), Visibility::default(), Part2d)); + return text2d::spawn(world, e, spec).map_err(|err| format!("{} {err}", t.id)); + } let (w, h) = (num(v, "w", 100.0), num(v, "h", 100.0)); // one of Bevy's 2D primitives as raea-sys-mesh reads it (a Mesh2d's , , a ring), or a shape let primitive = match v.get("primitive") { @@ -270,7 +284,8 @@ pub fn sync_2d(frame: Res, renders: Option>, mut ma } let cells = (num(v, "sheet_cols", 1.0).max(1.0) * num(v, "sheet_rows", 1.0).max(1.0)) as u32; let at = cell(v, cells); - if let Some(a) = s.texture_atlas.as_mut().filter(|a| a.index != at) { + // (a sheet's keyed cell; an atlas's picked picture stays as it was spawned) + if let Some(a) = s.texture_atlas.as_mut().filter(|a| a.index != at && !v.contains_key("atlas_pick")) { a.index = at; } // a render image's picture this frame (Bevy's compute_shader_game_of_life swaps its sprite's two each frame) diff --git a/systems/sprite/src/text2d.rs b/systems/sprite/src/text2d.rs new file mode 100644 index 00000000..54d43b2f --- /dev/null +++ b/systems/sprite/src/text2d.rs @@ -0,0 +1,106 @@ +//! Text in the 2D world drawn by Bevy's own Text2d (`` inside a , sdk/render's bevy3d/ui.tsx): its +//! layout, glyphs and draw order among the sprites are bevy_text's and bevy_sprite_render's, so TextBounds, +//! FontSmoothing::None, a Text2dShadow, spans and a z under a sprite are as Bevy draws them. The row is a shape2d's +//! with a `text` column, JSON: +//! { sections: [{ text, font (a font file's path, Bevy's default font when null), size, weight, color, background, +//! underline, smoothing }, ...], justify, linebreak, bounds: [w, h] (either null), anchor: [x, y], +//! shadow: { offset: [x, y], color } } +//! the first section the Text2d's own text and style, the rest its TextSpan children; colours sRGBA floats. + +use std::collections::HashMap; + +use bevy::prelude::*; +use bevy::sprite::{Anchor, Text2d, Text2dShadow}; +use bevy::text::{Font, FontSmoothing, FontWeight, Justify, LineBreak, TextBackgroundColor, TextBounds, TextColor, TextFont, TextLayout, TextSpan, Underline}; +use serde_json::Value; + +/// Fonts read so far, by their file's path. +#[derive(Resource, Default)] +struct Fonts(HashMap>); + +fn color(v: Option<&Value>) -> Option { + let a = v?.as_array()?; + let c = |i: usize| a.get(i).and_then(Value::as_f64).unwrap_or(1.0) as f32; + Some(Color::srgba(c(0), c(1), c(2), c(3))) +} + +fn pair(v: Option<&Value>) -> Option { + let a = v?.as_array()?; + Some(Vec2::new(a.first()?.as_f64()? as f32, a.get(1)?.as_f64()? as f32)) +} + +/// A section's TextFont, its font file read once. +fn font_of(world: &mut World, s: &Value) -> Result { + let mut f = TextFont::from_font_size(s.get("size").and_then(Value::as_f64).unwrap_or(20.0) as f32); + if let Some(path) = s.get("font").and_then(Value::as_str) { + let known = world.get_resource_or_init::().0.get(path).cloned(); + let h = match known { + Some(h) => h, + None => { + let bytes = std::fs::read(path).map_err(|e| format!("Text2d: font {path}: {e}"))?; + let h = world.resource_mut::>().add(Font::from_bytes(bytes)); + world.resource_mut::().0.insert(path.to_string(), h.clone()); + h + } + }; + f.font = h.into(); + } + if let Some(w) = s.get("weight").and_then(Value::as_u64) { + f.weight = FontWeight(w as u16); + } + if s.get("smoothing").and_then(Value::as_str) == Some("None") { + f.font_smoothing = FontSmoothing::None; + } + Ok(f) +} + +/// A section's text, font, colour, background and underline, on `e`. +fn section(world: &mut World, e: Entity, s: &Value) -> Result<(), String> { + let font = font_of(world, s)?; + let mut ent = world.entity_mut(e); + ent.insert((font, TextColor(color(s.get("color")).unwrap_or(Color::WHITE)))); + if let Some(b) = color(s.get("background")) { + ent.insert(TextBackgroundColor(b)); + } + if s.get("underline").and_then(Value::as_bool) == Some(true) { + ent.insert(Underline); + } + Ok(()) +} + +/// The Text2d a row's `text` spec makes on `e` (its place, visibility and Part2d the caller's), its spans children. +pub fn spawn(world: &mut World, e: Entity, spec: &str) -> Result<(), String> { + let spec: Value = serde_json::from_str(spec).map_err(|err| format!("Text2d: {err}"))?; + let sections = spec.get("sections").and_then(Value::as_array).filter(|s| !s.is_empty()).ok_or("Text2d: no text")?; + let justify = match spec.get("justify").and_then(Value::as_str).unwrap_or("Left") { + "Center" => Justify::Center, + "Right" => Justify::Right, + "Justified" => Justify::Justified, + "Start" => Justify::Start, + "End" => Justify::End, + _ => Justify::Left, + }; + let linebreak = match spec.get("linebreak").and_then(Value::as_str).unwrap_or("WordBoundary") { + "AnyCharacter" => LineBreak::AnyCharacter, + "WordOrCharacter" => LineBreak::WordOrCharacter, + "NoWrap" => LineBreak::NoWrap, + _ => LineBreak::WordBoundary, + }; + let text = |s: &Value| s.get("text").and_then(Value::as_str).unwrap_or("").to_string(); + world.entity_mut(e).insert((Text2d::new(text(§ions[0])), TextLayout::new(justify, linebreak), Anchor(pair(spec.get("anchor")).unwrap_or(Vec2::ZERO)))); + section(world, e, §ions[0])?; + if let Some(b) = spec.get("bounds").and_then(Value::as_array) { + let side = |i: usize| b.get(i).and_then(Value::as_f64).map(|x| x as f32); + world.entity_mut(e).insert(TextBounds { width: side(0), height: side(1) }); + } + if let Some(s) = spec.get("shadow").filter(|s| s.is_object()) { + let d = Text2dShadow::default(); + world.entity_mut(e).insert(Text2dShadow { offset: pair(s.get("offset")).unwrap_or(d.offset), color: color(s.get("color")).unwrap_or(d.color) }); + } + for s in §ions[1..] { + let span = world.spawn(TextSpan::new(text(s))).id(); + section(world, span, s)?; + world.entity_mut(e).add_child(span); + } + Ok(()) +}