Model Zyphos nested domains and Umbros binary
This commit is contained in:
parent
db8f767c4a
commit
61c3bd4ecc
19 changed files with 291 additions and 62 deletions
|
|
@ -13,8 +13,16 @@ Aquarium into a second lore repository.
|
|||
|
||||
- Eusocial Interbeing stores canon and design inference in Obsidian notes under
|
||||
`Eusocial Interbeing/`.
|
||||
- Aquarium.Zyphos renders a spherical planet, atmosphere, night-side glints, and
|
||||
moon through the shared Aquarium host and SDF renderer path.
|
||||
- Aquarium.Zyphos renders Zyphos, fixed-sky Umbros, atmosphere, night-side
|
||||
glints, and first-pass eclipse cadence through the shared Aquarium host and
|
||||
SDF renderer path.
|
||||
- `ZyphosUmbrosSystem` owns the current render-scale binary constants:
|
||||
Zyphos radius, Umbros radius ratio, 8-Zyphos-radii separation, sea level, and
|
||||
star phase used by the shader.
|
||||
- `Worlds/zyphos-first-fractal-terrain.aquageo` owns the first semantic world
|
||||
patch: solar, orbital, planetary, and lat/long domains wrap the tile terrain
|
||||
so later fractal grammar nodes have real nested reference frames instead of
|
||||
undocumented coordinate folklore.
|
||||
- No automatic sync exists. Changes cross the boundary by explicit notes and
|
||||
state-map updates.
|
||||
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ public readonly record struct AquariumFractalKey
|
|||
|
||||
public enum AquariumFractalDomainKind
|
||||
{
|
||||
Solar,
|
||||
Orbital,
|
||||
Planetary,
|
||||
LatLong,
|
||||
CubeSphereTile,
|
||||
Surface2D,
|
||||
Object3D,
|
||||
|
|
|
|||
|
|
@ -17,7 +17,11 @@ public static class FractalDebugDump
|
|||
ArgumentNullException.ThrowIfNull(selectedCut);
|
||||
|
||||
var builder = new StringBuilder();
|
||||
builder.AppendLine($"domain {tree.Domain.Key} kind={tree.Domain.Kind}");
|
||||
foreach (var domain in tree.Domains)
|
||||
{
|
||||
builder.AppendLine($"domain {domain.Key} kind={domain.Kind} parent={domain.ParentKey}");
|
||||
}
|
||||
|
||||
builder.AppendLine($"nodes {tree.Nodes.Count} claims {tree.Claims.Count} summaries {summaries.Count} cut {selectedCut.Count}");
|
||||
foreach (var node in tree.Nodes)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ public static class FractalDslCompiler
|
|||
var lines = source.Replace("\r\n", "\n", StringComparison.Ordinal).Split('\n');
|
||||
AquariumFractalDomain? domain = null;
|
||||
AquariumFractalKey rootKey = default;
|
||||
var domains = new List<AquariumFractalDomain>();
|
||||
var claims = new List<AquariumBrushClaim>();
|
||||
|
||||
for (var lineIndex = 0; lineIndex < lines.Length; lineIndex++)
|
||||
|
|
@ -26,17 +27,23 @@ public static class FractalDslCompiler
|
|||
var tokens = line.Split(' ', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
|
||||
switch (tokens[0])
|
||||
{
|
||||
case "domain":
|
||||
EnsureTokenCount(tokens, 4, lineIndex);
|
||||
domains.Add(ParseDomain(tokens, lineIndex));
|
||||
break;
|
||||
case "tile":
|
||||
EnsureTokenCount(tokens, 6, lineIndex);
|
||||
var tile = new CubeTileKey(ParseFace(tokens[1], lineIndex), ParseInt(tokens[2], lineIndex), ParseInt(tokens[3], lineIndex), ParseInt(tokens[4], lineIndex));
|
||||
var domainKey = FractalStableKeyBuilder.ForCubeTile(tile, tokens[5]);
|
||||
var parentKey = tokens.Length >= 7 ? new AquariumFractalKey(tokens[6]) : default;
|
||||
rootKey = FractalStableKeyBuilder.Child(domainKey, "root");
|
||||
domain = new AquariumFractalDomain(
|
||||
domainKey,
|
||||
AquariumFractalDomainKind.CubeSphereTile,
|
||||
default,
|
||||
parentKey,
|
||||
new Vector4((float)tile.Face, tile.Level, tile.X, tile.Y),
|
||||
Vector4.Zero);
|
||||
domains.Add(domain.Value);
|
||||
break;
|
||||
case "height":
|
||||
EnsureDomain(domain, lineIndex);
|
||||
|
|
@ -58,7 +65,29 @@ public static class FractalDslCompiler
|
|||
throw new FormatException("Fractal DSL must declare a `tile <face> <level> <x> <y> <path>` line before claims.");
|
||||
}
|
||||
|
||||
return FractalOwnershipTreeBuilder.BuildFlatUnion(domain.Value, rootKey, claims);
|
||||
return FractalOwnershipTreeBuilder.BuildFlatUnion(domain.Value, domains, rootKey, claims);
|
||||
}
|
||||
|
||||
private static AquariumFractalDomain ParseDomain(string[] tokens, int lineIndex)
|
||||
{
|
||||
if (!Enum.TryParse<AquariumFractalDomainKind>(tokens[1], ignoreCase: true, out var kind))
|
||||
{
|
||||
throw new FormatException($"Invalid domain kind `{tokens[1]}` at line {lineIndex + 1}.");
|
||||
}
|
||||
|
||||
var parent = tokens[3] == "-" ? default : new AquariumFractalKey(tokens[3]);
|
||||
var parameters = new float[8];
|
||||
for (var index = 4; index < tokens.Length && index < 12; index++)
|
||||
{
|
||||
parameters[index - 4] = ParseFloat(tokens[index], lineIndex);
|
||||
}
|
||||
|
||||
return new AquariumFractalDomain(
|
||||
new AquariumFractalKey(tokens[2]),
|
||||
kind,
|
||||
parent,
|
||||
new Vector4(parameters[0], parameters[1], parameters[2], parameters[3]),
|
||||
new Vector4(parameters[4], parameters[5], parameters[6], parameters[7]));
|
||||
}
|
||||
|
||||
private static AquariumBrushClaim ParseHeight(string[] tokens, AquariumFractalKey rootKey, int lineIndex, int claimIndex)
|
||||
|
|
|
|||
|
|
@ -8,14 +8,26 @@ public sealed class FractalOwnershipTree
|
|||
AquariumFractalDomain domain,
|
||||
IReadOnlyList<AquariumFractalNode> nodes,
|
||||
IReadOnlyList<AquariumBrushClaim> claims)
|
||||
: this(domain, [domain], nodes, claims)
|
||||
{
|
||||
}
|
||||
|
||||
public FractalOwnershipTree(
|
||||
AquariumFractalDomain domain,
|
||||
IReadOnlyList<AquariumFractalDomain> domains,
|
||||
IReadOnlyList<AquariumFractalNode> nodes,
|
||||
IReadOnlyList<AquariumBrushClaim> claims)
|
||||
{
|
||||
Domain = domain;
|
||||
Domains = domains;
|
||||
Nodes = nodes;
|
||||
Claims = claims;
|
||||
}
|
||||
|
||||
public AquariumFractalDomain Domain { get; }
|
||||
|
||||
public IReadOnlyList<AquariumFractalDomain> Domains { get; }
|
||||
|
||||
public IReadOnlyList<AquariumFractalNode> Nodes { get; }
|
||||
|
||||
public IReadOnlyList<AquariumBrushClaim> Claims { get; }
|
||||
|
|
|
|||
|
|
@ -9,8 +9,18 @@ public static class FractalOwnershipTreeBuilder
|
|||
AquariumFractalDomain domain,
|
||||
AquariumFractalKey rootKey,
|
||||
IReadOnlyList<AquariumBrushClaim> claims)
|
||||
{
|
||||
return BuildFlatUnion(domain, [domain], rootKey, claims);
|
||||
}
|
||||
|
||||
public static FractalOwnershipTree BuildFlatUnion(
|
||||
AquariumFractalDomain domain,
|
||||
IReadOnlyList<AquariumFractalDomain> domains,
|
||||
AquariumFractalKey rootKey,
|
||||
IReadOnlyList<AquariumBrushClaim> claims)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(claims);
|
||||
ArgumentNullException.ThrowIfNull(domains);
|
||||
|
||||
var bounds = BoundsForClaims(claims);
|
||||
var root = new AquariumFractalNode(
|
||||
|
|
@ -25,7 +35,7 @@ public static class FractalOwnershipTreeBuilder
|
|||
bounds,
|
||||
Seed: 0);
|
||||
|
||||
return new FractalOwnershipTree(domain, [root], claims);
|
||||
return new FractalOwnershipTree(domain, domains, [root], claims);
|
||||
}
|
||||
|
||||
private static Vector4 BoundsForClaims(IReadOnlyList<AquariumBrushClaim> claims)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,18 @@ float3 zyPlanetDir(float3 local, SdfObject sdfObject)
|
|||
return normalize(zyRotateZ(local, -sdfObject.state.y));
|
||||
}
|
||||
|
||||
float3 zyPrimaryStarDirectionLocal(SdfObject sdfObject)
|
||||
{
|
||||
return normalize(float3(cos(sdfObject.state.w), sin(sdfObject.state.w), 0.18));
|
||||
}
|
||||
|
||||
float zyUmbrosEclipse(float3 starDirectionLocal)
|
||||
{
|
||||
const float umbrosAngularRadius = 0.1127;
|
||||
float alignment = dot(normalize(starDirectionLocal), float3(1.0, 0.0, 0.0));
|
||||
return smoothstep(cos(umbrosAngularRadius * 1.45), cos(umbrosAngularRadius * 0.45), alignment);
|
||||
}
|
||||
|
||||
float zySphericalField(float3 dir)
|
||||
{
|
||||
float latitude = asin(saturate(abs(dir.z)) * 2.0 - 1.0);
|
||||
|
|
@ -80,17 +92,19 @@ float3 shadeSdf(float2 uv, float travel, float3 p, float3 normal, int sdfIndex,
|
|||
SdfObject sdfObject = sdfObjects[sdfIndex];
|
||||
float3 dir = zyPlanetDir(p - sdfObject.centerRadius.xyz, sdfObject);
|
||||
float3 viewDirection = normalize(cameraPosition - p);
|
||||
float3 sunDirection = normalize(float3(-0.46, -0.72, 0.52));
|
||||
float daylight = saturate(dot(normal, sunDirection) * 0.74 + 0.34);
|
||||
float night = saturate(-dot(normal, sunDirection) * 1.7 - 0.20);
|
||||
float3 starDirectionLocal = zyPrimaryStarDirectionLocal(sdfObject);
|
||||
float eclipse = zyUmbrosEclipse(starDirectionLocal);
|
||||
float daylight = saturate(dot(dir, starDirectionLocal) * 0.74 + 0.24) * (1.0 - eclipse * 0.86);
|
||||
float night = saturate(-dot(dir, starDirectionLocal) * 1.7 - 0.20 + eclipse * 0.55);
|
||||
float citySeed = sin(dir.x * 43.0 + sin(dir.y * 19.0) * 4.0 + dir.z * 31.0);
|
||||
float cityWeb = smoothstep(0.82, 0.96, citySeed * 0.5 + 0.5);
|
||||
float coast = 1.0 - smoothstep(0.020, 0.070, abs(zySphericalField(dir) - sdfObject.state.z));
|
||||
float fresnel = pow(1.0 - saturate(dot(normal, viewDirection)), 3.2);
|
||||
float3 city = float3(1.0, 0.54, 0.14) * cityWeb * coast * night * 1.25;
|
||||
float3 eclipseTint = float3(0.15, 0.19, 0.26) * eclipse * saturate(dot(dir, starDirectionLocal) * 0.5 + 0.5);
|
||||
float3 atmosphere = float3(0.07, 0.38, 0.78) * (fresnel * 1.35 + pow(fresnel, 6.0) * 2.6);
|
||||
|
||||
return shadeSdfPbr(p, normal, surface) * daylight + city + atmosphere;
|
||||
return shadeSdfPbr(p, normal, surface) * daylight + city + atmosphere + eclipseTint;
|
||||
}
|
||||
|
||||
#include "D3D12SdfProxy.hlsli"
|
||||
|
|
|
|||
|
|
@ -3,15 +3,20 @@ static const int SDF_INDEX = 1;
|
|||
#include "D3D12SdfCommon.hlsli"
|
||||
#include "D3D12SdfMath.hlsli"
|
||||
|
||||
float zyMoonRelief(float3 dir)
|
||||
float zyUmbrosRelief(float3 dir)
|
||||
{
|
||||
float ridges =
|
||||
sin(dir.x * 15.0 + dir.y * 4.0) * 0.018 +
|
||||
sin(dir.y * 21.0 - dir.z * 7.0) * 0.012 +
|
||||
sin((dir.x + dir.y + dir.z) * 34.0) * 0.006;
|
||||
float craterA = 1.0 - smoothstep(0.055, 0.115, abs(length(dir.xy - float2(0.22, -0.18)) - 0.32));
|
||||
float craterB = 1.0 - smoothstep(0.040, 0.090, abs(length(dir.yz - float2(0.30, 0.24)) - 0.22));
|
||||
return ridges - (craterA * 0.035 + craterB * 0.026);
|
||||
float basinA = 1.0 - smoothstep(0.055, 0.115, abs(length(dir.xy - float2(0.22, -0.18)) - 0.32));
|
||||
float basinB = 1.0 - smoothstep(0.040, 0.090, abs(length(dir.yz - float2(0.30, 0.24)) - 0.22));
|
||||
return ridges - (basinA * 0.035 + basinB * 0.026);
|
||||
}
|
||||
|
||||
float3 zyPrimaryStarDirection(float phase)
|
||||
{
|
||||
return normalize(float3(cos(phase), sin(phase), 0.18));
|
||||
}
|
||||
|
||||
float sdfDistance(float3 p, int sdfIndex)
|
||||
|
|
@ -20,18 +25,18 @@ float sdfDistance(float3 p, int sdfIndex)
|
|||
float radius = max(sdfObject.state.x, 0.001);
|
||||
float3 local = p - sdfObject.centerRadius.xyz;
|
||||
float3 dir = normalize(local);
|
||||
return length(local) - (radius + zyMoonRelief(dir));
|
||||
return length(local) - (radius + zyUmbrosRelief(dir));
|
||||
}
|
||||
|
||||
SdfSurface sdfSurface(float3 p, int sdfIndex)
|
||||
{
|
||||
SdfObject sdfObject = sdfObjects[sdfIndex];
|
||||
float3 dir = normalize(p - sdfObject.centerRadius.xyz);
|
||||
float relief = zyMoonRelief(dir);
|
||||
float relief = zyUmbrosRelief(dir);
|
||||
float dust = sin(dir.x * 31.0 + dir.y * 17.0 - dir.z * 11.0) * 0.5 + 0.5;
|
||||
SdfSurface surface;
|
||||
surface.baseColor = lerp(float3(0.31, 0.30, 0.28), float3(0.66, 0.62, 0.54), dust);
|
||||
surface.baseColor = lerp(surface.baseColor, float3(0.20, 0.20, 0.19), saturate(-relief * 18.0));
|
||||
surface.baseColor = lerp(float3(0.18, 0.19, 0.20), float3(0.44, 0.42, 0.38), dust);
|
||||
surface.baseColor = lerp(surface.baseColor, float3(0.10, 0.11, 0.12), saturate(-relief * 18.0));
|
||||
surface.metallic = 0.0;
|
||||
surface.roughness = 0.92;
|
||||
surface.emission = 0.0;
|
||||
|
|
@ -40,8 +45,9 @@ SdfSurface sdfSurface(float3 p, int sdfIndex)
|
|||
|
||||
float3 shadeSdf(float2 uv, float travel, float3 p, float3 normal, int sdfIndex, SdfSurface surface)
|
||||
{
|
||||
float3 sunDirection = normalize(float3(-0.46, -0.72, 0.52));
|
||||
float daylight = saturate(dot(normal, sunDirection) * 0.82 + 0.24);
|
||||
SdfObject sdfObject = sdfObjects[sdfIndex];
|
||||
float3 starDirection = zyPrimaryStarDirection(sdfObject.state.y);
|
||||
float daylight = saturate(dot(normal, starDirection) * 0.74 + 0.16);
|
||||
return shadeSdfPbr(p, normal, surface) * daylight;
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,10 @@
|
|||
# Zyphos first Aquarium fractal terrain DSL proof.
|
||||
tile PositiveZ 0 0 0 zyphos/first-fractal-terrain
|
||||
domain Solar zyphos/parent-star - 0.25 0.006 0.077 16
|
||||
domain Orbital zyphos/zyphos-umbros-orbit zyphos/parent-star 8 1.0 12.9 52
|
||||
domain Planetary zyphos/planet zyphos/zyphos-umbros-orbit 1.0 0.56 0 0
|
||||
domain Planetary zyphos/umbros zyphos/zyphos-umbros-orbit 0.9 8 12.9 0
|
||||
domain LatLong zyphos/planet-latlong zyphos/planet -90 90 -180 180
|
||||
tile PositiveZ 0 0 0 zyphos/first-fractal-terrain zyphos/planet-latlong
|
||||
height basin 0 0 30 30 0 3 1 -0.12 7 basin
|
||||
ifs crater 3 2 -5 3 6 2.5 0.48 2.6 0.42 4 0.85 -0.10 19 crater
|
||||
ifs ridge 2 3 6 -4 5 1.35 0.45 3.2 -0.27 3.6 0.72 0.075 31 ridge
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ namespace Aquarium.Zyphos;
|
|||
public static class ZyphosRenderPlan
|
||||
{
|
||||
public const int PlanetIndex = 0;
|
||||
public const int MoonIndex = 1;
|
||||
public const int UmbrosIndex = 1;
|
||||
public const int SdfObjectCount = 2;
|
||||
|
||||
public static AquariumRenderPlan Create()
|
||||
|
|
@ -14,7 +14,7 @@ public static class ZyphosRenderPlan
|
|||
app.Shaders
|
||||
.Core("D3D12HeightField.hlsl", "D3D12Scene.hlsl", "D3D12Post.hlsl")
|
||||
.SdfShader("D3D12ZyphosPlanet.hlsl")
|
||||
.SdfShader("D3D12ZyphosMoon.hlsl");
|
||||
.SdfShader("D3D12ZyphosUmbros.hlsl");
|
||||
|
||||
var heightField = app.RenderTargets.Create("height-field")
|
||||
.FixedSize(128, 128)
|
||||
|
|
|
|||
|
|
@ -48,10 +48,12 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
panel.Readout("Runtime", () => $"{timeSeconds:0.0}s");
|
||||
panel.Readout("Camera", () => $"{orbitDistance:0.0} wu / yaw {orbitYaw:0.00}");
|
||||
panel.Readout("Terrain DSL", () => ZyphosFractalTerrain.Summary);
|
||||
panel.Readout("Objects", () => "fractal height DSL, atmosphere, moon");
|
||||
panel.Readout("Binary", () => $"Umbros {ZyphosUmbrosSystem.UmbrosAngularDiameterDegrees:0.0} deg / {ZyphosUmbrosSystem.SeparationInZyphosRadii:0.0} Rz");
|
||||
panel.Readout("Objects", () => "fractal height DSL, atmosphere, Umbros");
|
||||
})
|
||||
.Command("zyphos", _ => $"Zyphos: {ZyphosFractalTerrain.Summary}", "Report Zyphos demo status.")
|
||||
.Command("zyphos-fractal", _ => ZyphosFractalTerrain.DebugDump, "Dump the compiled Zyphos fractal terrain grammar.");
|
||||
.Command("zyphos-fractal", _ => ZyphosFractalTerrain.DebugDump, "Dump the compiled Zyphos fractal terrain grammar.")
|
||||
.Command("zyphos-system", _ => $"Zyphos-Umbros: separation {ZyphosUmbrosSystem.SeparationInZyphosRadii:0.0} Zyphos radii, Umbros radius {ZyphosUmbrosSystem.UmbrosRadiusRatio:0.00} Zyphos, apparent diameter {ZyphosUmbrosSystem.UmbrosAngularDiameterDegrees:0.0} degrees.", "Report the modeled Zyphos/Umbros/star baseline.");
|
||||
}
|
||||
|
||||
public AquariumFrame ComposeFrame(AquariumFrame frame, AquariumFrameInput input)
|
||||
|
|
|
|||
|
|
@ -5,11 +5,6 @@ namespace Aquarium.Zyphos;
|
|||
|
||||
public static class ZyphosSceneBuilder
|
||||
{
|
||||
private const float PlanetSurfaceRadius = 3.8f;
|
||||
private const float PlanetBoundRadius = 4.52f;
|
||||
private const float MoonSurfaceRadius = 0.54f;
|
||||
private const float MoonBoundRadius = 0.70f;
|
||||
|
||||
public static AquariumSceneState Build(float timeSeconds, float previousTimeSeconds)
|
||||
{
|
||||
return new AquariumSceneState
|
||||
|
|
@ -27,50 +22,35 @@ public static class ZyphosSceneBuilder
|
|||
|
||||
private static AquariumSdfObject[] BuildSdfObjects(float timeSeconds, float previousTimeSeconds)
|
||||
{
|
||||
var planetCenter = new Vector3(0.0f, 0.0f, PlanetSurfaceRadius + 0.48f);
|
||||
var rotation = timeSeconds * 0.032f;
|
||||
var previousRotation = previousTimeSeconds * 0.032f;
|
||||
var moonCenter = MoonCenter(timeSeconds);
|
||||
var previousMoonCenter = MoonCenter(previousTimeSeconds);
|
||||
var planetCenter = ZyphosUmbrosSystem.ZyphosCenter;
|
||||
var rotation = ZyphosUmbrosSystem.MutualPhase(timeSeconds);
|
||||
var umbrosCenter = ZyphosUmbrosSystem.UmbrosCenter(timeSeconds);
|
||||
var previousUmbrosCenter = ZyphosUmbrosSystem.UmbrosCenter(previousTimeSeconds);
|
||||
|
||||
var objects = new AquariumSdfObject[ZyphosRenderPlan.SdfObjectCount];
|
||||
objects[ZyphosRenderPlan.PlanetIndex] = new AquariumSdfObject(
|
||||
new Vector4(planetCenter, PlanetBoundRadius),
|
||||
new Vector4(planetCenter, ZyphosUmbrosSystem.ZyphosBoundRadius),
|
||||
new Vector4(planetCenter, 0.0f),
|
||||
new Vector4(PlanetSurfaceRadius, rotation, 0.56f, previousRotation));
|
||||
objects[ZyphosRenderPlan.MoonIndex] = new AquariumSdfObject(
|
||||
new Vector4(moonCenter, MoonBoundRadius),
|
||||
new Vector4(previousMoonCenter, 0.0f),
|
||||
new Vector4(MoonSurfaceRadius, timeSeconds * 0.11f, PlanetSurfaceRadius, 0.0f));
|
||||
new Vector4(ZyphosUmbrosSystem.ZyphosSurfaceRadius, rotation, ZyphosUmbrosSystem.SeaLevel, rotation));
|
||||
objects[ZyphosRenderPlan.UmbrosIndex] = new AquariumSdfObject(
|
||||
new Vector4(umbrosCenter, ZyphosUmbrosSystem.UmbrosBoundRadius),
|
||||
new Vector4(previousUmbrosCenter, 0.0f),
|
||||
new Vector4(ZyphosUmbrosSystem.UmbrosSurfaceRadius, rotation, ZyphosUmbrosSystem.CenterSeparation, 0.0f));
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
private static AquariumSdfLight[] BuildSdfLights(float timeSeconds)
|
||||
{
|
||||
var sunPhase = timeSeconds * 0.015f;
|
||||
var sunCenter = new Vector3(
|
||||
-12.0f + MathF.Sin(sunPhase) * 2.4f,
|
||||
-18.0f,
|
||||
11.0f + MathF.Cos(sunPhase * 0.7f) * 1.3f);
|
||||
var starCenter = ZyphosUmbrosSystem.PrimaryStarCenter(timeSeconds);
|
||||
return
|
||||
[
|
||||
new AquariumSdfLight(
|
||||
new Vector4(sunCenter, 5.5f),
|
||||
new Vector4(8.6f, 7.9f, 6.7f, -100.0f)),
|
||||
new Vector4(starCenter, 5.5f),
|
||||
new Vector4(3.2f, 2.5f, 1.8f, -100.0f)),
|
||||
new AquariumSdfLight(
|
||||
new Vector4(0.0f, 0.0f, PlanetSurfaceRadius + 0.48f, 4.0f),
|
||||
new Vector4(0.10f, 0.18f, 0.28f, -101.0f))
|
||||
new Vector4(ZyphosUmbrosSystem.UmbrosCenter(timeSeconds), ZyphosUmbrosSystem.UmbrosSurfaceRadius),
|
||||
new Vector4(0.06f, 0.08f, 0.11f, -101.0f))
|
||||
];
|
||||
}
|
||||
|
||||
private static Vector3 MoonCenter(float timeSeconds)
|
||||
{
|
||||
var orbit = timeSeconds * 0.075f + 1.3f;
|
||||
var radius = 6.35f;
|
||||
return new Vector3(
|
||||
MathF.Cos(orbit) * radius,
|
||||
MathF.Sin(orbit) * radius * 0.62f,
|
||||
PlanetSurfaceRadius + 0.62f + MathF.Sin(orbit * 0.73f) * 1.2f);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
52
src/Aquarium.Zyphos/ZyphosUmbrosSystem.cs
Normal file
52
src/Aquarium.Zyphos/ZyphosUmbrosSystem.cs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace Aquarium.Zyphos;
|
||||
|
||||
public static class ZyphosUmbrosSystem
|
||||
{
|
||||
public const float ZyphosSurfaceRadius = 3.8f;
|
||||
public const float ZyphosBoundRadius = 4.52f;
|
||||
public const float UmbrosRadiusRatio = 0.9f;
|
||||
public const float SeparationInZyphosRadii = 8.0f;
|
||||
public const float SeaLevel = 0.56f;
|
||||
public const float MutualPhaseRate = 0.032f;
|
||||
|
||||
public static float UmbrosSurfaceRadius => ZyphosSurfaceRadius * UmbrosRadiusRatio;
|
||||
|
||||
public static float UmbrosBoundRadius => UmbrosSurfaceRadius + 0.42f;
|
||||
|
||||
public static float CenterSeparation => ZyphosSurfaceRadius * SeparationInZyphosRadii;
|
||||
|
||||
public static float UmbrosAngularDiameterDegrees =>
|
||||
MathF.Asin(Math.Clamp(UmbrosSurfaceRadius / CenterSeparation, -1.0f, 1.0f)) * 2.0f * 180.0f / MathF.PI;
|
||||
|
||||
public static Vector3 ZyphosCenter => new(0.0f, 0.0f, ZyphosSurfaceRadius + 0.48f);
|
||||
|
||||
public static float MutualPhase(float timeSeconds)
|
||||
{
|
||||
return timeSeconds * MutualPhaseRate;
|
||||
}
|
||||
|
||||
public static Vector3 UmbrosDirection(float timeSeconds)
|
||||
{
|
||||
// Zyphos renders in the mutually locked local frame: Umbros is fixed in the sky while the primary star phase moves.
|
||||
_ = timeSeconds;
|
||||
return Vector3.UnitX;
|
||||
}
|
||||
|
||||
public static Vector3 UmbrosCenter(float timeSeconds)
|
||||
{
|
||||
return ZyphosCenter + UmbrosDirection(timeSeconds) * CenterSeparation;
|
||||
}
|
||||
|
||||
public static Vector3 PrimaryStarDirection(float timeSeconds)
|
||||
{
|
||||
var phase = MutualPhase(timeSeconds);
|
||||
return Vector3.Normalize(new Vector3(MathF.Cos(phase), MathF.Sin(phase), 0.18f));
|
||||
}
|
||||
|
||||
public static Vector3 PrimaryStarCenter(float timeSeconds)
|
||||
{
|
||||
return ZyphosCenter + PrimaryStarDirection(timeSeconds) * (CenterSeparation * 3.2f);
|
||||
}
|
||||
}
|
||||
|
|
@ -135,3 +135,4 @@
|
|||
{"timestamp":"2026-05-18T06:29:00+01:00","topic":"zyphos-height-brush-table-budget","lesson":"Zyphos' first DSL terrain grammar must currently emit no more than eight height brushes because `D3D12HeightFieldBrushConstants.MaxBrushCount` is still 8. Do not let the demo silently author more claims than the renderer draws; either keep the visible grammar within the fixed table or make the height brush table dynamic before increasing recursive density.","files":["src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs","src/Aquarium.Engine/Render/Features/D3D12HeightFieldBrushConstants.cs"],"source":"runtime proof pass noticed the DSL emitted 12 claims while the current height brush constant table renders only 8"}
|
||||
{"timestamp":"2026-05-18T06:43:00+01:00","topic":"height-brush-table-sixteen","lesson":"The fixed D3D12 height-field brush table now carries 16 brushes, so Zyphos can render its 12-claim DSL terrain without silent truncation. This is still a bounded interim table, not the final streaming brush backend; before raising recursive density further, move height brush packets to a structured buffer or selected-cut page stream.","files":["src/Aquarium.Engine/Render/Features/D3D12HeightFieldBrushConstants.cs","src/Aquarium.Engine/Render/Shaders/D3D12HeightField.hlsl","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs"],"source":"follow-up after detecting the fixed eight-brush table clipped the first Zyphos DSL terrain"}
|
||||
{"timestamp":"2026-05-18T06:58:00+01:00","topic":"aquageo-world-patch-files","lesson":"Aquarium fractal world DSL patches should be authored as `.aquageo` content files, copied into the client output, and loaded from disk at runtime. Zyphos' first terrain proof now loads `Worlds/zyphos-first-fractal-terrain.aquageo`; do not keep demo grammars embedded as fallback strings because that hides asset pipeline failures.","files":["src/Aquarium.Zyphos/Worlds/zyphos-first-fractal-terrain.aquageo","src/Aquarium.Zyphos/ZyphosFractalTerrain.cs","src/Aquarium.Zyphos/Aquarium.Zyphos.csproj","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs"],"source":"user asked to load the world DSL patch via file and call it .aquageo"}
|
||||
{"timestamp":"2026-05-18T07:16:00+01:00","topic":"zyphos-nested-domains-and-umbros-authority","lesson":"Zyphos' `.aquageo` patch now declares solar, orbital, planetary, and lat/long domains before terrain tiles, giving fractal DSL nodes explicit nested reference frames. The Zyphos/Umbros binary constants live in `ZyphosUmbrosSystem`: Umbros is a fixed-sky 0.9-radius twin at 8 Zyphos radii, while the dim primary star phase moves through the Zyphos-local frame for first-pass eclipse cadence. Do not reintroduce moon language or hidden orbital constants in shader files.","files":["src/Aquarium.Zyphos/Worlds/zyphos-first-fractal-terrain.aquageo","src/Aquarium.Zyphos/ZyphosUmbrosSystem.cs","src/Aquarium.Zyphos/Shaders/D3D12ZyphosPlanet.hlsl","src/Aquarium.Zyphos/Shaders/D3D12ZyphosUmbros.hlsl","tests/Aquarium.Engine.Fractal.Tests/ZyphosUmbrosSystemTests.cs","tests/Aquarium.Engine.Fractal.Tests/ZyphosFractalTerrainTests.cs"],"source":"user asked to express nested solar/orbital/planetary/lat-long domains and verify Zyphos/Umbros/parent-star modeling against worldbuilding docs"}
|
||||
|
|
|
|||
|
|
@ -106,9 +106,11 @@ renderer_state:
|
|||
- 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; preview isolation is owned by a preview-only scene shader, while the engine exposes only final-frame PNG capture.
|
||||
- Zyphos is the first nontrivial non-Epiphany client: a planetary-scale demo with spherical-domain terrain, atmospheric rim lighting, night-side glints, and an orbiting moon.
|
||||
- Zyphos is the first nontrivial non-Epiphany client: a planetary-scale demo with spherical-domain terrain, atmospheric rim lighting, night-side glints, fixed-sky Umbros, and first-pass eclipse cadence.
|
||||
- Zyphos/Umbros render-scale binary constants live in src/Aquarium.Zyphos/ZyphosUmbrosSystem.cs: Umbros is modeled as a 0.9-radius mutually tidally locked twin at 8 Zyphos radii, while the dim primary star phase moves through the Zyphos-local frame.
|
||||
- Zyphos simulates the neighboring Eusocial Interbeing setting; the vault at E:\Projects\Eusocial Interbeing owns canon, while Aquarium owns demo rendering constraints and feeds worldbuilding questions back through the vault's Zyphos Simulation Brief.
|
||||
- Future planetary terrain and fractal body detail should use a cube-sphere/QSC-family address space: six quadtree cube faces projected to the sphere with a measured low-distortion warp, avoiding lat-long pole singularities.
|
||||
- Fractal world patches can declare nested semantic domains before terrain tiles. The first .aquageo patch declares solar, orbital, planetary, and lat/long domains for Zyphos so DSL nodes can attach to explicit reference frames before backend lowering.
|
||||
- Future multiscale terrain and agent/body detail should come from bounded IFS brush grammars using shared shaped anisotropic envelopes; texture/material detail can be abundant, but traced SDF form detail must be proxy-bounded, LOD-gated, and measured.
|
||||
- The IFS brush grammar should preserve a semantic ownership tree before backend lowering: local frames, deterministic seeds, named fields/captures, tags, payload bindings, LOD/cost tiers, and boolean-style union/subtract/common nodes should survive even if the first renderer path flattens them into fixed brush tables or SDF shader code.
|
||||
- IFS LOD should be driven by cached node contribution summaries: each node carries bounds, projected error/material delta, coverage, cost, estimator state, residency, and summary/child payload handles so traversal can choose a stable hierarchy cut and render parent summaries while child details stream or fade in.
|
||||
|
|
|
|||
|
|
@ -8,7 +8,11 @@ public sealed class FractalDslCompilerTests
|
|||
public void DslCompilesHeightClaimsIntoSemanticTree()
|
||||
{
|
||||
const string source = """
|
||||
tile PositiveZ 0 0 0 zyphos/terrain
|
||||
domain Solar demo/star - 0.25 0.006 0.077 16
|
||||
domain Orbital demo/orbit demo/star 8 1 12.9 52
|
||||
domain Planetary demo/planet demo/orbit 1 0.56 0 0
|
||||
domain LatLong demo/latlong demo/planet -90 90 -180 180
|
||||
tile PositiveZ 0 0 0 zyphos/terrain demo/latlong
|
||||
height basin 0 0 30 30 0 3 1 -0.18 7 basin
|
||||
height ridge 3 -2 4 1.5 0.4 4 0.8 0.06 11 ridge
|
||||
""";
|
||||
|
|
@ -16,11 +20,30 @@ public sealed class FractalDslCompilerTests
|
|||
var tree = FractalDslCompiler.Compile(source);
|
||||
|
||||
Assert.Equal("cube/PositiveZ/L00/0/0:zyphos/terrain", tree.Domain.Key.Value);
|
||||
Assert.Equal(new AquariumFractalKey("demo/latlong"), tree.Domain.ParentKey);
|
||||
Assert.Equal(5, tree.Domains.Count);
|
||||
Assert.Contains(tree.Domains, domain => domain.Kind == AquariumFractalDomainKind.Solar && domain.Key.Value == "demo/star");
|
||||
Assert.Contains(tree.Domains, domain => domain.Kind == AquariumFractalDomainKind.LatLong && domain.ParentKey.Value == "demo/planet");
|
||||
Assert.Equal(2, tree.Claims.Count);
|
||||
Assert.Equal("cube/PositiveZ/L00/0/0:zyphos/terrain/root/claim/0001/ridge", tree.Claims[1].Key.Value);
|
||||
Assert.Equal(0.06f, tree.Claims[1].Amplitude);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void LegacyDslTileStillCompilesWithoutExplicitDomainStack()
|
||||
{
|
||||
const string source = """
|
||||
tile PositiveZ 0 0 0 zyphos/terrain
|
||||
height basin 0 0 30 30 0 3 1 -0.18 7 basin
|
||||
""";
|
||||
|
||||
var tree = FractalDslCompiler.Compile(source);
|
||||
|
||||
Assert.Equal("cube/PositiveZ/L00/0/0:zyphos/terrain", tree.Domain.Key.Value);
|
||||
Assert.Single(tree.Domains);
|
||||
Assert.Single(tree.Claims);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DslIfsEmitsDeterministicRecursiveClaims()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ public sealed class ZyphosFractalTerrainTests
|
|||
|
||||
Assert.EndsWith(".aquageo", ZyphosFractalTerrain.PatchPath, StringComparison.Ordinal);
|
||||
Assert.True(File.Exists(ZyphosFractalTerrain.PatchPath), $"Expected copied aquageo patch at {ZyphosFractalTerrain.PatchPath}.");
|
||||
Assert.Contains(tree.Domains, domain => domain.Kind == AquariumFractalDomainKind.Solar && domain.Key.Value == "zyphos/parent-star");
|
||||
Assert.Contains(tree.Domains, domain => domain.Kind == AquariumFractalDomainKind.Orbital && domain.Key.Value == "zyphos/zyphos-umbros-orbit");
|
||||
Assert.Contains(tree.Domains, domain => domain.Kind == AquariumFractalDomainKind.Planetary && domain.Key.Value == "zyphos/umbros");
|
||||
Assert.Contains(tree.Domains, domain => domain.Kind == AquariumFractalDomainKind.LatLong && domain.Key.Value == "zyphos/planet-latlong");
|
||||
Assert.Equal(new AquariumFractalKey("zyphos/planet-latlong"), tree.Domain.ParentKey);
|
||||
Assert.Equal(12, tree.Claims.Count);
|
||||
Assert.Equal(tree.Claims.Count, brushes.Length);
|
||||
Assert.Contains(tree.Claims, claim => claim.Tags == "crater");
|
||||
|
|
|
|||
36
tests/Aquarium.Engine.Fractal.Tests/ZyphosNamingTests.cs
Normal file
36
tests/Aquarium.Engine.Fractal.Tests/ZyphosNamingTests.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
namespace Aquarium.Engine.Fractal.Tests;
|
||||
|
||||
public sealed class ZyphosNamingTests
|
||||
{
|
||||
[Fact]
|
||||
public void ZyphosSourceDoesNotModelUmbrosAsMoon()
|
||||
{
|
||||
var root = FindRepositoryRoot();
|
||||
var zyphosFiles = Directory.GetFiles(Path.Combine(root, "src", "Aquarium.Zyphos"), "*.*", SearchOption.AllDirectories)
|
||||
.Where(path => path.EndsWith(".cs", StringComparison.Ordinal) || path.EndsWith(".hlsl", StringComparison.Ordinal))
|
||||
.ToArray();
|
||||
|
||||
foreach (var file in zyphosFiles)
|
||||
{
|
||||
var text = File.ReadAllText(file);
|
||||
Assert.DoesNotContain("Moon", text, StringComparison.Ordinal);
|
||||
Assert.DoesNotContain("moon", text, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
||||
private static string FindRepositoryRoot()
|
||||
{
|
||||
var directory = new DirectoryInfo(AppContext.BaseDirectory);
|
||||
while (directory is not null)
|
||||
{
|
||||
if (File.Exists(Path.Combine(directory.FullName, "Aquarium.Engine.sln")))
|
||||
{
|
||||
return directory.FullName;
|
||||
}
|
||||
|
||||
directory = directory.Parent;
|
||||
}
|
||||
|
||||
throw new DirectoryNotFoundException("Could not find Aquarium.Engine.sln.");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
using System.Numerics;
|
||||
using Aquarium.Zyphos;
|
||||
|
||||
namespace Aquarium.Engine.Fractal.Tests;
|
||||
|
||||
public sealed class ZyphosUmbrosSystemTests
|
||||
{
|
||||
[Fact]
|
||||
public void UmbrosMatchesWorkingBinaryBaselineScale()
|
||||
{
|
||||
Assert.Equal(0.9f, ZyphosUmbrosSystem.UmbrosRadiusRatio);
|
||||
Assert.Equal(8.0f, ZyphosUmbrosSystem.SeparationInZyphosRadii);
|
||||
Assert.InRange(ZyphosUmbrosSystem.UmbrosAngularDiameterDegrees, 12.8f, 13.0f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UmbrosDirectionIsFixedInPlanetLocalFrame()
|
||||
{
|
||||
var firstDirection = ZyphosUmbrosSystem.UmbrosDirection(0.0f);
|
||||
var laterDirection = ZyphosUmbrosSystem.UmbrosDirection(100.0f);
|
||||
|
||||
Assert.Equal(Vector3.UnitX, firstDirection);
|
||||
Assert.Equal(Vector3.UnitX, laterDirection);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UmbrosCenterUsesFixedSkyBinarySeparation()
|
||||
{
|
||||
var offset = ZyphosUmbrosSystem.UmbrosCenter(0.0f) - ZyphosUmbrosSystem.ZyphosCenter;
|
||||
var laterOffset = ZyphosUmbrosSystem.UmbrosCenter(100.0f) - ZyphosUmbrosSystem.ZyphosCenter;
|
||||
|
||||
Assert.Equal(ZyphosUmbrosSystem.CenterSeparation, offset.Length(), 4);
|
||||
Assert.Equal(offset, laterOffset);
|
||||
Assert.True(ZyphosUmbrosSystem.CenterSeparation > ZyphosUmbrosSystem.ZyphosSurfaceRadius * 7.9f);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue