reflow_components 0.2.1

Standard component catalog for Reflow β€” procedural, media, GPU, animation, I/O, and stream actors.
Documentation
# reflow_components β€” Backlog

Tracks outstanding work for the GPU / shader-graph / lighting / post-processing stack in `reflow_components`. Formerly `docs/shader_graph_plan.md`; converted to a backlog once the foundational phases landed.

Legend:
- βœ… shipped
- 🟑 partial (IR present but no actor / no codegen / limited use)
- ⬜ not started

---

## Foundation β€” shader graph IR + compilation βœ…

- βœ… `reflow_shader` crate (`ir.rs`, `codegen.rs`) with `ShaderNode` IR and `compile()` β†’ WGSL vertex + fragment pair.
- βœ… `CompiledMaterial` output with `vertex_wgsl`, `fragment_wgsl`, `texture_slots`, `material_uniforms`, `pipeline_hash`.
- βœ… `PbrUniforms` packed to std140-friendly layout.
- βœ… `compile_sdf_shade` β€” SDF shade-function injection used by SDF ray march path.

## Scene render integration βœ…

- βœ… `SceneRenderActor` gained `material` inport and parses `Message::Object` `CompiledMaterial`.
- βœ… Dynamic pipeline cache keyed by `pipeline_hash` (`HashMap<u64, CachedDynamicPipeline>` under `OnceLock<Mutex<_>>`).
- βœ… Fallback paths retained for objects without a shader-graph material (vertex-color, textured).
- ⬜ LRU eviction on pipeline cache (currently unbounded β€” max 32 from plan not enforced).
- ⬜ `wgsl_debug` outport on `ShaderCompilerActor` for editor-side inspection.

## Shader node actors βœ…

All 29 planned templates are registered:

`tpl_shader_const_float`, `tpl_shader_const_color`, `tpl_shader_texcoord`, `tpl_shader_position`, `tpl_shader_normal`, `tpl_shader_time`, `tpl_shader_vertex_color`, `tpl_shader_image_texture`, `tpl_shader_noise_texture`, `tpl_shader_checker_texture`, `tpl_shader_voronoi_texture`, `tpl_shader_gradient_texture`, `tpl_shader_brick_texture`, `tpl_shader_musgrave_texture`, `tpl_shader_wave_texture`, `tpl_shader_math`, `tpl_shader_color_mix`, `tpl_shader_color_ramp`, `tpl_shader_separate_xyz`, `tpl_shader_combine_xyz`, `tpl_shader_fresnel`, `tpl_shader_bump_map`, `tpl_shader_normal_map`, `tpl_shader_mapping`, `tpl_shader_clamp`, `tpl_shader_map_range`, `tpl_shader_principled_bsdf`, `tpl_shader_material_output`, `tpl_shader_compiler`.

Missing actors for IR variants that exist:
- ⬜ `tpl_shader_white_noise` (IR: `WhiteNoiseTexture`).
- ⬜ `tpl_shader_tangent` (IR: `Tangent`).
- ⬜ `tpl_shader_camera_vector` (IR: `CameraVector`).
- ⬜ `tpl_shader_environment_texture` (IR: `EnvironmentTexture`).
- ⬜ `tpl_shader_sky_texture` (IR: `SkyTexture`).
- ⬜ `tpl_shader_displacement` (IR: `Displacement`).

## PBR lighting βœ…

- βœ… Cook–Torrance rasterized `pbr_shade` and `pbr_shade_multi` in WGSL.
- βœ… Multi-light loop: `u_scene.light_count` uniform, driven by `tpl_scene_light_collector`.
- βœ… SDF variant `pbr_shade_sdf` used by SDF ray march path.
- 🟑 Point / spot light handling β€” only directional is exercised end-to-end in examples. Need a targeted test.
- ⬜ Area lights (rectangular / disc) for studio-style lighting.

## Advanced BSDF β€” ArmorPaint parity

PrincipledBsdf IR carries every advanced parameter; codegen coverage is mixed.

| Feature | IR | Rasterized codegen | SDF codegen | Actor |
|---------|----|--------------------|-------------|-------|
| Clearcoat | βœ… | βœ… | βœ… | via `tpl_shader_principled_bsdf` |
| Sheen | βœ… | βœ… | βœ… | via `tpl_shader_principled_bsdf` |
| Subsurface | βœ… | 🟑 color/radius fields compiled, no scattering approximation in rasterized path | βœ… used by SDF | via `tpl_shader_principled_bsdf` |
| Transmission / IOR | βœ… | ⬜ ignored (`_` in destructure) | βœ… fully wired (refraction + dispersion in melting_ice) | via `tpl_shader_principled_bsdf` |
| Anisotropic | βœ… | ⬜ ignored in rasterized path | ⬜ | via `tpl_shader_principled_bsdf` |
| Iridescence / thin-film | ⬜ | β€” | β€” | β€” |

Pending:
- ⬜ Rasterized transmission (refraction through the backbuffer, chromatic dispersion toggle).
- ⬜ Anisotropic GGX in both rasterized and SDF paths.
- ⬜ Iridescence node.

## Lighting β€” environment / IBL

- ⬜ `EnvironmentTexture` + `SkyTexture` IR variants have no actor and no codegen path.
- ⬜ Prefiltered environment cubemap (specular split-sum).
- ⬜ Irradiance map (diffuse convolution).
- ⬜ BRDF LUT (split-sum integration).
- ⬜ Light probe actor for local reflections.

## Shadow mapping

- βœ… `tpl_shadow_map` CPU depth rasterizer actor.
- ⬜ Scene render samples the shadow map to modulate diffuse contribution (currently produces the map; nothing consumes it in the rasterized PBR path).
- ⬜ Directional cascaded shadow maps (CSM).
- ⬜ Point light cube maps.
- ⬜ Variance shadow maps / percentage-closer filtering.

## Post-processing

- βœ… `tpl_tone_map` (ACES filmic, Reinhard, Uncharted2 + gamma).
- βœ… `tpl_bloom` (threshold β†’ downsample β†’ separable blur β†’ composite).
- βœ… `tpl_ssao` (screen-space AO from luminance approximation).
- ⬜ SSAO upgrade to HBAO/GTAO using real depth + normal buffers.
- ⬜ FXAA / TAA actor.
- ⬜ Depth-of-field / motion blur / chromatic aberration.
- ⬜ Post-process pipeline descriptor so a DAG can express a full chain without per-pair wiring.

## Displacement & surface tricks

- 🟑 `Displacement` IR variant exists; no actor, no codegen.
- ⬜ Vertex-stage displacement (height map sampling in vertex shader, auto-LOD friendly).
- ⬜ Parallax occlusion mapping in fragment shader.
- ⬜ Triplanar mapping (UV-free texturing for terrain / organic surfaces).
- ⬜ Decal projection (project texture onto surface via projector matrix).

## Bake actors

- ⬜ `tpl_bake_ao` β€” ray-traced ambient occlusion β†’ texture.
- ⬜ `tpl_bake_curvature` β€” convexity / concavity map.
- ⬜ `tpl_bake_position` β€” world / object-space position map.
- ⬜ `tpl_bake_normal_transfer` β€” high-poly β†’ low-poly normals.
- ⬜ `tpl_bake_thickness` β€” for SSS approximation.
- ⬜ All bake outputs stored in AssetDB as textures for reuse as shader inputs.

## Optimization

- ⬜ Shader module cache: hash `fragment_wgsl` β†’ reuse `wgpu::ShaderModule` across pipelines that differ only in bind-group layout.
- ⬜ LRU eviction on `DYNAMIC_PIPELINE_CACHE` (cap around 32).
- ⬜ Benchmark the pipeline-creation hot path under a large material library.

## Docs / developer experience

- ⬜ Example graph JSON for each shader-node category in `docs/components/standard-library.md`.
- ⬜ Quick-start tutorial: "Author your first PBR material as a DAG".
- ⬜ Publish `reflow_shader` rustdoc to docs.rs (depends on the publishing work).

---

## Priority slate (next pass)

1. Fill the missing actors for existing IR variants (`WhiteNoiseTexture`, `Tangent`, `CameraVector`, `EnvironmentTexture`, `SkyTexture`, `Displacement`).
2. Wire the shadow map into the rasterized PBR path.
3. Rasterized transmission so the melting-ice quality generalises to mesh rendering.
4. Environment / IBL split-sum β€” the single biggest upgrade to surface realism.
5. LRU pipeline cache + shader-module dedupe before external users stress it.