Polish brass cursor shape
This commit is contained in:
parent
7f0e5b43c4
commit
4a8e97d43d
4 changed files with 38 additions and 28 deletions
|
|
@ -263,17 +263,25 @@ bool traceSphereInInterval(float3 origin, float3 direction, float3 center, float
|
|||
float cursorLocatorProfileRadius(float z)
|
||||
{
|
||||
static const float ContactZ = -1.0;
|
||||
static const float BulbCenterZ = -0.46;
|
||||
static const float BulbRadius = 0.54;
|
||||
static const float TipStartZ = -0.10;
|
||||
static const float TipZ = 1.15;
|
||||
static const float PeakRadius = 0.39;
|
||||
static const float Normalization = 6.75;
|
||||
static const float TipBaseRadius = 0.34;
|
||||
|
||||
float u = saturate((z - ContactZ) / (TipZ - ContactZ));
|
||||
float top = 1.0 - u;
|
||||
float baseRadius = PeakRadius * Normalization * u * top * top;
|
||||
float rippleEnvelope = smoothstep(0.10, 0.28, u) * (1.0 - smoothstep(0.82, 0.98, u));
|
||||
float sphereY = (z - BulbCenterZ) / BulbRadius;
|
||||
float bulbRadius = BulbRadius * sqrt(saturate(1.0 - sphereY * sphereY));
|
||||
float tipT = saturate((z - TipStartZ) / (TipZ - TipStartZ));
|
||||
float taper = (1.0 - tipT);
|
||||
float tipRadius = TipBaseRadius * taper * taper * taper;
|
||||
float blend = smoothstep(-0.24, 0.10, z);
|
||||
float baseRadius = lerp(bulbRadius, tipRadius, blend);
|
||||
baseRadius = max(baseRadius, 0.0);
|
||||
float rippleEnvelope = smoothstep(0.08, 0.22, u) * (1.0 - smoothstep(0.72, 0.92, u));
|
||||
float rippleWave = 0.5 + 0.5 * sin(z * 28.0 - timeSeconds * 4.0);
|
||||
float rippleRidge = rippleWave * rippleWave * rippleWave;
|
||||
float rippleRadius = min(0.026, baseRadius * 0.16) * rippleRidge * rippleEnvelope;
|
||||
float rippleRadius = min(0.018, baseRadius * 0.10) * rippleRidge * rippleEnvelope;
|
||||
return baseRadius + rippleRadius;
|
||||
}
|
||||
|
||||
|
|
@ -723,24 +731,21 @@ float3 shadeBody(float3 p, float3 normal, int primitiveId)
|
|||
|
||||
if (primitiveId == CURSOR_PRIMITIVE_ID)
|
||||
{
|
||||
float3 cursorCenter = float3(cursorWorlds.xy, CURSOR_RADIUS);
|
||||
float3 local = (p - cursorCenter) / CURSOR_RADIUS;
|
||||
float height01 = saturate((local.z + 1.0) / 2.15);
|
||||
float ripplePhase = local.z * 28.0 - timeSeconds * 4.0;
|
||||
float rippleWave = 0.5 + 0.5 * sin(ripplePhase);
|
||||
float rippleLine = pow(rippleWave, 18.0);
|
||||
float envelope = smoothstep(0.04, 0.18, height01) * (1.0 - smoothstep(0.90, 1.0, height01));
|
||||
float latitudinalGlow = rippleLine * envelope;
|
||||
float rim = pow(1.0 - saturate(dot(normal, normalize(cameraPosition - p))), 2.4);
|
||||
float light = 0.18 + saturate(dot(normal, lightDirection)) * 1.45;
|
||||
float3 baseColor = lerp(float3(0.30, 0.78, 0.88), float3(0.56, 1.0, 1.0), latitudinalGlow * 0.45);
|
||||
float3 rippleColor = float3(0.72, 1.0, 1.0) * latitudinalGlow * (0.35 + rim * 0.65);
|
||||
return baseColor * light + float3(0.90, 0.78, 1.0) * rim * 0.65 + rippleColor;
|
||||
float3 viewDirection = normalize(cameraPosition - p);
|
||||
float3 halfVector = normalize(lightDirection + viewDirection);
|
||||
float specularCore = pow(saturate(dot(normal, halfVector)), 180.0);
|
||||
float specularShoulder = pow(saturate(dot(normal, halfVector)), 42.0);
|
||||
float fresnel = pow(1.0 - saturate(dot(normal, viewDirection)), 5.0);
|
||||
float3 brass = float3(0.92, 0.58, 0.20);
|
||||
float3 darkBrass = float3(0.22, 0.13, 0.045);
|
||||
float3 diffuse = brass * (ndl * 0.34);
|
||||
float3 reflection = brass * (specularCore * 7.0 + specularShoulder * 0.85) + lerp(darkBrass, brass, 0.65) * fresnel * 1.05;
|
||||
return diffuse + reflection;
|
||||
}
|
||||
|
||||
float hue = hash21(float2(primitiveId, 6.3));
|
||||
float3 albedo = lerp(float3(0.34, 0.42, 0.18), float3(0.70, 0.76, 0.42), hue);
|
||||
return albedo * (0.08 + ndl * 1.6);
|
||||
return albedo * (ndl * 1.68);
|
||||
}
|
||||
|
||||
SceneOut D3D12ScenePS(VertexOut input)
|
||||
|
|
|
|||
|
|
@ -122,3 +122,5 @@
|
|||
{"timestamp":"2026-05-10T07:26:31.5212759+01:00","topic":"d3d12-cursor-droplet-locator","lesson":"The symmetric spinning-top cursor read as a space station, and the first droplet/needle pass read as a candle flame. The live cursor profile is now a smaller droplet/needle locator: local z=-1 contacts the Grid, a modest belly peaks near z=-0.42, the needle ends near z=0.95, and CPU/HLSL bounds are 0.72. Keep this profile cheap; numeric slope probes and fractional pow made D3D12 initial pipeline compile exceed the headless startup timeout.","files":["src/Aquarium.Engine/Render/D3D12Renderer.cs","src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json","state/scratch.md"]}
|
||||
{"timestamp":"2026-05-10T07:31:25.0639878+01:00","topic":"d3d12-cursor-asymmetric-teardrop","lesson":"The segmented droplet/needle profile still read as a constructed seed/locator rather than a mathematical teardrop. The live cursor profile is a single asymmetric lobe with radius proportional to normalized `u * (1 - u)^2`, contact at local z=-1, tip at local z=1.15, and bound radius 0.72. This biases the mass downward while keeping the evaluator polynomial and cheap.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json","state/scratch.md"]}
|
||||
{"timestamp":"2026-05-10T07:35:54.0685316+01:00","topic":"d3d12-cursor-sdf-ripples","lesson":"Cursor surface juice should compose through the SDF, not only through shading. The teardrop radius now gets small latitudinal ridge offsets from `sin(localZ * 28 - time * 4)`, and the shader glow uses the same phase so normals, silhouette, and highlight all agree.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json","state/scratch.md"]}
|
||||
{"timestamp":"2026-05-10T07:41:01.6985223+01:00","topic":"d3d12-diegetic-cursor-material","lesson":"Cursor ripples should be SDF geometry, not emissive glow. The cursor material is now brass/metallic with Self-lit diffuse, brass specular, and Fresnel reflection; the old cyan glow was removed. The remaining constant ambient diffuse floors on cursor and planet shading were also cut so only diegetic light shapes solid bodies.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json","state/scratch.md"]}
|
||||
{"timestamp":"2026-05-10T07:43:40.3417470+01:00","topic":"d3d12-cursor-round-bulb-polish","lesson":"To avoid pagoda shelves and make the cursor bulb read more spherical, derive the lower profile from a sphere around local z=-0.46, blend into a strengthened cubic taper starting near local z=-0.10, and reduce ripple amplitude. Brass should read polished: use a tight high-power specular core plus a smaller shoulder, with no ambient diffuse floor.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json","state/scratch.md"]}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
"Do not put the D3D12 Grid through transparent froxel candidate/event traversal. The one-pass transparent binning experiment made the Grid angle-dependent and brittle. The live Grid contract is direct scene tracing as a non-terminating stochastic event before the nearest solid. Grid must not write the surface packet. Medium has a separate temporal packet even when a solid is behind it; Grid/particles have a separate stochastic-event color+metadata history lane. Git holds the old experiment; runtime code should stay lean.",
|
||||
"D3D12 Grid line width normalization should match the D3D11 reference: use periodic line domains with `fwidth()` and pixel-width constants, not world-space `ddx/ddy(p.xy)` footprint guesses. For a single Grid event, emit expected premultiplied event radiance from analytic coverage; do not blue-noise dither one sample into visible grain. Blue-noise stochastic selection belongs in the future multi-event chooser when several transparent samples compete for one ray/pixel.",
|
||||
"D3D12 solid scene candidate discovery belongs in the view-froxel volume. At 720p the active tube is 160x90x32; primitive ids are indexed by low-res screen cell and depth slice, then scene rays test exact solid intersections inside that slice interval. The CPU-filled view-froxel buffers are bootstrap only; the durable path should become GPU/raster binning so per-frame upload bandwidth does not become the next stupid tax.",
|
||||
"Mouse/cursor-owned SDF bodies need object-motion reprojection. Carry current and previous cursor world anchors through frame constants and reproject cursor hits from current center to previous center, just like orbiting planets. The current cursor body is an asymmetric teardrop lobe, not a SuperFormula and not the rejected spinning-top/space-station profile: local `z = -1` contacts the Grid, local `z = 1.15` is the top tip, and radius follows normalized `u * (1 - u)^2` so mass is biased downward. Cursor latitudinal ripples belong in the SDF radius function first, with surface glow reinforcing the same phase. Keep the shader bound radius and CPU froxel bound radius matched. Profile fields are not automatically distance fields; for this hot profile path, prefer conservative step scale and cheap polynomial pieces over sampled profile distance, numeric slope probes, or fractional `pow`, all of which can stall D3D12 shader pipeline compilation.",
|
||||
"Mouse/cursor-owned SDF bodies need object-motion reprojection. Carry current and previous cursor world anchors through frame constants and reproject cursor hits from current center to previous center, just like orbiting planets. The current cursor body is an asymmetric teardrop lobe, not a SuperFormula and not the rejected spinning-top/space-station profile: local `z = -1` contacts the Grid, local `z = 1.15` is the top tip, the bulb is sphere-derived around local `z = -0.46`, and the upper section uses a strengthened cubic taper. Cursor latitudinal ripples belong in the SDF radius function first; material is brass/metallic, sharper-specular, non-emissive, and has no ambient diffuse floor. Keep the shader bound radius and CPU froxel bound radius matched. Profile fields are not automatically distance fields; for this hot profile path, prefer conservative step scale and cheap polynomial pieces over sampled profile distance, numeric slope probes, or fractional `pow`, all of which can stall D3D12 shader pipeline compilation.",
|
||||
"Heavy/specialized SDF evaluators should not live inside the generic packed primitive-id hit helper when that helper is called for every int4 component. Detect specialized ids in the froxel loop and invoke the evaluator once per relevant froxel; otherwise the shader compiler clones the path into a startup-time punishment device.",
|
||||
"D3D12 pixel shader UAV registers share the output namespace. If a shader writes SV_Target0, bind the first manual UAV at u1, not u0.",
|
||||
"D3D12 shader routing derives its editable source directory from --shader-source/AQUARIUM_SHADER_SOURCE, then watches D3D12Grid/Medium/Scene/Post/Smoke HLSL files directly. Shader/PSO builds run on a background task. During initial startup, D3D12 should not touch or present the swapchain until the first pipeline set is ready; the host keeps repainting the Win32 splash instead. This can flicker slightly, but it avoids black loading frames and stale DirectWrite loading text in live backbuffers. Hot reload keeps the previous pipeline set if compilation fails.",
|
||||
|
|
|
|||
|
|
@ -72,19 +72,22 @@ reusing field identity/travel/control.
|
|||
- Cursor locator SDF: `AquariumFrame` carries the mouse cursor projected onto
|
||||
the Grid XY plane. D3D12 bins a cursor primitive into the existing view-froxel
|
||||
solid table and traces it as an asymmetric teardrop lobe: local `z = -1`
|
||||
kisses the Grid plane, local `z = 1.15` is the top tip, and radius follows
|
||||
normalized `u * (1 - u)^2` so the mass is biased downward instead of reading
|
||||
as a sunflower seed. Shader and CPU froxel bounds must stay matched (`0.72`
|
||||
currently) or candidate discovery clips the cursor. Frame constants pack
|
||||
kisses the Grid plane, local `z = 1.15` is the top tip, the lower bulb is
|
||||
sphere-derived around local `z = -0.46`, and the upper section blends into a
|
||||
strengthened cubic taper so the bulb reads round instead of pagoda/seed.
|
||||
Shader and CPU froxel bounds must stay matched (`0.72` currently) or
|
||||
candidate discovery clips the cursor. Frame constants pack
|
||||
current and previous cursor world anchors so the TAA resolve can reproject
|
||||
cursor hits with object motion instead of camera-only motion. Keep heavy SDF
|
||||
evaluators outside generic packed-id hit helpers, and keep this profile
|
||||
analytic/cheap: sampled profile-segment distance, numeric slope probing, and
|
||||
fractional `pow` all stalled D3D12 pipeline compilation. Cursor juice is part
|
||||
of the SDF: latitudinal ridges add a small animated radius offset using
|
||||
`sin(localZ * 28 - time * 4)`, with matching surface glow only reinforcing
|
||||
the same phase. The earlier spinning-top profile read as a space station or
|
||||
candle flame; keep it as evidence, not live cursor doctrine.
|
||||
`sin(localZ * 28 - time * 4)`, with amplitude reduced so ripples do not form
|
||||
shelves. The material is brass/metallic, non-emissive, has a sharper specular
|
||||
core, and has no ambient diffuse floor; only Self-driven lighting/specular
|
||||
terms should shape it. The earlier spinning-top profile read as a space
|
||||
station or candle flame; keep it as evidence, not live cursor doctrine.
|
||||
|
||||
## Hot Context
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue