Tighten Imagination SDF tracing

This commit is contained in:
Meta Vens 2026-05-11 16:33:02 +01:00
commit 1d2ec151cb
3 changed files with 15 additions and 13 deletions

View file

@ -326,10 +326,10 @@ float imaginationPetalSdf(float3 local, float angle, float activity, float heart
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.24 + activity * 0.08), 0.03 * sin(phase));
float3 petalCenter = float3(radial * (0.15 + activity * 0.04), 0.024 * sin(phase));
float3 p = local - petalCenter;
float3 q = float3(dot(p.xy, radial), dot(p.xy, tangent), p.z);
float3 petalRadius = float3(0.44 + activity * 0.05, 0.20, 0.58 + 0.06 * sin(phase));
float3 petalRadius = float3(0.50 + activity * 0.06, 0.25, 0.60 + 0.045 * sin(phase));
return sdEllipsoid(q, petalRadius);
}
@ -354,23 +354,23 @@ AgentSurface agentImaginationSdf(float3 local, AgentVisual agent)
{
float activity = agent.state.x;
float heartbeat = agent.state.y;
float core = sdSuperellipsoid(local, float3(0.48 + activity * 0.08, 0.48 + activity * 0.08, 0.54), 1.18);
float core = sdSuperellipsoid(local, float3(0.54 + activity * 0.08, 0.54 + activity * 0.08, 0.56), 1.18);
float phase = timeSeconds * 0.42;
float petal0 = imaginationPetalSdf(local, phase, activity, heartbeat);
float petal1 = imaginationPetalSdf(local, phase + 1.2566371, activity, heartbeat);
float petal2 = imaginationPetalSdf(local, phase + 2.5132741, activity, heartbeat);
float petal3 = imaginationPetalSdf(local, phase + 3.7699112, activity, heartbeat);
float petal4 = imaginationPetalSdf(local, phase + 5.0265482, activity, heartbeat);
float bloom = smoothUnion(core, petal0, 0.18);
bloom = smoothUnion(bloom, petal1, 0.18);
bloom = smoothUnion(bloom, petal2, 0.18);
bloom = smoothUnion(bloom, petal3, 0.18);
bloom = smoothUnion(bloom, petal4, 0.18);
float bloom = smoothUnion(core, petal0, 0.26);
bloom = smoothUnion(bloom, petal1, 0.26);
bloom = smoothUnion(bloom, petal2, 0.26);
bloom = smoothUnion(bloom, petal3, 0.26);
bloom = smoothUnion(bloom, petal4, 0.26);
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);
AgentSurface surface;
surface.distanceValue = smoothUnion(bloom, detail, 0.035);
surface.distanceValue = smoothUnion(bloom, detail, 0.05);
surface.materialId = bloom <= detail ? 2.0 : 2.4;
surface.costTier = 2.0;
return surface;
@ -446,7 +446,7 @@ bool traceAgentVisual(float3 origin, float3 direction, int agentIndex, float int
stepCount = 0.0;
costTier = 0.0;
[loop]
for (int stepIndex = 0; stepIndex < 40; stepIndex++)
for (int stepIndex = 0; stepIndex < 72; stepIndex++)
{
if (travel > endTravel)
{
@ -457,14 +457,14 @@ bool traceAgentVisual(float3 origin, float3 direction, int agentIndex, float int
AgentSurface surface = agentVisualSdf(p, agentIndex);
stepCount = (float)(stepIndex + 1);
costTier = max(costTier, surface.costTier);
if (abs(surface.distanceValue) < max(0.0025, travel * 0.00025))
if (abs(surface.distanceValue) < max(0.0016, travel * 0.00018))
{
normal = agentVisualNormal(p, agentIndex);
materialId = surface.materialId;
return true;
}
travel += max(abs(surface.distanceValue) * 0.24, 0.0025);
travel += max(abs(surface.distanceValue) * 0.12, 0.0016);
}
return false;
@ -963,7 +963,7 @@ SceneOut D3D12ScenePS(VertexOut input)
SceneOut output;
output.colorTravel = float4(result.color, min(result.travel, farDistance + 1.0));
output.metadata = float4(result.fieldId, result.normal);
output.control = float4(result.materialId, result.coverage, result.stepCount / 40.0, result.lodTier + result.costTier * 0.1);
output.control = float4(result.materialId, result.coverage, result.stepCount / 72.0, result.lodTier + result.costTier * 0.1);
output.eventColor = float4(result.eventColor, result.eventCoverage);
output.eventMetadata = float4(FIELD_ID_GRID, result.eventTravel, result.eventCoverage, 0.0);
return output;