7 Commits
Author SHA1 Message Date
shinyobjectz 4175c116fb MeshPass with depth and vertex colours, Mesh3d material={false}; Bevy parity for shader_advanced/specialized_mesh_pipeline, exact
Bevy's specialized_mesh_pipeline draws meshes that have no material by a SpecializedMeshPipeline of its own: positions
at location 0 (compressed or not), colours at 1 under VERTEX_COLORS when the mesh has them, depth tested and written
GreaterEqual, under the view's MSAA. raea's <MeshPass> now does all of it:
- `depth`: it tests and writes the view's depth as an opaque mesh does. The pass always attaches the view's depth (a
  pipeline's depth state must match the pass), so without `depth` it compares Always and writes nothing, as before.
- a mesh's colours go to location 1 under VERTEX_COLORS, as Bevy's own specialize does.
- the pipeline takes the view's MSAA sample count (it assumed 1, so it only worked with Msaa off).
And <Mesh3d material={false}> (any <Mesh>) gets no material at all, as a Bevy Mesh3d without a MeshMaterial3d, so
only its own pass draws it: row no_material, spawned beside the toon branch (engine/render line-neutral).

Parity: SSIM 1.000000, worst tile 0, batch keys 0 / 0 at frames 5 and 10. Without material={false} the pixels were
already exact, but raea drew 2 batch keys of default material Bevy doesn't. Mutants: without the vertex colours it
fails (0.961897, tile 147); without `depth` it is unchanged, since the rectangle is behind the triangles and the pass
draws far to near. custom_render_phase, custom_phase_item, custom_shader_instancing, 3d_scene and mesh2d still pass.
150 ported, 150 passing.
2026-11-08 16:42:57 -08:00
shinyobjectz 426567fb63 A camera's depth as a texture: <DepthCopy>, depth images and depth textures in <Material>; Bevy parity for shader_advanced/render_depth_to_texture
Three pieces, as Bevy's render_depth_to_texture uses them:
- "render:NAME:WxH:depth" names a depth image (Depth32Float, its sampler comparing Always), shared by every field
  that names it, as "render:NAME" images are (raea-runtime-plugins fields.rs; raea-sys-shader own::depth_image).
- <DepthCopy image> in a Camera3d (raea-sys-phase DepthCopy) copies the camera's depth buffer into that image after
  its prepass and before its main pass. A depth-only camera is Bevy's own components: RenderTarget::None { size },
  DepthPrepass and Msaa off, with an order before the main camera's.
- A <Material> may bind a texture_depth_2d and a sampler_comparison (rebind slots 25 and 26, raea-sys-shader-wgsl
  ui_bind DEPTH), its texture given by name as any other. Bevy has no depth fallback image, so a Material that binds
  none gets a shared 1 x 1 depth image there.

Parity: the scene is pixel-exact at frames 5, 10, 30 and 60 (SSIM 0.999617). The only difference left is the
instruction text's glyph edges (tile 6), the same text-over-3D blend fullscreen_material records. Mutants: without
the DepthCopy it fails (0.957, tile 35); the cube one update behind passes the bar (0.995), but the real port differs
from Bevy only in the text. Every port with a Material or StandardMaterial under shader/, shader_advanced/ and 2d/
still passes (29 ports). 149 ported, 149 passing.
2026-11-08 16:34:29 -08:00
shinyobjectz c240b8e99d Mesh shaders: <MeshShaderPass> on a camera, and Bevy parity for shader_advanced/mesh_shader_intro, exact
A camera's MeshShaderPass (raea-sys-phase mesh_shader.rs) runs your task shader (when given) and mesh shader, which
make primitives on the GPU and hand them to your fragment shader, straight into the view's colour and depth (compared
GreaterEqual) after the main opaque pass, as Bevy's mesh_shader_intro does. Each stage is a shader file compiled as
written; bind group 0 is Globals and the view uniform; `groups` is draw_mesh_tasks' workgroup count. raea's shared
device already takes every adapter feature, so Apple silicon's mesh shaders are there; a GPU without them logs once
and draws nothing. In TSX it is <MeshShaderPass task mesh fragment groups> from raea/3d.

Found on the way and fixed: a shader file's `import super::NAME` was read a line at a time, so a statement over
lines (`import super::{\n bindings::{globals, TaskPayload},\n};`, as the example's three files write it) imported
nothing, and a nested list would have read its items as modules; it is now read to its `;` with each top-level
item's first name. And raea-sys-phase's own shaders (PhaseItem, MeshPass, ShaderInstances, GBufferPass) are now
registered in a folder of their own with their super:: imports, as a Material's are.

Parity: SSIM 1.000000 with a worst tile of 0 at frames 5, 10, 30, 60, 120, 240 and 300. Frames 240 and 300 (64 and
125 cubes) are there because the bar passed a port with no pass at all at frame 120 (0.997961, tile 23: the cubes
are small); with them that mutant fails (0.984513 and 0.967070), and one without its task shader fails at 0.0001.
The ports that read shader files (shader_material, extended_material, shader_material_2d, deferred_raymarch,
custom_render_phase, custom_phase_item, custom_shader_instancing, manual_material) still pass. 148 ported, 148 passing.
2026-11-08 16:14:57 -08:00
shinyobjectz eeea139ade Bevy's deferred_raymarch, exact: a GBufferPass, drawn in the camera's viewport; cameras and lights placed by their own rotation
shader_advanced/deferred_raymarch (docs/control.feature FC2d) ports with a <GBufferPass> on the camera
(systems/phase gbuffer.rs): a shader file's fullscreen fragment writes Bevy's deferred G-buffer, the
lighting pass id and depth after the late deferred prepass, and its shadow entry writes every shadow view
the camera's lights draw, so Bevy's deferred lighting lights it and it casts shadows. It matches Bevy to
the pixel (SSIM 1.000000, 0 px off at frames 5, 10 and 30); the whole suite (147 ports) passes on pixels.

Three gaps closed on the way, each found by probing the shader's inputs on both sides:
- The pass sets the camera's viewport, as Bevy's own passes do. raea's target is w x (h + 1) (its tag
  row), so a fullscreen triangle drawn without it stretched its uv over 721 rows: rays a pixel low at the
  bottom.
- Camera3d sends its rotation, and the engine places the camera by it (rot_qx..qw, exact). It used to send
  a look-at point the engine turned back into a rotation in f32, about a millionth of a radian off. Bevy's
  lights do the same (their direction was also rounded to 1e-6).
- Transform.lookingAt computes in f32 as glam does (Dir3::new, cross, try_normalize,
  Quat::from_rotation_axes), the same quaternion to the bit; glam.test.ts holds it to glam's own bits.

The port sets Bevy's shadow defaults in a <Shadows> (2048 texels, cascades to 150 m, the first to 10 m,
overlap 0.2), as the other shadowed ports do. Mutants (no shadow entry, the first cascade at 8 m, 7000 lux,
the cube moved 5 cm, the camera's target 1 cm up) are each thousands of pixels off.
2026-11-08 14:40:08 -08:00
shinyobjectz be388ffe80 FC2d: a mesh drawn many times in one draw by your shader; shader_advanced/custom_shader_instancing passes
<ShaderInstances shader stride attributes words> inside a mesh draws it once per instance in one draw, in the camera's
Transparent3d phase: Bevy's mesh pipeline with its vertex and fragment shader swapped for your file as written, and a
second vertex buffer of your words stepped per instance (raea-sys-phase ShaderInstances, as the example's
CustomPipeline and DrawMeshInstanced). The phase components' shader registration is one function for all three now.

The port is pixel-identical to Bevy at frames 5 and 10. Moving the instances 2 cm, making a colour 2% darker or a cube
1 cm shorter puts 10,000 to 48,000 pixels off. 145 of 438 ported, 145 passing.
2026-11-08 13:38:14 -08:00
shinyobjectz 4103559dac FC2d: a mesh drawn again in a phase of its own, and compressed meshes; shader_advanced/custom_render_phase passes
<MeshPass shader> inside a mesh draws it again by your shader file as written, in a sorted phase after the camera's
main opaque pass, onto the colour target with no depth attachment and back faces culled, with Bevy's mesh view and
mesh bind groups: raea-sys-phase's MeshPass, Bevy's custom_render_phase stencil phase made a component. A mesh's
`compressed` prop compresses its geometry as Bevy's compressed_mesh(&MeshCompressionArgs::regular()) does
(raea-sys-mesh finished), so a shader reads its positions under VERTEX_POSITIONS_COMPRESSED; engine/render's mesh
build calls it in the same line, keyed on it.

The port is pixel-identical to Bevy at frames 5 and 10 (0 pixels differ). A 1 to 3 cm move of the sphere, camera or
cube still passes the SSIM bar but is 177 to 629 pixels off, so the exact match is the port's, not the bar's. The parity
host gets indexmap and nonmax, the example's own dependencies. 144 of 438 ported, 144 passing.
2026-11-08 13:28:22 -08:00
shinyobjectz a3db7b6dba FC2d: a compute writes a mesh, your own phase item, a frame pass as written; three shader_advanced ports pass
Three of Bevy's shader_advanced examples now run as written, each through a general feature.

A compute writes a mesh (shader_advanced/compute_mesh). A <Compute file> binds each var<storage> its file declares:
either its own buffer, its first contents in the type's storage layout and kept from frame to frame, or a mesh's
vertex or index slab in Bevy's MeshAllocator, found by its part's name (systems/compute/src/slab.rs). A uniform
field given { start: NAME } or { end: NAME } is that mesh's range in the slab, counted in the array's elements, and
is packed each frame once the allocator has placed the mesh. The allocator's slabs carry STORAGE usage, set before
MeshAllocatorPlugin's finish makes the allocator, as the example's plugin sets it. A <BufferMesh> with indices and
normals is now Bevy's indexed Mesh, its index buffer kept, instead of flat triangles (systems/mesh/src/indexed.rs);
3d/vertex_colors, which takes that path, still passes. Every row with a name now gets a Bevy Name, not only bare
entities.

Your own phase item (shader_advanced/custom_phase_item). <PhaseItem> puts raea-sys-phase's PhaseItem and an Aabb on
an <Entity>. A new crate, systems/phase, queues it into each view's Opaque3d phase with a pipeline of its shader
file as written, drawing its own vertex buffer (its stride and attributes) and index buffer with its depth state,
as the example's queue_custom_phase_item does.

A frame pass as written (shader_advanced/custom_post_processing). A <FramePass file> binds its file's own @group(0)
declarations: each texture_2d<f32> is the frame (the one `frame` names) or an image, each sampler Bevy's default or
the one given, each var<uniform> its value (systems/framepass/src/written.rs). Its uniforms may change frame by
frame: like a compute's entry and bind, they are a keyed string column, and the pass repacks them when they change.
FramePass moves out of materials.tsx (at its 500-line limit) into 3d/framepass.tsx. The group(0) declaration parser
the compute and the pass share is raea-sys-shader's bindings::group0.

A camera on the Engine's target now draws a w x h Viewport of the w x (h + 1) tag-row target, as orthographic
cameras already did. A perspective camera had a sub view of the whole target, so a draw in clip space, such as the
phase item's triangle, mapped to 721 rows: its bottom edge landed 0.75 px low and the port passed at SSIM 0.9936 with
2355 pixels off. It is now pixel-exact. The whole suite was rerun with the change.

Results:
- compute_mesh passes at frames 5 and 10 (SSIM 0.999999, 2 pixels off at a 2% threshold). Eight mutants all fail the
  bar: no dispatch, either range set to 0, indices written into the vertex slab, the compute's mesh unnamed, the
  other cube's colour, no shadows, and the other cube moved.
- custom_phase_item passes at frames 5 and 10 with SSIM 1.0 and 0 pixels off. Mutants: the second attribute at
  offset 12, a vertex given another colour, and the top vertex at y 0.9 all fail the bar; a vertex moved from 0.866 to
  0.86 passes on SSIM (0.9953) but leaves 1556 pixels off, where the port leaves 0.
- custom_post_processing passes at frames 10, 30 and 60 (SSIM 0.99995, 0 pixels off). Mutants: no white clear colour
  fails the bar; intensity times 4/3 (8100 pixels off), a slower turn (4256), a linear sampler (16) and sin(t) for
  sin(sin(t)) (2964 at frame 60) pass on SSIM but leave pixels off. The pass before tone mapping draws the same
  frame, as it should: the camera is not HDR, so Bevy tone-maps in the material shader and its tonemapping node is
  skipped.
- After the change, the whole suite passes: 141 of 141 ported (two first-run misses rerun clean: standard_widgets
  missed its replayed menu click on the Bevy side, automatic_instancing missed its frame-time bar under another load).
2026-11-08 10:31:46 -08:00