| Filename | Latest commit message | Latest commit date |
|---|---|---|
Soul (cut 2a-i, pass 2) found two defects in cellular's own math.cs source and its HLSL mirror: - cellular hashed pcg3d/pcg4d over the FLOAT32 BIT PATTERN of each integer-valued cell coordinate (pcg3d(neighbor), pcg4d(float4(cellId, 0))) instead of the integer coordinate itself. Two adjacent cells' bit patterns share more structure (same exponent, mantissa one increment apart) than the integers do going into pcg3d's own mixing, and that structure survived into the jitter: measured chi-square 203.8 for jitter.x over 1,000,000 cells against 15 degrees of freedom (critical value 37.7). Both call sites now hash int3(neighbor)/int4(int3(cellId), 0) directly, in C# and in the HLSL mirror (both shaders/CultMath.hlsl and the Unity copy, byte-identical as before). This changes cellular's noise output — nothing has shipped, so that is acceptable, but it is a real behavioural change, not a comment fix. - The F6 exactness proof's "near-side neighbour" bound was wrong as written: picking the near-side neighbour on a FIXED axis is not always within sqrt(3) of the query (counterexample: u = (0.5, 0, 0) with the x-neighbour jittered to (-1, 1-2^-24, 1-2^-24) gives ~2.06, past the radius-2 exclusion). The comment is rewritten to the correct argument: choose the axis whose u_i sits closest to a cell boundary (m = min(u_i, 1-u_i) <= 1/2 on that axis), and the near-side neighbour on THAT axis has squared distance at most (1+m)^2 + 2*(1-m)^2 = 3 - 2m + 3m^2 <= 3 on [0, 1/2], strictly below 3 since the jitter never reaches the boundary. Margin 2 - sqrt(3) ~= 0.268 (Soul's adversarial check: worst in-box F2 is exactly sqrt(3), only in the unattainable corner limit). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> |
||
| .. | ||
| Runtime | ||
| Shaders | ||
| CHANGELOG.md | ||
| CHANGELOG.md.meta | ||
| LICENSE.md | ||
| LICENSE.md.meta | ||
| package.json | ||
| package.json.meta | ||
| README.md | ||
| README.md.meta | ||
| Runtime.meta | ||
| Shaders.meta | ||
| THIRD-PARTY-NOTICES.md | ||
| THIRD-PARTY-NOTICES.md.meta | ||
CultMath for Unity
This is CultMath's Unity 2021.3-compatible Git-UPM surface. It contains the
precompiled CultMath.dll, portable symbols, the numeric
Shaders/CultMath.hlsl mirror, and the CultMath.UnityBridge assembly.
CultMath.UnityBridge is the only C# source Unity compiles here. It holds the
UnityEngine conversions the engine-free core cannot declare: ToCultMath() on
Vector2/3/4, Vector2Int/3Int, Quaternion, and Color; ToUnity() on
float2/3/4, int2/3, and quaternion; ToColor() on float4. C# only
admits conversion operators on the source or target type, so these are
extension methods rather than implicit casts. Import CultMath.UnityBridge to
use them.
Unity does not compile CultMath's repository source tree. That source uses the
current C# language and remains owned by the normal .NET project. The package
imports only the tracked auto-referenced precompiled assembly, so consumers do
not need csc.rsp language overrides or an asmdef propagation shim.
Build and inspect the package from the repository root:
.\scripts\build-unity-package.ps1
The builder fresh-builds CultMath for netstandard2.1, verifies the tracked
DLL/PDB and stable Unity metadata, and stages an inspectable package under
artifacts/unity/org.gamecult.cultmath.
Consume the repository package with:
"org.gamecult.cultmath": "https://github.com/GameCult/CultLib.git?path=/packages/cultmath/unity/org.gamecult.cultmath"
Production consumers should pin that URL to a commit or release tag.