Compile fractal height claims to brushes

This commit is contained in:
Meta Vens 2026-05-18 02:37:22 +01:00
commit 83f3d4f5b0
4 changed files with 106 additions and 2 deletions

View file

@ -187,7 +187,7 @@ Tasks:
- [x] Implement compact-support ellipse evaluator.
- [x] Add CPU/HLSL parity fixture.
- [x] Add brush bounds and support rejection tests.
- [ ] Add a small adapter that lowers one claim into the current height brush path.
- [x] Add a small adapter that lowers one claim into the current height brush path.
- [ ] Add debug overlay for envelope bounds and weight.
Tests:
@ -217,7 +217,7 @@ Tasks:
- [x] Add in-memory ownership tree builder.
- [ ] Implement operations: `Union`, `Subtract`, `Common`, `Repeat`, `Refine`, `Capture`, `Bind`.
- [ ] Implement operation bounds.
- [ ] Add flattening compiler to shaped 2D brush packets.
- [x] Add flattening compiler to shaped 2D brush packets.
- [ ] Add debug dump for authored tree and flattened packets.
Tests:

View file

@ -0,0 +1,45 @@
using Aquarium.Engine.Render;
namespace Aquarium.Engine.Fractal.Brushes;
public static class FractalHeightBrushCompiler
{
public static AquariumHeightFieldBrush Compile(AquariumBrushClaim claim)
{
if (claim.PayloadKind != AquariumFractalPayloadKind.Height)
{
throw new ArgumentException($"Claim {claim.Key} carries {claim.PayloadKind}; only height claims can compile to height-field brushes.", nameof(claim));
}
if (claim.Radii.X <= 0.0f || claim.Radii.Y <= 0.0f)
{
throw new ArgumentOutOfRangeException(nameof(claim), claim.Radii, "Height claim radii must be positive.");
}
return new AquariumHeightFieldBrush(
claim.Center,
claim.Radii.X,
claim.ShapePower,
claim.Amplitude,
WaveAmplitude: 0.0f,
WaveFrequency: 0.0f,
WaveSpeed: 0.0f,
WaveSinePower: 0.0f,
RadiusY: claim.Radii.Y,
RotationRadians: claim.RotationRadians,
EnvelopeFalloff: claim.Falloff);
}
public static AquariumHeightFieldBrush[] CompileMany(IReadOnlyList<AquariumBrushClaim> claims)
{
ArgumentNullException.ThrowIfNull(claims);
var brushes = new AquariumHeightFieldBrush[claims.Count];
for (var index = 0; index < claims.Count; index++)
{
brushes[index] = Compile(claims[index]);
}
return brushes;
}
}

View file

@ -121,3 +121,5 @@
{"timestamp":"2026-05-18T03:04:00+01:00","topic":"fractal-brush-envelope-reference","lesson":"The shaped 2D brush envelope now has a pure CPU reference before renderer integration. `FractalBrushEnvelope2D` owns compact elliptical support, anisotropic radii, rotation, truncated Gaussian-style falloff, shape power, conservative axis-aligned bounds, and a packed packet row. Future HLSL and height-field lowering should match this evaluator instead of redefining envelope semantics in shader code.","files":["src/Aquarium.Engine.Fractal/Brushes/FractalBrushEnvelope2D.cs","src/Aquarium.Engine.Fractal/Brushes/FractalBrushEnvelope2DPacket.cs","tests/Aquarium.Engine.Fractal.Tests/FractalBrushEnvelope2DTests.cs","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"second fractal implementation slice established the shaped brush envelope math and support tests"}
{"timestamp":"2026-05-18T03:31:00+01:00","topic":"height-field-shaped-envelope-lowering","lesson":"The live height-field brush contract now carries shaped-envelope fields without breaking legacy circular brush callers: Radius remains X radius and support fallback, RadiusY opts into anisotropy, RotationRadians rotates the local ellipse, EnvelopeFalloff switches the renderer from legacy power pulse to compact Gaussian-style support, and Power becomes the shaped envelope exponent in that mode. The D3D12 height-field shader and Epiphany CPU height evaluator now share the same compact-envelope formula; keep future terrain brush lowering on this path until semantic claims replace direct brush authoring.","files":["src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","src/Aquarium.Engine/Render/Shaders/D3D12HeightField.hlsl","src/Aquarium.Engine/Render/Features/D3D12HeightFieldBrushConstants.cs","src/Aquarium.Epiphany/EpiphanySceneBuilder.cs","tests/Aquarium.Engine.Fractal.Tests/FractalBrushEnvelope2DTests.cs"],"source":"third fractal implementation slice lowered shaped envelope fields into the existing height-field brush path while preserving old circular brush defaults"}
{"timestamp":"2026-05-18T03:55:00+01:00","topic":"fractal-semantic-contracts-first-slice","lesson":"The fractal system now has portable semantic rows before backend lowering: stable keys, domains, brush claims, operation nodes, summaries, contribution state, and selected-cut rows live in contracts, while the pure fractal core owns deterministic cube-tile grammar keys and a flat-union ownership tree builder. This is deliberately not a full CSG kernel yet; it is the first authority boundary that keeps authored claims visible before renderer packets flatten them.","files":["src/Aquarium.Engine.Contracts/Fractal/AquariumFractalContracts.cs","src/Aquarium.Engine.Fractal/Grammar/FractalStableKeyBuilder.cs","src/Aquarium.Engine.Fractal/Grammar/FractalOwnershipTreeBuilder.cs","tests/Aquarium.Engine.Fractal.Tests/FractalGrammarContractTests.cs"],"source":"fourth fractal implementation slice established semantic claim and ownership-tree contract rows"}
{"timestamp":"2026-05-18T02:36:48+01:00","topic":"face-realtime-voice-first-slice","lesson":"Aquarium's first Face voice slice keeps ownership narrow: the engine owns a generic queued PCM playback lane, while Epiphany owns a native Face realtime session controller and persists only loopback URI, thread id, voice, and prompt in CultCache live state. The current transport is explicitly a Codex app-server WebSocket JSON-RPC compatibility edge for text input and streamed audio output, not full microphone/WebRTC capture yet. Speech remains an ephemeral Face surface and must not mutate durable memory, evidence, project state, or code authority automatically.","files":["src/Aquarium.Engine.Contracts/Audio/AquariumAudio.cs","src/Aquarium.Engine.Contracts/AquariumRuntimeContracts.cs","src/Aquarium.Engine/Audio/AquariumSynthHost.cs","src/Aquarium.Epiphany/Voice/RealtimeFaceVoiceSession.cs","src/Aquarium.Epiphany/AquariumRuntime.cs","src/Aquarium.Epiphany/State/AquariumLiveState.cs","state/map.yaml"],"source":"user asked to start Aquarium-Engine work on Codex realtime voice for talking to Faces inside Aquarium"}
{"timestamp":"2026-05-18T04:07:00+01:00","topic":"fractal-height-claim-lowering","lesson":"Semantic height claims now lower into the live shaped height-field brush contract through `FractalHeightBrushCompiler`. This keeps the current renderer path useful without making the renderer own grammar semantics: claims remain authored meaning, height brushes remain backend output, and non-height payloads fail fast instead of sneaking through a height-only adapter.","files":["src/Aquarium.Engine.Fractal/Brushes/FractalHeightBrushCompiler.cs","tests/Aquarium.Engine.Fractal.Tests/FractalHeightBrushCompilerTests.cs","research/rendering/fractal-brush-implementation-roadmap.md"],"source":"fifth fractal implementation slice added the first semantic-claim-to-renderer-packet lowering path"}

View file

@ -0,0 +1,57 @@
using System.Numerics;
using Aquarium.Engine.Fractal;
using Aquarium.Engine.Fractal.Brushes;
namespace Aquarium.Engine.Fractal.Tests;
public sealed class FractalHeightBrushCompilerTests
{
[Fact]
public void HeightClaimCompilesToShapedHeightFieldBrush()
{
var claim = new AquariumBrushClaim(
new AquariumFractalKey("claim/ridge"),
new AquariumFractalKey("domain/tile"),
new AquariumFractalKey("node/root"),
AquariumFractalPayloadKind.Height,
new Vector2(1.0f, 2.0f),
new Vector2(5.0f, 2.5f),
RotationRadians: 0.4f,
Falloff: 3.5f,
ShapePower: 0.7f,
Amplitude: -1.2f,
Seed: 11,
Tags: "ridge");
var brush = FractalHeightBrushCompiler.Compile(claim);
Assert.Equal(claim.Center, brush.Center);
Assert.Equal(5.0f, brush.Radius);
Assert.Equal(2.5f, brush.RadiusY);
Assert.Equal(0.4f, brush.RotationRadians);
Assert.Equal(3.5f, brush.EnvelopeFalloff);
Assert.Equal(0.7f, brush.Power);
Assert.Equal(-1.2f, brush.Amplitude);
Assert.Equal(0.0f, brush.WaveAmplitude);
}
[Fact]
public void NonHeightClaimDoesNotCompileToHeightFieldBrush()
{
var claim = new AquariumBrushClaim(
new AquariumFractalKey("claim/material"),
new AquariumFractalKey("domain/tile"),
new AquariumFractalKey("node/root"),
AquariumFractalPayloadKind.Material,
Vector2.Zero,
Vector2.One,
RotationRadians: 0.0f,
Falloff: 2.0f,
ShapePower: 1.0f,
Amplitude: 1.0f,
Seed: 0,
Tags: "material");
Assert.Throws<ArgumentException>(() => FractalHeightBrushCompiler.Compile(claim));
}
}