Fix simplex gradient tensor construction

This commit is contained in:
Ken Simpson
2025-10-04 16:09:53 -07:00
parent 863d603db6
commit d0aaa4cdf5
+14 -12
View File
@@ -236,20 +236,22 @@ def _simplex_noise_2d(x, y, perm, dtype):
gi1 = perm[ii + i1_int + perm[jj + j1_int]] % 12
gi2 = perm[ii + 1 + perm[jj + 1]] % 12
inv_sqrt2 = 1.0 / math.sqrt(2.0)
gradients = torch.tensor(
[
[1, 1],
[-1, 1],
[1, -1],
[-1, -1],
[1, 0],
[-1, 0],
[0, 1],
[0, -1],
[1, 1] / math.sqrt(2.0),
[-1, 1] / math.sqrt(2.0),
[1, -1] / math.sqrt(2.0),
[-1, -1] / math.sqrt(2.0),
[1.0, 1.0],
[-1.0, 1.0],
[1.0, -1.0],
[-1.0, -1.0],
[1.0, 0.0],
[-1.0, 0.0],
[0.0, 1.0],
[0.0, -1.0],
[inv_sqrt2, inv_sqrt2],
[-inv_sqrt2, inv_sqrt2],
[inv_sqrt2, -inv_sqrt2],
[-inv_sqrt2, -inv_sqrt2],
],
dtype=dtype,
device=x.device,