Skip to content

armgit / raea

Public Imported from GitHub
0

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

FC2a: a Material reads the camera's prepasses (shader/shader_prepass, 131/131); live play's 3D under the page drawn opaque, as a window shows it

shinyobjectzfa6a5ed17f98
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index 089ca9f1..584dae04 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -130,3 +130,4 @@ shader/fallback_image
shader/storage_buffer
shader/array_texture
shader/sprite_material
+shader/shader_prepass
diff --git a/bench/bevy-parity/input/shader_prepass.json b/bench/bevy-parity/input/shader_prepass.json
new file mode 100644
index 00000000..eb1efac3
--- /dev/null
+++ b/bench/bevy-parity/input/shader_prepass.json
@@ -0,0 +1 @@
+{"20": ["Space"], "21": [], "40": ["Space"], "41": [], "60": ["Space"], "61": []}
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index b1366d35..ddb4d099 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -129,3 +129,4 @@ shader/fallback_image - 10
shader/storage_buffer - 30,60
shader/array_texture - 30,100
shader/sprite_material - 29,40,70,95,110,130 bench/bevy-parity/input/sprite_material.json
+shader/shader_prepass - 10,30,50,70 bench/bevy-parity/input/shader_prepass.json
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index bbcc02fb..bdff3a6b 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 **130**, passing **130**, excluded **16** (docs/bevy-parity/excluded.tsv), left **292**.
+Examples: **438**, ported **131**, passing **131**, excluded **16** (docs/bevy-parity/excluded.tsv), left **291**.
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.
@@ -147,7 +147,6 @@ doesn't pay.
| ui/widgets/vertical_slider | 10 | 0.999004 | 11 | 0 / 0 | 459 / 508 | 5 / 7 | 1 / 1 | 45.692 / 1.516 = 1.516 + 0 | yes | |
| ui/widgets/virtual_keyboard | 10 | 0.993705 | 13 | 0 / 0 | 646 / 508 | 5 / 7 | 1 / 1 | 44.736 / 2.209 = 2.209 + 0 | yes | |
| ui/widgets/standard_widgets_observers | 10 | 0.998736 | 14 | 0 / 0 | 473 / 508 | 5 / 7 | 1 / 1 | 44.781 / 1.474 = 1.474 + 0 | yes | |
-| ui/widgets/standard_widgets | 10 | 0.994691 | 17 | 0 / 0 | 487 / 508 | 5 / 7 | 1 / 1 | 43.391 / 1.133 = 1.133 + 0 | yes | |
| ui/widgets/feathers_counter | 10 | 0.999941 | 1 | 0 / 0 | 493 / 508 | 5 / 7 | 1 / 1 | 41.503 / 1.368 = 1.368 + 0 | yes | |
| ui/widgets/feathers_number_input | 10 | 0.997483 | 6 | 0 / 0 | 972 / 508 | 5 / 7 | 1 / 1 | 44.783 / 1.825 = 1.825 + 0 | yes | |
| ui/widgets/feathers_gallery | 10 | 0.995606 | 9 | 0 / 0 | 1060 / 508 | 5 / 7 | 1 / 1 | 49.123 / 1.55 = 1.55 + 0 | yes | |
@@ -195,12 +194,17 @@ doesn't pay.
| shader/array_texture | 30 | 1.000000 | 0 | 0 / 0 | 458 / 542 | 6 / 8 | 1 / 12 | 19.391 / 1.975 = 1.975 + 0 | yes | |
| shader/storage_buffer | 30 | 0.999999 | 0 | 0 / 0 | 538 / 973 | 6 / 8 | 1 / 92 | 19.664 / 2.053 = 2.053 + 0 | yes | |
| shader/storage_buffer | 60 | 0.999999 | 0 | 0 / 0 | 538 / 973 | 6 / 8 | 1 / 92 | 3.572 / 1.798 = 1.798 + 0 | yes | |
-| shader/sprite_material | 110 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.304 / 1.727 = 1.727 + 0 | yes | |
-| shader/sprite_material | 130 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.359 / 1.654 = 1.654 + 0 | yes | |
-| shader/sprite_material | 29 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 19.17 / 1.813 = 1.813 + 0 | yes | |
-| shader/sprite_material | 40 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.813 / 1.612 = 1.612 + 0 | yes | |
-| shader/sprite_material | 70 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.645 / 1.691 = 1.691 + 0 | yes | |
-| shader/sprite_material | 95 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.425 / 1.391 = 1.391 + 0 | yes | |
+| ui/widgets/standard_widgets | 10 | 0.994691 | 17 | 0 / 0 | 487 / 516 | 5 / 7 | 1 / 1 | 45.788 / 2.282 = 2.282 + 0 | yes | |
+| shader/sprite_material | 110 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.188 / 1.566 = 1.566 + 0 | yes | |
+| shader/sprite_material | 130 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.472 / 1.413 = 1.413 + 0 | yes | |
+| shader/sprite_material | 29 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 17.195 / 1.746 = 1.746 + 0 | yes | |
+| shader/sprite_material | 40 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.863 / 1.279 = 1.279 + 0 | yes | |
+| shader/sprite_material | 70 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.457 / 1.325 = 1.325 + 0 | yes | |
+| shader/sprite_material | 95 | 0.999832 | 7 | 0 / 0 | 455 / 520 | 5 / 7 | 1 / 1 | 2.122 / 1.418 = 1.418 + 0 | yes | |
+| shader/shader_prepass | 10 | 0.995071 | 7 | 2 / 2 | 465 / 533 | 10 / 11 | 3 / 6 | 53.512 / 4.148 = 4.148 + 0 | yes | |
+| shader/shader_prepass | 30 | 0.995869 | 7 | 2 / 2 | 465 / 533 | 10 / 11 | 3 / 6 | 5.599 / 2.778 = 2.778 + 0 | yes | |
+| shader/shader_prepass | 50 | 0.994765 | 7 | 2 / 2 | 465 / 533 | 10 / 11 | 3 / 6 | 5.082 / 2.869 = 2.869 + 0 | yes | |
+| shader/shader_prepass | 70 | 0.997658 | 7 | 2 / 2 | 465 / 533 | 10 / 11 | 3 / 6 | 4.626 / 2.77 = 2.77 + 0 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index 10320133..1dbc6f9d 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -134,7 +134,6 @@
{"example":"ui/widgets/vertical_slider","frame":10,"ssim":0.999004,"tile":11,"bevy":{"batch_keys":0,"entities":459,"extents":[],"frame":10,"frame_ms":45.692,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.516,"step_ms":null,"cost_ms":1.516},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/widgets/virtual_keyboard","frame":10,"ssim":0.993705,"tile":13,"bevy":{"batch_keys":0,"entities":646,"extents":[],"frame":10,"frame_ms":44.736,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.209,"step_ms":null,"cost_ms":2.209},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/widgets/standard_widgets_observers","frame":10,"ssim":0.998736,"tile":14,"bevy":{"batch_keys":0,"entities":473,"extents":[],"frame":10,"frame_ms":44.781,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.474,"step_ms":null,"cost_ms":1.474},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"ui/widgets/standard_widgets","frame":10,"ssim":0.994691,"tile":17,"bevy":{"batch_keys":0,"entities":487,"extents":[],"frame":10,"frame_ms":43.391,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.133,"step_ms":null,"cost_ms":1.133},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/widgets/feathers_counter","frame":10,"ssim":0.999941,"tile":1,"bevy":{"batch_keys":0,"entities":493,"extents":[],"frame":10,"frame_ms":41.503,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.368,"step_ms":null,"cost_ms":1.368},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/widgets/feathers_number_input","frame":10,"ssim":0.997483,"tile":6,"bevy":{"batch_keys":0,"entities":972,"extents":[],"frame":10,"frame_ms":44.783,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.825,"step_ms":null,"cost_ms":1.825},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"ui/widgets/feathers_gallery","frame":10,"ssim":0.995606,"tile":9,"bevy":{"batch_keys":0,"entities":1060,"extents":[],"frame":10,"frame_ms":49.123,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":508,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.55,"step_ms":null,"cost_ms":1.55},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
@@ -182,9 +181,14 @@
{"example":"shader/array_texture","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":458,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":19.391,"materials":1,"mesh_entities":11,"meshes":6,"other_material":11,"visible":11},"raea":{"frame":39,"entities":542,"mesh_entities":11,"visible":11,"meshes":8,"materials":12,"batch_keys":0,"other_material":11,"extents":["0.5000 0.5000 0.5000"],"frame_ms":1.975,"step_ms":null,"cost_ms":1.975},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/storage_buffer","frame":30,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":0,"entities":538,"extents":["0.1500 0.1500 0.1500"],"frame":30,"frame_ms":19.664,"materials":1,"mesh_entities":91,"meshes":6,"other_material":91,"visible":91},"raea":{"frame":37,"entities":973,"mesh_entities":91,"visible":91,"meshes":8,"materials":92,"batch_keys":0,"other_material":91,"extents":["0.1500 0.1500 0.1500"],"frame_ms":2.053,"step_ms":null,"cost_ms":2.053},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/storage_buffer","frame":60,"ssim":0.999999,"tile":0,"bevy":{"batch_keys":0,"entities":538,"extents":["0.1500 0.1500 0.1500"],"frame":60,"frame_ms":3.572,"materials":1,"mesh_entities":91,"meshes":6,"other_material":91,"visible":91},"raea":{"frame":67,"entities":973,"mesh_entities":91,"visible":91,"meshes":8,"materials":92,"batch_keys":0,"other_material":91,"extents":["0.1500 0.1500 0.1500"],"frame_ms":1.798,"step_ms":null,"cost_ms":1.798},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":110,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":110,"frame_ms":2.304,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":117,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.727,"step_ms":null,"cost_ms":1.727},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":130,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":130,"frame_ms":2.359,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":137,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.654,"step_ms":null,"cost_ms":1.654},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":29,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":29,"frame_ms":19.17,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":36,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.813,"step_ms":null,"cost_ms":1.813},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":40,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":40,"frame_ms":2.813,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":47,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.612,"step_ms":null,"cost_ms":1.612},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":70,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":70,"frame_ms":2.645,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":77,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.691,"step_ms":null,"cost_ms":1.691},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
-{"example":"shader/sprite_material","frame":95,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":95,"frame_ms":2.425,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":102,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.391,"step_ms":null,"cost_ms":1.391},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"ui/widgets/standard_widgets","frame":10,"ssim":0.994691,"tile":17,"bevy":{"batch_keys":0,"entities":487,"extents":[],"frame":10,"frame_ms":45.788,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":17,"entities":516,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":2.282,"step_ms":null,"cost_ms":2.282},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":110,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":110,"frame_ms":2.188,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":117,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.566,"step_ms":null,"cost_ms":1.566},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":130,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":130,"frame_ms":2.472,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":137,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.413,"step_ms":null,"cost_ms":1.413},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":29,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":29,"frame_ms":17.195,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":36,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.746,"step_ms":null,"cost_ms":1.746},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":40,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":40,"frame_ms":2.863,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":47,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.279,"step_ms":null,"cost_ms":1.279},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":70,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":70,"frame_ms":2.457,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":77,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.325,"step_ms":null,"cost_ms":1.325},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/sprite_material","frame":95,"ssim":0.999832,"tile":7,"bevy":{"batch_keys":0,"entities":455,"extents":[],"frame":95,"frame_ms":2.122,"materials":1,"mesh_entities":0,"meshes":5,"other_material":0,"visible":0},"raea":{"frame":102,"entities":520,"mesh_entities":0,"visible":0,"meshes":7,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.418,"step_ms":null,"cost_ms":1.418},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/shader_prepass","frame":10,"ssim":0.995071,"tile":7,"bevy":{"batch_keys":2,"entities":465,"extents":["0.5000 0.5000 0.5000","10.0000 10.0000 0.0000","2.5000 0.0000 2.5000"],"frame":10,"frame_ms":53.512,"materials":3,"mesh_entities":5,"meshes":10,"other_material":3,"visible":5},"raea":{"frame":18,"entities":533,"mesh_entities":5,"visible":5,"meshes":11,"materials":6,"batch_keys":2,"other_material":3,"extents":["0.5000 0.5000 0.5000","10.0000 0.0000 10.0000","2.5000 0.0000 2.5000"],"frame_ms":4.148,"step_ms":null,"cost_ms":4.148},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/shader_prepass","frame":30,"ssim":0.995869,"tile":7,"bevy":{"batch_keys":2,"entities":465,"extents":["0.5000 0.5000 0.5000","10.0000 10.0000 0.0000","2.5000 0.0000 2.5000"],"frame":30,"frame_ms":5.599,"materials":3,"mesh_entities":5,"meshes":10,"other_material":3,"visible":5},"raea":{"frame":38,"entities":533,"mesh_entities":5,"visible":5,"meshes":11,"materials":6,"batch_keys":2,"other_material":3,"extents":["0.5000 0.5000 0.5000","10.0000 0.0000 10.0000","2.5000 0.0000 2.5000"],"frame_ms":2.778,"step_ms":null,"cost_ms":2.778},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/shader_prepass","frame":50,"ssim":0.994765,"tile":7,"bevy":{"batch_keys":2,"entities":465,"extents":["0.5000 0.5000 0.5000","10.0000 10.0000 0.0000","2.5000 0.0000 2.5000"],"frame":50,"frame_ms":5.082,"materials":3,"mesh_entities":5,"meshes":10,"other_material":3,"visible":5},"raea":{"frame":58,"entities":533,"mesh_entities":5,"visible":5,"meshes":11,"materials":6,"batch_keys":2,"other_material":3,"extents":["0.5000 0.5000 0.5000","10.0000 0.0000 10.0000","2.5000 0.0000 2.5000"],"frame_ms":2.869,"step_ms":null,"cost_ms":2.869},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/shader_prepass","frame":70,"ssim":0.997658,"tile":7,"bevy":{"batch_keys":2,"entities":465,"extents":["0.5000 0.5000 0.5000","10.0000 10.0000 0.0000","2.5000 0.0000 2.5000"],"frame":70,"frame_ms":4.626,"materials":3,"mesh_entities":5,"meshes":10,"other_material":3,"visible":5},"raea":{"frame":78,"entities":533,"mesh_entities":5,"visible":5,"meshes":11,"materials":6,"batch_keys":2,"other_material":3,"extents":["0.5000 0.5000 0.5000","10.0000 0.0000 10.0000","2.5000 0.0000 2.5000"],"frame_ms":2.77,"step_ms":null,"cost_ms":2.77},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
diff --git a/engine/page/src/motion/place.rs b/engine/page/src/motion/place.rs
index 56a856a2..c55ae6a0 100644
--- a/engine/page/src/motion/place.rs
+++ b/engine/page/src/motion/place.rs
@@ -145,10 +145,20 @@ impl BlitzPage {
self.place_texture_at(id, src, (0, 0), w, h, false)
}
+ /// `place_texture` drawn opaque: the 3D under a whole page (live play's), whose alpha a window would ignore (a
+ /// Material's own shader may write any, shader/shader_prepass's custom_material 0.5).
+ pub fn place_under(&mut self, id: u64, src: &bevy::render::render_resource::Texture, w: u32, h: u32) {
+ self.placed(id, src, (0, 0), w, h, (false, true))
+ }
+
/// `place_texture` for the box of `src` at `origin` (a camera's view in its element's box: docs/sdk.feature S3a),
/// and for a camera's picture, premultiplied in its stored values, made straight on the way as raea-runtime-js's page
/// makes it (B5: `place_premultiplied`). The box is kept inside the texture.
pub fn place_texture_at(&mut self, id: u64, src: &bevy::render::render_resource::Texture, origin: (u32, u32), w: u32, h: u32, premultiplied: bool) {
+ self.placed(id, src, origin, w, h, (premultiplied, false))
+ }
+
+ fn placed(&mut self, id: u64, src: &bevy::render::render_resource::Texture, origin: (u32, u32), w: u32, h: u32, (premultiplied, opaque): (bool, bool)) {
let (x, y) = (origin.0.min(src.width().saturating_sub(1)), origin.1.min(src.height().saturating_sub(1)));
let (w, h) = (w.min(src.width() - x).max(1), h.min(src.height() - y).max(1));
let image = match self.views.get(&id) {
@@ -161,7 +171,7 @@ impl BlitzPage {
}
};
self.views.insert(id, image.clone());
- raea_sys_page::view_at(&mut self.app, image, Some(raea_sys_page::Placed { texture: (**src).clone(), origin: (x, y), premultiplied }));
+ raea_sys_page::view_at(&mut self.app, image, Some(raea_sys_page::Placed { texture: (**src).clone(), origin: (x, y), premultiplied, opaque }));
}
/// Element `id` drawn as an image: `data` (RGBA8) as its raster, its layout made again for the picture's size.
diff --git a/runtime/page/src/bevy_page.rs b/runtime/page/src/bevy_page.rs
index 0b8a99bc..e73fd344 100644
--- a/runtime/page/src/bevy_page.rs
+++ b/runtime/page/src/bevy_page.rs
@@ -217,7 +217,7 @@ impl BevyPage {
/// The 3D frame under the page: the top left `w` x `h` of `src` (raea-render's target on the shared device), copied there on
/// the GPU.
pub fn set_under(&mut self, src: &wgpu::Texture, w: u32, h: u32) {
- self.page.place_texture(UNDER, &src.clone().into(), w, h);
+ self.page.place_under(UNDER, &src.clone().into(), w, h);
}
/// The layered Canvas3D's frame as its slot's picture, made straight on the GPU as the render's is (live play;
diff --git a/sdk/raea/bench/bevy-parity/shader/shader_prepass.tsx b/sdk/raea/bench/bevy-parity/shader/shader_prepass.tsx
new file mode 100644
index 00000000..f56349f1
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/shader/shader_prepass.tsx
@@ -0,0 +1,80 @@
+// Bevy v0.20.0 examples/shader/shader_prepass.rs in raea's TSX (docs/control.feature FC0a, FC2a): the camera at
+// (-2, 3, 5) with Bevy's DepthPrepass, NormalPrepass and MotionVectorPrepass and Msaa::Off; a 5 m plane in srgb(0.3,
+// 0.5, 0.3); three 1 m cubes at x -1, 0, 1: the example's own Material (assets/shaders/custom_material.wesl, white,
+// Bevy's icon) opaque and turning about Z by (sin(t) * 0.5 + 0.5) * TAU, a StandardMaterial of the icon masked at 1.0,
+// and the own Material blended (which the prepass leaves out); a shadow-casting PointLight at (4, 8, 4). In front of
+// the camera, a 20 m quad with the example's PrepassOutputMaterial (assets/shaders/show_prepass.wesl as written,
+// blended, no shadow) shows what the prepass wrote: Space (bench/bevy-parity/input/shader_prepass.json) steps it from
+// transparent through depth, normals and motion vectors, as toggle_prepass_view does, and the label with it. In Bevy's
+// default 1280 x 720 window.
+import { AbsoluteFill, Composition, registerRoot, staticFile, useCurrentFrame, useGameState, useInput } from "raea";
+import { Quat, Transform } from "raea/transform";
+import { Camera3d } from "raea/camera";
+import { Cuboid, Mesh3d, Plane3d } from "raea/mesh";
+import { PointLight } from "raea/light";
+import { StandardMaterial } from "raea/pbr";
+import { BevyComponent, Canvas3D } from "raea/3d";
+import { Material } from "@raea/render/bevy3d"; // raea/pbr once scene-loop lands (its pbr.ts commit)
+
+const FONT = `@font-face { font-family: "Fira Mono"; src: url("${staticFile("fonts/FiraMono-Medium.ttf")}"); }`;
+const ICON = staticFile("branding/icon.png");
+const LABELS = ["transparent", "depth", "normals", "motion vectors"];
+// a Rectangle (XY, facing +Z) is a Plane3d (XZ, facing +Y) turned +PI/2 about X
+const UPRIGHT = Quat.fromRotationX(Math.PI / 2);
+const QUAD = Transform.fromXyz(-0.75, 1.25, 3).lookingAt([2, -2.5, -5]);
+
+/** toggle_prepass_view: each Space press steps the view (its Local), and the material's settings with it */
+function step(s: { view: number; space: boolean }, input: { keys: string[] }) {
+ const space = input.keys.includes("Space");
+ return { view: space && !s.space ? (s.view + 1) % 4 : s.view, space };
+}
+
+function Custom({ x, alpha_mode, turn }: { x: number; alpha_mode: "Opaque" | "Blend"; turn?: number }) {
+ return (
+ <Mesh3d transform={{ translation: [x, 0.5, 0], rotation: Quat.fromRotationZ(turn ?? 0) }}>
+ <Cuboid half_size={[0.5, 0.5, 0.5]} />
+ <Material fragment={staticFile("shaders/custom_material.wesl")} uniforms={{ material_color: [1, 1, 1, 1] }} textures={{ material_color_texture: ICON }} alpha_mode={alpha_mode} />
+ </Mesh3d>
+ );
+}
+
+function Shot() {
+ // Bevy's picture of frame f is drawn after update f, which read frame f's keys: the fold (updates before f) and f's own
+ const { view } = step(useGameState({ view: 0, space: false }, step), useInput());
+ // rotate: Time::elapsed_secs, f updates of 1/60 s (none on the first), as an f32
+ const t = Math.fround(useCurrentFrame() * 0.016666667);
+ const turn = Math.fround((Math.sin(t) * 0.5 + 0.5) * Math.PI * 2);
+ const settings = { show_depth: view === 1 ? 1 : 0, show_normals: view === 2 ? 1 : 0, show_motion_vectors: view === 3 ? 1 : 0, padding_1: 0, padding_2: 0 };
+ return (
+ <AbsoluteFill>
+ <style>{FONT}</style>
+ <Canvas3D>
+ <Camera3d transform={Transform.fromXyz(-2, 3, 5).lookingAt([0, 0, 0])}>
+ <BevyComponent type="bevy_render::view::Msaa" value="Off" />
+ <BevyComponent type="bevy_core_pipeline::prepass::DepthPrepass" value={{}} />
+ <BevyComponent type="bevy_core_pipeline::prepass::NormalPrepass" value={{}} />
+ <BevyComponent type="bevy_core_pipeline::prepass::MotionVectorPrepass" value={{}} />
+ </Camera3d>
+ <Mesh3d>
+ <Plane3d half_size={[2.5, 2.5]} />
+ <StandardMaterial base_color="rgb(76.5, 127.5, 76.5)" />
+ </Mesh3d>
+ <Mesh3d transform={{ translation: QUAD.translation, rotation: Quat.mul(QUAD.rotation, UPRIGHT) }}>
+ <Plane3d half_size={[10, 10]} />
+ <Material fragment={staticFile("shaders/show_prepass.wesl")} uniforms={{ settings }} alpha_mode="Blend" />
+ <BevyComponent type="bevy_light::NotShadowCaster" value={{}} />
+ </Mesh3d>
+ <Custom x={-1} alpha_mode="Opaque" turn={turn} />
+ <Mesh3d transform={Transform.fromXyz(0, 0.5, 0)}>
+ <Cuboid half_size={[0.5, 0.5, 0.5]} />
+ <StandardMaterial alpha_mode={{ Mask: 1 }} base_color_texture={ICON} />
+ </Mesh3d>
+ <Custom x={1} alpha_mode="Blend" />
+ <PointLight shadow_maps_enabled transform={Transform.fromXyz(4, 8, 4)} />
+ </Canvas3D>
+ <div style={{ position: "absolute", top: 12, left: 12, fontFamily: "Fira Mono", fontSize: 20, lineHeight: 1.2, color: "#fff", whiteSpace: "pre" }}>{`Prepass Output: ${LABELS[view]}\n\n\nControls\n---------------\nSpace - Change output\n`}</div>
+ </AbsoluteFill>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={71} fps={60} width={1280} height={720} />);
diff --git a/systems/filters/src/premul.rs b/systems/filters/src/premul.rs
index 480208d0..e81693b4 100644
--- a/systems/filters/src/premul.rs
+++ b/systems/filters/src/premul.rs
@@ -11,6 +11,8 @@ pub struct Premul {
pub straight: wgpu::RenderPipeline,
/// a premultiplied picture (a camera's) made straight for Vello, which takes an element's picture so
pub unpremul: wgpu::RenderPipeline,
+ /// a picture made opaque, as a window shows it (the 3D under a whole page)
+ pub opaque: wgpu::RenderPipeline,
pub layout: wgpu::BindGroupLayout,
}
@@ -45,8 +47,8 @@ impl Premul {
multiview_mask: None,
cache: None,
});
- let (pipeline, straight, unpremul) = (make("fs"), make("fs_straight"), make("fs_unpremul"));
- Premul { pipeline, straight, unpremul, layout }
+ let (pipeline, straight, unpremul, opaque) = (make("fs"), make("fs_straight"), make("fs_unpremul"), make("fs_opaque"));
+ Premul { pipeline, straight, unpremul, opaque, layout }
}
}
diff --git a/systems/filters/src/premul.wgsl b/systems/filters/src/premul.wgsl
index 0e765b71..e73548c5 100644
--- a/systems/filters/src/premul.wgsl
+++ b/systems/filters/src/premul.wgsl
@@ -30,3 +30,8 @@ fn encoded(c: vec3f) -> vec3f {
}
return vec4f(linear(min(floor((e * 255.0 + floor(a / 2.0)) / a), vec3f(255.0)) / 255.0), a / 255.0);
}
+// the 3D under a whole page (live play's, which a window would show): its colour as stored, opaque, as a window
+// presents it whatever alpha a material wrote (a Material's own shader may write any)
+@fragment fn fs_opaque(@builtin(position) p: vec4f) -> @location(0) vec4f {
+ return vec4f(textureLoad(src, vec2i(p.xy), 0).rgb, 1.0);
+}
diff --git a/systems/page/src/draw.rs b/systems/page/src/draw.rs
index 52307751..36be75ba 100644
--- a/systems/page/src/draw.rs
+++ b/systems/page/src/draw.rs
@@ -39,7 +39,7 @@ pub struct Vello {
/// copied on the GPU into its atlas each frame it's drawn (a 3D scene, a game, live video); None ends it. `image` is
/// the placeholder an element holds (its size and blob are the key). Both live on the App's device.
pub fn view(app: &mut App, image: vello::peniko::ImageData, texture: Option<wgpu::Texture>) {
- view_at(app, image, texture.map(|t| Placed { texture: t, origin: (0, 0), premultiplied: false }));
+ view_at(app, image, texture.map(|t| Placed { texture: t, origin: (0, 0), premultiplied: false, opaque: false }));
}
/// A texture an element shows (`view_at`): its box from `origin` at the placeholder's size, and whether it's a
@@ -49,6 +49,8 @@ pub struct Placed {
pub texture: wgpu::Texture,
pub origin: (u32, u32),
pub premultiplied: bool,
+ /// drawn opaque, its alpha 1 (the 3D under a whole page, as a window shows it)
+ pub opaque: bool,
}
/// `view`, the element's picture a box of the texture, straight or made so.
@@ -80,7 +82,7 @@ pub fn draw(mut scenes: ResMut<Scenes>, mut vello: ResMut<Vello>, device: Res<Re
let mut straighten = device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("raea-page views made straight") });
straightened.retain(|id, _| image_views.iter().any(|v| v.2 && v.1.id() == *id));
// the premultiplied texture made straight into `out` (its whole size, so a box of it is cut as from the texture)
- let unpremul = |encoder: &mut wgpu::CommandEncoder, src: &wgpu::TextureView, out: &wgpu::Texture| {
+ let unpremul = |encoder: &mut wgpu::CommandEncoder, pipeline: &wgpu::RenderPipeline, src: &wgpu::TextureView, out: &wgpu::Texture| {
let bind = device.create_bind_group(&wgpu::BindGroupDescriptor { label: Some("raea-page view made straight"), layout: &premul.layout, entries: &[wgpu::BindGroupEntry { binding: 0, resource: wgpu::BindingResource::TextureView(src) }] });
let view = out.create_view(&default());
let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
@@ -88,7 +90,7 @@ pub fn draw(mut scenes: ResMut<Scenes>, mut vello: ResMut<Vello>, device: Res<Re
color_attachments: &[Some(wgpu::RenderPassColorAttachment { view: &view, depth_slice: None, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::TRANSPARENT), store: wgpu::StoreOp::Store } })],
..default()
});
- pass.set_pipeline(&premul.unpremul);
+ pass.set_pipeline(pipeline);
pass.set_bind_group(0, &bind, &[]);
pass.draw(0..3, 0..1);
};
@@ -100,25 +102,26 @@ pub fn draw(mut scenes: ResMut<Scenes>, mut vello: ResMut<Vello>, device: Res<Re
for (placeholder, handle, premultiplied) in image_views.drain(..) {
let Some(gpu) = images.get(&handle) else { continue };
if !premultiplied {
- pending.push((placeholder, Some(Placed { texture: (*gpu.texture).clone(), origin: (0, 0), premultiplied: false })));
+ pending.push((placeholder, Some(Placed { texture: (*gpu.texture).clone(), origin: (0, 0), premultiplied: false, opaque: false })));
continue;
}
let size = gpu.texture.size();
let out = straightened.entry(handle.id()).or_insert_with(|| straight_target(device, size));
sized(out, size);
- unpremul(&mut straighten, &gpu.texture_view, out);
- pending.push((placeholder, Some(Placed { texture: out.clone(), origin: (0, 0), premultiplied: false })));
+ unpremul(&mut straighten, &premul.unpremul, &gpu.texture_view, out);
+ pending.push((placeholder, Some(Placed { texture: out.clone(), origin: (0, 0), premultiplied: false, opaque: false })));
}
- // placed textures (`view_at`) that are premultiplied: their straight copies, a placeholder gone with its own
- straight_placed.retain(|id, _| pending.iter().any(|(i, p)| i.data.id() == *id && p.as_ref().is_some_and(|p| p.premultiplied)));
+ // placed textures (`view_at`) that are premultiplied or drawn opaque: their copies so, a placeholder gone with its own
+ let copied = |p: &Placed| p.premultiplied || p.opaque;
+ straight_placed.retain(|id, _| pending.iter().any(|(i, p)| i.data.id() == *id && p.as_ref().is_some_and(copied)));
for (placeholder, placed) in pending.iter_mut() {
- let Some(p) = placed.as_mut().filter(|p| p.premultiplied) else { continue };
+ let Some(p) = placed.as_mut().filter(|p| copied(p)) else { continue };
let size = p.texture.size();
let out = straight_placed.entry(placeholder.data.id()).or_insert_with(|| straight_target(device, size));
sized(out, size);
- unpremul(&mut straighten, &p.texture.create_view(&default()), out);
+ unpremul(&mut straighten, if p.opaque { &premul.opaque } else { &premul.unpremul }, &p.texture.create_view(&default()), out);
p.texture = out.clone();
- p.premultiplied = false;
+ (p.premultiplied, p.opaque) = (false, false);
}
queue.submit([straighten.finish()]);
// a view's texture changes under the same paint: any view placed this frame draws every page again