Improve Fensalir visitor docs

This commit is contained in:
Meta Vens 2026-05-23 19:17:23 +01:00
commit 35ff187373
4 changed files with 203 additions and 139 deletions

107
README.md
View file

@ -4,48 +4,103 @@
<img src="Fensalir-Icon.png" alt="Fensalir icon" width="160" />
</p>
Fensalir is the native C# runtime for Aquarium-style clients: Win32 hosting,
D3D12 rendering, input, hot reload, audio output, debug UI, render contracts,
fractal/field machinery, and engine demo clients.
Fensalir is a native C# runtime for interactive visual clients. It opens the
window, owns the D3D12 renderer, loads client runtimes behind contracts, keeps
hot reload alive, mixes audio, draws debug UI, and carries the reusable
field/fractal machinery used by Aquarium-style projects.
Epiphany Aquarium is no longer inside this repo. It lives next door at
`E:\Projects\Aquarium-Engine` and consumes Fensalir as a dependency.
The repo is not the Epiphany Aquarium client. Epiphany now lives in
`GameCult/Aquarium-Engine` and consumes this repo as its runtime dependency.
## Repository Shape
## What Runs
- `src/Aquarium.Engine.Contracts`: client-facing runtime, render, UI, audio,
input, and frame contracts.
- `src/Aquarium.Engine`: Win32 host, D3D12 backend, reload transport, debug UI,
audio host, bundled engine assets, and renderer-owned shaders.
- `src/Aquarium.Engine.Fractal`: reusable fractal, field, reservoir, and DSL
machinery.
- `src/Aquarium.Fensalir`: Fensalir splash/art reconstruction demo client.
- `src/Aquarium.Sample.Minimal`: minimal client boundary proof.
- `src/Aquarium.Zyphos`: planetary-scale engine demo client.
- `src/Aquarium.LocalCast`: LocalCast/Mimir-facing runtime bridge experiments.
- `tests`: engine, fractal, LocalCast, and demo coverage.
- `tools`: engine/fractal receipt tools.
Fensalir runs a host executable from `src/Aquarium.Engine`. The host loads a
client assembly that implements `IAquariumRuntime`, then drives this loop:
The assemblies still use `Aquarium.*` names for API continuity. Rename the
public namespace deliberately later if the package boundary earns that churn.
```text
Win32 input + window
-> client runtime update
-> AquariumFrame + AquariumSceneState
-> D3D12 renderer passes
-> DirectWrite debug overlay
-> WASAPI audio output
```
Clients describe render targets, cameras, shaders, SDF proxy objects, UI panels,
audio buffers, and frame state through `Aquarium.Engine.Contracts`. The engine
translates that data into D3D12 resources, pipeline state, command lists,
presentation, hot reload, and diagnostics.
## Projects
- `src/Aquarium.Engine.Contracts`: public client/runtime contracts.
- `src/Aquarium.Engine`: Win32 host, D3D12 renderer, reload transport, debug UI,
audio host, bundled assets, and renderer-owned shaders.
- `src/Aquarium.Engine.Fractal`: `.aquageo`, fractal/IFS, reservoir, temporal
field, and lowering machinery.
- `src/Aquarium.Fensalir`: splash/art reconstruction demo using a Fensalir
scene patch and custom shaders.
- `src/Aquarium.Sample.Minimal`: tiny client proving the runtime boundary.
- `src/Aquarium.Zyphos`: planetary/fractal terrain demo.
- `src/Aquarium.LocalCast`: LocalCast/Mimir-facing bridge experiments.
- `tools/Aquarium.Fractal.Receipt`: CPU/GPU fractal receipt harness.
The assemblies still use `Aquarium.*` names for API continuity. That naming is
legacy surface, not current repo ownership.
## Build
Requirements:
- Windows
- .NET SDK matching `global.json`
- sibling repos currently expected at `E:\Projects\CultMath` and
`E:\Projects\CultLib`
```powershell
dotnet build Fensalir.sln
```
## Run A Client
## Run
Run the Fensalir splash demo:
```powershell
.\scripts\dev-reload.ps1 -ClientProject src\Aquarium.Fensalir\Aquarium.Fensalir.csproj
```
Other demo clients can be launched by changing `-ClientProject`.
Run headless:
```powershell
.\scripts\dev-reload.ps1 -Headless -RetainSlots 4 -ClientProject src\Aquarium.Fensalir\Aquarium.Fensalir.csproj
```
Watch and reload on source changes:
```powershell
.\scripts\dev-watch.ps1 -ClientProject src\Aquarium.Fensalir\Aquarium.Fensalir.csproj
```
Run another client by changing `-ClientProject`.
## Research And State
- `docs/`: live engine architecture and subsystem notes.
- `research/`: rendering/fractal/D3D12 research that informs implementation.
- `state/`: persistent project memory for future agents.
Start with:
- `docs/engine-client-boundary.md`
- `docs/hlsl-renderer.md`
- `docs/perfect-machine-architecture.md`
- `docs/temporal-spatial-evidence-reservoir.md`
- `research/README.md`
- `state/README.md`
## Boundary
Fensalir owns reusable host and renderer authority. Client repos own their
semantics. Do not add Epiphany, Mimir, or other client policy nouns here unless
they are demo/client projects inside this repo. Shared capability belongs in
contracts or reusable engine modules; client interpretation belongs outside.
Fensalir owns reusable runtime and renderer authority. Client repos own meaning.
If a feature requires app-specific policy, role names, story state, or client
layout semantics, it belongs outside the engine unless it has been reduced to a
reusable data-only contract.

22
docs/README.md Normal file
View file

@ -0,0 +1,22 @@
# Fensalir Docs
Start here if you are trying to understand the engine rather than a specific
historical branch scar.
- `engine-client-boundary.md`: what Fensalir owns versus what client repos own.
- `hlsl-renderer.md`: current D3D12/HLSL frame path.
- `vortice-spine.md`: native host and renderer spine.
- `cult-runtime-surface.md`: cache-path and typed-state boundary.
- `input.md`: input and camera contracts.
- `temporal-spatial-evidence-reservoir.md`: stable-key temporal evidence cache.
- `temporal-sdf-gaussian-field.md`: temporal Form-field evidence lane.
- `perfect-machine-architecture.md`: broader field/reservoir architecture.
- `tsr-inspired-taa-spec.md`: temporal resolve design.
- `stochastic-transparent-surface-pipeline.md`: transparent field rendering
notes.
- `d3d12-best-practices-audit.md` and `d3d12-migration.md`: D3D12 migration and
audit notes.
- `zyphos-eusocial-sync.md`: Zyphos demo worldbuilding boundary.
Research notes live under `research/`. Persistent agent state lives under
`state/`.

View file

@ -1,117 +1,103 @@
# HLSL Renderer
Aquarium's visible world is currently a D3D12 HLSL renderer with a small,
explicit frame graph.
Fensalir's renderer is a D3D12/HLSL runtime that consumes client-declared render
plans and frame state. The renderer owns GPU resources, command recording,
shader compilation/reload, presentation, debug views, and final overlay text.
Clients own the scene meaning and shader modules they declare.
## Current Path
## Frame Path
1. Engine-owned `D3D12HeightField.hlsl` renders a 128x128 scalar height-field
target from client-authored brush data.
2. Engine-owned `D3D12Scene.hlsl` traces the background and Grid into
scene-linear HDR targets.
3. Epiphany-owned body shaders each get their own proxy pipeline:
`D3D12FaceAgent.hlsl`, `D3D12ImaginationAgent.hlsl`,
`D3D12EyesAgent.hlsl`, `D3D12BodyAgent.hlsl`, `D3D12HandsAgent.hlsl`,
`D3D12SoulAgent.hlsl`, `D3D12LifeAgent.hlsl`, `D3D12SelfBody.hlsl`, and
`D3D12CursorBody.hlsl`. Shared proxy mechanics live in the engine includes
`D3D12SdfCommon.hlsli`, `D3D12SdfProxy.hlsli`, and `D3D12SdfMath.hlsli`.
4. Engine-owned `D3D12Post.hlsl` builds bloom, resolves diagnostics/history, applies
exposure and ACES, then presents.
5. `DirectWriteOverlay` draws crisp final-pixel debug UI after scene rendering.
The current frame path is deliberately small:
C# feeds explicit frame constants: resolution, time, Grid radius, camera
position, presentation controls, previous frame state, cursor anchors, and debug
mode. CultMath is the CPU-side math grammar. Vortice math stays at the graphics
API membrane.
1. `D3D12HeightField.hlsl` renders a scalar height target from client-authored
`AquariumHeightFieldBrush` rows.
2. A client-selected scene shader renders the main HDR scene target. The default
engine scene shader is `D3D12Scene.hlsl`; demos may provide their own.
3. Client-declared SDF proxy shaders render bounded object passes through shared
engine includes: `D3D12SdfCommon.hlsli`, `D3D12SdfProxy.hlsli`, and
`D3D12SdfMath.hlsli`.
4. Optional fractal/field passes consume GPU-resident splat/reservoir buffers.
5. `D3D12Post.hlsl` resolves temporal diagnostics, builds bloom, applies
exposure/ACES, and presents.
6. `DirectWriteOverlay` draws crisp final-pixel debug UI after scene rendering.
## Grid
The C# renderer feeds explicit constants for resolution, time, camera,
presentation controls, previous-frame state, cursor anchors, and debug mode.
Vortice stays at the graphics API membrane; clients talk through contracts.
The Grid height target is centered on the camera target; body anchors remain in
world space. The target stores height in `.r` only. A future useful expansion is
packed gradients in `.g/.b` if normal cost becomes worth the extra bandwidth.
## Render Plan
Grid linework is derivative-aware in the final scene pass. Cartesian lines use
screen-space `fwidth` against their world-domain coordinate so minor and major
lines stay the same pixel width across zoom distances. Terrain isolines derive
from the Grid height field, while field lines quantize terrain gradient angle
and fade out on flat surfaces.
Clients build an `AquariumRenderPlan` with `AquariumApp`:
The fullscreen scene pass owns environment and Grid only. Bodies are not folded
into that pass. After the Grid writes scene color and travel-derived depth,
each body gets its own proxy draw and shader pipeline. The shared proxy vertex
shader computes a conservative screen rectangle from the uploaded body center
and bound radius. The body-specific pixel shader raymarches only that object
and writes travel-derived depth so the Grid and nearer bodies arbitrate
visibility through the depth target.
- render targets and formats;
- cameras;
- fullscreen, proxy, and feature passes;
- shader paths;
- SDF libraries and per-object proxy shaders;
- debug target views;
- presentation features such as bloom and DirectWrite overlay.
## Solids
The live renderer still contains some fixed execution paths, but ownership is
already split: clients declare intent, Fensalir owns D3D12 lowering.
Epiphany uploads Self, Face, Imagination, Eyes, Body, Hands, Soul, Life, and the
cursor through the engine `AquariumSdfObject` buffer, including current center,
previous center, and state scalars. Aquarium owns the D3D12 upload, proxy draw,
depth, and presentation machinery; Epiphany owns which bodies exist, where they
are, and which shader files describe them.
## Height Fields
The cursor is a luminous three-lobed hibiscus SDF that lives on the XY plane:
its center is one cursor radius above XY, so its lower contact tip lands at
Grid z=0 instead of sampling the Grid height field. The previous MathWorld
teardrop formula remains in `D3D12SdfMath.hlsli` for later reuse. Agent visuals
carry their previous centers in the structured buffer for temporal reprojection.
The height-field target is currently a 128x128 `R16Float` scalar field. Client
brushes may use circular or shaped anisotropic envelopes. The target stores
height in `.r`; extra channels are not free and need a pass contract before they
exist.
Lighting is currently direct and diegetic: Self is the emitter. No ambient fill
is allowed to quietly solve a bad light story.
The height-field lane is used by multiple clients and demos as a cheap scalar
surface, not as a global engine worldview. Future terrain, water, and projected
field work should move through explicit field/page contracts instead of growing
one magic grid.
## SDF Proxies
SDF objects render as bounded proxy draws. The shared proxy vertex shader builds
a conservative screen rectangle from the uploaded object center and bound
radius. The object-specific pixel shader raymarches only that object and writes
travel-derived depth so surfaces and nearer proxies arbitrate visibility through
normal depth testing.
SDF control flow is split by cost:
- `sdfDistance` participates in marching and normals.
- `sdfSurface` runs once at the refined hit.
- Material output uses base color, metallic, roughness, and emission.
Reusable math belongs in engine includes. Client anatomy, symbols, bodies, and
materials belong in client shaders.
## Fractal And Field Passes
Fensalir has a GPU-resident fractal/field lane:
- `.aquageo` and flame fixtures compile into semantic ownership trees and
backend packets.
- persistent flame state lives in GPU UAV rows so samples advance over frames;
- Form/Appearance/Transport reservoirs keep stable temporal evidence;
- opaque signed-distance splats and transparent density/extinction splats render
through separate pipeline states over shared packed buffers;
- guide output follows the TAA schema: confidence, sample age, domain validity,
invalidation code.
The receipt harness lives in `tools/Aquarium.Fractal.Receipt`.
## Temporal Diagnostics
The temporal resolver is documented in `docs/tsr-inspired-taa-spec.md`. The live
frame keeps color, metadata, and control history. Projection jitter uses a small
Halton sequence, and final presentation blends validated history. SDF object
highlights get a narrow hot-current history path so transient specular spikes
can be damped without relaxing travel, field, or normal validation. Bloom is
clamped at prefilter for unsupported single-pixel HDR spikes, then attenuated
when the resolved scene has damped a much hotter current sample, so transient
fireflies do not keep blooming through the current-frame bloom path.
Dormant event lanes are not preserved without a producer and pass contract.
`D3D12Post.hlsl` keeps color, metadata, and control history. Projection jitter
uses a small Halton sequence. History is accepted only when travel, field,
normal, coverage, and control signals stay coherent.
Debug modes:
- `0` final
- `1` raw current scene
- `2` reprojected history sample
- `3` history age
- `4` history weight
- `5` coverage and step ratio
- `6` current field identity
- `7` bloom contribution
- `8` exposed luminance
- `9` agent identity
- `10` agent SDF step count
`F1` cycles modes. Number keys select the first modes directly. Startup mode can
be set with `--render-debug` or `AQUARIUM_RENDER_DEBUG_MODE`.
Debug modes include final color, raw current scene, history, history age,
history weight, coverage/step ratio, field identity, bloom contribution,
exposed luminance, proxy identity, proxy step count, and reservoir/TAA guide
views. Startup mode can be set with `--render-debug` or
`AQUARIUM_RENDER_DEBUG_MODE`.
## HDR
Presentation applies explicit exposure before display transformation and adds a
low-gain pre-tonemap bloom/veil pyramid. The bloom pass renders exposed
scene-linear HDR color into half-, quarter-, and eighth-resolution targets, uses
firefly-safe downsampling, blurs each level with separable horizontal/vertical
passes, then contributes gently before the ACES fit. This is not threshold glow.
## Overlay Text
Readable overlay text is handled by `DirectWriteOverlay`, using DirectWrite for
font layout/rasterization and Direct2D for final draw. D3D12 reaches that path
through D3D11On12 only after the scene frame is rendered. The bridge is
overlay-only.
The debug controls live in `Render/Ui/DebugUi.cs`. The grammar is a native
version of CultLib's generator API: panels, sections, sliders, toggles, options,
and buttons are declared in code and bound to engine state with explicit read
and write delegates. The visual language is compact, flat, and allowed to have
taste. Frighteningly controversial, apparently.
The overlay owns a private DirectWrite font collection built from bundled Google
Fonts files in `Assets/Fonts`: Montserrat for thin small-cap display text and
Ubuntu Sans for body/debug copy. Runtime must not depend on system-installed
fonts.
Presentation is scene-linear until the final display transform. Bloom is a
low-gain pre-tonemap veil pyramid with firefly-safe downsampling; it is not a
threshold glow sticker over a broken exposure model.

View file

@ -212,3 +212,4 @@
{"timestamp":"2026-05-22T01:20:00+01:00","topic":"fensalir-fixed-headless-capture","lesson":"Fensalir now has a repeatable headless frame-capture lane for art-target iteration. AquariumHost accepts --capture-frame plus headless width/height, suppresses overlay debug UI while headless, waits for ready frames, and saves the last presented backbuffer through IAquariumRenderer.SaveFramePng. scripts/capture-fensalir-frame.ps1 builds disposable engine/client slots and uses Start-Process with a timeout because Aquarium.Engine is a Windows GUI exe and plain PowerShell invocation can return before rendering is complete. The latest capture, artifacts/fensalir-captures/fixed-cathedral-forward.png, proves the current gap honestly: the cathedral silhouette is now visible and DSL patch claims drive surface/cathedral fields, but the spine/pillar grammar is still partly shader-authored and needs a real IFS-owned structural lowering before the splash reproduction stops being a hand-guided proxy.","files":["src/Aquarium.Engine/AquariumHost.cs","scripts/capture-fensalir-frame.ps1","src/Aquarium.Fensalir/FensalirRuntime.cs","src/Aquarium.Fensalir/FensalirSceneBuilder.cs","src/Aquarium.Fensalir/Shaders/D3D12FensalirScene.hlsl","src/Aquarium.Fensalir/Shaders/D3D12FensalirSpine.hlsl","src/Aquarium.Fensalir/Worlds/fensalir-spine-emblem.aquageo","tests/Aquarium.Engine.Fractal.Tests/FensalirFractalSceneTests.cs","state/map.yaml","state/memory.json"],"source":"user asked to exercise the cathedral through the DSL and set up fixed-camera headless capture for unattended renderer iteration"}
{"timestamp":"2026-05-22T01:32:00+01:00","topic":"fensalir-cathedral-guide-is-scaffolding","lesson":"The fixed capture made the visual failure impossible to dodge: Fensalir's previous shader/SDF mix had the nouns of the splash but not the image. A temporary screen-space cathedral guide now exposes the target composition more clearly in artifacts/fensalir-captures/fixed-cathedral-guide-clean.png, while SDF authority is cut back to the central spine/reeds instead of traced pillar rods fighting atmospheric glass. This guide is not final architecture. The next coherent slice is a separate `.aquageo`-lowered transparent pane/rune/material field target, distinct from the marsh height texture, so the cathedral glass, waterline glow, rune dust, and material confidence are authored field claims rather than hardcoded screen composition.","files":["src/Aquarium.Fensalir/Shaders/D3D12FensalirScene.hlsl","src/Aquarium.Fensalir/Shaders/D3D12FensalirSpine.hlsl","src/Aquarium.Fensalir/FensalirSceneBuilder.cs","state/map.yaml","state/memory.json"],"source":"user correctly mocked the prior receipt as visually nowhere near the provided splash reference"}
{"timestamp":"2026-05-23T00:00:00+01:00","topic":"fensalir-repo-split","lesson":"Fensalir now has its own adjacent repo at E:\\Projects\\Fensalir and owns the native host, renderer, contracts, fractal machinery, audio host, reload scripts, and engine demos. Epiphany Aquarium moved out to E:\\Projects\\Aquarium-Engine as a client repo that references Fensalir source projects until packaging exists. Keep dependency direction one-way: client repos may depend on Fensalir; Fensalir must not depend on client policy nouns.","files":["Fensalir.sln","README.md","AGENTS.md","state/map.yaml","state/memory.json"],"source":"user directed Fensalir and engine demos into a new adjacent repo while Aquarium-Engine remains only the Epiphany Aquarium client"}
{"timestamp":"2026-05-23T19:16:55.4706855+01:00","topic":"visitor-docs-refresh","lesson":"Fensalir visitor docs now describe the live runtime machine: host loop, contracts, D3D12 frame path, field/fractal lane, demo clients, build/run commands, and doc indexes. Keep README/docs oriented around current ownership and runnable surfaces, not split-history cleanup prose.","files": ["README.md","docs/hlsl-renderer.md","docs/README.md"],"source":"user asked both repos to describe the machines they contain for visitors"}