Generate every HLSL swizzle and mixed constructor; fix intrinsic types
tools/generate-swizzles.ps1 writes the checked-in src/CultMath/Swizzles.g.cs
as partial structs plus a partial math: for float2/3/4, int2/3/4 and bool2/3/4
every swizzle of length 2-4 including repeats, in xyzw and rgba naming, with
setters only on non-repeating masks, plus single-component r/g/b/a. double2/3
get lengths 2-3 (there is no double4). Every HLSL mixed constructor
(float4(float2, float2), float4(float, float2, float), copy forms, ...) exists
as a struct constructor and, for float/int/bool, a math function. The
hand-written swizzles and mixed constructors it supersedes are deleted.
Matrices store private rows and return ref float2/float3 from the row
indexer ([UnscopedRef], polyfilled for netstandard2.1), so m[1][2] = s
compiles as in HLSL; _mRC are get/set properties over the rows. Equality and
hashing stay value-based.
Intrinsics follow HLSL: sign returns int/intN and yields 0 for NaN; step is
x >= y ? 1 : 0 so NaN yields 0; any/all accept float and int vectors;
min/max/abs on int vectors return int vectors, and abs(int) returns int.
Strips the UTF-8 BOMs this branch added to math.cs, CultMath.csproj and
HlslSemanticsTests.cs.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 13:57:02 +02:00
<Project Sdk= "Microsoft.NET.Sdk" >
2026-05-08 01:49:44 +01:00
<PropertyGroup >
2026-07-12 19:33:59 +01:00
<TargetFrameworks > net8.0;netstandard2.1</TargetFrameworks>
2026-05-08 01:49:44 +01:00
<ImplicitUsings > enable</ImplicitUsings>
<Nullable > enable</Nullable>
2026-07-12 19:33:59 +01:00
<LangVersion > latest</LangVersion>
2026-05-08 01:49:44 +01:00
<RootNamespace > CultMath</RootNamespace>
<AssemblyName > CultMath</AssemblyName>
2026-08-26 17:35:51 +02:00
<PackageId > GameCult.Math</PackageId>
CultMath: Cycles node semantics (Math, Map Range, Clamp, Mix, RGB to BW, ramp index) as math.Cycles.cs and CultMath.Cycles.hlsl under Apache-2.0
Ports of Blender v5.2.2's intern/cycles kernel functions, one function per node
operation, with the HLSL mirror, the Unity copy, the lowering table entry for a
separate Apache-2.0 GLSL file, the golden-fixture families, the package licence
expressions and the notices section.
Builds. Does not pass yet: CultMath.Cycles.glsl and the regenerated golden
fixture arrive in a later commit, so CommittedGlslEqualsLowering and
GoldenFixtureMatchesCSharp fail at this commit.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 03:59:59 +02:00
<!-- MIT overall; math.Phacelle.cs and CultPhasor.cs (and the two Phacelle HLSL files) are MPL - 2.0; math.Cycles.cs and CultMath.Cycles.hlsl are Apache - 2.0. -->
<PackageLicenseExpression > MIT AND MPL-2.0 AND Apache-2.0</PackageLicenseExpression>
2026-10-11 04:31:21 +02:00
<Version > 0.4.1</Version>
2026-05-08 01:49:44 +01:00
<Description > Clean-room C# math shaped for HLSL-style renderer code.</Description>
<Authors > GameCult</Authors>
<PackageReadmeFile > README.md</PackageReadmeFile>
<NoWarn > $(NoWarn);CS8981</NoWarn>
2026-06-03 02:58:56 +01:00
<AllowUnsafeBlocks > true</AllowUnsafeBlocks>
2026-09-14 14:27:44 +02:00
<!-- The Unity DLL is committed beside its source, so its bytes must not name a commit. -->
<IncludeSourceRevisionInInformationalVersion > false</IncludeSourceRevisionInInformationalVersion>
2026-05-08 01:49:44 +01:00
</PropertyGroup>
<ItemGroup >
<None Include= "..\..\README.md" Pack= "true" PackagePath= "\" />
2026-06-10 21:22:43 +01:00
<None Include= "..\..\shaders\CultMath.hlsl" Pack= "true" PackagePath= "contentFiles\any\any\shaders\CultMath.hlsl" CopyToOutputDirectory= "PreserveNewest" />
CultMath: Phacelle port moves into MPL-2.0 files; prune cut pinned by boundary points
MPL-2.0 is file-level and the Phacelle port sat inside MIT files. phacelle and
CultPhasor now live in math.Phacelle.cs and CultPhasor.cs, and cultmath_phacelle
in CultMath.Phacelle.hlsl (included by CultMath.hlsl, both tracked copies), each
with the MPL header and Johansen / Luke Mitchell attribution. math stays one
partial class, so math.phacelle is called exactly as before. The GameCult.Math
package declares MIT AND MPL-2.0 and packs THIRD-PARTY-NOTICES.md and the new
include; the Unity LICENSE.md points at CultLib; build-unity-package.ps1
requires the new include.
The random sweeps never met a cell whose box bound sits just under the 2.25 cut
while its weight is still nonzero, so cuts of 2.245, 2.24 and 2.2 survived.
Six hard-coded points (found by an offline search) sit next to such cells; the
C# pruned-vs-unpruned test and the HLSL mirror test both use them, with a
witness check that re-derives the property from the hash.
Docs: the prune keeps about 45 of 64 cells (14 is the nonzero-weight count),
the support radius is 1.49998 (d^2 = 2.24995), normalization's range and
saturation, W = 0 only for adversarial hashes, and the support-edge gradient
seam size.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 00:34:27 +02:00
<None Include= "..\..\shaders\CultMath.Phacelle.hlsl" Pack= "true" PackagePath= "contentFiles\any\any\shaders\CultMath.Phacelle.hlsl" CopyToOutputDirectory= "PreserveNewest" />
CultMath intervals: cultmath_iv_* over float2(lo, hi) in C# and HLSL, with snoise and fbm ball bounds
math.Interval.cs and shaders/CultMath.Interval.hlsl (included from CultMath.hlsl after Phacelle;
both tracked copies) add iv_point, iv_add, iv_sub, iv_neg, iv_mul, iv_scale, iv_abs, iv_min,
iv_max, iv_sqr, iv_sqrt, iv_exp, iv_clamp, iv_saturate, iv_smoothstep, iv_lerp, iv_snoise_ball
and iv_fbm_ball, and SNOISE_LIPSCHITZ = 10.099261 (1.10 x the refined max |snoise_grad| that
NoiseBoundTests.MeasureLipschitz prints). iv_exp and iv_smoothstep widen by one ulp through
asfloat(uint), added beside asuint as the HLSL intrinsic. The mirror test now compares 52
functions; the Unity package and the NuGet content files carry the new include.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 19:52:33 +02:00
<None Include= "..\..\shaders\CultMath.Interval.hlsl" Pack= "true" PackagePath= "contentFiles\any\any\shaders\CultMath.Interval.hlsl" CopyToOutputDirectory= "PreserveNewest" />
2026-10-09 22:03:43 +02:00
<None Include= "..\..\shaders\CultMath.Affine.hlsl" Pack= "true" PackagePath= "contentFiles\any\any\shaders\CultMath.Affine.hlsl" CopyToOutputDirectory= "PreserveNewest" />
CultMath: Cycles node semantics (Math, Map Range, Clamp, Mix, RGB to BW, ramp index) as math.Cycles.cs and CultMath.Cycles.hlsl under Apache-2.0
Ports of Blender v5.2.2's intern/cycles kernel functions, one function per node
operation, with the HLSL mirror, the Unity copy, the lowering table entry for a
separate Apache-2.0 GLSL file, the golden-fixture families, the package licence
expressions and the notices section.
Builds. Does not pass yet: CultMath.Cycles.glsl and the regenerated golden
fixture arrive in a later commit, so CommittedGlslEqualsLowering and
GoldenFixtureMatchesCSharp fail at this commit.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-12 03:59:59 +02:00
<None Include= "..\..\shaders\CultMath.Cycles.hlsl" Pack= "true" PackagePath= "contentFiles\any\any\shaders\CultMath.Cycles.hlsl" CopyToOutputDirectory= "PreserveNewest" />
CultMath: Phacelle port moves into MPL-2.0 files; prune cut pinned by boundary points
MPL-2.0 is file-level and the Phacelle port sat inside MIT files. phacelle and
CultPhasor now live in math.Phacelle.cs and CultPhasor.cs, and cultmath_phacelle
in CultMath.Phacelle.hlsl (included by CultMath.hlsl, both tracked copies), each
with the MPL header and Johansen / Luke Mitchell attribution. math stays one
partial class, so math.phacelle is called exactly as before. The GameCult.Math
package declares MIT AND MPL-2.0 and packs THIRD-PARTY-NOTICES.md and the new
include; the Unity LICENSE.md points at CultLib; build-unity-package.ps1
requires the new include.
The random sweeps never met a cell whose box bound sits just under the 2.25 cut
while its weight is still nonzero, so cuts of 2.245, 2.24 and 2.2 survived.
Six hard-coded points (found by an offline search) sit next to such cells; the
C# pruned-vs-unpruned test and the HLSL mirror test both use them, with a
witness check that re-derives the property from the hash.
Docs: the prune keeps about 45 of 64 cells (14 is the nonzero-weight count),
the support radius is 1.49998 (d^2 = 2.24995), normalization's range and
saturation, W = 0 only for adversarial hashes, and the support-edge gradient
seam size.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-30 00:34:27 +02:00
<None Include= "..\..\THIRD-PARTY-NOTICES.md" Pack= "true" PackagePath= "\" />
2026-05-08 01:49:44 +01:00
</ItemGroup>
</Project>