Plan Zyphos fractal cuts per camera frame
This commit is contained in:
parent
d49200c871
commit
70adeaaf81
4 changed files with 38 additions and 8 deletions
|
|
@ -29,6 +29,24 @@ public static class ZyphosFractalTerrain
|
|||
|
||||
public static string DebugDump => FractalDebugDump.Build(OwnershipTree, Summaries.Value, SelectedCut.Value);
|
||||
|
||||
public static ZyphosFractalRenderPlan BuildRenderPlan(ZyphosCameraShot shot)
|
||||
{
|
||||
var pixelsPerWorld = Math.Clamp(72.0f / MathF.Max(shot.EffectiveDistance, 0.001f), 0.25f, 48.0f);
|
||||
var selectedCut = FractalSelectedCutBuilder.Build(Summaries.Value, _ => pixelsPerWorld, maxEstimatedCost: 64.0f);
|
||||
var brushes = FractalHeightBrushCompiler.CompileSelectedTree(Tree.Value, selectedCut);
|
||||
return new ZyphosFractalRenderPlan(
|
||||
brushes,
|
||||
selectedCut,
|
||||
pixelsPerWorld,
|
||||
$"{selectedCut.Length}/{Summaries.Value.Length} cuts / {brushes.Length}/{OwnershipTree.Claims.Count} brushes / {pixelsPerWorld:0.00} px-wu");
|
||||
}
|
||||
|
||||
public static string Summary =>
|
||||
$"{Path.GetFileName(PatchPath)} / {OwnershipTree.Claims.Count} DSL claims / {OwnershipTree.Nodes.Count} tile nodes / {SelectedCut.Value.Length} cuts / {HeightBrushes.Length} shaped brushes";
|
||||
}
|
||||
|
||||
public readonly record struct ZyphosFractalRenderPlan(
|
||||
AquariumHeightFieldBrush[] HeightBrushes,
|
||||
AquariumSelectedCut[] SelectedCuts,
|
||||
float PixelsPerWorld,
|
||||
string Summary);
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
get
|
||||
{
|
||||
var shot = CurrentShot();
|
||||
var fractalPlan = ZyphosFractalTerrain.BuildRenderPlan(shot);
|
||||
var starPose = ZyphosSpatialDomainCatalog.GetRequired(ZyphosSpatialDomainCatalog.Solar).Pose(timeSeconds);
|
||||
var viewRadius = MathF.Max(
|
||||
MathF.Max(32.0f, shot.EffectiveDistance * 1.15f),
|
||||
|
|
@ -62,7 +63,7 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
shot.CameraTarget,
|
||||
timeSeconds,
|
||||
Vector2.Zero,
|
||||
ZyphosSceneBuilder.Build(timeSeconds, previousTimeSeconds));
|
||||
ZyphosSceneBuilder.Build(timeSeconds, previousTimeSeconds, fractalPlan));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -78,6 +79,7 @@ public sealed class ZyphosRuntime : IAquariumRuntime
|
|||
panel.Readout("Runtime", () => $"{timeSeconds:0.0}s");
|
||||
panel.Readout("Camera", () => $"{ZyphosCameraComposer.DisplayName(selectedDomainKey)} / {CurrentShot().EffectiveDistance:0.00} wu / yaw {orbitYaw:0.00}");
|
||||
panel.Readout("Terrain DSL", () => ZyphosFractalTerrain.Summary);
|
||||
panel.Readout("Fractal Cut", () => ZyphosFractalTerrain.BuildRenderPlan(CurrentShot()).Summary);
|
||||
panel.Readout("Binary", () => $"Umbros {ZyphosUmbrosSystem.UmbrosAngularDiameterDegrees:0.0} deg / {ZyphosUmbrosSystem.SeparationInZyphosRadii:0.0} Rz");
|
||||
panel.Readout("Objects", () => "fractal height DSL, atmosphere, Umbros");
|
||||
})
|
||||
|
|
|
|||
|
|
@ -5,23 +5,18 @@ namespace Aquarium.Zyphos;
|
|||
|
||||
public static class ZyphosSceneBuilder
|
||||
{
|
||||
public static AquariumSceneState Build(float timeSeconds, float previousTimeSeconds)
|
||||
public static AquariumSceneState Build(float timeSeconds, float previousTimeSeconds, ZyphosFractalRenderPlan fractalPlan)
|
||||
{
|
||||
return new AquariumSceneState
|
||||
{
|
||||
TraceHeightFieldSurface = false,
|
||||
UseStarfieldBackground = true,
|
||||
HeightFieldBrushes = BuildHeightFieldBrushes(),
|
||||
HeightFieldBrushes = fractalPlan.HeightBrushes,
|
||||
SdfObjects = BuildSdfObjects(timeSeconds, previousTimeSeconds),
|
||||
SdfLights = BuildSdfLights(timeSeconds),
|
||||
};
|
||||
}
|
||||
|
||||
private static AquariumHeightFieldBrush[] BuildHeightFieldBrushes()
|
||||
{
|
||||
return ZyphosFractalTerrain.HeightBrushes;
|
||||
}
|
||||
|
||||
private static AquariumSdfObject[] BuildSdfObjects(float timeSeconds, float previousTimeSeconds)
|
||||
{
|
||||
var planetCenter = ZyphosUmbrosSystem.ZyphosCenter;
|
||||
|
|
|
|||
|
|
@ -34,4 +34,19 @@ public sealed class ZyphosFractalTerrainTests
|
|||
Assert.Contains(tree.Claims, claim => claim.Tags == "pebble");
|
||||
Assert.Contains(brushes, brush => brush.EnvelopeFalloff > 0.0f && brush.RadiusY > 0.0f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZyphosFractalRenderPlanUsesCameraContributionPressure()
|
||||
{
|
||||
var nearShot = ZyphosCameraComposer.Compose(ZyphosSpatialDomainCatalog.CanopyLeaf, 0.1f, 0.4f, 0.1f, 0.0f);
|
||||
var farShot = ZyphosCameraComposer.Compose(ZyphosSpatialDomainCatalog.Solar, 0.1f, 0.4f, 80.0f, 0.0f);
|
||||
|
||||
var near = ZyphosFractalTerrain.BuildRenderPlan(nearShot);
|
||||
var far = ZyphosFractalTerrain.BuildRenderPlan(farShot);
|
||||
|
||||
Assert.True(near.PixelsPerWorld > far.PixelsPerWorld);
|
||||
Assert.Equal(ZyphosFractalTerrain.SelectedCuts.Length, near.SelectedCuts.Length);
|
||||
Assert.Equal(ZyphosFractalTerrain.HeightBrushes.Length, near.HeightBrushes.Length);
|
||||
Assert.Contains("px-wu", near.Summary, StringComparison.Ordinal);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue