Make CultMath normalize follow dxc and release 0.2.2
dxc 1.9.0.5402 lowers float2/3/4 normalize(x) to x * Rsqrt(Dot(x, x)), and DXIL.rst defines Rsqrt as 1 / sqrt(src). A zero vector normalizes to NaN and a NaN component poisons every component. CultMath divided by max(length, 1e-20), which returned 0 for a zero vector and a huge finite component beside a NaN one. - math.normalize(float2/3/4) is now value * (1 / sqrt(dot(value, value))). - The HLSL mirror drops cultmath_normalize and its epsilon constant: it now equals the normalize intrinsic, and nothing consumed it. - HlslSemanticsTests pins zero and NaN normalize, the rsqrt bit pattern, and zero length/distance. design.md states the rule and notes that DXIL.rst's Rsqrt special-value table is a copy of Round's. - GameCult.Geometry's iso-surface gave degenerate triangles (an inside vertex on the isovalue) a zero normal through the old epsilon. It now guards them explicitly, with a test. - quaternion normalize keeps its identity fallback: quaternion is not an HLSL type. - Bump to 0.2.2 and rebuild the tracked Unity DLL and pdb. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f0605367e0
commit
111b918ec0
14 changed files with 63 additions and 28 deletions
|
|
@ -172,7 +172,9 @@ namespace GameCult.Geometry
|
|||
normal = -normal;
|
||||
}
|
||||
|
||||
normal = math.normalize(normal);
|
||||
// A degenerate triangle (an inside vertex exactly on the isovalue) has no area and gets a zero
|
||||
// normal; normalize follows HLSL and would return NaN for it.
|
||||
normal = math.dot(normal, normal) > 0f ? math.normalize(normal) : float3.zero;
|
||||
var firstIndex = (uint)(positions.Count / 3);
|
||||
Append(a, positions);
|
||||
Append(b, positions);
|
||||
|
|
|
|||
Loading…
Reference in a new issue