Use GGX brass cursor material
This commit is contained in:
parent
1fb689fd8d
commit
a28f5f1afc
4 changed files with 28 additions and 13 deletions
|
|
@ -723,16 +723,29 @@ float3 shadeBody(float3 p, float3 normal, int primitiveId)
|
|||
|
||||
if (primitiveId == CURSOR_PRIMITIVE_ID)
|
||||
{
|
||||
static const float MinimumRoughness = 0.045;
|
||||
static const float CursorRoughness = 0.22;
|
||||
static const float SelfRadiance = 18.0;
|
||||
|
||||
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 ndv = saturate(dot(normal, viewDirection));
|
||||
float ndh = saturate(dot(normal, halfVector));
|
||||
float vdh = saturate(dot(viewDirection, halfVector));
|
||||
float roughness = max(CursorRoughness, MinimumRoughness);
|
||||
float alpha = roughness * roughness;
|
||||
float alpha2 = alpha * alpha;
|
||||
float denominator = ndh * ndh * (alpha2 - 1.0) + 1.0;
|
||||
float distribution = alpha2 / max(PI * denominator * denominator, 0.00001);
|
||||
float k = (roughness + 1.0);
|
||||
k = (k * k) * 0.125;
|
||||
float geometryL = ndl / max(ndl * (1.0 - k) + k, 0.00001);
|
||||
float geometryV = ndv / max(ndv * (1.0 - k) + k, 0.00001);
|
||||
float geometry = geometryL * geometryV;
|
||||
float3 f0 = float3(0.95, 0.62, 0.26);
|
||||
float3 fresnel = f0 + (1.0 - f0) * pow(1.0 - vdh, 5.0);
|
||||
float3 specular = (distribution * geometry) * fresnel / max(4.0 * ndl * ndv, 0.00001);
|
||||
return specular * ndl * SelfRadiance;
|
||||
}
|
||||
|
||||
float hue = hash21(float2(primitiveId, 6.3));
|
||||
|
|
|
|||
|
|
@ -125,3 +125,4 @@
|
|||
{"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"]}
|
||||
{"timestamp":"2026-05-10T07:47:46.8566891+01:00","topic":"d3d12-cursor-mathworld-teardrop","lesson":"Use the actual MathWorld teardrop curve for the cursor profile instead of hand-sculpted bulb/taper pieces. With x=cos(t) and y=sin(t)*sin^m(t/2), revolving around the x axis gives radius `sqrt(1 - x^2) * ((1 - x) / 2)^(m/2)`. The current shader uses m=6, avoiding fractional pow while giving the higher-exponent teardrop silhouette.","files":["src/Aquarium.Engine/Render/Shaders/D3D12Scene.hlsl","state/memory.json","state/scratch.md"],"source":"https://mathworld.wolfram.com/TeardropCurve.html"}
|
||||
{"timestamp":"2026-05-10T07:56:15.1955843+01:00","topic":"d3d12-cursor-ggx-metal","lesson":"Cursor brass now uses a compact GGX microfacet metal model instead of Blinn-style tinted specular. It has brass F0, Schlick Fresnel, GGX distribution, Smith-Schlick visibility, no diffuse metal term, no glow, and no ambient floor. Until a reflection source exists, Self is the only direct radiance term.","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 uses the MathWorld teardrop curve profile with m=6, revolved around vertical: x=cos(t), y=sin(t)*sin^m(t/2), so radius from vertical x is `sqrt(1 - x^2) * ((1 - x) / 2)^3`. 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.",
|
||||
"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 uses the MathWorld teardrop curve profile with m=6, revolved around vertical: x=cos(t), y=sin(t)*sin^m(t/2), so radius from vertical x is `sqrt(1 - x^2) * ((1 - x) / 2)^3`. Cursor latitudinal ripples belong in the SDF radius function first; material is brass GGX metal with brass-tinted F0, no diffuse metal term, non-emissive, and no ambient floor. It only has Self as direct radiance until a reflection source exists. 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.",
|
||||
|
|
|
|||
|
|
@ -84,10 +84,11 @@ reusing field identity/travel/control.
|
|||
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 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.
|
||||
shelves. The material is brass/metallic GGX with brass-tinted F0, no diffuse
|
||||
metal term, no emissive glow, and no ambient floor; it currently only has
|
||||
Self as direct radiance until a reflection source exists. 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