Tighten Imagination SDF tracing
This commit is contained in:
parent
3bf608e70b
commit
1d2ec151cb
3 changed files with 15 additions and 13 deletions
|
|
@ -326,10 +326,10 @@ float imaginationPetalSdf(float3 local, float angle, float activity, float heart
|
|||
float2 radial = float2(cos(angle), sin(angle));
|
||||
float2 tangent = float2(-radial.y, radial.x);
|
||||
float phase = timeSeconds * 1.15 + angle * 1.7 + heartbeat * 6.28318;
|
||||
float3 petalCenter = float3(radial * (0.24 + activity * 0.08), 0.03 * sin(phase));
|
||||
float3 petalCenter = float3(radial * (0.15 + activity * 0.04), 0.024 * sin(phase));
|
||||
float3 p = local - petalCenter;
|
||||
float3 q = float3(dot(p.xy, radial), dot(p.xy, tangent), p.z);
|
||||
float3 petalRadius = float3(0.44 + activity * 0.05, 0.20, 0.58 + 0.06 * sin(phase));
|
||||
float3 petalRadius = float3(0.50 + activity * 0.06, 0.25, 0.60 + 0.045 * sin(phase));
|
||||
return sdEllipsoid(q, petalRadius);
|
||||
}
|
||||
|
||||
|
|
@ -354,23 +354,23 @@ AgentSurface agentImaginationSdf(float3 local, AgentVisual agent)
|
|||
{
|
||||
float activity = agent.state.x;
|
||||
float heartbeat = agent.state.y;
|
||||
float core = sdSuperellipsoid(local, float3(0.48 + activity * 0.08, 0.48 + activity * 0.08, 0.54), 1.18);
|
||||
float core = sdSuperellipsoid(local, float3(0.54 + activity * 0.08, 0.54 + activity * 0.08, 0.56), 1.18);
|
||||
float phase = timeSeconds * 0.42;
|
||||
float petal0 = imaginationPetalSdf(local, phase, activity, heartbeat);
|
||||
float petal1 = imaginationPetalSdf(local, phase + 1.2566371, activity, heartbeat);
|
||||
float petal2 = imaginationPetalSdf(local, phase + 2.5132741, activity, heartbeat);
|
||||
float petal3 = imaginationPetalSdf(local, phase + 3.7699112, activity, heartbeat);
|
||||
float petal4 = imaginationPetalSdf(local, phase + 5.0265482, activity, heartbeat);
|
||||
float bloom = smoothUnion(core, petal0, 0.18);
|
||||
bloom = smoothUnion(bloom, petal1, 0.18);
|
||||
bloom = smoothUnion(bloom, petal2, 0.18);
|
||||
bloom = smoothUnion(bloom, petal3, 0.18);
|
||||
bloom = smoothUnion(bloom, petal4, 0.18);
|
||||
float bloom = smoothUnion(core, petal0, 0.26);
|
||||
bloom = smoothUnion(bloom, petal1, 0.26);
|
||||
bloom = smoothUnion(bloom, petal2, 0.26);
|
||||
bloom = smoothUnion(bloom, petal3, 0.26);
|
||||
bloom = smoothUnion(bloom, petal4, 0.26);
|
||||
float ring = sdTorus(local, float2(0.72 + activity * 0.08, 0.032));
|
||||
float halo = sdTorus(local.zxy, float2(0.50, 0.024));
|
||||
float detail = min(ring, halo);
|
||||
AgentSurface surface;
|
||||
surface.distanceValue = smoothUnion(bloom, detail, 0.035);
|
||||
surface.distanceValue = smoothUnion(bloom, detail, 0.05);
|
||||
surface.materialId = bloom <= detail ? 2.0 : 2.4;
|
||||
surface.costTier = 2.0;
|
||||
return surface;
|
||||
|
|
@ -446,7 +446,7 @@ bool traceAgentVisual(float3 origin, float3 direction, int agentIndex, float int
|
|||
stepCount = 0.0;
|
||||
costTier = 0.0;
|
||||
[loop]
|
||||
for (int stepIndex = 0; stepIndex < 40; stepIndex++)
|
||||
for (int stepIndex = 0; stepIndex < 72; stepIndex++)
|
||||
{
|
||||
if (travel > endTravel)
|
||||
{
|
||||
|
|
@ -457,14 +457,14 @@ bool traceAgentVisual(float3 origin, float3 direction, int agentIndex, float int
|
|||
AgentSurface surface = agentVisualSdf(p, agentIndex);
|
||||
stepCount = (float)(stepIndex + 1);
|
||||
costTier = max(costTier, surface.costTier);
|
||||
if (abs(surface.distanceValue) < max(0.0025, travel * 0.00025))
|
||||
if (abs(surface.distanceValue) < max(0.0016, travel * 0.00018))
|
||||
{
|
||||
normal = agentVisualNormal(p, agentIndex);
|
||||
materialId = surface.materialId;
|
||||
return true;
|
||||
}
|
||||
|
||||
travel += max(abs(surface.distanceValue) * 0.24, 0.0025);
|
||||
travel += max(abs(surface.distanceValue) * 0.12, 0.0016);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -963,7 +963,7 @@ SceneOut D3D12ScenePS(VertexOut input)
|
|||
SceneOut output;
|
||||
output.colorTravel = float4(result.color, min(result.travel, farDistance + 1.0));
|
||||
output.metadata = float4(result.fieldId, result.normal);
|
||||
output.control = float4(result.materialId, result.coverage, result.stepCount / 40.0, result.lodTier + result.costTier * 0.1);
|
||||
output.control = float4(result.materialId, result.coverage, result.stepCount / 72.0, result.lodTier + result.costTier * 0.1);
|
||||
output.eventColor = float4(result.eventColor, result.eventCoverage);
|
||||
output.eventMetadata = float4(FIELD_ID_GRID, result.eventTravel, result.eventCoverage, 0.0);
|
||||
return output;
|
||||
|
|
|
|||
|
|
@ -24,3 +24,4 @@
|
|||
{"timestamp":"2026-05-11T16:18:00+01:00","topic":"agent-visual-state-first-slice","lesson":"The fixed orbit bodies are now backed by an AgentVisualGpu buffer carrying current center, previous center, role id, state scalars, and LOD. D3D12Scene uses the buffer for bounded agent SDF hits; D3D12Post uses the same buffer for agent temporal reprojection. Body and Imagination are the first LOD 1 role SDFs, with debug modes for role, material, step count, LOD, and cost.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Engine.Contracts/GraphicsSettings.cs","docs/hlsl-renderer.md","state/map.yaml","state/memory.json"]}
|
||||
{"timestamp":"2026-05-11T16:28:00+01:00","topic":"agent-sdf-polar-seams","lesson":"Do not animate role SDF lobes with raw atan2 angle fields inside the traced distance function; the polar branch cut creates visible cracks and sliced surfaces. Use continuous harmonic polynomial lobes over normalized directions, widen conservative proxy bounds, and reduce march step scale for distance-ish composite organs.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json"],"source":"visible artifact review"}
|
||||
{"timestamp":"2026-05-11T16:32:00+01:00","topic":"imagination-sdf-connected-lobes","lesson":"Continuous polar harmonics can still behave like a decorative pseudo-distance and leave visible petal gaps. Imagination now uses a central superquadric plus smooth-unioned ellipsoid petals, keeping the bloom continuous enough for bounded sphere tracing while preserving the five-lobed visual character.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json"],"source":"visible artifact review"}
|
||||
{"timestamp":"2026-05-11T16:34:00+01:00","topic":"imagination-sdf-march-conservatism","lesson":"Visible missing structure in Imagination came from shallow petal overlap plus a too-brave march through chained smooth unions. Petals now sit deeper into the core, use broader axes and larger union radii, and agent tracing uses 72 steps with smaller hit epsilon and 0.12 step scale.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json"],"source":"visible artifact review"}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
"The first live AgentVisualState slice uploads current and previous centers, role id, state scalars, and LOD through AgentVisualGpu. Temporal reprojection must use those uploaded centers for agent field ids; do not rederive moving agent centers separately in post.",
|
||||
"Role SDF animation should avoid raw atan2 polar fields for lobe deformation unless the branch cut is explicitly handled. Use continuous harmonic polynomials over normalized XY directions for rotational lobes so sphere tracing does not open visible seams.",
|
||||
"If a role SDF still shows cut-through gaps after removing angular branch cuts, stop using radial pseudo-distance deformation for that organ. Prefer smooth unions of analytic primitives with conservative bounds so the marcher sees connected surfaces instead of decorative distance fiction.",
|
||||
"Chained smooth-union role organs need conservative tracing even when each primitive has a decent distance estimate. Keep petal overlaps substantial, union radii generous, hit epsilon tight, and step scale small enough that narrow joins are sampled instead of skipped.",
|
||||
"Heavy/specialized SDF evaluators should not live inside generic packed-id helpers when those helpers are called repeatedly; avoid shader compiler path cloning.",
|
||||
"Lighting is diegetic. Self is the initial emitter; later other Selves should emit through an explicit body light lane, not generic field instances or ambient convenience fill.",
|
||||
"Keep bundled blue-noise texture assets available for future dithering/noise work even when no current pass samples them.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue