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.

shader_advanced/fullscreen_material: a FullscreenMaterial is a <FramePass file> before tonemapping

shinyobjectze9b22879a05c
diff --git a/bench/bevy-parity/examples.list b/bench/bevy-parity/examples.list
index 93a84c68..14f24360 100644
--- a/bench/bevy-parity/examples.list
+++ b/bench/bevy-parity/examples.list
@@ -142,3 +142,4 @@ shader_advanced/compute_mesh
shader_advanced/custom_phase_item
shader_advanced/custom_post_processing
shader_advanced/custom_vertex_attribute
+shader_advanced/fullscreen_material
diff --git a/bench/bevy-parity/runs.tsv b/bench/bevy-parity/runs.tsv
index dbdc939b..5ab658b4 100644
--- a/bench/bevy-parity/runs.tsv
+++ b/bench/bevy-parity/runs.tsv
@@ -141,3 +141,4 @@ shader_advanced/compute_mesh - 5,10
shader_advanced/custom_phase_item - 5,10
shader_advanced/custom_post_processing - 10,30,60
shader_advanced/custom_vertex_attribute - 5,10
+shader_advanced/fullscreen_material - 10,30,60
diff --git a/docs/bevy-parity.md b/docs/bevy-parity.md
index 0f65ae38..c88f4f39 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 **142**, passing **142**, excluded **17** (docs/bevy-parity/excluded.tsv), left **279**.
+Examples: **438**, ported **143**, passing **143**, excluded **17** (docs/bevy-parity/excluded.tsv), left **278**.
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.
@@ -229,6 +229,9 @@ doesn't pay.
| shader_advanced/custom_post_processing | 60 | 0.999954 | 0 | 1 / 1 | 443 / 522 | 6 / 8 | 2 / 2 | 3.697 / 2.305 = 2.305 + 0 | yes | |
| shader_advanced/custom_vertex_attribute | 10 | 1.000000 | 0 | 0 / 0 | 449 / 521 | 6 / 8 | 1 / 2 | 2.875 / 1.367 = 1.367 + 0 | yes | |
| shader_advanced/custom_vertex_attribute | 5 | 1.000000 | 0 | 0 / 0 | 447 / 521 | 6 / 8 | 1 / 2 | 41.257 / 2.953 = 2.953 + 0 | yes | |
+| shader_advanced/fullscreen_material | 10 | 0.999748 | 6 | 1 / 1 | 444 / 522 | 6 / 8 | 2 / 2 | 23.02 / 0.953 = 0.953 + 0 | yes | |
+| shader_advanced/fullscreen_material | 30 | 0.999749 | 6 | 1 / 1 | 444 / 522 | 6 / 8 | 2 / 2 | 1.521 / 0.746 = 0.746 + 0 | yes | |
+| shader_advanced/fullscreen_material | 60 | 0.999749 | 6 | 1 / 1 | 444 / 522 | 6 / 8 | 2 / 2 | 1.584 / 0.658 = 0.658 + 0 | yes | |
## Excluded
diff --git a/docs/bevy-parity/results.jsonl b/docs/bevy-parity/results.jsonl
index 60c9f94a..d3590516 100644
--- a/docs/bevy-parity/results.jsonl
+++ b/docs/bevy-parity/results.jsonl
@@ -216,3 +216,6 @@
{"example":"shader_advanced/custom_post_processing","frame":60,"ssim":0.999954,"tile":0,"bevy":{"batch_keys":1,"entities":443,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":3.697,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":522,"mesh_entities":1,"visible":1,"meshes":8,"materials":2,"batch_keys":1,"other_material":0,"extents":["0.5000 0.5000 0.5000"],"frame_ms":2.305,"step_ms":null,"cost_ms":2.305},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader_advanced/custom_vertex_attribute","frame":10,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":449,"extents":["0.5000 0.5000 0.5000"],"frame":10,"frame_ms":2.875,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":17,"entities":521,"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.367,"step_ms":null,"cost_ms":1.367},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
{"example":"shader_advanced/custom_vertex_attribute","frame":5,"ssim":1.000000,"tile":0,"bevy":{"batch_keys":0,"entities":447,"extents":["0.5000 0.5000 0.5000"],"frame":5,"frame_ms":41.257,"materials":1,"mesh_entities":1,"meshes":6,"other_material":1,"visible":1},"raea":{"frame":12,"entities":521,"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.953,"step_ms":null,"cost_ms":2.953},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader_advanced/fullscreen_material","frame":10,"ssim":0.999748,"tile":6,"bevy":{"batch_keys":1,"entities":444,"extents":["0.5000 0.5000 0.5000"],"frame":10,"frame_ms":23.02,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":17,"entities":522,"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.953,"step_ms":null,"cost_ms":0.953},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader_advanced/fullscreen_material","frame":30,"ssim":0.999749,"tile":6,"bevy":{"batch_keys":1,"entities":444,"extents":["0.5000 0.5000 0.5000"],"frame":30,"frame_ms":1.521,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":37,"entities":522,"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.746,"step_ms":null,"cost_ms":0.746},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
+{"example":"shader_advanced/fullscreen_material","frame":60,"ssim":0.999749,"tile":6,"bevy":{"batch_keys":1,"entities":444,"extents":["0.5000 0.5000 0.5000"],"frame":60,"frame_ms":1.584,"materials":2,"mesh_entities":1,"meshes":6,"other_material":0,"visible":1},"raea":{"frame":67,"entities":522,"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.658,"step_ms":null,"cost_ms":0.658},"pixels":true,"draws":true,"time":true,"pass":true,"why":""}
diff --git a/sdk/raea/bench/bevy-parity/shader_advanced/fullscreen_material.tsx b/sdk/raea/bench/bevy-parity/shader_advanced/fullscreen_material.tsx
new file mode 100644
index 00000000..ab9dca84
--- /dev/null
+++ b/sdk/raea/bench/bevy-parity/shader_advanced/fullscreen_material.tsx
@@ -0,0 +1,41 @@
+// Bevy v0.20.0 examples/shader_advanced/fullscreen_material.rs in raea's TSX (docs/control.feature FC2d): a
+// FullscreenMaterial, assets/shaders/fullscreen_effect.wesl as written in a <FramePass file> (a chromatic aberration):
+// its screen_texture the frame as drawn so far, its texture_sampler Bevy's SamplerDescriptor::default(), its uniform
+// `settings` { intensity }. The pass runs in Core3d's PostProcess before tonemapping (FullscreenMaterial's default
+// schedule_configs). update_intensity sets it each update from Time::elapsed_secs t: its phase offset stays 0 (the
+// effect starts at 0, as its Local does), so intensity = (sin(2 t) + 1) / 2 * 0.015. A default Cuboid of srgb(0.8,
+// 0.7, 0.6) at the origin, a DirectionalLight of 1000 lux facing -Z, the camera at (0, 0, 5) looking at the origin
+// over Bevy's default clear colour, and the text "(T) FullscreenEffect: On" 12 px from the top left, in Bevy's default
+// 1280 x 720 window.
+import { Composition, registerRoot, staticFile, useCurrentFrame } from "raea";
+import { FramePass } from "raea/3d";
+import { Camera3d } from "raea/camera";
+import { Srgba } from "raea/color";
+import { DirectionalLight } from "raea/light";
+import { Cuboid, Mesh3d } from "raea/mesh";
+import { StandardMaterial } from "raea/pbr";
+import { Transform } from "raea/transform";
+import { Text, px } from "raea/ui";
+
+const DT = Math.fround(0.016666667);
+
+function Shot() {
+ const f = useCurrentFrame();
+ const t = Math.fround(f * DT);
+ const phase = Math.fround(t * 2);
+ const intensity = Math.fround(Math.fround((Math.fround(Math.sin(phase)) + 1) / 2) * Math.fround(0.015));
+ return (
+ <>
+ <Mesh3d transform={Transform.IDENTITY}>
+ <Cuboid half_size={[0.5, 0.5, 0.5]} />
+ <StandardMaterial base_color={new Srgba(0.8, 0.7, 0.6)} />
+ </Mesh3d>
+ <DirectionalLight illuminance={1000} />
+ <Camera3d transform={Transform.fromXyz(0, 0, 5).lookingAt([0, 0, 0])} />
+ <FramePass file={staticFile("shaders/fullscreen_effect.wesl")} frame="screen_texture" at="before-tonemap" uniforms={{ settings: { intensity } }} />
+ <Text position_type="Absolute" top={px(12)} left={px(12)}>(T) FullscreenEffect: On</Text>
+ </>
+ );
+}
+
+registerRoot(() => <Composition id="main" component={Shot} durationInFrames={61} fps={60} width={1280} height={720} />);