accidental-noise-library
accidental-noise-library copied to clipboard
SEAMLESS_XY causes the range to exceed -1..1
If I do:
anl::CKernel kernel;
anl::CArray2Dd img2d(256,256);
auto b = kernel.gradientBasis( kernel.constant(3), kernel.seed(123) );
auto c = kernel.scaleDomain( b, kernel.constant(5) );
anl::map2DNoZ( anl::SEAMLESS_XY img2d, kernel, anl::SMappingRanges(), c );
...then I see values in the image that are outside [-1,1] range.
When I use SEAMLESS_NONE, I see no such values.
Why is this?
SEAMLESS_XY uses a 4D noise function underneath (5D if you don't use map2DNoZ, though that's not your case here). SEAMLESS_NONE only uses a 2D noise function underneath. Normalization of the outputs of the higher order noise functions is a little wonky. The gradients in the table for the 2D function are normalized to unit length, but the gradients in the higher-order look-up tables are not. I don't remember the reasoning for that at this point, since that code was written over a decade ago, and I haven't really touched it much lately.
If using scaleToRange(0,1) is not enough as a fix, then you could try iterating the gradient4D_lut table and normalize those 4-tuples to unit length. If I get a chance, I'll try to figure out why I didn't do that initially, and whether I should push a commit doing that now.