Rebuild Life from Nautilus shell solve
This commit is contained in:
parent
a0efe390b4
commit
3ca4d50922
3 changed files with 176 additions and 102 deletions
|
|
@ -3,85 +3,157 @@ static const int SDF_INDEX = 7;
|
|||
#include "D3D12SdfCommon.hlsli"
|
||||
#include "D3D12SdfMath.hlsli"
|
||||
|
||||
struct LifeDomain
|
||||
static const float LIFE_SHELL_SCALE = 2.85;
|
||||
static const float LIFE_SPIRAL_GROWTH = 0.17;
|
||||
|
||||
struct LifeShellDomain
|
||||
{
|
||||
float body;
|
||||
float whorl;
|
||||
float lip;
|
||||
float bead;
|
||||
float shell;
|
||||
float rib;
|
||||
float crack;
|
||||
float lip;
|
||||
float bead;
|
||||
float chamber;
|
||||
float2 uv;
|
||||
float pearl;
|
||||
float stripe;
|
||||
float u;
|
||||
float v;
|
||||
float w;
|
||||
float turn;
|
||||
float radius;
|
||||
};
|
||||
|
||||
float lifePhase(float2 uv)
|
||||
float2 lifeRotate(float2 p, float angle)
|
||||
{
|
||||
float r = max(length(uv), 0.030);
|
||||
return atan2(uv.y, uv.x) - 1.38 * log(r + 0.060) + 0.55;
|
||||
float c = cos(angle);
|
||||
float s = sin(angle);
|
||||
return float2(c * p.x - s * p.y, s * p.x + c * p.y);
|
||||
}
|
||||
|
||||
float lifeWhorlDistance(float3 local, out float2 uv, out float phase, out float growth)
|
||||
float lifeShellTexture(float u, float v)
|
||||
{
|
||||
uv = float2(local.x + 0.060, local.z - 0.020);
|
||||
float r = length(uv);
|
||||
phase = lifePhase(uv);
|
||||
growth = smoothstep(0.035, 0.72, r);
|
||||
float du = u;
|
||||
float dv = v;
|
||||
|
||||
float spiralSeparation = abs(sin(phase)) * max(r, 0.035);
|
||||
float tube = 0.145 + 0.245 * growth;
|
||||
float shell = length(float2(spiralSeparation * 0.78, local.y * 0.74)) - tube;
|
||||
float outer = r - (0.72 + 0.028 * sin(atan2(uv.y, uv.x) * 2.0 + 0.4));
|
||||
return max(shell, outer);
|
||||
[unroll]
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
float f = exp2((float)i);
|
||||
du += 0.15 / f * sin(f * du) * cos(f * dv);
|
||||
dv += 0.15 / f * cos(f * du) * sin(f * dv);
|
||||
}
|
||||
|
||||
float middle = cos(46.0 * du);
|
||||
float side = cos(18.0 * du + 0.5) + 0.1;
|
||||
float sideFade = 0.5 - 0.5 * tanh(1.0 - 3.0 * sin(dv) * sin(dv));
|
||||
float shellTexture = lerp(middle, side, sideFade) + 0.5 - 0.6 * cos(dv);
|
||||
shellTexture += 0.5 + 0.5 * tanh(4.0 * (du - 1.8));
|
||||
return saturate(8.0 * shellTexture + 0.5);
|
||||
}
|
||||
|
||||
float lifeApertureLip(float3 local)
|
||||
LifeShellDomain lifeShellDomain(float3 local)
|
||||
{
|
||||
float2 q = (local.xz - float2(-0.365, 0.040)) / float2(0.36, 0.44);
|
||||
float angle = atan2(q.y, q.x);
|
||||
float aperture = abs(length(q) - 1.0) * 0.11;
|
||||
float openSide = max(angle - 1.58, -2.72 - angle);
|
||||
return max(max(aperture - 0.017, abs(local.y + 0.205) - 0.033), openSide * 0.055);
|
||||
}
|
||||
float3 p = float3(local.x + 0.18, local.z, local.y) * LIFE_SHELL_SCALE;
|
||||
p.x -= 0.70;
|
||||
|
||||
float lifeEmbeddedPearls(float3 local)
|
||||
{
|
||||
float2 q = (local.xz - float2(-0.365, 0.040)) / float2(0.36, 0.44);
|
||||
float angle = atan2(q.y, q.x);
|
||||
float arc = saturate((angle + 2.72) / 4.30);
|
||||
float aperture = abs(length(q) - 1.0) * 0.11;
|
||||
float beadWave = abs(sin(arc * 17.0 * PI)) - 0.42;
|
||||
float arcGate = max(angle - 1.58, -2.72 - angle);
|
||||
return max(max(aperture - 0.006, abs(local.y + 0.208) - 0.022), max(beadWave * 0.026, arcGate * 0.055));
|
||||
}
|
||||
float r = length(p.xy);
|
||||
float yaw = lerp(0.0, 0.45, smoothstep(0.0, 1.0, 0.5 * (r - 0.6)));
|
||||
p.xy = lifeRotate(p.xy, yaw);
|
||||
r = max(length(p.xy), 0.0005);
|
||||
float t = atan2(p.y, p.x);
|
||||
|
||||
LifeDomain lifeDomain(float3 local, SdfObject sdfObject)
|
||||
{
|
||||
float2 uv;
|
||||
float phase;
|
||||
float growth;
|
||||
float whorl = lifeWhorlDistance(local, uv, phase, growth);
|
||||
float lip = lifeApertureLip(local);
|
||||
float bead = lifeEmbeddedPearls(local);
|
||||
float shellBand = abs(whorl + 0.018) - 0.022;
|
||||
float rib = max(abs(sin(phase * 10.0 + growth * 2.2)) * max(length(uv), 0.035) - 0.014, shellBand);
|
||||
float crack = max(abs(sin(phase * 31.0 + growth * 18.0)) * max(length(uv), 0.035) - 0.004, abs(whorl + 0.004) - 0.011);
|
||||
float chamber = smoothstep(0.11, 0.0, length((local.xz - float2(-0.330, 0.055)) / float2(0.36, 0.42)) - 0.78)
|
||||
* smoothstep(0.060, -0.030, local.y + 0.155);
|
||||
float ro = exp(LIFE_SPIRAL_GROWTH * PI);
|
||||
float d = length(float2(length(p.xz - float2(-ro, 0.0)) - ro, p.y));
|
||||
float u = t;
|
||||
float dx = r - ro;
|
||||
float dy = p.z;
|
||||
float solvedTurn = 0.0;
|
||||
|
||||
float ribLift = (1.0 - smoothstep(0.0, 0.020, rib)) * 0.012;
|
||||
float lipLift = (1.0 - smoothstep(0.0, 0.020, lip)) * 0.026;
|
||||
float beadLift = (1.0 - smoothstep(0.0, 0.014, bead)) * 0.020;
|
||||
float n = (log(max((r * r + p.z * p.z) / (2.0 * r), 0.0001)) / LIFE_SPIRAL_GROWTH - t) / (2.0 * PI);
|
||||
n = min(n, 0.0);
|
||||
float n0 = floor(n);
|
||||
float n1 = ceil(n);
|
||||
float r0 = exp(LIFE_SPIRAL_GROWTH * (2.0 * PI * n0 + t));
|
||||
float r1 = exp(LIFE_SPIRAL_GROWTH * (2.0 * PI * n1 + t));
|
||||
float d0 = abs(length(float2(r - r0, p.z)) - r0);
|
||||
float d1 = abs(length(float2(r - r1, p.z)) - r1);
|
||||
|
||||
LifeDomain domain;
|
||||
domain.body = whorl - ribLift - lipLift - beadLift;
|
||||
domain.whorl = whorl;
|
||||
domain.lip = lip;
|
||||
domain.bead = bead;
|
||||
domain.rib = rib;
|
||||
domain.crack = crack;
|
||||
if (d0 < d)
|
||||
{
|
||||
d = d0;
|
||||
u = 2.0 * PI * n0 + t;
|
||||
dx = r - r0;
|
||||
dy = p.z;
|
||||
solvedTurn = n0;
|
||||
}
|
||||
|
||||
if (d1 < d)
|
||||
{
|
||||
d = d1;
|
||||
u = 2.0 * PI * n1 + t;
|
||||
dx = r - r1;
|
||||
dy = p.z;
|
||||
solvedTurn = n1;
|
||||
}
|
||||
|
||||
float chamberPhase = t + 2.0 * PI * (n0 + 0.5);
|
||||
float turnBlend = frac(n);
|
||||
float septumCurve = 2.35 * chamberPhase
|
||||
+ sqrt(max(0.25 - (turnBlend - 0.5) * (turnBlend - 0.5), 0.0))
|
||||
+ 0.5 * turnBlend;
|
||||
float siphuncle = min(1.0 / (40.0 * length(float2(turnBlend - 0.5, p.z)) + 1.0), 0.5);
|
||||
septumCurve += siphuncle * siphuncle;
|
||||
float septumWave = frac(septumCurve);
|
||||
septumWave = chamberPhase > -1.8 ? abs(septumCurve + 3.25) : min(septumWave, 1.0 - septumWave);
|
||||
float septumDistance = septumWave / 2.35 * exp(LIFE_SPIRAL_GROWTH * (chamberPhase + PI));
|
||||
|
||||
float chamberGate = 1.0 - smoothstep(2.6, 3.05, length(p * float3(1.0, 1.0, 1.5)));
|
||||
float septumSurface = 0.5 * septumDistance + 0.012;
|
||||
d = lerp(d, min(d, septumSurface), chamberGate);
|
||||
|
||||
float sectionRadius = max(exp(LIFE_SPIRAL_GROWTH * u), 0.0005);
|
||||
float v = atan2(dy, dx);
|
||||
float w = length(float2(dx, dy)) / sectionRadius;
|
||||
float shellThickness = 0.8 * max(0.02 * pow(r, 0.4), 0.02);
|
||||
d += 0.00012 * r * sin(200.0 * u);
|
||||
float shell = abs(d) - shellThickness;
|
||||
float cut = max(-1.35 - p.z, p.z - 0.82);
|
||||
shell = max(shell, cut);
|
||||
|
||||
float outerTurn = smoothstep(-1.05, -0.06, n);
|
||||
float lipBand = abs(w - 1.02) * sectionRadius;
|
||||
float apertureLip = max(lipBand - 0.040, -outerTurn);
|
||||
float cutLip = max(abs(cut) - 0.040, shell - 0.020);
|
||||
float lip = min(apertureLip, cutLip);
|
||||
float beadArc = abs(sin((v + 0.65 * sin(u)) * 19.0 + u * 1.4)) - 0.38;
|
||||
float beadRail = min(max(lipBand - 0.018, -outerTurn), cutLip);
|
||||
float bead = max(beadRail, beadArc * 0.030);
|
||||
float rib = max(septumDistance - 0.012, abs(shell + 0.006) - 0.026);
|
||||
float crackPhase = sin(u * 8.3 + sin(v * 3.1) * 1.7) * sin(v * 13.0 + u * 0.6);
|
||||
float crack = max(abs(crackPhase) - 0.965, abs(shell + 0.002) - 0.010);
|
||||
float chamber = saturate(outerTurn * smoothstep(1.20, 0.70, w) * smoothstep(0.35, -0.05, cut));
|
||||
float pearl = saturate((1.0 - smoothstep(0.000, 0.020, bead)) * outerTurn);
|
||||
|
||||
float ribLift = (1.0 - smoothstep(0.0, 0.018, rib)) * 0.038;
|
||||
float lipLift = (1.0 - smoothstep(0.0, 0.040, lip)) * 0.050;
|
||||
float beadLift = pearl * 0.035;
|
||||
|
||||
LifeShellDomain domain;
|
||||
domain.body = (shell - ribLift - lipLift - beadLift) / LIFE_SHELL_SCALE;
|
||||
domain.shell = shell / LIFE_SHELL_SCALE;
|
||||
domain.rib = rib / LIFE_SHELL_SCALE;
|
||||
domain.crack = crack / LIFE_SHELL_SCALE;
|
||||
domain.lip = lip / LIFE_SHELL_SCALE;
|
||||
domain.bead = bead / LIFE_SHELL_SCALE;
|
||||
domain.chamber = chamber;
|
||||
domain.uv = uv;
|
||||
domain.pearl = pearl;
|
||||
domain.stripe = lifeShellTexture(u, v);
|
||||
domain.u = u;
|
||||
domain.v = v;
|
||||
domain.w = w;
|
||||
domain.turn = solvedTurn;
|
||||
domain.radius = r / LIFE_SHELL_SCALE;
|
||||
return domain;
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +162,7 @@ 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 lifeDomain(local, sdfObject).body * radius;
|
||||
return lifeShellDomain(local).body * radius;
|
||||
}
|
||||
|
||||
SdfSurface sdfSurface(float3 p, int sdfIndex)
|
||||
|
|
@ -98,37 +170,37 @@ 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;
|
||||
LifeDomain domain = lifeDomain(local, sdfObject);
|
||||
LifeShellDomain domain = lifeShellDomain(local);
|
||||
float heartbeat = saturate(sdfObject.state.y);
|
||||
float pressure = saturate(sdfObject.state.z + (1.0 - heartbeat) * 0.14);
|
||||
|
||||
float lip = 1.0 - smoothstep(0.000, 0.021, domain.lip);
|
||||
float bead = (1.0 - lip * 0.45) * (1.0 - smoothstep(0.000, 0.014, domain.bead));
|
||||
float rib = (1.0 - lip) * (1.0 - bead) * (1.0 - smoothstep(0.000, 0.021, domain.rib));
|
||||
float shell = saturate(1.0 - lip - bead - rib);
|
||||
float chamber = shell * domain.chamber;
|
||||
float crack = shell * (1.0 - chamber) * (1.0 - smoothstep(0.000, 0.010, domain.crack));
|
||||
float phase = lifePhase(domain.uv);
|
||||
float nacre = 0.5 + 0.5 * sin(phase * 6.0 + local.y * 7.0 + timeSeconds * 0.12);
|
||||
float lip = 1.0 - smoothstep(0.000, 0.020, domain.lip);
|
||||
float bead = domain.pearl;
|
||||
float rib = (1.0 - lip) * (1.0 - bead) * (1.0 - smoothstep(0.000, 0.010, domain.rib));
|
||||
float crack = (1.0 - lip) * (1.0 - bead) * (1.0 - smoothstep(0.000, 0.006, domain.crack));
|
||||
float chamber = domain.chamber * (1.0 - lip * 0.40);
|
||||
float ornament = saturate(max(max(lip, bead), rib));
|
||||
|
||||
float3 teal = lerp(float3(0.018, 0.30, 0.34), float3(0.085, 0.58, 0.62), nacre);
|
||||
float3 gold = lerp(float3(0.90, 0.48, 0.10), float3(1.0, 0.78, 0.28), nacre);
|
||||
float3 nacreLip = float3(1.0, 0.88, 0.60);
|
||||
float3 pearl = lerp(float3(0.78, 0.72, 0.58), float3(1.0, 0.96, 0.82), nacre);
|
||||
float3 deepTeal = float3(0.018, 0.42, 0.42);
|
||||
float3 teal = lerp(deepTeal, float3(0.060, 0.86, 0.76), domain.stripe);
|
||||
float3 warmNacre = lerp(float3(0.70, 0.54, 0.26), float3(1.0, 0.78, 0.30), saturate(domain.chamber + 0.25 * domain.stripe));
|
||||
float3 lipColor = float3(0.95, 0.82, 0.55);
|
||||
float3 pearlColor = float3(0.98, 0.92, 0.72);
|
||||
float3 crackGold = float3(1.0, 0.55, 0.10);
|
||||
|
||||
SdfSurface surface;
|
||||
surface.baseColor = teal * shell * (1.0 - chamber)
|
||||
+ gold * chamber
|
||||
+ nacreLip * saturate(lip + rib)
|
||||
+ pearl * bead;
|
||||
surface.baseColor = lerp(surface.baseColor, gold, crack * 0.55);
|
||||
surface.metallic = 0.32 * saturate(lip + rib);
|
||||
surface.roughness = 0.22 * shell + 0.13 * chamber + 0.10 * saturate(lip + rib) + 0.09 * bead;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) * 0.03
|
||||
+ gold * chamber * (0.52 + heartbeat * 0.34)
|
||||
+ nacreLip * lip * 0.16
|
||||
+ pearl * bead * 0.14
|
||||
+ gold * crack * (0.05 + pressure * 0.14);
|
||||
surface.baseColor = lerp(teal, warmNacre, chamber * 0.62);
|
||||
surface.baseColor = lerp(surface.baseColor, lipColor, saturate(lip * 0.24 + rib * 0.36));
|
||||
surface.baseColor = lerp(surface.baseColor, pearlColor, bead);
|
||||
surface.baseColor = lerp(surface.baseColor, crackGold, crack * 0.65);
|
||||
surface.metallic = 0.04 + 0.28 * ornament;
|
||||
surface.roughness = 0.20 * (1.0 - ornament) + 0.13 * chamber + 0.09 * ornament + 0.10 * bead;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) * 0.025
|
||||
+ teal * 0.070
|
||||
+ warmNacre * chamber * (0.70 + heartbeat * 0.34)
|
||||
+ lipColor * lip * 0.12
|
||||
+ pearlColor * bead * 0.16
|
||||
+ crackGold * crack * (0.05 + pressure * 0.16);
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
@ -137,19 +209,19 @@ float3 shadeSdf(float2 uv, float travel, float3 p, float3 normal, int sdfIndex,
|
|||
SdfObject sdfObject = sdfObjects[sdfIndex];
|
||||
float radius = max(sdfObject.centerRadius.w, 0.001);
|
||||
float3 local = (p - sdfObject.centerRadius.xyz) / radius;
|
||||
LifeDomain domain = lifeDomain(local, sdfObject);
|
||||
LifeShellDomain domain = lifeShellDomain(local);
|
||||
float3 shaded = shadeSdfPbr(p, normal, surface);
|
||||
|
||||
float3 viewDirection = normalize(cameraPosition - p);
|
||||
float edge = pow(1.0 - saturate(dot(normal, viewDirection)), 3.0);
|
||||
float core = exp(-dot(local - float3(-0.16, -0.14, 0.04), local - float3(-0.16, -0.14, 0.04)) * 9.0);
|
||||
float core = exp(-dot(local - float3(-0.20, -0.05, 0.02), local - float3(-0.20, -0.05, 0.02)) * 18.0);
|
||||
return shaded
|
||||
+ float3(1.0, 0.50, 0.08) * core * 0.35
|
||||
+ float3(0.12, 0.62, 0.70) * edge * 0.10
|
||||
+ float3(0.95, 0.70, 0.30) * domain.chamber * 0.12;
|
||||
+ float3(1.0, 0.48, 0.08) * core * 0.30
|
||||
+ float3(0.10, 0.52, 0.56) * edge * 0.08
|
||||
+ float3(0.95, 0.62, 0.18) * domain.chamber * 0.14;
|
||||
}
|
||||
|
||||
#define SDF_TRACE_STEP_SCALE 0.15
|
||||
#define SDF_TRACE_MAX_STEP_RADIUS_SCALE 0.008
|
||||
#define SDF_TRACE_STEP_SCALE 0.12
|
||||
#define SDF_TRACE_MAX_STEP_RADIUS_SCALE 0.006
|
||||
|
||||
#include "D3D12SdfProxy.hlsli"
|
||||
|
|
|
|||
|
|
@ -98,3 +98,4 @@
|
|||
{"timestamp":"2026-05-14T02:55:00+01:00","topic":"life-no-detached-ornament","lesson":"Life's nautilus shell must be one connected shell domain. Detached hoops, bead trails, and separate ember spheres are a sign that ornament escaped the governing field. The aperture lip is the shell's opened edge; pearls must be relief/material on that lip field, and inner light should be chamber shading, not freestanding geometry.","files":["src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl","state/life-agent-sdf-notes.md","state/evidence.jsonl"],"source":"user called out disconnected elements as lazy spatial-domain construction"}
|
||||
{"timestamp":"2026-05-14T04:10:00+01:00","topic":"life-aperture-authority","lesson":"Life's aperture is not a boolean cut face. Render it as a concave inner shell surface integrated into the same log-polar/aperture domain, with the nacre lip owning the boundary and the warm chamber sitting behind it. If chamber material has priority over lip material, the shell reads as a flat sliced object.","files":["src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl","state/life-agent-sdf-notes.md","state/evidence.jsonl"],"source":"user build screenshots showed the aperture as a flat segmented golden cut"}
|
||||
{"timestamp":"2026-05-14T04:55:00+01:00","topic":"life-swept-whorl-field","lesson":"Life must not preserve the ellipsoid-plus-aperture lineage. Build the shell from a swept whorl field: log-polar phase defines the growing spiral sweep, radial growth thickens the tube until whorls overlap into a continuous mass, and lip/ribs/cracks/pearls/chamber light are masks on that same domain. A welded disc or separate cup is a failed model, not a feature to polish.","files":["src/Aquarium.Epiphany/Shaders/D3D12LifeAgent.hlsl","state/life-agent-sdf-notes.md","state/evidence.jsonl"],"source":"user supplied supershape shell reference and called out failure enshrinement"}
|
||||
{"timestamp":"2026-05-14T05:55:00+01:00","topic":"life-nautilus-source-port","lesson":"For Life, the durable model is the Nautilus.glsl logarithmic shell solve: find the nearest exponential spiral boundary in cylindrical space, use its u/v/w section coordinates for wall thickness, septa, ribs, aperture/cut, pearls, cracks, and materials. A loose phase field plus welded opening is not a coherent shell."}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,12 @@ Working model:
|
|||
- The readable form is a memory nautilus, not a generic seed.
|
||||
- An ellipsoid silhouette with spiral material masks reads as wallpaper and fails the reference.
|
||||
- A disc/cup welded onto the shell is worse: it enshrines the failed cut-face model.
|
||||
- The form should start from a swept whorl field: log-polar phase gives the growing shell sweep, while tube thickness grows with radius so the whorls overlap into a continuous shell mass.
|
||||
- Lip, pearls, ribs, cracks, and chamber light are fields on the same whorl/aperture coordinates, not separate child objects.
|
||||
- The supershape reference has two openings, but it preserves the useful spirit: a continuous swept shell surface with rolled lip and nested growth.
|
||||
- The source-backed model comes from `artifacts/Nautilus.glsl`: solve the nearest logarithmic spiral boundary in cylindrical shell space, then derive wall thickness, septa, aperture/cut exposure, ribs, stripes, lip, pearls, cracks, and chamber light from that solved domain.
|
||||
- Do not replace the solve with a loose `sin(phase)` whorl. That was the false shortcut.
|
||||
- Lip, pearls, ribs, cracks, and chamber light are fields on the same `u/v/w` shell coordinates, not separate child objects.
|
||||
- The supershape reference has two openings, but it preserves the useful spirit: a continuous swept shell surface with rolled lip and nested growth. The Shadertoy source provides the stronger mathematical prior.
|
||||
|
||||
Latest preview used for judgment:
|
||||
|
||||
- `artifacts/agent-previews/Life/20260514-045034/life-front.png`
|
||||
- `artifacts/agent-previews/Life/20260514-045034/life-mouth-oblique.png`
|
||||
- `artifacts/agent-previews/Life/20260514-055444/life-front.png`
|
||||
- `artifacts/agent-previews/Life/20260514-055444/life-mouth-oblique.png`
|
||||
|
|
|
|||
Loading…
Reference in a new issue