Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,8 @@ sdk/raea/.scratch-*/

# the Tripo CLI writes its last task id into the directory it runs in
.tripo/
# examples/materials/wear: its house is made by make-house.ts (media/) and baked at render time (assets/wear/)
/examples/materials/wear/media/
/examples/materials/wear/assets/
# tools/bevy-parity links each example folder's assets/ to Bevy's checkout at run time (an absolute, per-machine path)
/sdk/raea/bench/bevy-parity/**/assets
23 changes: 12 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ members = [
"systems/canvas",
"systems/tweak",
"systems/filters",
"systems/wear",
"systems/weathering",
"systems/runoff",
"systems/touch",
"systems/exposure",
"systems/damage",
"systems/glb",
"systems/procmat",
"systems/page",
Expand Down
7 changes: 7 additions & 0 deletions core/ease/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@ pub mod color;
pub mod easing;
pub mod interpolate;
pub mod spring;

/// 0 below `a`, 1 above `b`, and between them the cubic Hermite ease (WGSL's smoothstep), for a value that fades in
/// over a range rather than a key's time.
pub fn smoothstep(a: f32, b: f32, x: f32) -> f32 {
let t = ((x - a) / (b - a)).clamp(0.0, 1.0);
t * t * (3.0 - 2.0 * t)
}
7 changes: 3 additions & 4 deletions docs/manual/reference/sdk/pbr.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,8 @@ Used in: [3d/fog_volumes](https://github.com/shinyobjectz/raea/blob/main/sdk/rae

### `WearExtension`

raea's chips, grime and rust over a StandardMaterial, as an ExtendedMaterial's extension (systems/wear):

Bevy: `bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_wear::Wear>>`.
raea's chips, grime and rust over a StandardMaterial, as an ExtendedMaterial's extension: a surface shader of
raea's own (worn.ts) on the hook a ShaderExtension uses, so its Bevy type is ShaderExtension's.

| Prop | Type | What it does |
| --- | --- | --- |
Expand Down Expand Up @@ -792,7 +791,7 @@ where density and heat come in: a burner, or an engine moving `at` -> `to` (a co

### `WearExtensionProps`

raea's extension of StandardMaterial that wears it (the engine's Wear MaterialExtension, systems/wear): its paint
raea's extension of StandardMaterial that wears it (a surface shader of raea's own, worn.ts): its paint
mottled, chipped back to `chip_color` on edges and a few spots, `grime` gathered low and underneath and `rust` run
down in streaks, fixed in the part's own space as it moves. `amount` 0-1; `chips`, `grime` and `rust` each 0-1 of it
(0.6, 0.5, 0.25); `scale` a blotch's size in metres (0.08); `seed` moves the pattern. It goes in an
Expand Down
7 changes: 3 additions & 4 deletions docs/sdk-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ reaches it yet).
| area | kind | tier 1 | tier 2 | tier 3 | not rendered | SVG attribute only | blocked upstream | excluded | unmapped | total |
|---|---|---:|---:|---:|---:|---:|---:|---:|---:|---:|
| bevy | asset | 9 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 9 |
| bevy | component | 61 | 869 | 0 | 0 | 0 | 0 | 1 | 0 | 931 |
| bevy | component | 60 | 869 | 0 | 0 | 0 | 0 | 1 | 0 | 930 |
| bevy | event | 0 | 13 | 0 | 0 | 0 | 0 | 0 | 0 | 13 |
| bevy | message | 0 | 40 | 0 | 0 | 0 | 0 | 0 | 0 | 40 |
| bevy | resource | 4 | 86 | 0 | 0 | 0 | 0 | 1 | 0 | 91 |
Expand All @@ -23,9 +23,9 @@ reaches it yet).
| css | shorthand | 60 | 0 | 0 | 11 | 0 | 0 | 0 | 0 | 71 |
| element | html | 113 | 0 | 0 | 0 | 0 | 0 | 18 | 0 | 131 |
| plugin | declared | 0 | 0 | 53 | 0 | 0 | 21 | 0 | 3 | 77 |
| **all** | | **495** | **1009** | **53** | **55** | **14** | **21** | **21** | **3** | **1671** |
| **all** | | **494** | **1009** | **53** | **55** | **14** | **21** | **21** | **3** | **1670** |

Reached (tiers 1-3): **1557**. The ratchet (`tools/sdk-coverage --check`, in tools/agents/check) keeps it from dropping.
Reached (tiers 1-3): **1556**. The ratchet (`tools/sdk-coverage --check`, in tools/agents/check) keeps it from dropping.

## Bevy types (the plugin build's TypeRegistry)

Expand Down Expand Up @@ -624,7 +624,6 @@ Reached (tiers 1-3): **1557**. The ratchet (`tools/sdk-coverage --check`, in too
| `bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_look::paint::Paint>>` | component | 2 | bevy.MeshMaterial3dExtendedMaterialStandardMaterialPaint (raea/plugins/bevy) |
| `bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_material::toon::ToonExt>>` | component | 2 | bevy.MeshMaterial3dExtendedMaterialStandardMaterialToonExt (raea/plugins/bevy) |
| `bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_shader::ShaderExt>>` | component | 1 | SurfaceShader (sdk/render/src/3d/materials.tsx) |
| `bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_wear::Wear>>` | component | 1 | WearExtension (sdk/render/src/bevy3d/extensions.tsx) |
| `bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::pbr_material::StandardMaterial>` | component | 1 | Mesh3d (sdk/render/src/bevy3d/core.tsx) |
| `bevy_pbr::mesh_material::MeshMaterial3d<bevy_trenchbroom::special_textures::QuakeSkyMaterial>` | component | 2 | bevy.MeshMaterial3dQuakeSkyMaterial (raea/plugins/bevy) |
| `bevy_pbr::mesh_material::MeshMaterial3d<raea_sys_fog::fire::FireMaterial>` | component | 2 | bevy.MeshMaterial3dFireMaterial (raea/plugins/bevy) |
Expand Down
1 change: 0 additions & 1 deletion docs/sdk-coverage/bevy.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,6 @@ bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMat
bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_look::paint::Paint>> component
bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_material::toon::ToonExt>> component
bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_shader::ShaderExt>> component
bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::extended_material::ExtendedMaterial<bevy_pbr::pbr_material::StandardMaterial, raea_sys_wear::Wear>> component
bevy_pbr::mesh_material::MeshMaterial3d<bevy_pbr::pbr_material::StandardMaterial> component
bevy_pbr::mesh_material::MeshMaterial3d<bevy_trenchbroom::special_textures::QuakeSkyMaterial> component
bevy_pbr::mesh_material::MeshMaterial3d<raea_sys_fog::fire::FireMaterial> component
Expand Down
57 changes: 53 additions & 4 deletions docs/wear.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Feature: raea/wear, weathering that has a cause
version, "realistic procedural and highly intelligent seeding ... for what makes sense on wear, wear by material,
crumbling infrastructure, doors, walls, plates", and the same for how textures are built and made cheap.

raea's wear so far is shader-only (systems/wear: noise, screen-space curvature, grime on faces turned down;
raea's wear was shader-only (systems/wear: noise, screen-space curvature, grime on faces turned down;
systems/procmat: a pattern with dust, dirt and edges). Nothing in it knows where water runs, what is sheltered, where
hands touch or what a surface is made of, so the marks are scattered evenly rather than caused. The fix is the
method of the literature: the agents of wear are traced through the geometry from their sources, and they leave
Expand Down Expand Up @@ -246,14 +246,28 @@ Feature: raea/wear, weathering that has a cause
faded, the railing rusted; rain, snow with a storm and autumn render; an unbaked sphere under the same shader is
unchanged. The corner house with stills of every cause and condition is WR7's

@needs:WR5,WR3
@needs:WR5,WR3 @done
Scenario: WR6. Crumbling
Then where damage is high (ground band, edges, sheltered damp, neglect), plaster is gone to the brick 2 cm behind
it under a shadowed lip, paint to primer and wood, enamel to iron; cracks run from the corners of openings;
panes are broken or boarded by neglect; slates are missing; and spots.json puts debris under the losses
And the cracked-road fracture of the kit waits for a piece that needs it
And as built (11-19)
| crate | file | lines | job |
| raea-sys-damage | systems/damage/src/lib.rs | 241 | an opening's corners, a crack from about half of them (by a seed per corner), each point's loss potential (damp foot, soaked faces, knocked arrises, along a crack), debris under the losses where the rain falls, landed on the walk below; version 3 |
| raea-sys-damage | systems/damage/src/tests.rs | 190 | an opening's four corners and no others, cracks along the wall, what loosens a coat, debris under the foot (none indoors, none on a plinth), about half the corners cracking |
| raea-sys-weathering | src/lib.rs, rays.rs, touch.rs | +33 | causes3 a's crack, the loss potential and the debris spots from raea-sys-damage |
| raea-sys-touch | src/lib.rs, spots.rs | +18 | a spot's loss, the seed shared with damage |
| raea/wear | sdk/wear/src/causes.ts | 159 | neglect = (1 - e^(-years / 25)) x (1.15 - upkeep); abandon, the share of a house past what a lived-in one lets go (smoothstep from 0.85 of neglect at its base upkeep) |
| raea/wear | sdk/wear/src/recipes.ts | 303 | plaster off to the brick under its lip, paint to primer and wood, enamel flaked to iron, cracks opening by neglect (stepped through brick's joints), panes broken (38%) and boarded (16%) by abandon, slates gone by neglect and abandon |
| raea/wear | sdk/wear/src/index.ts | 257 | wearDebris: the bake's debris spots where loss x abandon reaches 0.3 |
And proof: `cargo test -p raea-sys-damage` (5 tests) and `-p raea-sys-weathering`; `bun test` in sdk/wear (22
tests: neglect and upkeep, abandonment's threshold in the shader's text, debris none at upkeep 0.35, all at 90
years and 0.05, some at 80 and 0.2); the corner house (WR7) rendered after 80 years and as a ruin: plaster off
the rusticated foot and around the openings, cracks from the window corners, the ruin's panes broken and
boarded and slates gone, heaps on the walk under the losses and none inside or on the plinth

@needs:WR5
@needs:WR5 @done
Scenario: WR9. Every season and weather, from uniforms over the causes
Given the look's date and weather, the values the realism lane's sets carry: `day` (the day of the year, 1-366)
and `hour`, from which the season's phase (day / 365.25) and the sun follow; snow, wet and ice as weather of
Expand Down Expand Up @@ -297,21 +311,56 @@ Feature: raea/wear, weathering that has a cause
posted as i-acp-mwlb9fb4-110
And still open: the mapping from the look's `day` and weather to these values is WR5's (the prototype takes
storm, leaves, dust and melt as values of their own); frost and algae; the flash of thunder is the light's
And the shader's half as built (11-19): the eight conditions are WR5's recipes over these causes (spring's damp
and algae, summer's dust, autumn's leaves, frost where December's sun misses, snow lying and driven, rain
wetting, streaming and puddling), named once, and weather that changes during a shot eases toward the sky's
| crate | file | lines | job |
| raea/wear | sdk/wear/src/weather.ts | 79 | WEAR_CONDITIONS (the eight as weather), weatherAt(base, spells, minutes): each value eased exactly toward the sky's per spell, so any frame draws alone; WEATHER_RATES (wetting in about 3 minutes, drying over an hour, snow settling over 20 and melting over 2 hours, driven snow in 10 and off in 30, frost over 30 and gone in 20; ASSUMED until measured) |
| raea/wear | sdk/wear/test/wear.test.ts | 216 | rain soaks and dries at its rates, frames stand alone with no jump at a spell, snow, storm and frost, spells out of order refused, each condition in its season |
And proof: `bun test` in sdk/wear; the corner house under all eight by day and at dusk, and a shower crossing it
(WR7's rain-passes: dry, soaked and drying at frames 0, 40 and 119)

Rule: 3. Shown, then cheap

@needs:WR5
@needs:WR5 @done
Scenario: WR7. The demo, and EX9
Then examples/materials/wear/ is a corner house made in code (plinth, rusticated ground floor, plastered storeys,
sills, string course, cornice on consoles, door, iron balcony, zinc gutter and downpipe, an enamel street
plate, a sandstone surround, steps, a cellar hatch), baked and shaded, with stills of every cause in false
colour and the house under each of WR9's eight conditions, by day and at dusk
And `wear` on MeshStandardMaterial and <WearExtension> are raea/wear's, and systems/wear, its spawn branch and
its row columns are deleted in the same landing (docs/examples.feature EX9)
And as built (11-19)
| crate | file | lines | job |
| example | examples/materials/wear/house.ts | 260 | the corner house as solids (each 8 corners), a hip roof, openings cut through each band, one .glb material per class |
| example | examples/materials/wear/make-house.ts | 11 | writes media/house.glb |
| example | examples/materials/wear/wear.tsx | 179 | before, new, after (80 sooty years), ruin, ruin-near, door; debug-CAUSE for all 16; the eight conditions and their -dusk; rain-passes (120 frames, half a minute each); paint (worn paint with no bake) |
| example | examples/materials/wear/wear.test.ts | 85 | every part WR7 names, the openings through the walls, the .glb, every cause and condition listed, the paint still |
| raea/render | sdk/render/src/worn.ts | 119 | worn paint as a surface shader on the public hook (WORN_WESL, wornShader): systems/wear's shader ported, same noise, curvature edges, grime, rust and chips in the mesh's own space |
| raea/render | sdk/render/src/3d/materials.tsx | +12 | a material's `wear` becomes that shader (none at amount 0; refused beside `shader` or `grid`) |
| deleted | systems/wear, spawn.rs, raea_plugins.rs, runtime/scene parts.rs | -480 | raea-sys-wear, its WearPlugin, spawn branch and row columns; its type out of the registry snapshot, bevy.gen.tsx and sdk-coverage |
And worn paint's shader lives in raea/render beside the material that takes it, not in raea/wear: raea/wear is
built on raea/render, so the other way would be a cycle. <WearExtension> and `wear` keep their props, and the
guides are unchanged
And proof: `bun test` in examples/materials/wear (7 tests) and conformance bevy3d.test.tsx (wear's shader, its
uniforms, none at amount 0, alone); a parity scene of worn paint (sharp, turned and round parts, every setting)
rendered through systems/wear and through worn.ts matches (RMSE 3.8e-5 of full scale); every still, and
rain-passes at frames 0, 40 and 119, render with 0 errors on the Mac. Clay now draws worn paint as it draws any custom surface shader

@needs:WR7
Scenario: WR8. Detail textures from mask stacks, and what they cost
Then each class's detail (brick bond, plaster grain, stone tooling, wood grain) is a stack of procedural masks
rendered by raea once into tiling layers, instead of noise evaluated per pixel per frame
And texture arrays get mips (SH9 arrays have none, so a tiling layer shimmers far off) and maps can be BC
compressed into KTX2, with the memory and frame time each saves measured
And measured first (11-19, M5 Pro, the corner house at 4K, 121-127 frames each, plain and worn interleaved): with
the machine quiet, 17.2 ms a frame plain and 17.2 worn, 17.6 and 17.7; under other sessions' load both rise
together (18-75 ms). The recipes' per-pixel noise costs no frame time a render can see, so detail layers
would save nothing yet; a live scene at 60 fps with many baked buildings is where to measure again
And the maps' memory: four RGBA8 maps of 2048 x 1108 for the house, 36 MB on the GPU; BC7 would take that to
about 9 MB, but causes2's alpha is the class code read exactly by textureLoad (it needs a map of its own
before the rest compress), and an iPhone has no BC (ASTC there). Worth it for a city of baked buildings, not
one house
And still open, so not done: the detail layers, mips on arrays (they come with the detail layers: adding them
now would grow the city's 40-layer room atlas by a third for no wear user), and BC/KTX2 maps with the class
split out and a fallback where BC isn't
2 changes: 0 additions & 2 deletions engine/render/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ bevy = { version = "=0.20.0", default-features = false, features = ["std", "defa
image = { version = "0.25", default-features = false, features = ["png", "jpeg", "hdr"] }
# an edit as rows keyed per frame, and 3D shapes as values (docs/media.feature M2)
raea-core-program = { path = "../../core/program" }
# worn surfaces on a mesh row (`wear`)
raea-sys-wear = { path = "../../systems/wear" }
# procedural surfaces on a mesh row (`proc`)
raea-sys-procmat = { path = "../../systems/procmat" }
raea-core-shape = { path = "../../core/shape" }
Expand Down
1 change: 0 additions & 1 deletion engine/render/src/engine/raea_plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ raea_plugin! {
Draws2dPlugin: raea_sys_sprite::install, "Plugins' 2D drawing brings up the scene's 2D camera (raea-sys-sprite's Draws2d).";
ScreenPlugin: super::screen::install, "Live pictures on surfaces, drawn as CRTs (screen.rs).";
GridPlugin: super::grid::install, "Greybox surfaces: graph paper and outlines (grid.rs).";
WearPlugin: raea_sys_wear::install, "Worn surfaces: chipped paint, grime and rust (systems/wear).";
ProcMatPlugin: raea_sys_procmat::install, "Procedural surfaces: wood, stone, brick, tiles and the rest, with dust and dirt (systems/procmat).";
PaintPlugin: super::paint::install, "The paint and cartoon looks' surfaces (paint.rs).";
PassesPlugin: super::passes::install, "Render passes per view (passes.rs).";
Expand Down
Loading
Loading