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's texture_2d_array, its layer picked by each cube's MeshTag (shader/array_texture, 129/129)

shinyobjectz8ff3d0cf0010
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index b060715a..b9e435c8 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -128,3 +128,4 @@ shader/shader_material_screenspace_texture
shader/shader_material_2d
shader/fallback_image
shader/storage_buffer
+shader/array_texture
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index a5d0ca1c..cdba63f0 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -127,3 +127,4 @@ shader/shader_material_screenspace_texture - 10,60
shader/shader_material_2d - 10
shader/fallback_image - 10
shader/storage_buffer - 30,60
+shader/array_texture - 30,100
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index dd01602f..9aadebcd 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 **128**, passing **128**, excluded **16** (docs/bevy-parity/excluded.tsv), left **294**.
+Examples: **438**, ported **129**, passing **129**, excluded **16** (docs/bevy-parity/excluded.tsv), left **293**.
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.
@@ -193,6 +193,8 @@ doesn't pay.
| shader/shader_material_screenspace_texture | 60 | 0.998929 | 2 | 1 / 1 | 449 / 513 | 7 / 9 | 2 / 3 | 3.417 / 1.736 = 1.736 + 0 | yes | |
| shader/shader_material_2d | 10 | 1.000000 | 0 | 0 / 0 | 447 / 511 | 6 / 8 | 1 / 1 | 47.105 / 1.75 = 1.75 + 0 | yes | |
| shader/fallback_image | 10 | 1.000000 | 0 | 0 / 0 | 447 / 511 | 6 / 8 | 1 / 2 | 46.188 / 2.415 = 2.415 + 0 | yes | |
+| shader/array_texture | 100 | 1.000000 | 0 | 0 / 0 | 458 / 534 | 6 / 8 | 1 / 12 | 3.238 / 1.589 = 1.589 + 0 | yes | |
+| shader/array_texture | 30 | 1.000000 | 0 | 0 / 0 | 458 / 534 | 6 / 8 | 1 / 12 | 19.592 / 1.952 = 1.952 + 0 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index 928a7f72..a77c2e77 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -180,3 +180,5 @@
{"example":"shader/shader_material_screenspace_texture","frame":60,"ssim":0.998929,"tile":2,"bevy":{"batch_keys":1,"entities":449,"extents":["0.5000 0.5000 0.5000","2.5000 0.0000 2.5000"],"frame":60,"frame_ms":3.417,"materials":2,"mesh_entities":2,"meshes":7,"other_material":1,"visible":2},"raea":{"frame":68,"entities":513,"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.736,"step_ms":null,"cost_ms":1.736},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/shader_material_2d","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":[],"frame":10,"frame_ms":47.105,"materials":1,"mesh_entities":0,"meshes":6,"other_material":0,"visible":0},"raea":{"frame":17,"entities":511,"mesh_entities":0,"visible":0,"meshes":8,"materials":1,"batch_keys":0,"other_material":0,"extents":[],"frame_ms":1.75,"step_ms":null,"cost_ms":1.75},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader/fallback_image","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":10,"frame_ms":46.188,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":17,"entities":511,"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.415,"step_ms":null,"cost_ms":2.415},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/array_texture","frame":100,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":458,"extents":["0.5000 0.5000 0.5000"],"frame":100,"frame_ms":3.238,"materials":1,"mesh_entities":11,"meshes":6,"other_material":11,"visible":11},"raea":{"frame":109,"entities":534,"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.589,"step_ms":null,"cost_ms":1.589},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader/array_texture","frame":30,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":458,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":19.592,"materials":1,"mesh_entities":11,"meshes":6,"other_material":11,"visible":11},"raea":{"frame":39,"entities":534,"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.952,"step_ms":null,"cost_ms":1.952},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
diff --git a/sdk/raea/bench/bevy-parity/shader/array_texture.tsx b/sdk/raea/bench/bevy-parity/shader/array_texture.tsx
new file mode 100644
index 00000000..a47f9473
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/shader/array_texture.tsx
@@ -0,0 +1,36 @@
+// Bevy v0.20.0 examples/shader/array_texture.rs in raea's TSX (docs/control.feature FC0a, FC2a): eleven 1 m cubes at
+// (x + 0.5, 0, 0) for x in -5..=5 with the example's own Material, assets/shaders/array_texture.wesl as written: it
+// lights a StandardMaterial-like surface whose base colour is a layer of a texture_2d_array (textures/array_texture.png,
+// four rows stacked, ImageArrayLayout::RowCount) picked by the cube's MeshTag, x as u32 % 4. The example's
+// update_mesh_tags steps every tag by one each time its 1.5 s repeating Timer finishes. A default DirectionalLight from
+// (3, 2, 1), the camera at (5, 5, 5) looking at (1.5, 0, 0), in Bevy's default 1280 x 720 window.
+import { Composition, registerRoot, staticFile, useCurrentFrame } from "raea";
+import { Transform } from "raea/transform";
+import { Camera3d } from "raea/camera";
+import { Cuboid, Mesh3d } from "raea/mesh";
+import { DirectionalLight } from "raea/light";
+import { BevyComponent } from "raea/3d";
+import { Material } from "@raea/render/bevy3d"; // raea/pbr once scene-loop lands (its pbr.ts commit)
+
+const ARRAY = { src: staticFile("textures/array_texture.png"), layers: 4 };
+
+function Shot() {
+ // the Timer finishes once per 1.5 s of elapsed time (1/60 s a frame, none on the first update)
+ const steps = Math.floor(useCurrentFrame() / 90);
+ return (
+ <>
+ <DirectionalLight transform={Transform.fromXyz(3, 2, 1).lookingAt([0, 0, 0])} />
+ <Camera3d transform={Transform.fromXyz(5, 5, 5).lookingAt([1.5, 0, 0])} />
+ {Array.from({ length: 11 }, (_, i) => i - 5).map((x) => (
+ <Mesh3d key={x} transform={Transform.fromXyz(x + 0.5, 0, 0)}>
+ <Cuboid half_size={[0.5, 0.5, 0.5]} />
+ <Material fragment={staticFile("shaders/array_texture.wesl")} textures={{ my_array_texture: ARRAY }} />
+ {/* x as u32 % 4 wraps a negative x to 2^32 + x, whose remainder is x's non-negative one */}
+ <BevyComponent type="bevy_mesh::components::MeshTag" value={{ value: ((((x % 4) + 4) % 4) + steps) % 4 }} />
+ </Mesh3d>
+ ))}
+ </>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={101} fps={60} width={1280} height={720} />);