Give cursor hibiscus flower anatomy

This commit is contained in:
Meta Vens 2026-05-11 23:23:19 +01:00
commit 010aff7453
4 changed files with 43 additions and 15 deletions

View file

@ -39,7 +39,7 @@ public sealed class D3D12Renderer : IAquariumRenderer
private const float BodyGridClearanceRadiusScale = 2.0f;
private const float SelfGravityRadius = 17.0f;
private const float CursorBodyRadius = 0.56f;
private const float CursorBodyBoundRadius = 0.72f;
private const float CursorBodyBoundRadius = 0.88f;
private const Format SceneHdrFormat = Format.R16G16B16A16_Float;
private const string GridShaderRelativePath = "Render/Shaders/D3D12Grid.hlsl";
private const string SceneShaderRelativePath = "Render/Shaders/D3D12Scene.hlsl";

View file

@ -75,11 +75,16 @@ float3 cursorEmissionRadiance(float3 p, float3 normal)
AgentVisual cursor = agentVisuals[CURSOR_OBJECT_INDEX];
float3 local = (p - cursor.centerRadius.xyz) / CURSOR_RADIUS;
float petal = 0.55 + 0.45 * cos(atan2(local.y, local.x) * 3.0 - timeSeconds * 1.8);
float throat = exp(-dot(local.xy, local.xy) * 7.0) * smoothstep(0.46, -0.28, local.z);
float throat = exp(-dot(local.xy, local.xy) * 7.0) * smoothstep(0.30, -0.18, local.z);
float stamen = smoothstep(0.015, -0.035, sdCapsuleSegment(local, float3(0.02, 0.0, 0.06), float3(-0.22, 0.72, 0.58), 0.06));
float calyx = smoothstep(0.08, -0.02, sdEllipsoid(local - float3(0.0, 0.0, -0.78), float3(0.24, 0.22, 0.22)));
float rim = pow(1.0 - saturate(dot(normal, normalize(cameraPosition - p))), 2.0);
float3 petalColor = lerp(float3(1.25, 0.12, 0.56), float3(1.0, 0.42, 0.88), petal);
float3 throatColor = float3(1.0, 0.76, 0.22);
return petalColor * (0.82 + rim * 0.75) + throatColor * throat * 1.7;
float3 stamenColor = float3(1.0, 0.58, 0.22);
float3 calyxColor = float3(0.20, 0.72, 0.16);
float3 blossom = petalColor * (0.82 + rim * 0.75) + throatColor * throat * 1.7 + stamenColor * stamen * 1.35;
return lerp(blossom, calyxColor * (0.55 + rim * 0.25), calyx);
}
float3 shadeBody(float2 uv, float travel, float3 p, float3 normal, int agentIndex, BodySurface surface)

View file

@ -12,6 +12,14 @@ float sdTorus(float3 p, float2 radius)
return length(q) - radius.y;
}
float sdCapsuleSegment(float3 p, float3 a, float3 b, float radius)
{
float3 pa = p - a;
float3 ba = b - a;
float h = saturate(dot(pa, ba) / max(dot(ba, ba), 0.0001));
return length(pa - ba * h) - radius;
}
float sdSuperellipsoid(float3 p, float3 scale, float exponent)
{
float3 q = abs(p) / scale;
@ -59,25 +67,39 @@ float sdHibiscusCursorPetal(float3 local, float angle, float timeSeconds)
{
float2 radial = float2(cos(angle), sin(angle));
float2 tangent = float2(-radial.y, radial.x);
float phase = timeSeconds * 1.35 + angle * 0.7;
float3 center = float3(radial * 0.18, 0.04 + 0.035 * sin(phase));
float phase = timeSeconds * 0.95 + angle * 1.7;
float3 center = float3(radial * 0.30, 0.12 + 0.030 * sin(phase));
float3 p = local - center;
float3 q = float3(dot(p.xy, radial), dot(p.xy, tangent), p.z);
float taper = saturate((q.z + 1.0) * 0.55);
float edgeCurl = 0.035 * sin(q.x * 8.0 + phase) * taper;
return sdEllipsoid(q + float3(0.0, 0.0, edgeCurl), float3(0.62, 0.19, 0.72));
float flare = saturate((q.x + 0.28) * 1.25);
float ruffle = 0.035 * sin(q.y * 28.0 + q.x * 7.0 + phase) * flare;
float curl = 0.075 * sin(q.x * 3.8 + phase) * flare;
float petal = sdEllipsoid(q + float3(0.0, ruffle, curl), float3(0.80, 0.24, 0.30));
return petal;
}
float sdHibiscusCursor(float3 local, float timeSeconds)
{
float petal0 = sdHibiscusCursorPetal(local, 0.35 + timeSeconds * 0.12, timeSeconds);
float petal1 = sdHibiscusCursorPetal(local, 2.444395 + timeSeconds * 0.12, timeSeconds);
float petal2 = sdHibiscusCursorPetal(local, 4.53879 + timeSeconds * 0.12, timeSeconds);
float sway = 0.10 * sin(timeSeconds * 0.85);
float petal0 = sdHibiscusCursorPetal(local, 1.58 + sway, timeSeconds);
float petal1 = sdHibiscusCursorPetal(local, 3.58 + sway * 0.6, timeSeconds);
float petal2 = sdHibiscusCursorPetal(local, 5.42 + sway * 0.4, timeSeconds);
float petals = min(petal0, min(petal1, petal2));
float throat = sdEllipsoid(local - float3(0.0, 0.0, -0.12), float3(0.28, 0.28, 0.50));
float body = smoothUnion(petals, throat, 0.075);
float contactTip = length(float2(length(local.xy) * 1.22, local.z + 1.0)) - 0.035;
return smoothUnion(body, contactTip, 0.05);
float throat = sdEllipsoid(local - float3(0.0, 0.0, -0.03), float3(0.34, 0.30, 0.22));
float column = sdCapsuleSegment(local, float3(0.02, 0.0, 0.06), float3(-0.22, 0.72, 0.58), 0.035);
float bead0 = sdSphere(local - float3(-0.31, 0.83, 0.64), 0.060);
float bead1 = sdSphere(local - float3(-0.18, 0.78, 0.68), 0.045);
float bead2 = sdSphere(local - float3(-0.38, 0.69, 0.60), 0.040);
float stamen = min(column, min(bead0, min(bead1, bead2)));
float calyx = sdEllipsoid(local - float3(0.0, 0.0, -0.78), float3(0.20, 0.18, 0.18));
float contactStem = sdCapsuleSegment(local, float3(0.0, 0.0, -1.0), float3(0.0, 0.0, -0.70), 0.030);
float blossom = smoothUnion(petals, throat, 0.10);
blossom = smoothUnion(blossom, stamen, 0.045);
float base = smoothUnion(calyx, contactStem, 0.045);
return smoothUnion(blossom, base, 0.070);
}
#endif

View file

@ -33,3 +33,4 @@
{"timestamp":"2026-05-11T22:29:04+01:00","topic":"per-body-proxy-indexing","lesson":"Per-body proxy shaders must not rely on DrawInstanced StartInstanceLocation reaching SV_InstanceID for body identity. Each body shader now declares a shader-local BODY_INDEX constant, and shared proxy VS/PS use that constant for AgentVisualGpu lookup, proxy rectangle placement, and raymarch selection. This keeps per-body shader files transform-locked to their own visual row.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12FaceAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12ImaginationAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12EyesAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12BodyAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12HandsAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12SoulAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12LifeAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12SelfBody.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl"],"source":"visible transform bug report"}
{"timestamp":"2026-05-11T22:32:12+01:00","topic":"canonical-agent-visual-order","lesson":"AgentVisualGpu row order is canonical and must match shader BODY_INDEX constants, body pipeline order, Grid brush indexing, and temporal reprojection: 0 Self, 1 Face, 2 Imagination, 3 Eyes, 4 Body, 5 Hands, 6 Soul, 7 Life, 8 Cursor. Roles-first buffer ordering breaks transforms even if each shader has its own file.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12Post.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12SelfBody.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12FaceAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12ImaginationAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12EyesAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12BodyAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12HandsAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12SoulAgent.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12LifeAgent.hlsl"],"source":"visible transform bug report"}
{"timestamp":"2026-05-11T23:17:40+01:00","topic":"body-proxy-screen-space-convention","lesson":"Body proxy quads and body proxy ray construction must use the same screen-space Y convention as the fullscreen scene pass. Clip-space proxy center should use projected.y directly, and the proxy pixel shader must convert SV_Position top-left pixel coordinates to the bottom-left pixel coordinates expected by rayDirectionForPixel. If they disagree, bodies appear to swim in camera space instead of staying grounded in world space.","files":["src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12BodyProxy.hlsli"],"source":"visible transform bug report"}
{"timestamp":"2026-05-11T23:23:04+01:00","topic":"cursor-hibiscus-anatomy","lesson":"The cursor hibiscus needs recognizable flower anatomy, not just three glossy petals. The cursor SDF now includes curled ruffled petals, a throat, a protruding staminal column with pollen beads, and a green calyx/contact stem, with a larger proxy bound to prevent clipping the expanded silhouette.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfMath.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl","src/Aquarium.Engine/Render/D3D12Renderer.cs"],"source":"visual reference comparison"}