Make Self a routing heart SDF
This commit is contained in:
parent
680d4e71eb
commit
024037fefc
3 changed files with 107 additions and 5 deletions
|
|
@ -3,27 +3,127 @@ static const int SDF_INDEX = 0;
|
|||
#include "D3D12SdfCommon.hlsli"
|
||||
#include "D3D12SdfMath.hlsli"
|
||||
|
||||
struct SelfParts
|
||||
{
|
||||
float core;
|
||||
float rail;
|
||||
float gate;
|
||||
float seam;
|
||||
float distanceValue;
|
||||
};
|
||||
|
||||
float sdTorusArc(float3 q, float majorRadius, float tubeRadius, float2 midDirection, float halfAngle)
|
||||
{
|
||||
float2 radial = q.xy;
|
||||
float radialLength = max(length(radial), 0.0001);
|
||||
float2 direction = radial / radialLength;
|
||||
float angularDistance = (cos(halfAngle) - dot(direction, midDirection)) * majorRadius;
|
||||
float torus = length(float2(radialLength - majorRadius, q.z)) - tubeRadius;
|
||||
return max(torus, angularDistance);
|
||||
}
|
||||
|
||||
float3 rotateZ(float3 p, float angle)
|
||||
{
|
||||
float c = cos(angle);
|
||||
float s = sin(angle);
|
||||
return float3(p.x * c - p.y * s, p.x * s + p.y * c, p.z);
|
||||
}
|
||||
|
||||
float sdRoutingArc(float3 local, float angle, float tilt, float pressure, float phase)
|
||||
{
|
||||
float3 p = rotateZ(local, angle);
|
||||
float3 q = float3(p.x, p.z * cos(tilt) - p.y * sin(tilt), p.z * sin(tilt) + p.y * cos(tilt));
|
||||
float majorRadius = lerp(0.82, 0.68, pressure);
|
||||
float tubeRadius = 0.025 + 0.006 * sin(phase + angle * 1.7);
|
||||
return sdTorusArc(q, majorRadius, tubeRadius, float2(1.0, 0.0), 1.22);
|
||||
}
|
||||
|
||||
float gateNode(float3 local, float angle, float tilt, float pressure)
|
||||
{
|
||||
float majorRadius = lerp(0.82, 0.68, pressure);
|
||||
float3 p = float3(majorRadius, 0.0, 0.0);
|
||||
float3 untilt = float3(p.x, p.z * sin(tilt) + p.y * cos(tilt), p.z * cos(tilt) - p.y * sin(tilt));
|
||||
float3 node = rotateZ(untilt, -angle);
|
||||
return sdSphere(local - node, 0.075);
|
||||
}
|
||||
|
||||
SelfParts selfParts(float3 local, SdfObject sdfObject, float timeSeconds)
|
||||
{
|
||||
float activity = saturate(sdfObject.state.x);
|
||||
float heartbeat = saturate(sdfObject.state.y);
|
||||
float pressure = saturate(sdfObject.state.z);
|
||||
float phase = timeSeconds * 0.55 + heartbeat * 6.28318;
|
||||
float pulse = 0.025 * sin(phase);
|
||||
float core = sdSphere(local, 0.62 + pulse);
|
||||
|
||||
float arc0 = sdRoutingArc(local, 0.00, 0.50, pressure, phase);
|
||||
float arc1 = sdRoutingArc(local, 1.57, -0.58, pressure, phase + 1.2);
|
||||
float arc2 = sdRoutingArc(local, 3.14, 0.76, pressure, phase + 2.4);
|
||||
float arc3 = sdRoutingArc(local, -1.57, -0.34, pressure, phase + 3.6);
|
||||
float rail = min(min(arc0, arc1), min(arc2, arc3));
|
||||
|
||||
float gate0 = gateNode(local, 0.00, 0.50, pressure);
|
||||
float gate1 = gateNode(local, 1.57, -0.58, pressure);
|
||||
float gate2 = gateNode(local, 3.14, 0.76, pressure);
|
||||
float gate3 = gateNode(local, -1.57, -0.34, pressure);
|
||||
float gate = min(min(gate0, gate1), min(gate2, gate3));
|
||||
|
||||
float seamRing = sdTorus(local.xzy, float2(0.63, 0.012));
|
||||
float seamMask = abs(local.z) - 0.10;
|
||||
float seam = max(seamRing, -seamMask);
|
||||
|
||||
float routed = smoothUnion(core, rail, 0.045);
|
||||
routed = smoothUnion(routed, gate, 0.040);
|
||||
float distanceValue = smoothUnion(routed, seam, lerp(0.012, 0.030, activity));
|
||||
|
||||
SelfParts parts;
|
||||
parts.core = core;
|
||||
parts.rail = rail;
|
||||
parts.gate = gate;
|
||||
parts.seam = seam;
|
||||
parts.distanceValue = distanceValue;
|
||||
return parts;
|
||||
}
|
||||
|
||||
float sdfDistance(float3 p, int sdfIndex)
|
||||
{
|
||||
SdfObject sdfObject = sdfObjects[sdfIndex];
|
||||
float radius = max(sdfObject.centerRadius.w, 0.001);
|
||||
float3 local = (p - sdfObject.centerRadius.xyz) / radius;
|
||||
return sdSphere(local, 1.0) * radius;
|
||||
return selfParts(local, sdfObject, timeSeconds).distanceValue * radius;
|
||||
}
|
||||
|
||||
SdfSurface sdfSurface(float3 p, int sdfIndex)
|
||||
{
|
||||
SdfObject sdfObject = sdfObjects[sdfIndex];
|
||||
float radius = max(sdfObject.centerRadius.w, 0.001);
|
||||
float3 local = (p - sdfObject.centerRadius.xyz) / radius;
|
||||
SelfParts parts = selfParts(local, sdfObject, timeSeconds);
|
||||
float isGate = parts.gate <= min(min(parts.core, parts.rail), parts.seam) ? 1.0 : 0.0;
|
||||
float isRail = (1.0 - isGate) * (parts.rail <= min(parts.core, parts.seam) ? 1.0 : 0.0);
|
||||
float isSeam = (1.0 - isGate) * (1.0 - isRail) * (parts.seam <= parts.core ? 1.0 : 0.0);
|
||||
float isCore = (1.0 - isGate) * (1.0 - isRail) * (1.0 - isSeam);
|
||||
float glow = 0.5 + 0.5 * sin(timeSeconds * 1.4 + local.x * 2.0 - local.y * 1.5 + local.z * 2.5);
|
||||
float3 coreColor = lerp(float3(1.0, 0.58, 0.26), float3(1.0, 0.88, 0.62), glow);
|
||||
float3 railColor = float3(1.0, 0.62, 0.18);
|
||||
float3 gateColor = lerp(float3(1.0, 0.82, 0.24), float3(1.0, 0.96, 0.68), saturate(sdfObject.state.x));
|
||||
float3 seamColor = float3(0.09, 0.045, 0.032);
|
||||
|
||||
SdfSurface surface;
|
||||
surface.baseColor = 0.0;
|
||||
surface.baseColor = coreColor * isCore + railColor * isRail + gateColor * isGate + seamColor * isSeam;
|
||||
surface.metallic = 0.0;
|
||||
surface.roughness = 0.0;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex));
|
||||
surface.roughness = 0.34 * isCore + 0.22 * isRail + 0.16 * isGate + 0.74 * isSeam;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex))
|
||||
+ coreColor * isCore * 0.40
|
||||
+ railColor * isRail * 1.15
|
||||
+ gateColor * isGate * (1.35 + sdfObject.state.y * 0.45)
|
||||
+ seamColor * isSeam * 0.03;
|
||||
return surface;
|
||||
}
|
||||
|
||||
float3 shadeSdf(float2 uv, float travel, float3 p, float3 normal, int sdfIndex, SdfSurface surface)
|
||||
{
|
||||
return primitiveEmissionRadiance(sdfFieldId(sdfIndex));
|
||||
return shadeSdfPbr(p, normal, surface);
|
||||
}
|
||||
|
||||
#include "D3D12SdfProxy.hlsli"
|
||||
|
|
|
|||
|
|
@ -79,3 +79,4 @@
|
|||
{"timestamp":"2026-05-13T02:04:00+01:00","topic":"imagination-dead-code-cut","lesson":"User visual review caught dead implementation carryover: the polar-lobed Imagination seed was not in the spec, and the traced half-torus labeled shadow did not read as backlog shadow. Cut both instead of explaining them. Keep petal tips tapered through width/rim endpoints, avoid vertical rim columns, and only add shadow geometry when it has a readable visual contract.","files":["src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl","state/memory.json","state/evidence.jsonl"],"source":"user screenshot correction"}
|
||||
{"timestamp":"2026-05-13T02:08:00+01:00","topic":"imagination-continuous-ribbon-field","lesson":"The hibiscus cursor lesson applies to Imagination: use a continuous sheet parameterization when it can own the form. Replacing piecewise rim capsule chains with one pair-space field for film and raised edge distance removed straight posts, made the ribbon silhouette more coherent, and reduced headless reload time instead of adding compensating geometry.","files":["src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl","state/memory.json","state/evidence.jsonl"],"source":"user challenged piecewise construction after visual review"}
|
||||
{"timestamp":"2026-05-13T02:13:00+01:00","topic":"continuous-form-first-rule","lesson":"Carve this into local practice: when a spec describes a continuous visual, physical, or simulation form, start with continuous field math or a coherent parameterization that owns the form. Piecewise capsules, boxes, slabs, helper organs, adapters, and compensators are not acceptable lazy shortcuts; use them only when the form is actually piecewise or measured constraints force a documented cut.","files":["AGENTS.md","state/memory.json","state/evidence.jsonl"],"source":"user instruction after Imagination correction"}
|
||||
{"timestamp":"2026-05-13T02:40:00+01:00","topic":"self-routing-heart-sdf","lesson":"Self should not be a raw emissive placeholder sphere. Its live SDF is the routing authority object: a warm central sphere, continuous clipped torus-arc rails, gate nodes, and dark review seam, all returning standard PBR material fields plus emission. This keeps Self central and radiant without leaking special shading bypasses.","files":["src/Aquarium.Epiphany/Shaders/D3D12SelfBody.hlsl","state/memory.json","state/evidence.jsonl"],"source":"user asked to prioritize Self visual body"}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@
|
|||
"Imagination's live shader realizes the six-petal topology as three mirrored sheet-pair fields. Keep film, rim, tendril, spark, shadow, and seed distances separated through material classification so raised rims can glow without collapsing the petal sheets into one generic blob.",
|
||||
"Do not reintroduce Imagination's old polar-lobed seed or traced half-torus shadow. The seed is a plain luminous opal bud unless the spec asks otherwise; backlog shadow needs a visual contract before it becomes traced geometry.",
|
||||
"Imagination's ribbon sheets should use one continuous pair-space field for film and raised edge rims. Do not rebuild the bloom from piecewise rim capsules or straight root/tip posts when the sheet parameterization can own the silhouette directly.",
|
||||
"Self's body is the routing authority object: a warm central sphere crossed by continuous clipped torus-arc rails, bright gate nodes, and a dark review seam. Keep it decisive and radiant through PBR surface regions plus emission; do not collapse it back to a raw emissive placeholder sphere.",
|
||||
"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