From 8593f3be56ea658e5d6dbdb85c8cde58fb9d8068 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 9 May 2026 02:43:15 +0100 Subject: [PATCH] Gate volumetric medium composition --- docs/cult-runtime-surface.md | 3 +- docs/hlsl-renderer.md | 12 ++++--- docs/sdf-field-renderer-plan.md | 5 +-- .../GraphicsSettings.cs | 11 ++++-- .../State/AquariumCultStateStore.cs | 1 + .../State/AquariumGraphicsSettingsState.cs | 8 +++-- src/Aquarium.Engine/Render/D3D11Renderer.cs | 36 +++++++++++++++---- .../Render/Shaders/Aquarium.hlsl | 27 +++++++++++--- state/evidence.jsonl | 1 + state/map.yaml | 4 +-- state/memory.json | 4 +-- state/scratch.md | 4 +++ 12 files changed, 89 insertions(+), 27 deletions(-) diff --git a/docs/cult-runtime-surface.md b/docs/cult-runtime-surface.md index 6d5443d..193e56f 100644 --- a/docs/cult-runtime-surface.md +++ b/docs/cult-runtime-surface.md @@ -45,7 +45,8 @@ again during orderly shutdown. - name: `aquarium-client-graphics` It stores global renderer presentation controls: render debug mode, scene -exposure, bloom intensity, and bloom veil intensity. `GraphicsSettings` lives in +exposure, bloom intensity, bloom veil intensity, and medium composite intensity. +`GraphicsSettings` lives in the contracts assembly so the native host and renderer can consume the same typed values without depending on CultCache internals. The Direct2D debug panel edits the renderer copy, the host syncs changed values back to the live runtime, diff --git a/docs/hlsl-renderer.md b/docs/hlsl-renderer.md index 808967a..7c5480a 100644 --- a/docs/hlsl-renderer.md +++ b/docs/hlsl-renderer.md @@ -228,15 +228,17 @@ startup mode can still be set with `--render-debug` or Fog work has started behind diagnostics rather than final-frame haze. The host packs stable field instances into a structured buffer shared with HLSL. A half-resolution medium pass writes registered density, transmittance, and source -lighting into a separate texture before the scene pass. Modes `9`, `10`, and -`11` show medium density, transmittance, and source respectively. The signals -are deliberately debug-only until the explicit volume composition path exists. +lighting into diagnostic and transport textures before the scene pass. Modes +`9`, `10`, and `11` show medium density, transmittance, and source respectively. +Final composition uses `surface * transmittance + in-scattering`, gated by the +persisted Medium Composite control. The default is `0`, so the pass can be +inspected without changing the presented frame until the medium is tuned. The running window also has a Direct2D debug panel toggled with `F2`. It follows the CultLib code-first composition style rather than an immediate-mode toolkit: controls are retained rows bound to `Func`/`Action` pairs. The first panel -drives render debug mode, exposure, bloom intensity, and bloom veil. Those HDR -controls feed the shader constant buffer directly and round-trip through the +drives render debug mode, exposure, bloom intensity, bloom veil, and medium +composite strength. Those presentation controls feed the shader constant buffer directly and round-trip through the global `GraphicsSettings` CultCache document; they are not cosmetic labels painted over hardcoded renderer state. diff --git a/docs/sdf-field-renderer-plan.md b/docs/sdf-field-renderer-plan.md index 3116385..fd25f1e 100644 --- a/docs/sdf-field-renderer-plan.md +++ b/docs/sdf-field-renderer-plan.md @@ -101,8 +101,9 @@ except to replace them. Current status: the renderer now packs a first fixed-size field instance buffer for Self, planets, and local cloud/medium ellipsoids. HLSL consumes that buffer in a half-resolution medium pass that writes density, transmittance, and source -diagnostics while final scene color remains unchanged. This is the contract -foothold, not the final volume renderer. +diagnostics plus transport. Final composition uses the transport texture behind +a persisted intensity gate that defaults to zero. This is the contract foothold, +not the final volume renderer. ### Gate 2: Broad Phase diff --git a/src/Aquarium.Engine.Contracts/GraphicsSettings.cs b/src/Aquarium.Engine.Contracts/GraphicsSettings.cs index e5796f0..9198ef9 100644 --- a/src/Aquarium.Engine.Contracts/GraphicsSettings.cs +++ b/src/Aquarium.Engine.Contracts/GraphicsSettings.cs @@ -4,7 +4,8 @@ public readonly record struct GraphicsSettings( int RenderDebugMode, float SceneExposure, float BloomIntensity, - float BloomVeilIntensity) + float BloomVeilIntensity, + float MediumCompositeIntensity) { public const int MinRenderDebugMode = 0; public const int MaxRenderDebugMode = 11; @@ -14,12 +15,15 @@ public readonly record struct GraphicsSettings( public const float MaxBloomIntensity = 0.24f; public const float MinBloomVeilIntensity = 0.0f; public const float MaxBloomVeilIntensity = 0.08f; + public const float MinMediumCompositeIntensity = 0.0f; + public const float MaxMediumCompositeIntensity = 1.0f; public static GraphicsSettings Default { get; } = new( RenderDebugMode: 0, SceneExposure: 0.16f, BloomIntensity: 0.072f, - BloomVeilIntensity: 0.014f); + BloomVeilIntensity: 0.014f, + MediumCompositeIntensity: 0.0f); public GraphicsSettings Normalized() { @@ -27,6 +31,7 @@ public readonly record struct GraphicsSettings( Math.Clamp(RenderDebugMode, MinRenderDebugMode, MaxRenderDebugMode), Math.Clamp(SceneExposure, MinSceneExposure, MaxSceneExposure), Math.Clamp(BloomIntensity, MinBloomIntensity, MaxBloomIntensity), - Math.Clamp(BloomVeilIntensity, MinBloomVeilIntensity, MaxBloomVeilIntensity)); + Math.Clamp(BloomVeilIntensity, MinBloomVeilIntensity, MaxBloomVeilIntensity), + Math.Clamp(MediumCompositeIntensity, MinMediumCompositeIntensity, MaxMediumCompositeIntensity)); } } diff --git a/src/Aquarium.Engine.Live/State/AquariumCultStateStore.cs b/src/Aquarium.Engine.Live/State/AquariumCultStateStore.cs index 8d8c40f..0251e7b 100644 --- a/src/Aquarium.Engine.Live/State/AquariumCultStateStore.cs +++ b/src/Aquarium.Engine.Live/State/AquariumCultStateStore.cs @@ -90,6 +90,7 @@ public sealed class AquariumCultStateStore : IDisposable state.SceneExposure = normalized.SceneExposure; state.BloomIntensity = normalized.BloomIntensity; state.BloomVeilIntensity = normalized.BloomVeilIntensity; + state.MediumCompositeIntensity = normalized.MediumCompositeIntensity; state.SaveGeneration++; cache.AddAsync(state, new CultRecordHandle(GraphicsSettingsKey)).GetAwaiter().GetResult(); backingStore.PushAll(); diff --git a/src/Aquarium.Engine.Live/State/AquariumGraphicsSettingsState.cs b/src/Aquarium.Engine.Live/State/AquariumGraphicsSettingsState.cs index c6e1b94..4ed4132 100644 --- a/src/Aquarium.Engine.Live/State/AquariumGraphicsSettingsState.cs +++ b/src/Aquarium.Engine.Live/State/AquariumGraphicsSettingsState.cs @@ -26,6 +26,9 @@ public sealed class AquariumGraphicsSettingsState public float BloomVeilIntensity { get; set; } = GraphicsSettings.Default.BloomVeilIntensity; [Key(5)] + public float MediumCompositeIntensity { get; set; } = GraphicsSettings.Default.MediumCompositeIntensity; + + [Key(6)] public long SaveGeneration { get; set; } public static AquariumGraphicsSettingsState FromSettings(GraphicsSettings settings) @@ -36,12 +39,13 @@ public sealed class AquariumGraphicsSettingsState RenderDebugMode = normalized.RenderDebugMode, SceneExposure = normalized.SceneExposure, BloomIntensity = normalized.BloomIntensity, - BloomVeilIntensity = normalized.BloomVeilIntensity + BloomVeilIntensity = normalized.BloomVeilIntensity, + MediumCompositeIntensity = normalized.MediumCompositeIntensity }; } public GraphicsSettings ToSettings() { - return new GraphicsSettings(RenderDebugMode, SceneExposure, BloomIntensity, BloomVeilIntensity).Normalized(); + return new GraphicsSettings(RenderDebugMode, SceneExposure, BloomIntensity, BloomVeilIntensity, MediumCompositeIntensity).Normalized(); } } diff --git a/src/Aquarium.Engine/Render/D3D11Renderer.cs b/src/Aquarium.Engine/Render/D3D11Renderer.cs index 06ab962..41dc563 100644 --- a/src/Aquarium.Engine/Render/D3D11Renderer.cs +++ b/src/Aquarium.Engine/Render/D3D11Renderer.cs @@ -73,6 +73,9 @@ public sealed class D3D11Renderer : IDisposable private readonly ID3D11Texture2D mediumVolumeTexture; private readonly ID3D11RenderTargetView mediumVolumeRenderTargetView; private readonly ID3D11ShaderResourceView mediumVolumeShaderResourceView; + private readonly ID3D11Texture2D mediumTransportTexture; + private readonly ID3D11RenderTargetView mediumTransportRenderTargetView; + private readonly ID3D11ShaderResourceView mediumTransportShaderResourceView; private readonly ID3D11Texture2D[] bloomTextures = new ID3D11Texture2D[BloomLevelCount]; private readonly ID3D11RenderTargetView[] bloomRenderTargetViews = new ID3D11RenderTargetView[BloomLevelCount]; private readonly ID3D11ShaderResourceView[] bloomShaderResourceViews = new ID3D11ShaderResourceView[BloomLevelCount]; @@ -205,6 +208,9 @@ public sealed class D3D11Renderer : IDisposable mediumVolumeTexture = CreateHdrTexture(mediumVolumeWidth, mediumVolumeHeight); mediumVolumeRenderTargetView = device.CreateRenderTargetView(mediumVolumeTexture); mediumVolumeShaderResourceView = device.CreateShaderResourceView(mediumVolumeTexture); + mediumTransportTexture = CreateHdrTexture(mediumVolumeWidth, mediumVolumeHeight); + mediumTransportRenderTargetView = device.CreateRenderTargetView(mediumTransportTexture); + mediumTransportShaderResourceView = device.CreateShaderResourceView(mediumTransportTexture); for (var level = 0; level < BloomLevelCount; level++) { var divisor = 1 << (level + 1); @@ -326,7 +332,8 @@ public sealed class D3D11Renderer : IDisposable SceneExposure, BloomIntensity, BloomVeilIntensity, - (float2)Vector2.Zero); + MediumCompositeIntensity, + 0.0f); BuildFroxelPrimitiveTable(frame); BuildFieldInstanceTable(frame); @@ -357,6 +364,8 @@ public sealed class D3D11Renderer : IDisposable public float BloomVeilIntensity { get; set; } = GraphicsSettings.Default.BloomVeilIntensity; + public float MediumCompositeIntensity { get; set; } = GraphicsSettings.Default.MediumCompositeIntensity; + public bool DebugUiVisible { get => debugUi.IsVisible; @@ -375,7 +384,7 @@ public sealed class D3D11Renderer : IDisposable public GraphicsSettings CaptureGraphicsSettings() { - return new GraphicsSettings(RenderDebugMode, SceneExposure, BloomIntensity, BloomVeilIntensity).Normalized(); + return new GraphicsSettings(RenderDebugMode, SceneExposure, BloomIntensity, BloomVeilIntensity, MediumCompositeIntensity).Normalized(); } public void ApplyGraphicsSettings(GraphicsSettings settings) @@ -385,6 +394,7 @@ public sealed class D3D11Renderer : IDisposable SceneExposure = normalized.SceneExposure; BloomIntensity = normalized.BloomIntensity; BloomVeilIntensity = normalized.BloomVeilIntensity; + MediumCompositeIntensity = normalized.MediumCompositeIntensity; } private DebugUi CreateDebugUi() @@ -397,7 +407,9 @@ public sealed class D3D11Renderer : IDisposable .Section("HDR") .Slider("Exposure", () => SceneExposure, value => SceneExposure = Math.Clamp(value, GraphicsSettings.MinSceneExposure, GraphicsSettings.MaxSceneExposure), GraphicsSettings.MinSceneExposure, GraphicsSettings.MaxSceneExposure, "0.###", "Manual scene exposure before display transform.") .Slider("Bloom Intensity", () => BloomIntensity, value => BloomIntensity = Math.Clamp(value, GraphicsSettings.MinBloomIntensity, GraphicsSettings.MaxBloomIntensity), GraphicsSettings.MinBloomIntensity, GraphicsSettings.MaxBloomIntensity, "0.###", "Strength of pre-tonemap bloom energy.") - .Slider("Bloom Veil", () => BloomVeilIntensity, value => BloomVeilIntensity = Math.Clamp(value, GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity), GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity, "0.###", "Low-frequency veil from bright HDR energy.")); + .Slider("Bloom Veil", () => BloomVeilIntensity, value => BloomVeilIntensity = Math.Clamp(value, GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity), GraphicsSettings.MinBloomVeilIntensity, GraphicsSettings.MaxBloomVeilIntensity, "0.###", "Low-frequency veil from bright HDR energy.") + .Section("Medium") + .Slider("Composite", () => MediumCompositeIntensity, value => MediumCompositeIntensity = Math.Clamp(value, GraphicsSettings.MinMediumCompositeIntensity, GraphicsSettings.MaxMediumCompositeIntensity), GraphicsSettings.MinMediumCompositeIntensity, GraphicsSettings.MaxMediumCompositeIntensity, "0.###", "Blends registered medium transport into the final scene.")); } public void Dispose() @@ -448,6 +460,9 @@ public sealed class D3D11Renderer : IDisposable mediumVolumeShaderResourceView.Dispose(); mediumVolumeRenderTargetView.Dispose(); mediumVolumeTexture.Dispose(); + mediumTransportShaderResourceView.Dispose(); + mediumTransportRenderTargetView.Dispose(); + mediumTransportTexture.Dispose(); sceneMetadataShaderResourceView.Dispose(); sceneMetadataRenderTargetView.Dispose(); sceneMetadataTexture.Dispose(); @@ -544,7 +559,7 @@ public sealed class D3D11Renderer : IDisposable context.PSUnsetShaderResource(11); context.PSUnsetShaderResource(12); context.PSUnsetShaderResource(13); - context.PSUnsetShaderResource(13); + context.PSUnsetShaderResource(14); context.OMSetRenderTargets(gridHeightRenderTargetView); context.RSSetViewport(0.0f, 0.0f, GridHeightTextureSize, GridHeightTextureSize, 0.0f, 1.0f); context.ClearRenderTargetView(gridHeightRenderTargetView, new Color4(0.0f, 0.0f, 0.0f, 0.0f)); @@ -560,9 +575,11 @@ public sealed class D3D11Renderer : IDisposable { context.PSUnsetShaderResource(12); context.PSUnsetShaderResource(13); - context.OMSetRenderTargets(mediumVolumeRenderTargetView); + context.PSUnsetShaderResource(14); + context.OMSetRenderTargets(new[] { mediumVolumeRenderTargetView, mediumTransportRenderTargetView }); context.RSSetViewport(0.0f, 0.0f, mediumVolumeWidth, mediumVolumeHeight, 0.0f, 1.0f); context.ClearRenderTargetView(mediumVolumeRenderTargetView, new Color4(0.0f, 1.0f, 0.0f, 0.0f)); + context.ClearRenderTargetView(mediumTransportRenderTargetView, new Color4(0.0f, 0.0f, 0.0f, 1.0f)); context.IASetInputLayout(null); context.IASetPrimitiveTopology(PrimitiveTopology.TriangleList); context.VSSetShader(vertexShader); @@ -585,6 +602,7 @@ public sealed class D3D11Renderer : IDisposable context.PSUnsetShaderResource(10); context.PSUnsetShaderResource(11); context.PSUnsetShaderResource(13); + context.PSUnsetShaderResource(14); context.OMSetRenderTargets(new[] { sceneRenderTargetView, sceneMetadataRenderTargetView, sceneControlRenderTargetView }); context.RSSetViewport(0.0f, 0.0f, width, height, 0.0f, 1.0f); context.ClearRenderTargetView(sceneRenderTargetView, new Color4(0.0f, 0.0f, 0.0f, 0.0f)); @@ -600,6 +618,7 @@ public sealed class D3D11Renderer : IDisposable context.PSSetShaderResource(2, ditherShaderResourceView); context.PSSetShaderResource(12, fieldInstanceShaderResourceView); context.PSSetShaderResource(13, mediumVolumeShaderResourceView); + context.PSSetShaderResource(14, mediumTransportShaderResourceView); context.PSSetSampler(0, gridSampler); context.PSSetSampler(1, ditherSampler); context.Draw(3, 0); @@ -611,6 +630,8 @@ public sealed class D3D11Renderer : IDisposable context.PSUnsetShaderResource(10); context.PSUnsetShaderResource(11); context.PSUnsetShaderResource(12); + context.PSUnsetShaderResource(13); + context.PSUnsetShaderResource(14); for (var level = 0; level < BloomLevelCount; level++) { @@ -674,6 +695,7 @@ public sealed class D3D11Renderer : IDisposable context.PSUnsetShaderResource(10); context.PSUnsetShaderResource(11); context.PSUnsetShaderResource(13); + context.PSUnsetShaderResource(14); context.OMSetRenderTargets(new[] { renderTargetView, historyWriteView, historyMetadataWriteView, historyControlWriteView }); context.RSSetViewport(0.0f, 0.0f, width, height, 0.0f, 1.0f); context.ClearRenderTargetView(renderTargetView, new Color4(0.0f, 0.0f, 0.0f, 1.0f)); @@ -692,6 +714,7 @@ public sealed class D3D11Renderer : IDisposable context.PSSetShaderResource(10, bloomShaderResourceViews[1]); context.PSSetShaderResource(11, bloomShaderResourceViews[2]); context.PSSetShaderResource(13, mediumVolumeShaderResourceView); + context.PSSetShaderResource(14, mediumTransportShaderResourceView); context.PSSetSampler(0, gridSampler); context.Draw(3, 0); } @@ -1043,7 +1066,8 @@ public sealed class D3D11Renderer : IDisposable float Exposure, float BloomIntensity, float BloomVeilIntensity, - float2 Padding); + float MediumCompositeIntensity, + float Padding); private readonly record struct FroxelCell(int X, int Y, int Z); diff --git a/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl b/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl index bef9457..0cec27c 100644 --- a/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl @@ -17,7 +17,8 @@ cbuffer AquariumFrame : register(b0) float exposure; float bloomIntensity; float bloomVeilIntensity; - float2 presentationPadding; + float mediumCompositeIntensity; + float presentationPadding; }; Texture2D gridHeightTexture : register(t0); @@ -33,6 +34,7 @@ Texture2D bloomTexture0 : register(t9); Texture2D bloomTexture1 : register(t10); Texture2D bloomTexture2 : register(t11); Texture2D mediumVolumeTexture : register(t13); +Texture2D mediumTransportTexture : register(t14); struct FieldInstance { @@ -462,6 +464,11 @@ float4 sampleMediumVolume(float2 uv) return mediumVolumeTexture.SampleLevel(gridSampler, uv, 0.0); } +float4 sampleMediumTransport(float2 uv) +{ + return mediumTransportTexture.SampleLevel(gridSampler, uv, 0.0); +} + void cloudFieldInfo(int index, out float3 center, out float3 radius, out float3 tint, out float densityScale) { float slowTime = timeSeconds * 0.035; @@ -1444,7 +1451,13 @@ struct SceneOut float4 control : SV_Target2; }; -float4 MediumVolumePS(VertexOut input) : SV_Target +struct MediumVolumeOut +{ + float4 diagnostic : SV_Target0; + float4 transport : SV_Target1; +}; + +MediumVolumeOut MediumVolumePS(VertexOut input) { float2 screenUv = float2(input.uv.x, 1.0 - input.uv.y); float2 pixel = screenUv * resolution; @@ -1457,7 +1470,10 @@ float4 MediumVolumePS(VertexOut input) : SV_Target float densityDebug = saturate(densityIntegral * 0.18); float sourceDebug = saturate(dot(inScattering, float3(0.2126, 0.7152, 0.0722)) * 0.65); - return float4(densityDebug, saturate(transmittance), sourceDebug, 1.0); + MediumVolumeOut output; + output.diagnostic = float4(densityDebug, saturate(transmittance), sourceDebug, 1.0); + output.transport = float4(inScattering, saturate(transmittance)); + return output; } SceneOut AquariumScenePS(VertexOut input) @@ -1709,7 +1725,10 @@ ResolveOut AquariumResolvePS(VertexOut input) } } - float3 resolved = currentColor; + float4 mediumTransport = sampleMediumTransport(input.uv); + float mediumBlend = saturate(mediumCompositeIntensity); + float mediumTransmittance = lerp(1.0, saturate(mediumTransport.a), mediumBlend); + float3 resolved = currentColor * mediumTransmittance + mediumTransport.rgb * mediumBlend; float3 exposedColor = exposeSceneColor(resolved); float3 bloomColor = diff --git a/state/evidence.jsonl b/state/evidence.jsonl index 06b84f2..99deb71 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -48,3 +48,4 @@ {"area":"renderer/state","lesson":"Global renderer presentation knobs should be a typed CultCache document, not process-local debug UI state. Aquarium now uses a contracts-level GraphicsSettings DTO, a live epiphany.aquarium.graphics_settings document, host sync from renderer to runtime, and runtime flush before live assembly reload so render debug mode plus HDR exposure/bloom controls persist across restart and reload without forcing disk writes on every slider twitch.","files":["src/Aquarium.Engine.Contracts/GraphicsSettings.cs","src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs","src/Aquarium.Engine.Live/State/AquariumGraphicsSettingsState.cs","src/Aquarium.Engine.Live/State/AquariumCultStateStore.cs","src/Aquarium.Engine.Live/AquariumRuntime.cs","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Live/LiveRuntimeLoader.cs","src/Aquarium.Engine/Render/D3D11Renderer.cs","docs/cult-runtime-surface.md","docs/hlsl-renderer.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4","direct headless two-run probe: --render-debug 7 persisted as debug 7 on the next run using artifacts/verification/graphics-settings-persist.msgpack"],"ts":"2026-05-09"} {"area":"renderer/volumetrics","lesson":"The first fog-land implementation should establish the field contract and diagnostics before compositing fog. Aquarium now sends a fixed field instance structured buffer for Self, planets, and local medium ellipsoids to HLSL; modes 9 and 10 expose registered medium density and transmittance. Final mode 0 remains unchanged until the explicit low-res volume pass and compositor are built.","files":["src/Aquarium.Engine/Render/D3D11Renderer.cs","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","src/Aquarium.Engine.Contracts/GraphicsSettings.cs","src/Aquarium.Engine.Contracts/Input/InputState.cs","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Platform/Win32Window.cs","src/Aquarium.Engine/Render/DirectWriteOverlay.cs","docs/sdf-field-renderer-plan.md","docs/hlsl-renderer.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4","direct headless startup with --render-debug 10 compiled shaders and loaded persisted debug mode 10"],"ts":"2026-05-09"} {"area":"renderer/volumetrics","lesson":"Registered medium diagnostics now come from a separate half-resolution medium pass instead of being integrated inside the scene shader. The pass samples the field instance buffer, writes density/transmittance/source into a medium texture, and scene/resolve stages sample that texture for debug/control. Final composition remains unchanged until the compositor is explicit.","files":["src/Aquarium.Engine/Render/D3D11Renderer.cs","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","src/Aquarium.Engine.Contracts/GraphicsSettings.cs","docs/sdf-field-renderer-plan.md","docs/hlsl-renderer.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4","direct headless startup with --render-debug 11 compiled shaders and loaded persisted debug mode 11"],"ts":"2026-05-09"} +{"area":"renderer/volumetrics","lesson":"Medium composition is now explicit and gated: the half-resolution medium pass writes diagnostic and transport textures, and resolve can composite surface * transmittance + in-scattering through a persisted Medium Composite setting. The default remains zero so final presentation does not change until the medium is intentionally enabled and tuned.","files":["src/Aquarium.Engine.Contracts/GraphicsSettings.cs","src/Aquarium.Engine.Live/State/AquariumGraphicsSettingsState.cs","src/Aquarium.Engine.Live/State/AquariumCultStateStore.cs","src/Aquarium.Engine/Render/D3D11Renderer.cs","src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","docs/cult-runtime-surface.md","docs/hlsl-renderer.md","docs/sdf-field-renderer-plan.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx",".\\scripts\\dev-reload.ps1 -Headless -RetainSlots 4","direct headless startup in final mode with default Medium Composite 0"],"ts":"2026-05-09"} diff --git a/state/map.yaml b/state/map.yaml index 8ff5805..8e4e1d2 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -62,8 +62,8 @@ renderer_state: - Stable planet-local displaced SDF domains. - DirectWrite overlay text after scene rendering. - Direct2D/DirectWrite debug UI panel with code-first controls bound to renderer state. - - Global GraphicsSettings document feeding render debug, exposure, bloom intensity, and bloom veil. - - First field instance structured buffer feeding a half-resolution registered medium diagnostic pass. + - Global GraphicsSettings document feeding render debug, exposure, bloom intensity, bloom veil, and medium composite intensity. + - First field instance structured buffer feeding a half-resolution registered medium diagnostic/transport pass. - Splash screen with bundled app icon and GameCult typefaces. next: - Promote field instances from fixed renderer table to a CPU-owned registry with per-field debug controls. diff --git a/state/memory.json b/state/memory.json index ca3f57a..008f86c 100644 --- a/state/memory.json +++ b/state/memory.json @@ -44,7 +44,7 @@ "For research decks with recordings, pull subtitles/transcripts before distilling. The Dreams transcript changed the lesson: preserve the evaluator/field that serves the image, not the elegant SDF/brick/froxel experiment that drifted away from the art direction.", "Sea of Thieves clouds are the stylized counterexample: authored opaque cloud geometry filtered through low-res blurred color/depth compositing can beat dense raymarching when clouds are symbolic world objects or gameplay signage. Consider tool-time SDF baking for per-vertex cloud lighting, not runtime volume traversal by reflex.", "The SDF field renderer plan is docs/sdf-field-renderer-plan.md: solids and clouds should share one field grammar, with distance, density, material, medium, bounds, and debug views.", - "Fog-land started with a renderer/HLSL field instance ABI, not final-frame haze. Aquarium now packs Self, planets, and local medium ellipsoids into a structured buffer; a half-resolution medium pass emits density, transmittance, and source diagnostics in modes 9-11 while final composition remains unchanged until the explicit compositor exists.", + "Fog-land started with a renderer/HLSL field instance ABI, not final-frame haze. Aquarium now packs Self, planets, and local medium ellipsoids into a structured buffer; a half-resolution medium pass emits density, transmittance, source diagnostics, and transport. Final composition uses surface * transmittance + in-scattering behind a persisted Medium Composite control that defaults to zero.", "SDF cloud distance should shape and accelerate the medium, not create a positive-distance absorbing shell. Prototype ellipsoid edges occluded farther clouds until density was changed to eroded interior occupancy with lower extinction.", "A bounded cloud prototype should march analytic ray/volume intervals, not global SDF shells. The first cloud artifact persisted until rays jumped between true ellipsoid entry/exit intervals; otherwise near fields can consume the sample budget and masquerade as occluders.", "SDF clouds/solids need waterfall architecture, not agile accretion. Define and build the field contract, broad phase, explicit local volume pass, composition contract, and acceleration gates before adding more cloud features.", @@ -85,7 +85,7 @@ "state_and_reload": [ "CultCache is the client memory organ. Runtime state, camera, renderer knobs, body state, UI state, and future Epiphany connection state should be typed Cult documents.", "The current live document is epiphany.aquarium.live_state, stored through CultLib MessagePack backing. Direct runs can use --cache or AQUARIUM_CULTCACHE_PATH.", - "Global graphics presentation settings live in epiphany.aquarium.graphics_settings. The debug UI edits the renderer copy; the host syncs changes to the live runtime; the runtime flushes dirty settings through CultCache so render debug, exposure, bloom intensity, and bloom veil survive restart and live reload.", + "Global graphics presentation settings live in epiphany.aquarium.graphics_settings. The debug UI edits the renderer copy; the host syncs changes to the live runtime; the runtime flushes dirty settings through CultCache so render debug, exposure, bloom intensity, bloom veil, and medium composite intensity survive restart and live reload.", "A truncated or unreadable single-file CultCache backing store is not a schema migration failure. Aquarium should quarantine the corrupt snapshot and boot fresh typed state, while CultLib must write snapshots atomically so process death cannot leave a zero-byte cache.", "dev-reload builds disposable apphost slots so a running window does not lock normal build output. dev-watch hot reloads shaders and live runtime DLLs while preserving the last good process. Host/core/content changes, scripts, and src/Aquarium.Engine/Assets must rebuild and restart the apphost on demand. dev-watch must also relaunch if its recorded script-owned process is no longer running. For visible windows, dev-watch -ReopenWhenClosed reopens the last good visible slot without rebuilding.", "Live runtime reload is not successful just because dev-watch wrote live-current.txt. The watcher must see the host acknowledge the exact live DLL path in stdout, or treat the update as failed and keep the previous runtime/process alive.", diff --git a/state/scratch.md b/state/scratch.md index 1d5d0ee..d17d579 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -139,6 +139,10 @@ prototype integrated along the camera ray before surface composition. shader into a half-resolution medium pass. The texture stores density, transmittance, and source diagnostics. Mode 11 shows medium source. Final scene color remains unchanged; composition is still the next machine part. +- Fog composition gate: the medium pass now writes separate diagnostic and + transport targets. Resolve can composite `surface * transmittance + + in-scattering`, controlled by persisted `MediumCompositeIntensity`, which + defaults to zero so final remains unchanged until deliberately enabled/tuned. - Debug UI control grammar now includes named option rows. Render Debug uses an option/dropdown selector instead of a numeric slider so the expanding debug mode list remains legible.