Rewrite Imagination SDF body
This commit is contained in:
parent
38d616abf6
commit
eb53d04cc1
5 changed files with 112 additions and 43 deletions
|
|
@ -429,13 +429,17 @@ and ribbons communicate branching possibility while still returning to a center.
|
|||
|
||||
Math:
|
||||
|
||||
- Polar lobe field around a seed sphere:
|
||||
`r = base + amplitude * sin(k * theta + phase)`.
|
||||
- Ribbon petals as trefoil-knot tubes around the seed.
|
||||
- Smooth min unions for petal roots; sharp-ish material boundary near petal
|
||||
tips.
|
||||
- Harmonic count `k = 4 + floor(activity * 3) + min(backlogCount, 3)`.
|
||||
`amplitude = lerp(0.08, 0.28, activity)`.
|
||||
- Idea seed as a small opal superellipsoid.
|
||||
- Five curved ribbon-petal sheets around the seed. Each ribbon is driven by one
|
||||
longitudinal parameter: root overlap, outward travel, upward cup, widening
|
||||
blade, and tapering tip. This keeps the field readable from multiple angles
|
||||
and avoids decorative polar distance fiction.
|
||||
- Small emissive idea sparks as bounded spheres near petal tips. These are
|
||||
sparse accents, not a swarm.
|
||||
- Backlog shadow as a clipped low torus beneath the seed. Pressure can tighten
|
||||
and lower it without changing the main silhouette.
|
||||
- Smooth unions only at structural joins: seed-to-ribbon roots, sparse sparks,
|
||||
and the underside backlog ring.
|
||||
- Material regions: opal seed, pearlescent petals, emissive idea sparks, cool
|
||||
backlog shadow.
|
||||
|
||||
|
|
|
|||
|
|
@ -1,18 +1,6 @@
|
|||
#ifndef AQUARIUM_D3D12_SDF_OBJECT_CHARACTERS_HLSLI
|
||||
#define AQUARIUM_D3D12_SDF_OBJECT_CHARACTERS_HLSLI
|
||||
|
||||
float imaginationPetalSdf(float3 local, float angle, float activity, float heartbeat, float timeSeconds)
|
||||
{
|
||||
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.34 + activity * 0.05), 0.028 * sin(phase));
|
||||
float3 p = local - petalCenter;
|
||||
float3 q = float3(dot(p.xy, radial), dot(p.xy, tangent), p.z);
|
||||
float3 petalRadius = float3(0.50 + activity * 0.05, 0.13, 0.64 + 0.045 * sin(phase));
|
||||
return sdEllipsoid(q, petalRadius);
|
||||
}
|
||||
|
||||
float sdfObjectSdfSdf(float3 local, SdfObject sdfObject)
|
||||
{
|
||||
float pulse = sdfObject.state.y;
|
||||
|
|
@ -26,25 +14,6 @@ float sdfObjectSdfSdf(float3 local, SdfObject sdfObject)
|
|||
return smoothUnion(core, shell, 0.045);
|
||||
}
|
||||
|
||||
float sdfObjectImaginationSdf(float3 local, SdfObject sdfObject, float timeSeconds)
|
||||
{
|
||||
float activity = sdfObject.state.x;
|
||||
float heartbeat = sdfObject.state.y;
|
||||
float core = sdSuperellipsoid(local, float3(0.30 + activity * 0.04, 0.30 + activity * 0.04, 0.42), 1.18);
|
||||
float phase = timeSeconds * 0.42;
|
||||
float petal0 = imaginationPetalSdf(local, phase, activity, heartbeat, timeSeconds);
|
||||
float petal1 = imaginationPetalSdf(local, phase + 1.2566371, activity, heartbeat, timeSeconds);
|
||||
float petal2 = imaginationPetalSdf(local, phase + 2.5132741, activity, heartbeat, timeSeconds);
|
||||
float petal3 = imaginationPetalSdf(local, phase + 3.7699112, activity, heartbeat, timeSeconds);
|
||||
float petal4 = imaginationPetalSdf(local, phase + 5.0265482, activity, heartbeat, timeSeconds);
|
||||
float petals = min(petal0, min(petal1, min(petal2, min(petal3, petal4))));
|
||||
float bloom = smoothUnion(core, petals, 0.055);
|
||||
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);
|
||||
return smoothUnion(bloom, detail, 0.05);
|
||||
}
|
||||
|
||||
float sdfObjectFallbackSdf(float3 local, SdfObject sdfObject)
|
||||
{
|
||||
float pulse = sdfObject.state.y;
|
||||
|
|
|
|||
|
|
@ -2,25 +2,119 @@ static const int SDF_INDEX = 2;
|
|||
|
||||
#include "D3D12SdfCommon.hlsli"
|
||||
#include "D3D12SdfMath.hlsli"
|
||||
#include "D3D12AgentCharacters.hlsli"
|
||||
|
||||
struct ImaginationParts
|
||||
{
|
||||
float seed;
|
||||
float petals;
|
||||
float sparks;
|
||||
float shadow;
|
||||
float distanceValue;
|
||||
};
|
||||
|
||||
float sdImaginationRibbonPetal(float3 local, float angle, float activity, float heartbeat, float timeSeconds)
|
||||
{
|
||||
float2 radial = float2(cos(angle), sin(angle));
|
||||
float2 tangent = float2(-radial.y, radial.x);
|
||||
float pulse = sin(timeSeconds * 0.92 + angle * 1.63 + heartbeat * 6.28318);
|
||||
float openness = lerp(0.42, 0.62, activity);
|
||||
float3 root = float3(radial * 0.08, -0.08);
|
||||
float3 p = local - root;
|
||||
float3 q = float3(dot(p.xy, radial), dot(p.xy, tangent), p.z);
|
||||
float u = saturate(q.x / 0.76);
|
||||
float centerZ = -0.05 + openness * u + 0.18 * u * (1.0 - u);
|
||||
float centerY = 0.16 * sin((u - 0.15) * 3.14159) * sin(angle * 2.0 + timeSeconds * 0.36);
|
||||
float width = lerp(0.045, 0.18 + activity * 0.04, smoothstep(0.06, 1.0, u));
|
||||
float thickness = lerp(0.024, 0.050, smoothstep(0.0, 0.85, u));
|
||||
float edgeTaper = smoothstep(0.0, 0.18, u) * (1.0 - smoothstep(0.86, 1.0, u));
|
||||
width *= lerp(0.55, 1.0, edgeTaper);
|
||||
thickness *= lerp(0.75, 1.0 + pulse * 0.10, edgeTaper);
|
||||
|
||||
float along = max(-q.x, q.x - 0.86);
|
||||
float side = abs(q.y - centerY) - width;
|
||||
float sheet = abs(q.z - centerZ) - thickness;
|
||||
return max(max(along, side), sheet);
|
||||
}
|
||||
|
||||
float sdImaginationSpark(float3 local, float angle, float height, float phase)
|
||||
{
|
||||
float2 radial = float2(cos(angle), sin(angle));
|
||||
float3 center = float3(radial * (0.44 + 0.05 * sin(phase)), height + 0.035 * cos(phase));
|
||||
return sdSphere(local - center, 0.040);
|
||||
}
|
||||
|
||||
ImaginationParts imaginationParts(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 breath = 0.5 + 0.5 * sin(timeSeconds * 1.10 + heartbeat * 6.28318);
|
||||
float seedRadius = 0.22 + activity * 0.035 + breath * 0.018;
|
||||
float seed = sdSuperellipsoid(local, float3(seedRadius, seedRadius * 0.92, seedRadius * 1.16), 1.12);
|
||||
|
||||
float phase = timeSeconds * 0.18 + activity * 0.42;
|
||||
float petal0 = sdImaginationRibbonPetal(local, phase + 0.22, activity, heartbeat, timeSeconds);
|
||||
float petal1 = sdImaginationRibbonPetal(local, phase + 1.4766371, activity, heartbeat, timeSeconds);
|
||||
float petal2 = sdImaginationRibbonPetal(local, phase + 2.7332741, activity, heartbeat, timeSeconds);
|
||||
float petal3 = sdImaginationRibbonPetal(local, phase + 3.9899112, activity, heartbeat, timeSeconds);
|
||||
float petal4 = sdImaginationRibbonPetal(local, phase + 5.2465482, activity, heartbeat, timeSeconds);
|
||||
float petals = min(min(petal0, petal1), min(petal2, min(petal3, petal4)));
|
||||
|
||||
float sparkPhase = timeSeconds * 1.36 + heartbeat * 6.28318;
|
||||
float spark0 = sdImaginationSpark(local, phase + 0.84, 0.55, sparkPhase);
|
||||
float spark1 = sdImaginationSpark(local, phase + 2.66, 0.42, sparkPhase + 2.1);
|
||||
float spark2 = sdImaginationSpark(local, phase + 4.58, 0.49, sparkPhase + 4.2);
|
||||
float sparks = min(spark0, min(spark1, spark2));
|
||||
|
||||
float shadowRing = sdTorus((local - float3(0.0, 0.0, -0.12 - pressure * 0.05)).xzy, float2(0.34 + pressure * 0.08, 0.024));
|
||||
float shadowClip = local.z + 0.10;
|
||||
float shadow = max(shadowRing, shadowClip);
|
||||
|
||||
float bloom = smoothUnion(seed, petals, 0.115);
|
||||
bloom = smoothUnion(bloom, sparks, 0.030);
|
||||
ImaginationParts parts;
|
||||
parts.seed = seed;
|
||||
parts.petals = petals;
|
||||
parts.sparks = sparks;
|
||||
parts.shadow = shadow;
|
||||
parts.distanceValue = smoothUnion(bloom, shadow, 0.040);
|
||||
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 sdfObjectImaginationSdf(local, sdfObject, timeSeconds) * radius;
|
||||
return imaginationParts(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;
|
||||
ImaginationParts parts = imaginationParts(local, sdfObject, timeSeconds);
|
||||
float nearestBloom = min(parts.seed, parts.petals);
|
||||
float isSpark = parts.sparks <= min(nearestBloom, parts.shadow) ? 1.0 : 0.0;
|
||||
float isShadow = (1.0 - isSpark) * (parts.shadow <= nearestBloom ? 1.0 : 0.0);
|
||||
float isPetal = (1.0 - isSpark) * (1.0 - isShadow) * (parts.petals <= parts.seed ? 1.0 : 0.0);
|
||||
float isSeed = (1.0 - isSpark) * (1.0 - isShadow) * (1.0 - isPetal);
|
||||
float shimmer = 0.5 + 0.5 * sin((local.x * 3.1 + local.y * -2.4 + local.z * 1.7) + timeSeconds * 1.4);
|
||||
float3 seedColor = lerp(float3(0.42, 0.24, 0.78), float3(0.92, 0.86, 1.0), shimmer);
|
||||
float3 petalColor = lerp(float3(0.62, 0.20, 0.92), float3(1.0, 0.58, 0.96), sdfObject.state.x);
|
||||
float3 sparkColor = float3(1.0, 0.78, 0.34);
|
||||
float3 shadowColor = float3(0.10, 0.08, 0.22);
|
||||
|
||||
SdfSurface surface;
|
||||
surface.baseColor = lerp(float3(0.36, 0.16, 0.70), float3(0.96, 0.48, 0.92), sdfObject.state.x);
|
||||
surface.baseColor = seedColor * isSeed + petalColor * isPetal + sparkColor * isSpark + shadowColor * isShadow;
|
||||
surface.metallic = 0.0;
|
||||
surface.roughness = 0.34;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex)) + surface.baseColor * (0.08 + sdfObject.state.y * 0.08);
|
||||
surface.roughness = 0.30 * isSeed + 0.22 * isPetal + 0.18 * isSpark + 0.68 * isShadow;
|
||||
surface.emission = primitiveEmissionRadiance(sdfFieldId(sdfIndex))
|
||||
+ seedColor * isSeed * 0.08
|
||||
+ petalColor * isPetal * (0.10 + sdfObject.state.y * 0.08)
|
||||
+ sparkColor * isSpark * 1.2
|
||||
+ shadowColor * isShadow * 0.02;
|
||||
return surface;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,3 +73,4 @@
|
|||
{"timestamp":"2026-05-13T00:26:00+01:00","topic":"synth-package-boundary","lesson":"Aquarium must not build against the live AquariumSynthCSharp project while a synth agent is mutating it. Consume AquariumSynth.Dsl as a pinned repo-local NuGet package and update that package only by deliberate version bump.","files":["NuGet.config","packages/AquariumSynth.Dsl.0.1.0-aquarium.1.nupkg","src/Aquarium.Engine/Aquarium.Engine.csproj","scripts/update-synth-package.ps1","state/map.yaml","state/memory.json","state/scratch.md","state/evidence.jsonl"],"source":"user asked whether synth-agent work can break Aquarium builds"}
|
||||
{"timestamp":"2026-05-13T00:40:00+01:00","topic":"generic-sdf-field-ids","lesson":"Aquarium shared SDF code must not special-case Epiphany object identities. SDF field ids are generic base-plus-object-index metadata; Self, Cursor, and role meaning stay in Epiphany's object table and shaders, while temporal reprojection uses uploaded AquariumSdfObject current/previous centers for every SDF object.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Epiphany/EpiphanySceneBuilder.cs","docs/epiphany-agent-sdf-visual-language.md","state/memory.json"]}
|
||||
{"timestamp":"2026-05-13T01:05:00+01:00","topic":"sdf-metallic-roughness-pbr","lesson":"SDF surfaces now use the industry-standard metallic-roughness material language: baseColor, metallic, roughness, and emission. The shared shader derives dielectric F0, metal-tinted specular F0, non-metal diffuse color, direct Cook-Torrance GGX specular, Fresnel-gated Lambert diffuse, diffuse irradiance IBL, and roughness-mip PMREM specular from those fields.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12SdfProxy.hlsli","src/Aquarium.Epiphany/Shaders","docs/epiphany-agent-sdf-visual-language.md","state/memory.json"],"source":"Khronos glTF 2.0 metallic-roughness material model; Google Filament material model notes"}
|
||||
{"timestamp":"2026-05-13T01:20:00+01:00","topic":"imagination-ribbon-flower-sdf","lesson":"Imagination should own its role anatomy inside D3D12ImaginationAgent.hlsl, not a generic shared character helper. The live form is an opal seed plus five one-parameter curved ribbon-petal sheets, sparse bounded idea sparks, and a clipped underside backlog-shadow torus; this replaces the old ellipsoid-petal/ring composite that did not match the visual-language model or hibiscus lessons.","files":["src/Aquarium.Epiphany/Shaders/D3D12ImaginationAgent.hlsl","src/Aquarium.Epiphany/Shaders/D3D12AgentCharacters.hlsli","docs/epiphany-agent-sdf-visual-language.md","state/memory.json"],"source":"user requested Imagination rewrite after cursor hibiscus work"}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@
|
|||
"Agent role bodies should start from a small set of anatomical/form parameters that explain the whole silhouette before adding detail: a center curve, profile/width function, thickness function, repetition symmetry, and bounded material regions. If the SDF cannot be described as one coherent mapping from role state to form, stop and redesign instead of adding compensating organs.",
|
||||
"For agent SDFs, prefer cheap structural math over decorative geometry. Veins, ribs, glitter, pollen, texturing, and fine state response should first be material/shading signals or LOD-gated overlays; do not put trigonometric ornament or filament swarms into the traced distance field until the base form is stable, readable, and measured fast.",
|
||||
"Agent SDF iteration must separate form, evaluator, and ornament. First make the implicit form anatomically coherent from multiple views, then validate marcher behavior and cost, then add state-reactive detail. Screenshot-driven patches that only fix the current angle are a warning sign, not progress.",
|
||||
"Imagination's live SDF is an impossible flower built in its own object shader: opal seed, five curved ribbon-petal sheets driven by one longitudinal parameter, sparse bounded idea sparks, and a clipped underside backlog-shadow torus. Do not resurrect the old shared ellipsoid-petal/ring helper.",
|
||||
"Imagination should read as distinct petals first, not as a fully merged blob. Keep the central seed small, make petal lobes narrow and visibly separated, and accept intentional negative space when it makes the role shape legible.",
|
||||
"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.",
|
||||
|
|
|
|||
Loading…
Reference in a new issue