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.
TypeScript 3dagent-skillsai-agentsai-videobevyclaude-codegame-enginegpulinuxmacosmotion-designmotion-graphicsreactrusttypescriptvideo-editingvideo-renderingwgpuwindows
The volumetric fog's RAEA_FOG_* knobs are <VolumetricFog> props, and tools/nobuild.sh props checks each against its variable
shinyobjectzcb40dca08b4b
diff --git a/Cargo.lock b/Cargo.lockindex a79ce9eb..254345dc 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -15895,8 +15895,10 @@ dependencies = ["bevy","bytemuck","raea-core-program",+ "raea-io-trace","raea-sys-frame","raea-sys-volume",+ "serde_json",][[package]]diff --git a/docs/manual/reference/sdk/3d.md b/docs/manual/reference/sdk/3d.mdindex 2ad463fa..e382c8b5 100644--- a/docs/manual/reference/sdk/3d.md+++ b/docs/manual/reference/sdk/3d.md@@ -2735,5 +2735,10 @@ where density and heat come in: a burner, or an engine moving `at` -> `to` (a co| `tile` | `number` | the grid's cells across the frame, in pixels a side (16 by default; 4, 8 or 16) || `samples` | `number` | points lit in each cell, spread along its depth (1 by default; 1 to 8): more keeps thin shadows in the grid's soft light (a hero light's shafts don't need them) || `hero` | `boolean` | the grid's shafts: true (the default) integrates the first two volumetric spot lights and the first two volumetric directional lights exactly, over their shadow maps texel by texel, so a blind's bars or a doorway's edge are as crisp as the shadow map: integrated at samples along lines from the light across the frame (Chen et al.'s epipolar sampling), more of them where the depth or the light changes, and each pixel read from the samples either side of it at its depth; false lights them in the grid's cells with the rest |+| `shadow` | `"absorb" \| "delta" \| "full" \| "off" \| "bevy"` | what dims a light on its way through a volume to a point of it: "absorb" (the default: what the medium absorbs, which matched the path tracer best), "delta" (absorption and the share of scattering that turns light aside), "full" (the whole extinction), "off" (not dimmed) or "bevy" (Bevy's march's rule: each volume's light dimmed once by its own radius) |+| `heroExact` | `boolean` | the hero lights integrated at every pixel instead of at epipolar samples (false by default): several times slower, the reference the samples are measured against |+| `epipolar` | `{ lineGap?: number; spacing?: number; every?: number; relTolerance?: number; absToleran…` | the hero lights' epipolar samples: lines `lineGap` pixels apart round each light's rectangle on screen (8), samples `spacing` pixels apart along each (6), every `every`th traced (16) and those between traced too where they differ by more than `relTolerance` (0.2), `absTolerance` (2/255) or `depthTolerance` (0.02, relative) |+| `tricubic` | `boolean` | the hero passes read the grid's transmittance tricubic, as the apply pass reads its light (false by default: trilinear) |+| `solari` | `boolean \| { candidates?: number; frames?: number; skyRays?: number; lamps?: boolean; sk…` | under <SolariLighting>, the fog's light from Solari's scene: false lights it as without Solari; or its settings: light candidates a cell (8), frames its history averages (16), sky rays a cell (1), what lights it (`lamps`, the emissive meshes, and `sky`, both on), the history's filter (on), and what the sky's guide is made of (`guide` 3: 1 the cell's own last, 2 half a neighbour's, 3 both, 0 none) |<!-- generated:end -->diff --git a/docs/manual/reference/sdk/pbr.md b/docs/manual/reference/sdk/pbr.mdindex edf0e72a..fc12a9aa 100644--- a/docs/manual/reference/sdk/pbr.md+++ b/docs/manual/reference/sdk/pbr.md@@ -814,6 +814,11 @@ where density and heat come in: a burner, or an engine moving `at` -> `to` (a co| `tile` | `number` | the grid's cells across the frame, in pixels a side (16 by default; 4, 8 or 16) || `samples` | `number` | points lit in each cell, spread along its depth (1 by default; 1 to 8): more keeps thin shadows in the grid's soft light (a hero light's shafts don't need them) || `hero` | `boolean` | the grid's shafts: true (the default) integrates the first two volumetric spot lights and the first two volumetric directional lights exactly, over their shadow maps texel by texel, so a blind's bars or a doorway's edge are as crisp as the shadow map: integrated at samples along lines from the light across the frame (Chen et al.'s epipolar sampling), more of them where the depth or the light changes, and each pixel read from the samples either side of it at its depth; false lights them in the grid's cells with the rest |+| `shadow` | `"absorb" \| "delta" \| "full" \| "off" \| "bevy"` | what dims a light on its way through a volume to a point of it: "absorb" (the default: what the medium absorbs, which matched the path tracer best), "delta" (absorption and the share of scattering that turns light aside), "full" (the whole extinction), "off" (not dimmed) or "bevy" (Bevy's march's rule: each volume's light dimmed once by its own radius) |+| `heroExact` | `boolean` | the hero lights integrated at every pixel instead of at epipolar samples (false by default): several times slower, the reference the samples are measured against |+| `epipolar` | `{ lineGap?: number; spacing?: number; every?: number; relTolerance?: number; absToleran…` | the hero lights' epipolar samples: lines `lineGap` pixels apart round each light's rectangle on screen (8), samples `spacing` pixels apart along each (6), every `every`th traced (16) and those between traced too where they differ by more than `relTolerance` (0.2), `absTolerance` (2/255) or `depthTolerance` (0.02, relative) |+| `tricubic` | `boolean` | the hero passes read the grid's transmittance tricubic, as the apply pass reads its light (false by default: trilinear) |+| `solari` | `boolean \| { candidates?: number; frames?: number; skyRays?: number; lamps?: boolean; sk…` | under <SolariLighting>, the fog's light from Solari's scene: false lights it as without Solari; or its settings: light candidates a cell (8), frames its history averages (16), sky rays a cell (1), what lights it (`lamps`, the emissive meshes, and `sky`, both on), the history's filter (on), and what the sky's guide is made of (`guide` 3: 1 the cell's own last, 2 half a neighbour's, 3 both, 0 none) |### `WearExtensionProps`diff --git a/runtime/look/src/post.rs b/runtime/look/src/post.rsindex 8f7e6bbd..32b34c3e 100644--- a/runtime/look/src/post.rs+++ b/runtime/look/src/post.rs@@ -251,6 +251,41 @@ fn volfog(v: &Map<String, Value>, row: &mut BTreeMap<String, V>) {if let Some(c) = hex(v.get("ambientColor")) {row.insert("vfog_ambient_color".into(), V::S(c));}+ // what it tunes beyond its look (raea_sys_fog::froxel::tuning, docs/nobuild.feature NB1a)+ if let Some(s) = v.get("shadow").and_then(Value::as_str) {+ row.insert("vfog_shadow".into(), V::S(s.into()));+ }+ let flag = |o: &Map<String, Value>, k: &str| o.get(k).and_then(Value::as_bool).map(|b| V::N(b as u8 as f64));+ for (prop, col) in [("heroExact", "vfog_hero_exact"), ("tricubic", "vfog_tricubic")] {+ if let Some(b) = flag(v, prop) {+ row.insert(col.into(), b);+ }+ }+ if let Some(o) = v.get("epipolar").and_then(Value::as_object) {+ for (prop, col) in [("lineGap", "vfog_epi_line"), ("spacing", "vfog_epi_spacing"), ("every", "vfog_epi_every"), ("relTolerance", "vfog_epi_rel"), ("absTolerance", "vfog_epi_abs"), ("depthTolerance", "vfog_epi_depth")] {+ if let Some(x) = num(o, prop) {+ row.insert(col.into(), V::N(x));+ }+ }+ }+ match v.get("solari") {+ Some(Value::Bool(b)) => {+ row.insert("vfog_solari".into(), V::N(*b as u8 as f64));+ }+ Some(Value::Object(o)) => {+ for (prop, col) in [("candidates", "vfog_solari_candidates"), ("frames", "vfog_solari_frames"), ("skyRays", "vfog_solari_sky_rays"), ("guide", "vfog_solari_guide")] {+ if let Some(x) = num(o, prop) {+ row.insert(col.into(), V::N(x));+ }+ }+ for (prop, col) in [("lamps", "vfog_solari_lamps"), ("sky", "vfog_solari_sky"), ("filter", "vfog_solari_filter")] {+ if let Some(b) = flag(o, prop) {+ row.insert(col.into(), b);+ }+ }+ }+ _ => {}+ }}/// Each frame's <Shadows> (found once for every light): its props, and whether they change from frame to frame.diff --git a/sdk/guides/craft/bevy/post.md b/sdk/guides/craft/bevy/post.mdindex 9e7453c1..e65e4991 100644--- a/sdk/guides/craft/bevy/post.md+++ b/sdk/guides/craft/bevy/post.md@@ -31,6 +31,10 @@ Put these beside the camera, once each:0.966 / 52.7 dB at 7.7 ms (the march 0.751 / 28.8 dB at 3.4). `hero={false}` drops the exact shafts for the grid'ssofter ones (Mean Streets 2.8 ms a frame): use it when no shaft has a hard edge in shot. `slices` (128), `tile`(8 px) and `samples` (2 a cell) set the grid: more slices for a deep shot with fog close to the camera and far off.+ The rest is tuning, each prop's default the measured best: `shadow` (what dims light passing through a volume,+ "absorb"), `epipolar` (how densely the shafts are sampled), `heroExact` (every pixel integrated, the slow+ reference), `tricubic`, and under <SolariLighting> `solari` (`false`, or its candidates, history frames, sky rays,+ what lights it, filter and guide).- `<VolumetricFog mode="march" steps dither resolution />`: Bevy's ray march through each volume instead, as raeadrew fog before the grid. Only for matching an older piece: it grains or steps where the grid doesn't, compositesoverlapping volumes in row order, and lights a volume's whole box with `ambient`. `steps` (64) is how finely eachdiff --git a/sdk/render/src/3d/volumetric.tsx b/sdk/render/src/3d/volumetric.tsxindex 1b7d513a..d6e24e3c 100644--- a/sdk/render/src/3d/volumetric.tsx+++ b/sdk/render/src/3d/volumetric.tsx@@ -39,6 +39,26 @@ export interface VolumetricFogProps {* al.'s epipolar sampling), more of them where the depth or the light changes, and each pixel read from the* samples either side of it at its depth; false lights them in the grid's cells with the rest */hero?: boolean;+ /** what dims a light on its way through a volume to a point of it: "absorb" (the default: what the medium absorbs,+ * which matched the path tracer best), "delta" (absorption and the share of scattering that turns light aside),+ * "full" (the whole extinction), "off" (not dimmed) or "bevy" (Bevy's march's rule: each volume's light dimmed+ * once by its own radius) */+ shadow?: "absorb" | "delta" | "full" | "off" | "bevy";+ /** the hero lights integrated at every pixel instead of at epipolar samples (false by default): several times+ * slower, the reference the samples are measured against */+ heroExact?: boolean;+ /** the hero lights' epipolar samples: lines `lineGap` pixels apart round each light's rectangle on screen (8),+ * samples `spacing` pixels apart along each (6), every `every`th traced (16) and those between traced too where+ * they differ by more than `relTolerance` (0.2), `absTolerance` (2/255) or `depthTolerance` (0.02, relative) */+ epipolar?: { lineGap?: number; spacing?: number; every?: number; relTolerance?: number; absTolerance?: number; depthTolerance?: number };+ /** the hero passes read the grid's transmittance tricubic, as the apply pass reads its light (false by default:+ * trilinear) */+ tricubic?: boolean;+ /** under <SolariLighting>, the fog's light from Solari's scene: false lights it as without Solari; or its+ * settings: light candidates a cell (8), frames its history averages (16), sky rays a cell (1), what lights it+ * (`lamps`, the emissive meshes, and `sky`, both on), the history's filter (on), and what the sky's guide is made+ * of (`guide` 3: 1 the cell's own last, 2 half a neighbour's, 3 both, 0 none) */+ solari?: boolean | { candidates?: number; frames?: number; skyRays?: number; lamps?: boolean; sky?: boolean; filter?: boolean; guide?: 0 | 1 | 2 | 3 };}/** Volumetric fog on the camera: light in the air, drawn inside every <FogVolume>, with shafts from the lights marked@@ -54,6 +74,15 @@ export function VolumetricFog(props: VolumetricFogProps) {if (props.slices !== undefined && !(Number.isInteger(props.slices) && props.slices >= 32 && props.slices <= 256)) throw new RangeError(`VolumetricFog: slices must be a whole number from 32 to 256, got ${props.slices}`);if (props.tile !== undefined && ![4, 8, 16].includes(props.tile)) throw new RangeError(`VolumetricFog: tile must be 4, 8 or 16, got ${props.tile}`);if (props.samples !== undefined && !(Number.isInteger(props.samples) && props.samples >= 1 && props.samples <= 8)) throw new RangeError(`VolumetricFog: samples must be a whole number from 1 to 8, got ${props.samples}`);+ if (props.shadow !== undefined && !["absorb", "delta", "full", "off", "bevy"].includes(props.shadow)) throw new RangeError(`VolumetricFog: shadow must be "absorb", "delta", "full", "off" or "bevy", got ${JSON.stringify(props.shadow)}`);+ for (const [k, v] of Object.entries(props.epipolar ?? {})) if (!(typeof v === "number" && v > 0)) throw new RangeError(`VolumetricFog: epipolar.${k} must be a number over 0, got ${v}`);+ if (typeof props.solari === "object") {+ for (const k of ["candidates", "frames", "skyRays"] as const) {+ const v = props.solari[k];+ if (v !== undefined && !(Number.isInteger(v) && v >= 1)) throw new RangeError(`VolumetricFog: solari.${k} must be a whole number from 1, got ${v}`);+ }+ if (props.solari.guide !== undefined && ![0, 1, 2, 3].includes(props.solari.guide)) throw new RangeError(`VolumetricFog: solari.guide must be 0, 1, 2 or 3, got ${props.solari.guide}`);+ }return node3d("VolumetricFog", colours("VolumetricFog", props as Record<string, unknown>, ["ambientColor"]));}diff --git a/systems/fog-half/src/camera.rs b/systems/fog-half/src/camera.rsindex 4d01f483..e61e123e 100644--- a/systems/fog-half/src/camera.rs+++ b/systems/fog-half/src/camera.rs@@ -44,19 +44,25 @@ pub fn vfog(world: &mut World, e: Entity, vals: &Vals) {let grid = !reference && !march && env_mode.as_deref() != Ok("march");if grid {let lin = fog.ambient_color.to_linear();- froxel::insert(- world,- e,- froxel::FroxelFog {- ambient: Vec3::new(lin.red, lin.green, lin.blue) * fog.ambient_intensity,- slices: num(vals, "vfog_slices", 64.0).round().clamp(32.0, 256.0) as u32,- tile: num(vals, "vfog_tile", 16.0).round().clamp(4.0, 16.0) as u32,- samples: num(vals, "vfog_samples", 1.0).round().clamp(1.0, 8.0) as u32,- // (the ground truth integrates every light itself)- hero: num(vals, "vfog_hero", 1.0) != 0.0 && std::env::var("RAEA_FOG_HERO").as_deref() != Ok("0") && froxel::reference_steps().is_none(),- },+ // the props, each RAEA_FOG_* variable over its own (raea_sys_fog::froxel::tuning)+ let (tile, slices, samples) = froxel::tuning::grid(+ num(vals, "vfog_tile", 16.0).round().clamp(4.0, 16.0) as u32,+ num(vals, "vfog_slices", 64.0).round().clamp(32.0, 256.0) as u32,+ num(vals, "vfog_samples", 1.0).round().clamp(1.0, 8.0) as u32,);+ let f = froxel::FroxelFog {+ ambient: Vec3::new(lin.red, lin.green, lin.blue) * fog.ambient_intensity,+ slices,+ tile,+ samples,+ // (the ground truth integrates every light itself)+ hero: froxel::tuning::hero(num(vals, "vfog_hero", 1.0) != 0.0) && froxel::reference_steps().is_none(),+ tune: froxel::tuning::tuning(vals),+ };+ froxel::tuning::record(e, "froxel", Some(&f));+ froxel::insert(world, e, f);} else {+ froxel::tuning::record(e, if reference { "reference" } else { "march" }, None);crate::insert(world, e, fog, if reference { 1.0 } else { num(vals, "vfog_resolution", 1.0) });if !reference && vals.get("vfog_dither").is_some_and(V::truthy) {world.entity_mut(e).insert(FogDither);diff --git a/systems/fog/Cargo.toml b/systems/fog/Cargo.tomlindex 2769b8bc..b7688cbe 100644--- a/systems/fog/Cargo.toml+++ b/systems/fog/Cargo.toml@@ -10,5 +10,7 @@ description = "Froxel fog (one medium in a grid along the view), glass seen throraea-sys-frame = { path = "../frame" }raea-sys-volume = { path = "../volume" }raea-core-program = { path = "../../core/program" }+raea-io-trace = { path = "../../io/trace" }+serde_json = "1"bevy = { version = "=0.20.0", default-features = false, features = ["std", "default_app", "3d_bevy_render", "bevy_solari"] }bytemuck = "1"diff --git a/systems/fog/src/froxel.rs b/systems/fog/src/froxel.rsindex fad8e5d6..f65e4198 100644--- a/systems/fog/src/froxel.rs+++ b/systems/fog/src/froxel.rs@@ -60,6 +60,7 @@ pub use views::*;mod pipelines;pub use pipelines::*;mod solari;+pub mod tuning;/// The camera's fog as a grid: the ambient light the fog scatters (linear, times its intensity), and the grid's/// slices along the view, its tile in pixels and the points lit a cell.@@ -72,6 +73,8 @@ pub struct FroxelFog {pub samples: u32,/// the volumetric spot and directional lights integrated exactly per pixel (froxel_hero.wesl), not in the gridpub hero: bool,+ /// what <VolumetricFog> tunes beyond its look (tuning.rs)+ pub tune: tuning::Tuning,}pub fn insert(world: &mut World, e: Entity, fog: FroxelFog) {@@ -118,14 +121,14 @@ struct GpuVolume {shadow: Vec4,}-/// How the fog dims light on its way to a point of it (RAEA_FOG_SHADOW). The froxel passes scatter light once, so+/// How the fog dims light on its way to a point of it (<VolumetricFog shadow>). The froxel passes scatter light once, so/// dimming it by the whole extinction loses the light the medium scatters on toward the point (white fog under a/// uniform sky: 0.75 of the truth's); not dimming it keeps light that a grey or thick medium absorbs (grey fog: 0.60/// against 0.40). The path tracer is the truth they're measured against (bevy_solari pathtracer/media.wesl):/// absorption alone matched it (grey 0.411 against 0.398, white 1.000; the hall's air 0.955 of the truth's, Bevy's/// 0.939), so it's the default.#[derive(Clone, Copy, PartialEq, Debug)]-enum ShadowRule {+pub enum ShadowRule {/// Bevy's: a constant exp(-extinction x the box's half-diagonal) on every point of it, nothing elseBevy,/// not dimmed@@ -138,17 +141,6 @@ enum ShadowRule {Full,}-fn shadow_rule() -> ShadowRule {- static RULE: std::sync::OnceLock<ShadowRule> = std::sync::OnceLock::new();- *RULE.get_or_init(|| match std::env::var("RAEA_FOG_SHADOW").as_deref() {- Ok("off") => ShadowRule::Off,- Ok("absorb") => ShadowRule::Absorb,- Ok("delta") => ShadowRule::Delta,- Ok("full") => ShadowRule::Full,- Ok("bevy") => ShadowRule::Bevy,- _ => ShadowRule::Absorb,- })-}/// The frame's fog volumes, in rank order (their row ids), so the medium sums them in one order every frame.#[derive(Resource, Default)]@@ -159,7 +151,9 @@ pub struct Volumes {buffer: StorageBuffer<Vec<GpuVolume>>,}-fn extract_volumes(mut volumes: ResMut<Volumes>, q: Extract<Query<(&FogVolume, &GlobalTransform, Option<&FogRank>, Option<&FogShape>)>>) {+fn extract_volumes(mut volumes: ResMut<Volumes>, q: Extract<Query<(&FogVolume, &GlobalTransform, Option<&FogRank>, Option<&FogShape>)>>, cams: Extract<Query<&FroxelFog>>) {+ // the volumes are written once for every view: the first fog camera's rule+ let rule = cams.iter().next().map_or(ShadowRule::Absorb, |f| f.tune.shadow);let mut found: Vec<(String, GpuVolume, [Vec3; 8])> = Vec::new();for (fv, t, rank, shape) in &q {let affine = t.affine();@@ -173,7 +167,6 @@ fn extract_volumes(mut volumes: ResMut<Volumes>, q: Extract<Query<(&FogVolume, &let extinction = fv.density_factor * (fv.absorption + fv.scattering);let colour = fv.fog_color.to_linear().to_vec3();let tint = fv.light_tint.to_linear().to_vec3();- let rule = shadow_rule();let bevy = if rule == ShadowRule::Bevy { (-extinction * radius).exp() } else { 1.0 };let light = colour * tint * fv.light_intensity * fv.scattering * fv.density_factor * bevy;let shadow = fv.density_factor@@ -259,6 +252,7 @@ fn draw(Option<&ViewShadowBindings>,Option<&solari::SolariFog>,Option<&bevy::render::view::ViewUniformOffset>,+ &FroxelFog,)>,cache: Res<PipelineCache>,pipelines: Option<Res<Pipelines>>,@@ -268,7 +262,7 @@ fn draw(mut ctx: RenderContext,) {let Some(p) = pipelines else { return };- let (target, depth, ids, grid, tex, view_group, msaa, shadows, solari_fog, view_offset) = view.into_inner();+ let (target, depth, ids, grid, tex, view_group, msaa, shadows, solari_fog, view_offset, fog) = view.into_inner();if volumes.list.is_empty() {return;}@@ -380,7 +374,7 @@ fn draw();let epi = [0, 1, 2, 3].map(|i| cache.get_render_pipeline(ids.epi[i]));match (tex.epi.as_ref(), epi) {- (Some(t), [Some(coarse), Some(mark), Some(fine), Some(over)]) if std::env::var_os("RAEA_FOG_HERO_EXACT").is_none() => {+ (Some(t), [Some(coarse), Some(mark), Some(fine), Some(over)]) if !fog.tune.hero_exact => {// each light's samples along its lines: their depth; the coarse ones' light; every one's, interpolated// or marked; the marked integratedlet reads = |a: &CachedTexture| device.create_bind_group("froxel_epipolar", &cache.get_bind_group_layout(&p.epi_layout), &BindGroupEntries::single(&a.default_view));diff --git a/systems/fog/src/froxel/pipelines.rs b/systems/fog/src/froxel/pipelines.rsindex 6af4e32f..81120c51 100644--- a/systems/fog/src/froxel/pipelines.rs+++ b/systems/fog/src/froxel/pipelines.rs@@ -138,10 +138,11 @@ pub enum Key {Light(MeshPipelineViewLayoutKey),/// multisampled, the target's format, its samplesApply(bool, TextureFormat, u32),- Hero(MeshPipelineViewLayoutKey, TextureFormat, u32),+ /// (each hero pass also by whether it reads the transmittance tricubic: <VolumetricFog tricubic>)+ Hero(MeshPipelineViewLayoutKey, TextureFormat, u32, bool),/// the epipolar passes into their samples: place, coarse, mark, fine- Epi(MeshPipelineViewLayoutKey, u8),- Epipolar(MeshPipelineViewLayoutKey, TextureFormat, u32),+ Epi(MeshPipelineViewLayoutKey, u8, bool),+ Epipolar(MeshPipelineViewLayoutKey, TextureFormat, u32, bool),Reference(MeshPipelineViewLayoutKey, TextureFormat, u32),}@@ -218,14 +219,16 @@ pub struct HeroPass {pub epi: bool,/// the samples' mask: written (mark), or tested (fine: drawn at depth one half where it's 0)pub mask: Option<bool>,+ /// the grid's transmittance read tricubic (<VolumetricFog tricubic>)+ pub tricubic: bool,}/// a hero pass: `entry` into `format`, which has `samples`pub fn hero_descriptor(p: &Pipelines, view_key: MeshPipelineViewLayoutKey, entry: &'static str, format: TextureFormat, samples: u32, how: HeroPass) -> RenderPipelineDescriptor {- let HeroPass { blend, fog, epi, mask } = how;+ let HeroPass { blend, fog, epi, mask, tricubic } = how;let ms = view_key.contains(MeshPipelineViewLayoutKey::MULTISAMPLED);let mut defs: Vec<ShaderDefVal> = vec!["SHADOW_FILTER_METHOD_HARDWARE_2X2".into()];- if std::env::var_os("RAEA_FOG_TRICUBIC_T").is_some() {+ if tricubic {defs.push("TRICUBIC_TRANSMITTANCE".into());}if std::env::var_os("RAEA_FOG_SHOW_FALLBACK").is_some() {@@ -303,10 +306,11 @@ pub fn prepare_pipelines(pipelines: Option<Res<Pipelines>>,view_keys: Res<ViewKeyCache>,mut ids: Local<PipelineIds>,- views: Query<(Entity, &ExtractedView, &Msaa), With<FroxelFog>>,+ views: Query<(Entity, &ExtractedView, &Msaa, &FroxelFog)>,) {let Some(p) = pipelines else { return };- for (e, view, msaa) in &views {+ for (e, view, msaa, fog) in &views {+ let tri = fog.tune.tricubic;let Some(mesh_key) = view_keys.get(&view.retained_view_entity) else { continue };let view_key: MeshPipelineViewLayoutKey = (*mesh_key).into();let ms = !matches!(msaa, Msaa::Off);@@ -314,17 +318,17 @@ pub fn prepare_pipelines(// drawn into the multisampled frame, which the transparent pass after them resolves over the main texturelet samples = msaa.samples();let apply = *ids.render.entry(Key::Apply(ms, view.target_format, samples)).or_insert_with(|| cache.queue_render_pipeline(apply_descriptor(&p, ms, view.target_format, samples)));- let hero = *ids.render.entry(Key::Hero(view_key, view.target_format, samples)).or_insert_with(|| cache.queue_render_pipeline(hero_descriptor(&p, view_key, "hero", view.target_format, samples, HeroPass { blend: true, ..default() })));+ let hero = *ids.render.entry(Key::Hero(view_key, view.target_format, samples, tri)).or_insert_with(|| cache.queue_render_pipeline(hero_descriptor(&p, view_key, "hero", view.target_format, samples, HeroPass { blend: true, tricubic: tri, ..default() })));let mut epi = [hero; 4];let passes = [- ("coarse", TextureFormat::Rgba16Float, HeroPass::default()),- ("mark", TextureFormat::Rgba16Float, HeroPass { epi: true, mask: Some(true), ..default() }),- ("fine", TextureFormat::Rgba16Float, HeroPass { mask: Some(false), ..default() }),+ ("coarse", TextureFormat::Rgba16Float, HeroPass { tricubic: tri, ..default() }),+ ("mark", TextureFormat::Rgba16Float, HeroPass { epi: true, mask: Some(true), tricubic: tri, ..default() }),+ ("fine", TextureFormat::Rgba16Float, HeroPass { mask: Some(false), tricubic: tri, ..default() }),];for (i, (entry, format, how)) in passes.into_iter().enumerate() {- epi[i] = *ids.render.entry(Key::Epi(view_key, i as u8)).or_insert_with(|| cache.queue_render_pipeline(hero_descriptor(&p, view_key, entry, format, 1, how)));+ epi[i] = *ids.render.entry(Key::Epi(view_key, i as u8, tri)).or_insert_with(|| cache.queue_render_pipeline(hero_descriptor(&p, view_key, entry, format, 1, how)));}- epi[3] = *ids.render.entry(Key::Epipolar(view_key, view.target_format, samples)).or_insert_with(|| cache.queue_render_pipeline(hero_descriptor(&p, view_key, "epipolar", view.target_format, samples, HeroPass { blend: true, fog: true, epi: true, ..default() })));+ epi[3] = *ids.render.entry(Key::Epipolar(view_key, view.target_format, samples, tri)).or_insert_with(|| cache.queue_render_pipeline(hero_descriptor(&p, view_key, "epipolar", view.target_format, samples, HeroPass { blend: true, fog: true, epi: true, tricubic: tri, ..default() })));let integrate = *ids.compute.get_or_insert_with(|| {cache.queue_compute_pipeline(ComputePipelineDescriptor {label: Some("froxel_integrate".into()),diff --git a/systems/fog/src/froxel/solari.rs b/systems/fog/src/froxel/solari.rsindex b86b2dd3..a43cc807 100644--- a/systems/fog/src/froxel/solari.rs+++ b/systems/fog/src/froxel/solari.rs@@ -64,15 +64,6 @@ pub struct SolariFogPipelines {integrate: CachedComputePipelineId,}-fn on() -> bool {- static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();- *ON.get_or_init(|| std::env::var("RAEA_FOG_SOLARI").as_deref() != Ok("0"))-}--fn setting(name: &str, default: u32) -> u32 {- std::env::var(name).ok().and_then(|v| v.parse().ok()).filter(|v: &u32| *v > 0).unwrap_or(default)-}-fn make_pipelines(cache: &PipelineCache, assets: &AssetServer, scene: &RaytracingSceneBindings) -> SolariFogPipelines {let layout = BindGroupLayoutDescriptor::new("froxel_solari_layout",@@ -148,9 +139,10 @@ pub fn prepare(assets: Res<AssetServer>,pipelines: Option<Res<SolariFogPipelines>>,scene: Option<Res<RaytracingSceneBindings>>,- mut views: Query<(Entity, &ViewGrid, &ExtractedView, &SolariLighting, Option<&mut SolariFog>)>,+ mut views: Query<(Entity, &ViewGrid, &ExtractedView, &SolariLighting, Option<&mut SolariFog>, &super::FroxelFog)>,) {- if !on() {+ // <VolumetricFog solari>, RAEA_FOG_SOLARI_* over it (tuning.rs); a view with it off integrates as without Solari+ if !views.iter().any(|v| v.5.tune.solari.on) {return;}let Some(scene) = scene else { return };@@ -158,12 +150,17 @@ pub fn prepare(commands.insert_resource(make_pipelines(&cache, &assets, &scene));return;}- let (candidates, frames, sky) = (setting("RAEA_FOG_SOLARI_CANDIDATES", 8), setting("RAEA_FOG_SOLARI_FRAMES", 16), setting("RAEA_FOG_SOLARI_SKY", 1));- let parts = std::env::var("RAEA_FOG_SOLARI_PARTS").unwrap_or_else(|_| "lamps,sky".into());- let parts = parts.contains("lamps") as u32 | (parts.contains("sky") as u32) << 1;- let filter = (std::env::var("RAEA_FOG_SOLARI_FILTER").as_deref() != Ok("0")) as u32;- let guide = std::env::var("RAEA_FOG_SOLARI_GUIDE").ok().and_then(|v| v.parse().ok()).unwrap_or(3u32) & 3;- for (e, grid, view, solari, fog) in &mut views {+ for (e, grid, view, solari, fog, tuned) in &mut views {+ let t = tuned.tune.solari;+ if !t.on {+ if fog.is_some() {+ commands.entity(e).remove::<SolariFog>();+ }+ continue;+ }+ let (candidates, frames, sky) = (t.candidates, t.frames, t.sky_rays);+ let parts = t.lamps as u32 | (t.sky as u32) << 1;+ let (filter, guide) = (t.filter as u32, t.guide);let g = grid.params.grid;let size = UVec2::new(g.x * g.w, g.y * g.z.div_ceil(g.w));let now = (view.clip_from_view * view.world_from_view.to_matrix().inverse(), grid.params.slab);diff --git a/systems/fog/src/froxel/tuning.rs b/systems/fog/src/froxel/tuning.rsnew file mode 100644index 00000000..5273a420--- /dev/null+++ b/systems/fog/src/froxel/tuning.rs@@ -0,0 +1,217 @@+//! What a fog camera tunes beyond its look (docs/nobuild.feature NB1a): <VolumetricFog>'s shadow, heroExact,+//! epipolar, tricubic and solari props, read from the camera row's `vfog_*` columns. The RAEA_FOG_* variables that+//! tuned them before are only overrides now: each wins over its prop on every camera, and raea says so once. The+//! settings each camera draws with go into the run's trace (`fog_settings`), so a render says what it drew with.+use std::collections::BTreeMap;++use bevy::prelude::*;+use raea_core_program::ir::V;+use raea_sys_frame::num;++use super::{FroxelFog, ShadowRule};++type Vals = BTreeMap<String, V>;++#[derive(Clone, Copy, Debug, PartialEq)]+pub struct Tuning {+ /// what dims a light passing through a volume (`shadow`, "absorb" by default)+ pub shadow: ShadowRule,+ /// the hero lights integrated at every pixel instead of at epipolar samples (`heroExact`, false): slower, for a+ /// reference+ pub hero_exact: bool,+ /// the hero passes read the grid's transmittance tricubic, as the apply pass reads its light (`tricubic`, false)+ pub tricubic: bool,+ pub epi: Epipolar,+ pub solari: SolariFog,+}++/// The hero lights' epipolar samples (`epipolar`): lines `line_gap` pixels apart round each light's rectangle, samples+/// `spacing` apart along each, every `every`th traced and the rest interpolated unless they differ from the traced+/// ones by more than `rel` (relative), `abs` (absolute) or `depth` (relative depth).+#[derive(Clone, Copy, Debug, PartialEq)]+pub struct Epipolar {+ pub line_gap: f32,+ pub spacing: f32,+ pub every: u32,+ pub rel: f32,+ pub abs: f32,+ pub depth: f32,+}++/// The fog's light from Solari's scene under <SolariLighting> (`solari`): on, light candidates a cell, frames its+/// history averages, sky rays a cell, what lights it (the emissive meshes, the sky), the history's filter, and what+/// the sky's guide is made of (1 the cell's own last, 2 half a neighbour's, 3 both; 0 none).+#[derive(Clone, Copy, Debug, PartialEq)]+pub struct SolariFog {+ pub on: bool,+ pub candidates: u32,+ pub frames: u32,+ pub sky_rays: u32,+ pub lamps: bool,+ pub sky: bool,+ pub filter: bool,+ pub guide: u32,+}++impl Default for Tuning {+ fn default() -> Self {+ Self {+ shadow: ShadowRule::Absorb,+ hero_exact: false,+ tricubic: false,+ epi: Epipolar { line_gap: 8.0, spacing: 6.0, every: super::views::EPI_EVERY, rel: 0.2, abs: 2.0 / 255.0, depth: 0.02 },+ solari: SolariFog { on: true, candidates: 8, frames: 16, sky_rays: 1, lamps: true, sky: true, filter: true, guide: 3 },+ }+ }+}++fn shadow(s: &str) -> Option<ShadowRule> {+ Some(match s {+ "off" => ShadowRule::Off,+ "absorb" => ShadowRule::Absorb,+ "delta" => ShadowRule::Delta,+ "full" => ShadowRule::Full,+ "bevy" => ShadowRule::Bevy,+ _ => return None,+ })+}++fn var(name: &str) -> Option<String> {+ std::env::var(name).ok()+}++/// a variable's whole number over 0+fn count(name: &str) -> Option<u32> {+ var(name).and_then(|v| v.parse().ok()).filter(|v: &u32| *v > 0)+}++/// a variable's comma-separated numbers, each over its place's prop+fn list<T: std::str::FromStr>(name: &str) -> Vec<Option<T>> {+ var(name).map(|v| v.split(',').map(|x| x.trim().parse().ok()).collect()).unwrap_or_default()+}++/// The camera row's tuning, each RAEA_FOG_* variable over its prop.+pub fn tuning(vals: &Vals) -> Tuning {+ let d = Tuning::default();+ let on = |k: &str, d: bool| vals.get(k).map_or(d, V::truthy);+ let whole = |k: &str, d: u32| num(vals, k, d as f32).round().max(0.0) as u32;+ let mut t = Tuning {+ shadow: match vals.get("vfog_shadow") {+ Some(V::S(s)) => shadow(s).unwrap_or(d.shadow),+ _ => d.shadow,+ },+ hero_exact: on("vfog_hero_exact", d.hero_exact),+ tricubic: on("vfog_tricubic", d.tricubic),+ epi: Epipolar {+ line_gap: num(vals, "vfog_epi_line", d.epi.line_gap).max(0.5),+ spacing: num(vals, "vfog_epi_spacing", d.epi.spacing).max(0.5),+ every: whole("vfog_epi_every", d.epi.every).max(1),+ rel: num(vals, "vfog_epi_rel", d.epi.rel),+ abs: num(vals, "vfog_epi_abs", d.epi.abs),+ depth: num(vals, "vfog_epi_depth", d.epi.depth),+ },+ solari: SolariFog {+ on: on("vfog_solari", d.solari.on),+ candidates: whole("vfog_solari_candidates", d.solari.candidates).max(1),+ frames: whole("vfog_solari_frames", d.solari.frames).max(1),+ sky_rays: whole("vfog_solari_sky_rays", d.solari.sky_rays).max(1),+ lamps: on("vfog_solari_lamps", d.solari.lamps),+ sky: on("vfog_solari_sky", d.solari.sky),+ filter: on("vfog_solari_filter", d.solari.filter),+ guide: whole("vfog_solari_guide", d.solari.guide) & 3,+ },+ };+ // the variables, as they read before they were props+ if let Some(r) = var("RAEA_FOG_SHADOW").as_deref().and_then(shadow) {+ t.shadow = r;+ }+ if let Some(v) = var("RAEA_FOG_HERO_EXACT") {+ t.hero_exact = v != "0";+ }+ if let Some(v) = var("RAEA_FOG_TRICUBIC_T") {+ t.tricubic = v != "0";+ }+ let e: Vec<Option<f32>> = list("RAEA_FOG_EPI");+ let at = |i: usize| e.get(i).copied().flatten();+ t.epi.line_gap = at(0).map_or(t.epi.line_gap, |v| v.max(0.5));+ t.epi.spacing = at(1).map_or(t.epi.spacing, |v| v.max(0.5));+ t.epi.every = at(2).map_or(t.epi.every, |v| (v as u32).max(1));+ t.epi.rel = at(3).unwrap_or(t.epi.rel);+ t.epi.abs = at(4).unwrap_or(t.epi.abs);+ t.epi.depth = at(5).unwrap_or(t.epi.depth);+ if let Some(v) = var("RAEA_FOG_SOLARI") {+ t.solari.on = v != "0";+ }+ t.solari.candidates = count("RAEA_FOG_SOLARI_CANDIDATES").unwrap_or(t.solari.candidates);+ t.solari.frames = count("RAEA_FOG_SOLARI_FRAMES").unwrap_or(t.solari.frames);+ t.solari.sky_rays = count("RAEA_FOG_SOLARI_SKY").unwrap_or(t.solari.sky_rays);+ if let Some(p) = var("RAEA_FOG_SOLARI_PARTS") {+ (t.solari.lamps, t.solari.sky) = (p.contains("lamps"), p.contains("sky"));+ }+ if let Some(v) = var("RAEA_FOG_SOLARI_FILTER") {+ t.solari.filter = v != "0";+ }+ if let Some(g) = var("RAEA_FOG_SOLARI_GUIDE").and_then(|v| v.parse::<u32>().ok()) {+ t.solari.guide = g & 3;+ }+ t+}++/// RAEA_FOG_GRID=tile,slices,samples over the `tile`, `slices` and `samples` props.+pub fn grid(tile: u32, slices: u32, samples: u32) -> (u32, u32, u32) {+ let g: Vec<Option<u32>> = list("RAEA_FOG_GRID");+ let at = |i: usize, d: u32| g.get(i).copied().flatten().unwrap_or(d);+ (at(0, tile).max(1), at(1, slices).clamp(8, 256), at(2, samples).max(1))+}++/// RAEA_FOG_HERO over the `hero` prop ("0" off, anything else on).+pub fn hero(prop: bool) -> bool {+ var("RAEA_FOG_HERO").map_or(prop, |v| v != "0")+}++/// The RAEA_FOG_* variables set, each with the prop it overrides.+fn env() -> Vec<(&'static str, String, &'static str)> {+ [+ ("RAEA_FOG_MODE", "mode"),+ ("RAEA_FOG_HERO", "hero"),+ ("RAEA_FOG_GRID", "tile, slices, samples"),+ ("RAEA_FOG_SHADOW", "shadow"),+ ("RAEA_FOG_HERO_EXACT", "heroExact"),+ ("RAEA_FOG_EPI", "epipolar"),+ ("RAEA_FOG_TRICUBIC_T", "tricubic"),+ ("RAEA_FOG_SOLARI", "solari"),+ ("RAEA_FOG_SOLARI_CANDIDATES", "solari.candidates"),+ ("RAEA_FOG_SOLARI_FRAMES", "solari.frames"),+ ("RAEA_FOG_SOLARI_SKY", "solari.skyRays"),+ ("RAEA_FOG_SOLARI_PARTS", "solari.lamps and solari.sky"),+ ("RAEA_FOG_SOLARI_FILTER", "solari.filter"),+ ("RAEA_FOG_SOLARI_GUIDE", "solari.guide"),+ ]+ .into_iter()+ .filter_map(|(n, prop)| var(n).map(|v| (n, v, prop)))+ .collect()+}++/// A camera's fog as it draws, into the run's trace (`fog_settings`) each time it's put on: the mode, and for the grid+/// every setting; and once a run, on stderr, which variables override <VolumetricFog>'s props.+pub fn record(camera: Entity, mode: &str, fog: Option<&FroxelFog>) {+ let env = env();+ static SAID: std::sync::Once = std::sync::Once::new();+ if !env.is_empty() {+ SAID.call_once(|| {+ let list: Vec<String> = env.iter().map(|(n, v, prop)| format!("{n}={v} over {prop}")).collect();+ eprintln!("raea: <VolumetricFog> on every camera: {} (docs/nobuild.feature NB1a)", list.join(", "));+ });+ }+ let mut j = serde_json::json!({ "camera": camera.to_bits(), "mode": mode, "env": env.iter().map(|(n, v, _)| format!("{n}={v}")).collect::<Vec<_>>() });+ if let Some(f) = fog {+ let (t, e, s) = (&f.tune, &f.tune.epi, &f.tune.solari);+ j["grid"] = serde_json::json!({+ "slices": f.slices, "tile": f.tile, "samples": f.samples, "hero": f.hero,+ "shadow": format!("{:?}", t.shadow).to_lowercase(), "hero_exact": t.hero_exact, "tricubic": t.tricubic,+ "epipolar": [e.line_gap, e.spacing, e.every as f32, e.rel, e.abs, e.depth],+ "solari": { "on": s.on, "candidates": s.candidates, "frames": s.frames, "sky_rays": s.sky_rays, "lamps": s.lamps, "sky": s.sky, "filter": s.filter, "guide": s.guide },+ });+ }+ raea_io_trace::event("fog_settings", j);+}diff --git a/systems/fog/src/froxel/views.rs b/systems/fog/src/froxel/views.rsindex 1c25315c..34f5a8a3 100644--- a/systems/fog/src/froxel/views.rs+++ b/systems/fog/src/froxel/views.rs@@ -100,13 +100,12 @@ pub fn prepare_views(let suns = order.iter().filter(|(_, l)| l.volumetric).count().min(2) as u32;for (e, view, fog) in &views {let vp = view.viewport.as_vec4();- // RAEA_FOG_GRID=tile,slices,samples (tuning)- let tune: Vec<u32> = std::env::var("RAEA_FOG_GRID").unwrap_or_default().split(',').filter_map(|v| v.parse().ok()).collect();- let tile = tune.first().copied().unwrap_or(fog.tile).max(1);+ // the props, RAEA_FOG_GRID over them (tuning.rs)+ let tile = fog.tile.max(1);let gx = (vp.z as u32).div_ceil(tile).max(1);let gy = (vp.w as u32).div_ceil(tile).max(1);- let gz = tune.get(1).copied().unwrap_or(fog.slices).clamp(8, 256);- let samples = tune.get(2).copied().unwrap_or(fog.samples);+ let gz = fog.slices.clamp(8, 256);+ let samples = fog.samples;// the atlas: slices as tiles, as square as fits under 16384 a sidelet cols = gz.min((16384 / gx).max(1));let view_from_world = view.world_from_view.affine().inverse();@@ -142,10 +141,9 @@ pub fn prepare_views(};let mut params = params;if fog.hero {- // RAEA_FOG_EPI=line spacing,sample spacing,K,rel,abs,depth (tuning)- let tune: Vec<f32> = std::env::var("RAEA_FOG_EPI").unwrap_or_default().split(',').filter_map(|v| v.parse().ok()).collect();- let t = |i: usize, d: f32| tune.get(i).copied().unwrap_or(d);- let (line_gap, spacing) = (t(0, 8.0).max(0.5), t(1, 6.0).max(0.5));+ // <VolumetricFog epipolar>, RAEA_FOG_EPI over it (tuning.rs)+ let e = fog.tune.epi;+ let (line_gap, spacing) = (e.line_gap, e.spacing);// the fog's box in the world, which every hero light's rectangle is insidelet fog_box = volumes.corners.iter().flatten().fold((Vec3::MAX, Vec3::MIN), |(lo, hi), c| (lo.min(*c), hi.max(*c)));let clip_from_world = view.clip_from_view * Mat4::from(view_from_world);@@ -168,8 +166,8 @@ pub fn prepare_views(let n = slot as u32;let lines = (0..4).map(|i| params.hero_lines[i]).max().unwrap_or(0).max(1);let along = (0..4).map(|i| params.hero_along[i]).max().unwrap_or(0).max(4);- params.epi = UVec4::new(lines, along, t(2, EPI_EVERY as f32) as u32, n);- params.epi_tol = Vec4::new(t(3, 0.2), t(4, 2.0 / 255.0), t(5, 0.02), spacing);+ params.epi = UVec4::new(lines, along, e.every, n);+ params.epi_tol = Vec4::new(e.rel, e.abs, e.depth, spacing);if std::env::var_os("RAEA_FOG_DEBUG").is_some() {eprintln!("froxel heroes: rects {:?} lines {:?} along {:?} layers {:?}", ¶ms.hero_rect[..slot], params.hero_lines, params.hero_along, (cascades, points));}diff --git a/tools/nobuild.sh b/tools/nobuild.shindex 76c10f25..371ae5a6 100755--- a/tools/nobuild.sh+++ b/tools/nobuild.sh@@ -12,6 +12,10 @@# RAEA_BIN (target/release/raea) renders with every pass on: settable (raea set it), refused# (an array, a vector, not found) or absent (that Engine doesn't load the shader);# written to docs/nobuild/consts.tsv, NB1a's check for each row+# tools/nobuild.sh props each prop in tools/nobuild/props.tsv against the variable it replaced: its scene's+# composition that sets it, and the scene's base with the variable, rendered by+# RAEA_BIN and compared (the frame, and the settings the trace records); written to+# docs/nobuild/props.tsv, exits 1 if one fails## A decision row (tab-separated): kind:name, then its class, the TypeScript form it becomes, its check, its status# (open, doing, done, stays). Classes: frame (changes what a frame shows or costs: a prop), view (a debug view: NB2),@@ -47,13 +51,13 @@ causes() {cd "$RAEA" || exit 1# every RAEA_* variable the code names (its first mention), raea's own and its patches to vendored crates: any quoted# literal, as many are read through a helper (a switch(name), a settings table) rather than env::var at the name- # (git grep: tracked files only, so no target/ or node_modules)- git grep -nE '"RAEA_[A-Z0-9_]+"' -- '*.rs' ':!vendor' 'vendor/bevy_solari' 'vendor/blitz-dom' \+ # (git grep: tracked and new files, never what .gitignore leaves out: no target/ or node_modules)+ git grep --untracked -nE '"RAEA_[A-Z0-9_]+"' -- '*.rs' ':!vendor' 'vendor/bevy_solari' 'vendor/blitz-dom' \'vendor/blitz-paint' 'vendor/parley_engine' 'vendor/bevy_pbr' 'vendor/bevy_ui' |awk -F: '{ w = $1 ":" $2; s = $0; while (match(s, /"RAEA_[A-Z0-9_]+"/)) { print "env\t" substr(s, RSTART + 1, RLENGTH - 2) "\t" w; s = substr(s, RSTART + RLENGTH) } }' |sort -t$'\t' -k2,2 -u# constants in raea's and the vendored Solari's shaders (bench/ is LightBench's own)- git grep -nE '^[[:space:]]*const [A-Z][A-Z0-9_]*[[:space:]]*(:|=)' -- 'engine/*.wgsl' 'engine/*.wesl' 'systems/*.wgsl' 'systems/*.wesl' \+ git grep --untracked -nE '^[[:space:]]*const [A-Z][A-Z0-9_]*[[:space:]]*(:|=)' -- 'engine/*.wgsl' 'engine/*.wesl' 'systems/*.wgsl' 'systems/*.wesl' \'vendor/bevy_solari/*.wgsl' 'vendor/bevy_solari/*.wesl' |sed -E 's/^([^:]+):([0-9]+):[[:space:]]*const ([A-Z][A-Z0-9_]*).*/shader\t\3\t\1:\2/' | sort -t$'\t' -k2,2 -k3,3 -u# optional features of every binary raea ships or its sessions build (each a binary that differs from the shipped one)@@ -141,9 +145,65 @@ consts() {grep -q "unknown" "$out" || rm -rf -- "${dir:?}"}+# a frame's difference from another in 8-bit levels: ImageMagick's METRIC (MAE the mean, PAE the largest), normalised+diff_levels() {+ magick compare -metric "$1" "$2" "$3" null: 2>&1 | sed -nE 's/.*\(([0-9.e+-]+)\).*/\1/p' | awk '{ printf "%.3f", $1 * 255 }'+}++# one render of a props.tsv scene: its composition on its light path with the variables given, into OUT; beside it+# OUT.settings, the run's settings records (fog_settings, solari_settings) without what names the run+props_render() {+ local scene=$1 comp=$2 light=$3 out=$4; shift 4+ local tdir=$out.trace l=()+ rm -rf -- "${out:?}" "${tdir:?}"+ mkdir -p "$tdir"+ [ "$light" = solari ] && l=(RAEA_LIGHT=solari)+ (cd "$RAEA/tools/nobuild" && env RAEA_TRACE_DIR="$tdir" ${l[@]+"${l[@]}"} "$@" "$bin" render "$scene" --composition "$comp" -o "$out" > /dev/null 2> "$out.err")+ find "$tdir" -name events.jsonl -exec cat {} + 2>/dev/null | jq -c 'select(.kind == "fog_settings" or .kind == "solari_settings") | del(.camera, .view, .env, .t, .ts, .seq, .span)' | sort -u > "$out.settings"+}++props() {+ bin=${RAEA_BIN:-$RAEA/target/release/raea}+ local rows=$RAEA/tools/nobuild/props.tsv out=$DOCS/props.tsv+ [ -x "$bin" ] || { echo "nobuild: no raea at $bin (RAEA_BIN)" >&2; exit 1; }+ local dir; dir=$(mktemp -d "${TMPDIR:-/tmp}/nobuild-props.XXXXXX") || exit 1+ printf '# scene\tcomposition\tvariables\tlight\tframe\tprop vs variable (mean, max levels)\tnoise (base twice, mean)\tprop vs base (mean)\tsettings in the trace\tverdict\n' > "$out"+ local fails=0+ while IFS=$'\t' read -r scene comp vars light frame; do+ case $scene in '#'* | '') continue ;; esac+ local f; f=$(printf 'frame-%05d.png' "$frame")+ local b="$dir/${scene%.tsx}-$light-base"+ # the scene's base twice, once a scene and light path: their difference is the run-to-run noise+ if [ ! -d "$b" ]; then+ props_render "$scene" base "$light" "$b"+ props_render "$scene" base "$light" "$b.2"+ fi+ local p="$dir/$comp-prop" v="$dir/$comp-var"+ props_render "$scene" "$comp" "$light" "$p"+ # shellcheck disable=SC2086 # the variables are words+ props_render "$scene" base "$light" "$v" $vars+ local mae pae noise moved trace verdict+ mae=$(diff_levels MAE "$p/$f" "$v/$f"); pae=$(diff_levels PAE "$p/$f" "$v/$f")+ noise=$(diff_levels MAE "$b/$f" "$b.2/$f"); moved=$(diff_levels MAE "$p/$f" "$b/$f")+ if [ -s "$p.settings" ] && cmp -s "$p.settings" "$v.settings"; then trace=same; else trace=differ; fi+ # raster draws the same pixels twice: the prop and the variable must too; Solari's frames differ run to run, so+ # theirs must be as near as two base runs and the prop must move the frame well past that+ verdict=$(awk -v l="$light" -v mae="$mae" -v pae="$pae" -v n="$noise" -v m="$moved" -v t="$trace" -v img="$p/$f" 'BEGIN {+ if (mae == "" || m == "") { print "no frame (" img ")"; exit }+ same = l == "raster" ? pae == 0 : mae <= 2 * n + 0.002+ moves = l == "raster" ? m > 0 : m > 4 * n + 0.01+ print (same && moves && t == "same") ? "pass" : "FAIL" (same ? "" : ": prop and variable differ") (moves ? "" : ": the prop changes nothing") (t == "same" ? "" : ": settings differ") }')+ [ "$verdict" = pass ] || fails=$((fails + 1))+ printf '%s\t%s\t%s\t%s\t%s\t%s, %s\t%s\t%s\t%s\t%s\n' "$scene" "$comp" "$vars" "$light" "$frame" "$mae" "$pae" "$noise" "$moved" "$trace" "$verdict" | tee -a "$out"+ done < "$rows"+ echo "nobuild: $(grep -vc '^#' "$out") props against their variables in ${out#"$RAEA"/}, $fails failing, by $bin"+ if [ "$fails" = 0 ]; then rm -rf -- "${dir:?}"; else echo "nobuild: renders kept in $dir"; exit 1; fi+}+case ${1:-} inbuilds) shift; builds "$@" ;;scan) scan ;;consts) consts ;;- *) sed -n '2,24p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;+ props) props ;;+ *) sed -n '2,28p' "$0" | sed 's/^# \{0,1\}//'; exit 2 ;;esacdiff --git a/tools/nobuild/fog.tsx b/tools/nobuild/fog.tsxnew file mode 100644index 00000000..2da67d9d--- /dev/null+++ b/tools/nobuild/fog.tsx@@ -0,0 +1,52 @@+import { Composition, registerRoot } from "raea";+import { FogVolume, VolumetricFog, type VolumetricFogProps } from "raea/pbr";+import { Camera3d } from "raea/camera";+import { LinearRgba, Srgba } from "raea/color";+import { DirectionalLight, SpotLight } from "raea/light";+import { Cuboid, Mesh3d } from "raea/mesh";+import { StandardMaterial } from "raea/pbr";+import { Transform } from "raea/transform";++// docs/nobuild.feature NB1a: each <VolumetricFog> tuning prop against the RAEA_FOG_* variable it replaced+// (tools/nobuild.sh props, its rows in tools/nobuild/props.tsv). A stone wall with a window, a spot light's shaft+// through it, a sun from the side, a glowing lamp (Solari's fog light), one volume of dusty air. Each composition but+// base sets one prop; base takes the variable.+const VARIANTS: Record<string, VolumetricFogProps> = {+ base: {},+ shadow: { shadow: "off" },+ exact: { heroExact: true },+ tricubic: { tricubic: true },+ epi: { epipolar: { lineGap: 16, spacing: 6, every: 4 } },+ grid: { tile: 8, slices: 96 },+ nohero: { hero: false },+ march: { mode: "march" },+ solari: { solari: { candidates: 1, frames: 1, skyRays: 2, sky: false, filter: false, guide: 1 } },+ solarioff: { solari: false },+};++function Room({ fog }: { fog: VolumetricFogProps }) {+ return (+ <>+ <Camera3d transform={Transform.fromXyz(4.4, 1.6, 4.2).lookingAt([-0.9, 2.4, -1.6])} />+ <VolumetricFog {...fog} />+ <Mesh3d transform={Transform.fromXyz(0, -0.1, 0)}><Cuboid half_size={[5, 0.1, 5]} /><StandardMaterial base_color="#6a645c" perceptual_roughness={0.9} /></Mesh3d>+ <Mesh3d transform={Transform.fromXyz(-3.2, 3.5, -3)}><Cuboid half_size={[1.8, 3.5, 0.25]} /><StandardMaterial base_color="#5a5248" /></Mesh3d>+ <Mesh3d transform={Transform.fromXyz(2.6, 3.5, -3)}><Cuboid half_size={[2.4, 3.5, 0.25]} /><StandardMaterial base_color="#5a5248" /></Mesh3d>+ <Mesh3d transform={Transform.fromXyz(-0.7, 1.3, -3)}><Cuboid half_size={[0.7, 1.3, 0.25]} /><StandardMaterial base_color="#5a5248" /></Mesh3d>+ <Mesh3d transform={Transform.fromXyz(-0.7, 5.8, -3)}><Cuboid half_size={[0.7, 1.2, 0.25]} /><StandardMaterial base_color="#5a5248" /></Mesh3d>+ <Mesh3d transform={Transform.fromXyz(0, 0.6, 0)}><Cuboid half_size={[0.4, 0.6, 0.4]} /><StandardMaterial base_color="#c8c0b4" /></Mesh3d>+ <Mesh3d transform={Transform.fromXyz(1.6, 1.8, -1)}><Cuboid half_size={[0.4, 0.6, 0.4]} /><StandardMaterial base_color="#000000" emissive={LinearRgba.from(Srgba.hex("#ff8a3c")).mul(20000)} /></Mesh3d>+ <SpotLight color="#ffe6c4" volumetric={true} shadows_enabled transform={Transform.fromXyz(-2.8, 7.4, -6).lookingAt([0, 1, 0])} intensity={2340000} outer_angle={0.2} inner_angle={0.17} />+ <DirectionalLight volumetric={true} shadow_maps_enabled illuminance={3000} transform={Transform.fromXyz(5, 3, 1).lookingAt([0, 0, 0])} />+ <FogVolume name="air" position={[0, 3.5, 1]} scale={[9.5, 7, 7.8]} density={0.1} color="#fff2e0" scattering={0.45} absorption={0.15} anisotropy={0.55} />+ </>+ );+}++registerRoot(() => (+ <>+ {Object.entries(VARIANTS).map(([id, fog]) => (+ <Composition key={id} id={id} component={() => <Room fog={fog} />} width={480} height={270} fps={30} durationInFrames={24} />+ ))}+ </>+));diff --git a/tools/nobuild/props.tsv b/tools/nobuild/props.tsvnew file mode 100644index 00000000..af1c6473--- /dev/null+++ b/tools/nobuild/props.tsv@@ -0,0 +1,13 @@+# Each knob's prop against the variable it replaced (tools/nobuild.sh props, docs/nobuild.feature NB1a): the scene, the+# composition that sets the prop, the variables the scene's base composition is rendered with instead, the light path+# (raster or solari) and the frame compared. Raster frames are compared exactly; Solari's against two base runs' noise.+# scene composition variables light frame+fog.tsx shadow RAEA_FOG_SHADOW=off raster 1+fog.tsx exact RAEA_FOG_HERO_EXACT=1 raster 1+fog.tsx tricubic RAEA_FOG_TRICUBIC_T=1 raster 1+fog.tsx epi RAEA_FOG_EPI=16,6,4 raster 1+fog.tsx grid RAEA_FOG_GRID=8,96,1 raster 1+fog.tsx nohero RAEA_FOG_HERO=0 raster 1+fog.tsx march RAEA_FOG_MODE=march raster 1+fog.tsx solari RAEA_FOG_SOLARI_CANDIDATES=1 RAEA_FOG_SOLARI_FRAMES=1 RAEA_FOG_SOLARI_SKY=2 RAEA_FOG_SOLARI_PARTS=lamps RAEA_FOG_SOLARI_FILTER=0 RAEA_FOG_SOLARI_GUIDE=1 solari 23+fog.tsx solarioff RAEA_FOG_SOLARI=0 solari 23