splatNoiseOffset function

(double, double) splatNoiseOffset(
  1. double identity
)

splat_hashed.frag's offset into the 64 × 64 noise tile for a splat's identity, a whole number in [0, 4096): column and row, each whole.

A permutation of the tile's cells, so two identities never share one: an affine step and 2a² + a modulo 4096, then the high six bits stirred into the low six. Every product stays under 2^24 and every divisor is a power of two, so a GPU's 32-bit floats and these doubles give the same answer.

Implementation

(double, double) splatNoiseOffset(double identity) {
  final affine = (identity * 1597.0 + 2531.0) % 4096.0;
  final mixed = (affine * ((2.0 * affine + 1.0) % 4096.0)) % 4096.0;
  final row = (mixed / 64.0).floorToDouble();
  return ((mixed + row * 37.0) % 64.0, row);
}