Add isolated agent preview renderer

This commit is contained in:
Meta Vens 2026-05-13 21:00:46 +01:00
commit b9a2b9e22f
14 changed files with 493 additions and 4 deletions

View file

@ -31,6 +31,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aquarium.Engine.Tests", "tests\Aquarium.Engine.Tests\Aquarium.Engine.Tests.csproj", "{37363FC6-5AA3-49B4-A3B1-E4AB2CC986EB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aquarium.Epiphany.AgentPreview", "src\Aquarium.Epiphany.AgentPreview\Aquarium.Epiphany.AgentPreview.csproj", "{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -185,6 +187,18 @@ Global
{37363FC6-5AA3-49B4-A3B1-E4AB2CC986EB}.Release|x64.Build.0 = Release|Any CPU
{37363FC6-5AA3-49B4-A3B1-E4AB2CC986EB}.Release|x86.ActiveCfg = Release|Any CPU
{37363FC6-5AA3-49B4-A3B1-E4AB2CC986EB}.Release|x86.Build.0 = Release|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Debug|x64.ActiveCfg = Debug|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Debug|x64.Build.0 = Debug|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Debug|x86.ActiveCfg = Debug|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Debug|x86.Build.0 = Debug|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Release|Any CPU.Build.0 = Release|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Release|x64.ActiveCfg = Release|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Release|x64.Build.0 = Release|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Release|x86.ActiveCfg = Release|Any CPU
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -195,5 +209,6 @@ Global
{33654E0D-B31A-4062-B6AC-C1CE4C1A1F65} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{7564E6C2-FF01-4B5B-8C2B-F9CD796858BA} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{37363FC6-5AA3-49B4-A3B1-E4AB2CC986EB} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
{F12A367A-8D8E-490D-B60E-3FDBEA3E07E2} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
EndGlobal

View file

@ -0,0 +1,48 @@
param(
[string]$Agent = "Soul",
[string]$OutputDirectory,
[int]$Width = 768,
[int]$Height = 768,
[int]$FramesPerView = 18,
[float]$TimeSeconds = 18.0
)
$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
$projectPath = Join-Path $repoRoot "src\Aquarium.Epiphany.AgentPreview\Aquarium.Epiphany.AgentPreview.csproj"
$previewRoot = Join-Path $repoRoot "artifacts\agent-preview"
$slotPath = Join-Path $previewRoot ("slot-" + (Get-Date -Format "yyyyMMdd-HHmmss") + "-" + [guid]::NewGuid().ToString("N").Substring(0, 8))
if ([string]::IsNullOrWhiteSpace($OutputDirectory)) {
$OutputDirectory = Join-Path $repoRoot ("artifacts\agent-previews\$Agent\" + (Get-Date -Format "yyyyMMdd-HHmmss"))
}
New-Item -ItemType Directory -Force -Path $slotPath | Out-Null
New-Item -ItemType Directory -Force -Path $OutputDirectory | Out-Null
Write-Host "Building isolated preview renderer:"
Write-Host " $slotPath"
dotnet build $projectPath -c Debug -o $slotPath /p:UseAppHost=true
if ($LASTEXITCODE -ne 0) {
throw "preview build failed with exit code $LASTEXITCODE."
}
$exePath = Join-Path $slotPath "Aquarium.Epiphany.AgentPreview.exe"
if (-not (Test-Path $exePath)) {
throw "Expected preview executable was not produced: $exePath"
}
& $exePath `
--agent $Agent `
--output $OutputDirectory `
--width $Width `
--height $Height `
--frames $FramesPerView `
--time $TimeSeconds
if ($LASTEXITCODE -ne 0) {
throw "preview render failed with exit code $LASTEXITCODE."
}
Write-Host "Preview frames written:"
Write-Host " $OutputDirectory"

View file

@ -230,9 +230,18 @@ public sealed class AquariumSceneState
{
public static AquariumSceneState Empty { get; } = new();
public AquariumSceneVisualOptions VisualOptions { get; init; } = AquariumSceneVisualOptions.Default;
public IReadOnlyList<AquariumHeightFieldBrush> HeightFieldBrushes { get; init; } = [];
public IReadOnlyList<AquariumSdfObject> SdfObjects { get; init; } = [];
public IReadOnlyList<AquariumSdfLight> SdfLights { get; init; } = [];
}
public readonly record struct AquariumSceneVisualOptions(
float BackgroundIntensity,
float SurfaceVisibility)
{
public static AquariumSceneVisualOptions Default { get; } = new(1.0f, 1.0f);
}

View file

@ -140,6 +140,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
private float previousViewRadius = 0.001f;
private float previousTimeSeconds;
private D3D12HeightFieldBrushConstants heightFieldBrushConstants;
private Vector4 sceneVisualControls = Vector4.One;
private GraphicsSettings settings = GraphicsSettings.Default;
private double accumulatedFrameCpuMilliseconds;
private double accumulatedRecordCpuMilliseconds;
@ -484,7 +485,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
settings.SceneExposure,
settings.BloomIntensity,
settings.BloomVeilIntensity,
new Vector4(frame.CursorWorld.X, frame.CursorWorld.Y, previousCursorWorld.X, previousCursorWorld.Y)));
new Vector4(frame.CursorWorld.X, frame.CursorWorld.Y, previousCursorWorld.X, previousCursorWorld.Y),
sceneVisualControls));
frameResources.FrameConstantsDescriptor = frameResources.TransientShaderDescriptors.Allocate();
device.CreateConstantBufferView(
new ConstantBufferViewDescription(frameConstants.GpuVirtualAddress, frameConstants.SizeInBytes),
@ -572,6 +574,75 @@ public sealed class D3D12Renderer : IAquariumRenderer
frameIndex = (int)swapChain.CurrentBackBufferIndex;
}
public unsafe void SaveFramePng(string path)
{
if (!hasPresentedReadyFrame)
{
throw new InvalidOperationException("No completed frame is available to save.");
}
WaitForGpu();
var sourceIndex = (frameIndex + BackBufferCount - 1) % BackBufferCount;
var source = frames[sourceIndex].BackBuffer;
var rowBytes = checked(width * 4);
var rowPitch = AlignTo(rowBytes, D3D12.TextureDataPitchAlignment);
var bufferBytes = checked((long)rowPitch * height);
using var readback = device.CreateCommittedResource(
HeapType.Readback,
ResourceDescription.Buffer((ulong)bufferBytes),
ResourceStates.CopyDest,
null);
readback.Name = "Aquarium D3D12 Frame PNG Readback";
using var captureAllocator = device.CreateCommandAllocator(CommandListType.Direct);
using var captureList = device.CreateCommandList<ID3D12GraphicsCommandList>(0, CommandListType.Direct, captureAllocator, null);
source.Transition(captureList, ResourceStates.CopySource);
var footprint = new PlacedSubresourceFootPrint
{
Offset = 0,
Footprint = new SubresourceFootPrint(
Format.B8G8R8A8_UNorm,
(uint)width,
(uint)height,
1,
(uint)rowPitch),
};
var destination = new TextureCopyLocation(readback, footprint);
var textureSource = new TextureCopyLocation(source.Resource, 0);
captureList.CopyTextureRegion(destination, 0, 0, 0, textureSource, null);
source.Transition(captureList, ResourceStates.Present);
captureList.Close();
commandQueue.ExecuteCommandList(captureList);
WaitForGpu();
var rgba = new byte[checked(rowBytes * height)];
var mapped = readback.Map<byte>(0);
try
{
for (var y = 0; y < height; y++)
{
var sourceRow = mapped + ((long)y * rowPitch);
var destinationRow = y * rowBytes;
for (var x = 0; x < width; x++)
{
var sourcePixel = sourceRow + (x * 4);
var destinationPixel = destinationRow + (x * 4);
rgba[destinationPixel] = sourcePixel[2];
rgba[destinationPixel + 1] = sourcePixel[1];
rgba[destinationPixel + 2] = sourcePixel[0];
rgba[destinationPixel + 3] = sourcePixel[3];
}
}
}
finally
{
readback.Unmap(0, null);
}
PngImageWriter.WriteRgba(path, width, height, rgba);
}
private static Vector2 TemporalJitterPixels(int index)
{
const float scale = 0.42f;
@ -1315,6 +1386,11 @@ public sealed class D3D12Renderer : IAquariumRenderer
Array.Clear(sdfObjects);
Array.Clear(sdfLights);
heightFieldBrushConstants = D3D12HeightFieldBrushConstants.FromBrushes(scene.HeightFieldBrushes);
sceneVisualControls = new Vector4(
Math.Clamp(scene.VisualOptions.BackgroundIntensity, 0.0f, 4.0f),
Math.Clamp(scene.VisualOptions.SurfaceVisibility, 0.0f, 1.0f),
0.0f,
0.0f);
var objectCount = Math.Min(scene.SdfObjects.Count, MaxSdfObjectCount);
for (var index = 0; index < objectCount; index++)
@ -1594,6 +1670,11 @@ public sealed class D3D12Renderer : IAquariumRenderer
fenceEvent.WaitOne();
}
private static int AlignTo(int value, int alignment)
{
return (value + alignment - 1) & ~(alignment - 1);
}
private static void ReportStartupProgress(Action<string>? startupProgress, string message)
{
startupProgress?.Invoke(message);
@ -1951,7 +2032,8 @@ public sealed class D3D12Renderer : IAquariumRenderer
float Exposure,
float BloomIntensity,
float BloomVeilIntensity,
Vector4 CursorWorlds);
Vector4 CursorWorlds,
Vector4 SceneVisualControls);
private sealed record D3D12ShaderPaths(
string HeightField,

View file

@ -25,4 +25,6 @@ public interface IAquariumRenderer : IDisposable
void ApplyGraphicsSettings(GraphicsSettings settings);
void Render(AquariumFrame frame, int width, int height);
void SaveFramePng(string path);
}

View file

@ -0,0 +1,96 @@
using System.Buffers.Binary;
using System.IO.Compression;
using System.Text;
namespace Aquarium.Engine.Render;
internal static class PngImageWriter
{
private static readonly byte[] Signature = [137, 80, 78, 71, 13, 10, 26, 10];
private static readonly uint[] CrcTable = BuildCrcTable();
public static void WriteRgba(string path, int width, int height, ReadOnlySpan<byte> rgba)
{
if (rgba.Length != width * height * 4)
{
throw new ArgumentException("RGBA buffer size does not match image dimensions.", nameof(rgba));
}
var directory = Path.GetDirectoryName(Path.GetFullPath(path));
if (!string.IsNullOrWhiteSpace(directory))
{
Directory.CreateDirectory(directory);
}
using var stream = File.Create(path);
stream.Write(Signature);
Span<byte> ihdr = stackalloc byte[13];
BinaryPrimitives.WriteInt32BigEndian(ihdr, width);
BinaryPrimitives.WriteInt32BigEndian(ihdr[4..], height);
ihdr[8] = 8;
ihdr[9] = 6;
ihdr[10] = 0;
ihdr[11] = 0;
ihdr[12] = 0;
WriteChunk(stream, "IHDR", ihdr);
using var compressed = new MemoryStream();
using (var zlib = new ZLibStream(compressed, CompressionLevel.Fastest, leaveOpen: true))
{
var rowBytes = width * 4;
for (var y = 0; y < height; y++)
{
zlib.WriteByte(0);
zlib.Write(rgba.Slice(y * rowBytes, rowBytes));
}
}
WriteChunk(stream, "IDAT", compressed.ToArray());
WriteChunk(stream, "IEND", []);
}
private static void WriteChunk(Stream stream, string type, ReadOnlySpan<byte> data)
{
Span<byte> length = stackalloc byte[4];
BinaryPrimitives.WriteInt32BigEndian(length, data.Length);
stream.Write(length);
Span<byte> typeBytes = stackalloc byte[4];
Encoding.ASCII.GetBytes(type, typeBytes);
stream.Write(typeBytes);
stream.Write(data);
var crc = UpdateCrc(0xffffffff, typeBytes);
crc = UpdateCrc(crc, data) ^ 0xffffffff;
Span<byte> crcBytes = stackalloc byte[4];
BinaryPrimitives.WriteUInt32BigEndian(crcBytes, crc);
stream.Write(crcBytes);
}
private static uint UpdateCrc(uint crc, ReadOnlySpan<byte> data)
{
foreach (var value in data)
{
crc = CrcTable[(crc ^ value) & 0xff] ^ (crc >> 8);
}
return crc;
}
private static uint[] BuildCrcTable()
{
var table = new uint[256];
for (uint index = 0; index < table.Length; index++)
{
var c = index;
for (var bit = 0; bit < 8; bit++)
{
c = (c & 1) != 0 ? 0xedb88320 ^ (c >> 1) : c >> 1;
}
table[index] = c;
}
return table;
}
}

View file

@ -18,6 +18,7 @@ cbuffer AquariumFrame : register(b0)
float bloomIntensity;
float bloomVeilIntensity;
float4 cursorWorlds;
float4 sceneVisualControls;
};
cbuffer HeightFieldBrushes : register(b1)

View file

@ -18,6 +18,7 @@ cbuffer AquariumFrame : register(b0)
float bloomIntensity;
float bloomVeilIntensity;
float4 cursorWorlds;
float4 sceneVisualControls;
};
Texture2D<float4> sourceTexture : register(t0);

View file

@ -18,6 +18,7 @@ cbuffer AquariumFrame : register(b0)
float bloomIntensity;
float bloomVeilIntensity;
float4 cursorWorlds;
float4 sceneVisualControls;
};
Texture2D<float4> heightFieldTexture : register(t0);
@ -209,7 +210,7 @@ float3 backgroundRadiance(float3 direction)
RayMarchResult traverseRay(float3 origin, float3 direction)
{
RayMarchResult result;
result.color = backgroundRadiance(direction);
result.color = backgroundRadiance(direction) * sceneVisualControls.x;
result.travel = farDistance + 1.0;
result.fieldId = 0.0;
result.normal = 0.0;
@ -218,7 +219,7 @@ RayMarchResult traverseRay(float3 origin, float3 direction)
float3 surfacePosition;
float surfaceTravel;
bool surfaceHit = traceHeightFieldSurfaceDirect(origin, direction, 0.0, farDistance, surfacePosition, surfaceTravel);
bool surfaceHit = sceneVisualControls.y > 0.5 && traceHeightFieldSurfaceDirect(origin, direction, 0.0, farDistance, surfacePosition, surfaceTravel);
if (surfaceHit)
{
float3 surfaceNormal;

View file

@ -18,6 +18,7 @@ cbuffer AquariumFrame : register(b0)
float bloomIntensity;
float bloomVeilIntensity;
float4 cursorWorlds;
float4 sceneVisualControls;
};
TextureCube<float4> studioPmremTexture : register(t22);

View file

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Aquarium.Engine\Aquarium.Engine.csproj" />
<ProjectReference Include="..\Aquarium.Epiphany\Aquarium.Epiphany.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,214 @@
using System.Numerics;
using System.Text.Json;
using Aquarium.Engine;
using Aquarium.Engine.Input;
using Aquarium.Engine.Platform;
using Aquarium.Engine.Render;
using Aquarium.Epiphany;
var options = PreviewOptions.Parse(args);
var subject = PreviewSubject.Resolve(options.Subject);
var outputDirectory = Path.GetFullPath(options.OutputDirectory);
Directory.CreateDirectory(outputDirectory);
var shaderPath = Path.Combine(AppContext.BaseDirectory, "Render", "Shaders", "D3D12HeightField.hlsl");
if (!File.Exists(shaderPath))
{
throw new FileNotFoundException("Preview render requires copied Aquarium shader assets.", shaderPath);
}
var input = new InputState();
using var window = Win32Window.Create(
$"Aquarium {subject.DisplayName} Preview",
options.Width,
options.Height,
input,
visible: false);
using var renderer = new D3D12Renderer(
window.Handle,
options.Width,
options.Height,
shaderPath,
EpiphanyRenderPlan.Create(),
new GraphicsSettings(0, options.Exposure, options.BloomIntensity, options.BloomVeilIntensity));
renderer.DebugUiVisible = false;
var rendered = new List<RenderedView>();
foreach (var view in PreviewView.CreateSet(subject.Radius))
{
RenderSettledView(renderer, window, subject, view, options);
var path = Path.Combine(outputDirectory, $"{subject.Key}-{view.Key}.png");
renderer.SaveFramePng(path);
rendered.Add(new RenderedView(view.Key, path));
Console.WriteLine(path);
}
var manifestPath = Path.Combine(outputDirectory, $"{subject.Key}-manifest.json");
File.WriteAllText(
manifestPath,
JsonSerializer.Serialize(
new PreviewManifest(subject.Key, subject.DisplayName, options.Width, options.Height, options.FramesPerView, rendered),
new JsonSerializerOptions { WriteIndented = true }));
Console.WriteLine(manifestPath);
static void RenderSettledView(
D3D12Renderer renderer,
Win32Window window,
PreviewSubject subject,
PreviewView view,
PreviewOptions options)
{
for (var frameIndex = 0; frameIndex < options.FramesPerView || !renderer.HasPresentedReadyFrame; frameIndex++)
{
if (frameIndex > options.FramesPerView + options.PipelineWarmupFrameLimit)
{
throw new TimeoutException("Renderer did not produce a ready preview frame.");
}
window.PumpMessages();
var frame = CreateFrame(subject, view, options.TimeSeconds + frameIndex / 60.0f);
renderer.Render(frame, options.Width, options.Height);
if (!renderer.HasPresentedReadyFrame)
{
Thread.Sleep(16);
}
}
}
static AquariumFrame CreateFrame(PreviewSubject subject, PreviewView view, float timeSeconds)
{
var objects = Enumerable.Range(0, EpiphanyRenderPlan.SdfVisualCount)
.Select(index => InactiveObject(index))
.ToArray();
var selected = new AquariumSdfObject(
new Vector4(Vector3.Zero, subject.Radius),
new Vector4(Vector3.Zero, 0.0f),
subject.State);
objects[subject.SdfIndex] = selected;
var lights = new[]
{
new AquariumSdfLight(
new Vector4(1.8f, -2.6f, 2.4f, 1.0f),
new Vector4(5.8f, 5.1f, 4.2f, 0.0f)),
new AquariumSdfLight(
new Vector4(-2.4f, 1.2f, 1.4f, 1.0f),
new Vector4(1.1f, 1.5f, 2.1f, 0.0f)),
};
var scene = new AquariumSceneState
{
VisualOptions = new AquariumSceneVisualOptions(0.0f, 0.0f),
SdfObjects = objects,
SdfLights = lights,
};
return new AquariumFrame(new ViewFrame(Vector2.Zero, 20.0f), view.CameraPosition, timeSeconds, Vector2.Zero, scene);
}
static AquariumSdfObject InactiveObject(int index)
{
var center = new Vector3(10000.0f + index * 13.0f, 10000.0f, 10000.0f);
return new AquariumSdfObject(new Vector4(center, 0.001f), new Vector4(center, 0.0f), Vector4.Zero);
}
sealed record PreviewOptions(
string Subject,
string OutputDirectory,
int Width,
int Height,
int FramesPerView,
int PipelineWarmupFrameLimit,
float TimeSeconds,
float Exposure,
float BloomIntensity,
float BloomVeilIntensity)
{
public static PreviewOptions Parse(string[] args)
{
var subject = ValueAfter(args, "--agent") ?? ValueAfter(args, "--subject") ?? FirstPositional(args) ?? "Soul";
var output = ValueAfter(args, "--output") ?? Path.Combine("artifacts", "agent-previews", subject, DateTime.Now.ToString("yyyyMMdd-HHmmss"));
return new PreviewOptions(
subject,
output,
IntValueAfter(args, "--width", 768),
IntValueAfter(args, "--height", 768),
IntValueAfter(args, "--frames", 18),
IntValueAfter(args, "--warmup-limit", 900),
FloatValueAfter(args, "--time", 18.0f),
FloatValueAfter(args, "--exposure", 0.24f),
FloatValueAfter(args, "--bloom", 0.12f),
FloatValueAfter(args, "--veil", 0.032f));
}
private static string? FirstPositional(IReadOnlyList<string> args)
{
return args.FirstOrDefault(arg => !arg.StartsWith("--", StringComparison.Ordinal));
}
private static string? ValueAfter(IReadOnlyList<string> args, string name)
{
for (var index = 0; index < args.Count - 1; index++)
{
if (string.Equals(args[index], name, StringComparison.OrdinalIgnoreCase))
{
return args[index + 1];
}
}
return null;
}
private static int IntValueAfter(IReadOnlyList<string> args, string name, int fallback)
{
return int.TryParse(ValueAfter(args, name), out var value) ? Math.Max(1, value) : fallback;
}
private static float FloatValueAfter(IReadOnlyList<string> args, string name, float fallback)
{
return float.TryParse(ValueAfter(args, name), out var value) ? value : fallback;
}
}
sealed record PreviewSubject(string Key, string DisplayName, int SdfIndex, float Radius, Vector4 State)
{
private static readonly PreviewSubject[] All =
[
new("self", "Self", EpiphanyRenderPlan.SelfVisualIndex, 1.12f, new Vector4(1.0f, 1.0f, 0.0f, 0.0f)),
new("face", "Face", EpiphanyRenderPlan.RoleAgentBaseIndex, 0.58f, new Vector4(0.8f, 0.45f, 0.35f, 0.0f)),
new("imagination", "Imagination", EpiphanyRenderPlan.RoleAgentBaseIndex + 1, 0.70f, new Vector4(0.95f, 0.62f, 0.28f, 0.0f)),
new("eyes", "Eyes", EpiphanyRenderPlan.RoleAgentBaseIndex + 2, 0.58f, new Vector4(0.72f, 0.58f, 0.24f, 0.0f)),
new("body", "Body", EpiphanyRenderPlan.RoleAgentBaseIndex + 3, 0.64f, new Vector4(0.62f, 0.54f, 0.42f, 0.0f)),
new("hands", "Hands", EpiphanyRenderPlan.RoleAgentBaseIndex + 4, 0.62f, new Vector4(0.88f, 0.64f, 0.36f, 0.0f)),
new("soul", "Soul", EpiphanyRenderPlan.RoleAgentBaseIndex + 5, 0.92f, new Vector4(0.9f, 0.5f, 0.42f, 0.0f)),
new("life", "Life", EpiphanyRenderPlan.RoleAgentBaseIndex + 6, 0.66f, new Vector4(0.66f, 0.68f, 0.22f, 0.0f)),
new("cursor", "Cursor", EpiphanyRenderPlan.CursorVisualIndex, 0.88f, new Vector4(1.0f, 0.5f, 0.0f, 0.0f)),
];
public static PreviewSubject Resolve(string value)
{
return All.FirstOrDefault(subject =>
string.Equals(subject.Key, value, StringComparison.OrdinalIgnoreCase)
|| string.Equals(subject.DisplayName, value, StringComparison.OrdinalIgnoreCase))
?? throw new ArgumentException($"Unknown preview subject '{value}'. Known values: {string.Join(", ", All.Select(subject => subject.Key))}.");
}
}
sealed record PreviewView(string Key, Vector3 CameraPosition)
{
public static IReadOnlyList<PreviewView> CreateSet(float radius)
{
var distance = MathF.Max(radius * 2.35f, 1.75f);
return
[
new("front", new Vector3(0.0f, -distance, distance * 0.36f)),
new("front-high", new Vector3(0.0f, -distance * 0.82f, distance * 0.86f)),
new("right", new Vector3(distance, 0.0f, distance * 0.36f)),
new("left", new Vector3(-distance, 0.0f, distance * 0.36f)),
new("three-quarter", new Vector3(distance * 0.72f, -distance * 0.72f, distance * 0.52f)),
new("top-oblique", new Vector3(distance * 0.22f, -distance * 0.32f, distance * 1.16f)),
];
}
}
sealed record RenderedView(string View, string Path);
sealed record PreviewManifest(string Subject, string DisplayName, int Width, int Height, int FramesPerView, IReadOnlyList<RenderedView> Views);

View file

@ -93,3 +93,4 @@
{"timestamp":"2026-05-13T19:45:00+01:00","topic":"soul-facet-normal-authority","lesson":"Soul must shade like cut crystal, not thermoformed plastic. If relief participates in ray distance, do not let the finite-difference relief normal dominate broad facets; shade from the governing facet normal and blend the traced normal only near cuts. Transmission should support dark glass depth and inner oath light, not wash every face into milky white.","files":["src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl","state/evidence.jsonl"],"source":"user screenshot showed Soul still reading as vacuum-formed packaging after domain reset"}
{"timestamp":"2026-05-13T20:00:00+01:00","topic":"soul-plane-intersection-crystal","lesson":"Soul seams are not unreasonable as geometry: build the crystal from explicit signed half-space planes, derive edges from adjacent active plane intersections, then extrude face interiors and cut narrow V-grooves on selected edge chains. Auxiliary gates may choose which edges glow, but the edge itself must come from the plane intersection graph. Broad shading uses the active plane normal; cut normals are secondary.","files":["src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl","state/evidence.jsonl"],"source":"user asked for organic plane intersections with extruded faces and glowing groove centers"}
{"timestamp":"2026-05-13T20:18:00+01:00","topic":"soul-organic-plane-family","lesson":"Soul's plane-intersection crystal should not default back to symmetric octahedral sign pairs. Keep the half-space/active-edge architecture, but use an irregular family of constraint planes with varied offsets plus a few smaller trimming planes so the crystal reads as a living verdict object instead of an octahedron with minor perturbations.","files":["src/Aquarium.Epiphany/Shaders/D3D12SoulAgent.hlsl","state/evidence.jsonl"],"source":"user noted the plane-intersection model was right but the cutting planes still looked too octahedral"}
{"timestamp":"2026-05-13T20:56:00+01:00","topic":"isolated-agent-preview-loop","lesson":"Agent SDF iteration needs a renderer-owned visual feedback loop. Use the real D3D12 renderer to render one selected Epiphany SDF subject across several isolated camera views with background and surface disabled, then save final-frame PNGs for reference-art comparison; do not duplicate shader logic in a separate toy renderer.","files":["src/Aquarium.Epiphany.AgentPreview/Program.cs","scripts/render-agent-preview.ps1","src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine.Contracts/Render/AquariumRenderPlan.cs","state/map.yaml","state/evidence.jsonl"],"source":"user requested self-directed visual iteration instead of screenshot babysitting"}

View file

@ -34,6 +34,7 @@ current_model:
implementation: src/Aquarium.Epiphany
render_plan: src/Aquarium.Epiphany/EpiphanyRenderPlan.cs
scene_builder: src/Aquarium.Epiphany/EpiphanySceneBuilder.cs
agent_preview: src/Aquarium.Epiphany.AgentPreview
shaders: src/Aquarium.Epiphany/Shaders
state_store: src/Aquarium.Epiphany/State/AquariumCultStateStore.cs
state_document: epiphany.aquarium.live_state
@ -84,6 +85,7 @@ renderer_state:
- Aquarium exposes an optional synth/audio hosting boundary through AquariumSynthDocument; Aquarium consumes AquariumSynth.Dsl as a pinned repo-local NuGet package so synth-agent construction cannot break Aquarium builds until the package is intentionally updated.
- Global GraphicsSettings document feeding render debug, exposure, bloom intensity, and bloom veil.
- Temporal resolve uses scene color, metadata, and control history only; dormant event history lanes are cut until a real producer and consumer contract exists.
- Isolated Epiphany agent preview renders run through the real D3D12 renderer from src/Aquarium.Epiphany.AgentPreview; the engine exposes only generic scene visual controls and final-frame PNG capture.
- Bundled blue-noise texture assets are retained for future dithering/noise work even though the removed medium path no longer samples them.
- D3D11 scene renderer, runtime volumetrics, cloud/fog research, medium/froxel render targets, and the SDF-field renderer plan are shelved and removed from live repo state.
next:
@ -101,6 +103,7 @@ next_actions:
- Verify publish output after every packaging-affecting change.
- Update AquariumSynth.Dsl only by packing a new version into packages and changing the pinned PackageReference version deliberately.
- Grow renderer debug controls through the Direct2D/DirectWrite overlay path.
- Use scripts/render-agent-preview.ps1 for multi-view isolated SDF review before asking the user to judge another agent body iteration.
- Follow research/rendering/hdr-pbr-presentation.md before changing HDR exposure, bloom, tonemapping, or display transforms.
- Follow docs/tsr-inspired-taa-spec.md when changing current temporal diagnostics.
- Promote future runtime knobs into typed CultCache documents before they become process folklore.