From d0aaa4cdf5c1e53f4b8850cd84c71091322f2d2d Mon Sep 17 00:00:00 2001 From: Ken Simpson Date: Sat, 4 Oct 2025 16:09:53 -0700 Subject: [PATCH] Fix simplex gradient tensor construction --- __init__.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/__init__.py b/__init__.py index 667f993..8332517 100644 --- a/__init__.py +++ b/__init__.py @@ -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,