diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12BodyAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12BodyAgent.hlsl index e9f63e5..0f467b5 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12BodyAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12BodyAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 4; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentBodySdf(local, agent).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli b/src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli index 5b0d940..63d0f81 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli +++ b/src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli @@ -80,6 +80,10 @@ struct BodySurface float roleId; float lodTier; float costTier; + float3 albedo; + float roughness; + float3 f0; + float3 emission; }; void cameraBasis(float3 camera, float2 center, out float3 forward, out float3 right, out float3 up) @@ -250,6 +254,15 @@ float3 studioIrradianceDiffuseRadiance(float3 p, float3 normal, float3 albedo, f return diffuseShare * albedo * irradiance * (STUDIO_IRRADIANCE_INTENSITY / PI); } +float3 shadeBodyPbr(float3 p, float3 normal, BodySurface surface) +{ + return surface.emission + + surface.albedo * bodyLightIrradianceAt(p, normal) / PI + + studioIrradianceDiffuseRadiance(p, normal, surface.albedo, surface.roughness, surface.f0) + + bodyLightSpecularRadiance(p, normal, surface.roughness, surface.f0, 7.0) + + studioPmremSpecularRadiance(p, normal, surface.roughness, surface.f0); +} + float3 shadeRoleAgentBody(float3 p, float3 normal, int agentIndex) { float roleId = agentVisuals[agentIndex].previousCenterRole.w; diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12BodyProxy.hlsli b/src/Aquarium.Engine/Render/Shaders/D3D12BodyProxy.hlsli index c465830..797e88b 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12BodyProxy.hlsli +++ b/src/Aquarium.Engine/Render/Shaders/D3D12BodyProxy.hlsli @@ -17,25 +17,22 @@ float3 bodyNormal(float3 p, int agentIndex) { float epsilon = 0.006; - float dx = bodySurface(p + float3(epsilon, 0.0, 0.0), agentIndex).distanceValue - bodySurface(p - float3(epsilon, 0.0, 0.0), agentIndex).distanceValue; - float dy = bodySurface(p + float3(0.0, epsilon, 0.0), agentIndex).distanceValue - bodySurface(p - float3(0.0, epsilon, 0.0), agentIndex).distanceValue; - float dz = bodySurface(p + float3(0.0, 0.0, epsilon), agentIndex).distanceValue - bodySurface(p - float3(0.0, 0.0, epsilon), agentIndex).distanceValue; + float dx = bodyDistance(p + float3(epsilon, 0.0, 0.0), agentIndex) - bodyDistance(p - float3(epsilon, 0.0, 0.0), agentIndex); + float dy = bodyDistance(p + float3(0.0, epsilon, 0.0), agentIndex) - bodyDistance(p - float3(0.0, epsilon, 0.0), agentIndex); + float dz = bodyDistance(p + float3(0.0, 0.0, epsilon), agentIndex) - bodyDistance(p - float3(0.0, 0.0, epsilon), agentIndex); return normalize(float3(dx, dy, dz)); } bool refineBodyHit(float3 origin, float3 direction, int agentIndex, float lowTravel, float highTravel, out float travel, out float3 normal, out BodySurface surface) { - BodySurface highSurface = bodySurface(origin + direction * highTravel, agentIndex); - [unroll] for (int i = 0; i < 8; i++) { float midTravel = (lowTravel + highTravel) * 0.5; - BodySurface midSurface = bodySurface(origin + direction * midTravel, agentIndex); - if (midSurface.distanceValue <= 0.0) + float midDistance = bodyDistance(origin + direction * midTravel, agentIndex); + if (midDistance <= 0.0) { highTravel = midTravel; - highSurface = midSurface; } else { @@ -44,8 +41,9 @@ bool refineBodyHit(float3 origin, float3 direction, int agentIndex, float lowTra } travel = highTravel; - surface = highSurface; - normal = bodyNormal(origin + direction * travel, agentIndex); + float3 p = origin + direction * travel; + surface = bodySurface(p, agentIndex); + normal = bodyNormal(p, agentIndex); return true; } @@ -69,9 +67,18 @@ bool traceBody(float3 origin, float3 direction, int agentIndex, out float travel travel = max(-b - h, 0.0); normal = 0.0; stepCount = 0.0; - surface = bodySurface(origin + direction * travel, agentIndex); + surface.distanceValue = 0.0; + surface.materialId = 0.0; + surface.fieldId = FIELD_ID_GRID; + surface.roleId = 0.0; + surface.lodTier = 0.0; + surface.costTier = 0.0; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; float previousTravel = travel; - float previousDistance = surface.distanceValue; + float previousDistance = bodyDistance(origin + direction * travel, agentIndex); float maxStep = max(agent.centerRadius.w * BODY_TRACE_MAX_STEP_RADIUS_SCALE, BODY_TRACE_MIN_STEP); [loop] @@ -83,22 +90,23 @@ bool traceBody(float3 origin, float3 direction, int agentIndex, out float travel } float3 p = origin + direction * travel; - surface = bodySurface(p, agentIndex); + float distanceValue = bodyDistance(p, agentIndex); stepCount = (float)(stepIndex + 1); - if (surface.distanceValue <= 0.0) + if (distanceValue <= 0.0) { if (previousDistance > 0.0) { return refineBodyHit(origin, direction, agentIndex, previousTravel, travel, travel, normal, surface); } + surface = bodySurface(p, agentIndex); normal = bodyNormal(p, agentIndex); return true; } previousTravel = travel; - previousDistance = surface.distanceValue; - travel += clamp(abs(surface.distanceValue) * BODY_TRACE_STEP_SCALE, BODY_TRACE_MIN_STEP, maxStep); + previousDistance = distanceValue; + travel += clamp(abs(distanceValue) * BODY_TRACE_STEP_SCALE, BODY_TRACE_MIN_STEP, maxStep); } return false; diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl index 2e7a3c7..06c703b 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl @@ -5,6 +5,15 @@ static const int BODY_INDEX = 8; static const float CURSOR_RADIUS = 0.56; +struct CursorHibiscusParts +{ + float petals; + float throat; + float stamen; + float calyx; + float distanceValue; +}; + float2 hibiscusPetalCenter(float u) { float radial = 0.92 * u * u * (1.0 - 0.10 * u); @@ -55,7 +64,7 @@ float sdHibiscusStamen(float3 local) return min(column, beads); } -float sdHibiscusCursor(float3 local, float timeSeconds) +CursorHibiscusParts cursorHibiscusParts(float3 local, float timeSeconds) { float sway = 0.10 * sin(timeSeconds * 0.85); float petal0 = sdHibiscusCursorPetal(local, 1.45 + sway, timeSeconds); @@ -76,54 +85,56 @@ float sdHibiscusCursor(float3 local, float timeSeconds) float blossom = smoothUnion(petals, throat, 0.10); blossom = smoothUnion(blossom, stamen, 0.065); - return smoothUnion(blossom, calyx, 0.120); + CursorHibiscusParts parts; + parts.petals = petals; + parts.throat = throat; + parts.stamen = stamen; + parts.calyx = calyx; + parts.distanceValue = smoothUnion(blossom, calyx, 0.120); + return parts; } -float cursorHibiscusSdf(float3 p) +float bodyDistance(float3 p, int agentIndex) { AgentVisual cursor = agentVisuals[CURSOR_OBJECT_INDEX]; float3 local = (p - cursor.centerRadius.xyz) / CURSOR_RADIUS; - return sdHibiscusCursor(local, timeSeconds) * CURSOR_RADIUS; + return cursorHibiscusParts(local, timeSeconds).distanceValue * CURSOR_RADIUS; } BodySurface bodySurface(float3 p, int agentIndex) { + AgentVisual cursor = agentVisuals[CURSOR_OBJECT_INDEX]; + float3 local = (p - cursor.centerRadius.xyz) / CURSOR_RADIUS; + CursorHibiscusParts parts = cursorHibiscusParts(local, timeSeconds); + float blossomPart = min(parts.petals, min(parts.throat, parts.stamen)); + float isCalyx = parts.calyx <= blossomPart ? 1.0 : 0.0; + float isStamen = (1.0 - isCalyx) * (parts.stamen <= min(parts.petals, parts.throat) ? 1.0 : 0.0); + float isThroat = (1.0 - isCalyx) * (1.0 - isStamen) * (parts.throat <= parts.petals ? 1.0 : 0.0); + float isPetal = (1.0 - isCalyx) * (1.0 - isStamen) * (1.0 - isThroat); + + float petalTone = 0.55 + 0.45 * cos(atan2(local.y, local.x) * 3.0 - timeSeconds * 1.8); + float3 petalAlbedo = lerp(float3(1.0, 0.34, 0.62), float3(1.0, 0.78, 0.90), petalTone); + float3 throatAlbedo = float3(1.0, 0.20, 0.48); + float3 stamenAlbedo = float3(1.0, 0.72, 0.18); + float3 calyxAlbedo = float3(0.34, 0.66, 0.12); + BodySurface surface; - surface.distanceValue = cursorHibiscusSdf(p); - surface.materialId = 5.0; + surface.distanceValue = parts.distanceValue * CURSOR_RADIUS; + surface.materialId = 5.0 + isStamen * 0.1 + isCalyx * 0.2 + isThroat * 0.3; surface.fieldId = FIELD_ID_CURSOR; surface.roleId = 0.0; surface.lodTier = 0.0; surface.costTier = 1.0; + surface.albedo = petalAlbedo * isPetal + throatAlbedo * isThroat + stamenAlbedo * isStamen + calyxAlbedo * isCalyx; + surface.roughness = isCalyx > 0.5 ? 0.46 : 0.22; + surface.f0 = lerp(float3(1.0, 0.38, 0.72), float3(0.04, 0.06, 0.03), isCalyx); + surface.emission = surface.albedo * (isCalyx > 0.5 ? 0.05 : 0.56); return surface; } -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.30, -0.18, local.z); - float stamen = smoothstep(0.018, -0.035, sdHibiscusStamen(local)); - float calyxCore = sdQuadraticTube(local, float3(0.0, 0.0, -1.0), float3(0.06, -0.04, -0.62), float3(0.0, 0.0, -0.18), 0.018, 0.130); - float calyxSepals = min(sdHibiscusSepal(local, 1.57), min(sdHibiscusSepal(local, 3.66), sdHibiscusSepal(local, 5.75))); - float calyx = smoothstep(0.08, -0.02, min(calyxCore, calyxSepals)); - float rim = pow(1.0 - saturate(dot(normal, normalize(cameraPosition - p))), 2.0); - float3 petalColor = lerp(float3(1.12, 0.28, 0.58), float3(1.0, 0.78, 0.90), petal); - float3 throatColor = float3(1.0, 0.18, 0.45); - float3 stamenColor = float3(1.0, 0.70, 0.10); - float3 calyxColor = float3(0.36, 0.68, 0.10); - 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) { - static const float CursorRoughness = 0.22; - float3 cursorF0 = float3(1.0, 0.38, 0.72); - return cursorEmissionRadiance(p, normal) - + bodyLightSpecularRadiance(p, normal, CursorRoughness, cursorF0, 7.0) - + studioPmremSpecularRadiance(p, normal, CursorRoughness, cursorF0); + return shadeBodyPbr(p, normal, surface); } #include "D3D12BodyProxy.hlsli" diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12EyesAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12EyesAgent.hlsl index 3d55bf6..6e4f2fc 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12EyesAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12EyesAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 3; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentFallbackSdf(local, agent).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12FaceAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12FaceAgent.hlsl index f58ea18..5a6db7d 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12FaceAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12FaceAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 1; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentFallbackSdf(local, agent).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12HandsAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12HandsAgent.hlsl index f8542cd..b83de54 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12HandsAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12HandsAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 5; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentFallbackSdf(local, agent).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12ImaginationAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12ImaginationAgent.hlsl index 3638ebd..9e42094 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12ImaginationAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12ImaginationAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 2; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentImaginationSdf(local, agent, timeSeconds).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12LifeAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12LifeAgent.hlsl index 4167851..63d1d53 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12LifeAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12LifeAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 7; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentFallbackSdf(local, agent).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12SelfBody.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12SelfBody.hlsl index ee8ca74..b1f4e40 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12SelfBody.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12SelfBody.hlsl @@ -3,19 +3,27 @@ static const int BODY_INDEX = 0; #include "D3D12BodyCommon.hlsli" #include "D3D12SdfMath.hlsli" -BodySurface bodySurface(float3 p, int agentIndex) +float bodyDistance(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; float radius = max(agent.centerRadius.w, 0.001); float3 local = (p - agent.centerRadius.xyz) / radius; + return sdSphere(local, 1.0) * radius; +} +BodySurface bodySurface(float3 p, int agentIndex) +{ BodySurface surface; - surface.distanceValue = sdSphere(local, 1.0) * radius; + surface.distanceValue = bodyDistance(p, agentIndex); surface.materialId = 0.0; surface.fieldId = FIELD_ID_SELF; surface.roleId = 0.0; surface.lodTier = 0.0; surface.costTier = 0.0; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = primitiveEmissionRadiance(FIELD_ID_SELF); return surface; } diff --git a/src/Aquarium.Engine/Render/Shaders/D3D12SoulAgent.hlsl b/src/Aquarium.Engine/Render/Shaders/D3D12SoulAgent.hlsl index 2cb4ccf..cb9afae 100644 --- a/src/Aquarium.Engine/Render/Shaders/D3D12SoulAgent.hlsl +++ b/src/Aquarium.Engine/Render/Shaders/D3D12SoulAgent.hlsl @@ -4,6 +4,14 @@ static const int BODY_INDEX = 6; #include "D3D12SdfMath.hlsli" #include "D3D12AgentCharacters.hlsli" +float bodyDistance(float3 p, int agentIndex) +{ + AgentVisual agent = agentVisuals[agentIndex]; + float radius = max(agent.centerRadius.w, 0.001); + float3 local = (p - agent.centerRadius.xyz) / radius; + return agentFallbackSdf(local, agent).distanceValue * radius; +} + BodySurface bodySurface(float3 p, int agentIndex) { AgentVisual agent = agentVisuals[agentIndex]; @@ -18,6 +26,10 @@ BodySurface bodySurface(float3 p, int agentIndex) surface.roleId = agent.previousCenterRole.w; surface.lodTier = agent.lodIndexFlags.x; surface.costTier = agentSurface.costTier; + surface.albedo = 0.0; + surface.roughness = 0.0; + surface.f0 = 0.0; + surface.emission = 0.0; return surface; } diff --git a/state/evidence.jsonl b/state/evidence.jsonl index d37459b..e258412 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -43,3 +43,4 @@ {"timestamp":"2026-05-12T00:17:00+01:00","topic":"cursor-hibiscus-reset","lesson":"When the hibiscus cursor starts turning into SDF Jenga, reset the function around anatomical parameters instead of stapling on fixes. The current reset keeps five petals as one cheap graph-style ribbon formula each: u comes from height, radial displacement is quadratic so roots start vertical, width and thickness grow with u, and decorative trig/filament swarms are cut until the core form is stable and fast.","files":["src/Aquarium.Engine/Render/Shaders/D3D12SdfMath.hlsli","state/memory.json"],"source":"user architecture correction"} {"timestamp":"2026-05-12T00:26:00+01:00","topic":"agent-sdf-form-discipline","lesson":"Carry the cursor hibiscus lesson into agent bodies: start every role SDF from a coherent anatomical/form model with a small set of parameters that explain the silhouette across views. Prefer one governing coordinate, profile, width, thickness, symmetry, and material-region model over stitched primitives. Add ornament only after the core form is readable, fast, and stable; fine veins, glitter, filaments, and state pulses should begin as shading or LOD-gated overlays, not traced geometry.","files":["state/memory.json","state/map.yaml"],"source":"cursor hibiscus iteration review"} {"timestamp":"2026-05-12T00:34:00+01:00","topic":"shader-include-ownership","lesson":"Keep shader include ownership strict before role bodies multiply. D3D12SdfMath.hlsli should hold reusable SDF primitives and generic form helpers, not cursor-specific hibiscus anatomy. Body-specific SDF structure belongs in the owning body shader. Shared lighting equations belong in D3D12BodyCommon.hlsli as material-parameterized helpers so cursor, agents, and future bodies do not duplicate GGX/body-light loops.","files":["src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl","src/Aquarium.Engine/Render/Shaders/D3D12SdfMath.hlsli","state/memory.json"],"source":"user architecture correction"} +{"timestamp":"2026-05-12T00:51:00+01:00","topic":"body-distance-surface-shading-split","lesson":"Body SDF passes should be a bounded-cost machine: ray steps and normal samples evaluate only scalar bodyDistance; bodySurface is evaluated once after the hit is refined and returns the PBR material packet. Avoid second-pass SDF component scans such as cursorEmissionRadiance; material choice belongs in the hit surface packet and lighting belongs in shared material-parameterized functions.","files":["src/Aquarium.Engine/Render/Shaders/D3D12BodyCommon.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12BodyProxy.hlsli","src/Aquarium.Engine/Render/Shaders/D3D12CursorBody.hlsl","state/memory.json","state/map.yaml"],"source":"user architecture correction"} diff --git a/state/map.yaml b/state/map.yaml index 3c3472d..9bfd84f 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -70,7 +70,7 @@ renderer_state: - Deferred scalar Grid height target rendered from additive brush passes. - Self Grid brush uses a widened 17-world-unit gravity bowl plus an Aetheria-style radial cosine wave; CPU, Grid shader, scene placement, and temporal reprojection share the same brush equation. - Direct-traced Grid surface is a terminating perfect mirror over the scalar height field, sampling Studio2 PMREM mip 0. - - Fullscreen scene pass owns background and Grid only; each visible body owns a separate proxy pipeline and shader file, with shared proxy plumbing factored into HLSL includes. + - Fullscreen scene pass owns background and Grid only; each visible body owns a separate proxy pipeline and shader file, with shared proxy plumbing factored into HLSL includes. Body proxy marching evaluates only bodyDistance; bodySurface runs once at the refined hit and returns the material packet used by shared PBR lighting. - Reusable SDF primitives live in D3D12SdfMath.hlsli; current role character organs live in D3D12AgentCharacters.hlsli. - Cursor is a luminous five-petal hibiscus SDF centered one cursor radius above the XY plane so its contact tip reaches Grid z=0 without projecting to the Grid surface. - SDF/analytic bodies for Self, Face, Imagination, Eyes, Body, Hands, Soul, Life, and the cursor locator upload current and previous centers through `AgentVisualGpu`; Body plus Imagination use LOD 1 role SDFs. diff --git a/state/memory.json b/state/memory.json index a7f3b84..eef3a1f 100644 --- a/state/memory.json +++ b/state/memory.json @@ -37,6 +37,7 @@ "The fullscreen scene pass owns background and Grid only. Self, Face, Imagination, Eyes, Body, Hands, Soul, Life, and cursor each render through their own shader file and proxy pipeline using AgentVisualGpu, conservative screen rectangles from center plus bound radius, and travel-derived depth writes for Grid/body occlusion. Shared body proxy mechanics may live in includes; body identity SDF and material code should not collapse back into a single body shader.", "Reusable SDF primitives and preserved formulas belong in D3D12SdfMath.hlsli. Current role character organs belong in D3D12AgentCharacters.hlsli. D3D12Renderer expands local shader includes before D3DCompile because the Vortice convenience path does not provide a working include handler here.", "Shader include ownership should stay boring and strict: D3D12SdfMath.hlsli contains reusable SDF primitives and generic form helpers only; body-specific anatomy such as the cursor hibiscus lives in that body's shader; shared lighting equations live in D3D12BodyCommon.hlsli and take material parameters rather than being duplicated per body.", + "Body proxy control flow is split by cost and authority: ray marching calls bodyDistance only, normals sample bodyDistance only, and bodySurface is evaluated once at the refined hit to return distance, material ids, albedo, roughness, F0, and emission. Final shading should go through shared material-parameterized lighting helpers such as shadeBodyPbr rather than re-evaluating SDF components for color.", "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.",