FastNoise2 icon indicating copy to clipboard operation
FastNoise2 copied to clipboard

Double support?

Open sfla opened this issue 2 years ago • 11 comments

The examples output to a vector<float>, and I find no mention of Doubles. Having used the older FastNoise, I remember I could just add #define FN_USE_DOUBLES. Is there similar support here?

sfla avatar Jan 28 '22 13:01 sfla

Spooky. I googled around, and found a similar question posted on the FastNoiseSIMD. Asked by ME two years ago. https://github.com/Auburn/FastNoiseSIMD/issues/44

Anyway, I also found the even older question, with answer, here: https://github.com/Auburn/FastNoiseSIMD/issues/4#issuecomment-725702763 So I assume it's not in yet.. Unfortunately, that's a deal breaker for my use case.

sfla avatar Jan 28 '22 13:01 sfla

https://github.com/users/Auburn/projects/1#card-49182907 It's on the todo list. I am also eager to see this implemented, and willing to help. @Auburn what all is involved in refactoring for double-precision input functions?

connorjak avatar Feb 16 '22 00:02 connorjak

It's quite a difficult task, there would need to be special versions for most the coherent noise nodes so as not to half the performance. FastSIMD would also need support for doubles which is a reasonable amount of work, although hopefully easier to do with the new version I'm working on.

Auburn avatar Feb 16 '22 09:02 Auburn

Ideally this could be done without a macro that disables single-precision support.

I had a look at the code and it seems like this is the workload:

  • Duplicate FastNoise Utils.h and FastSIMD FunctionList.h and their dependencies with doubles, maybe postpending the name with 64
  • Duplicate all nodes with doubles, revising binary operations
  • Optionally implement SIMD specializations on those nodes
    • For initial support, it might be ok to use doubles without explicit SIMD support. The APIs would be unchanged when the SIMD side would be built out.

connorjak avatar Feb 18 '22 03:02 connorjak

@Auburn what's the order of magnitude for the timeframe you're expecting for the FastSIMD replacement? I'm evaluating my options for what noise library I should go forward with for now. I would prefer to stick with FastNoise2 for the NoiseTool, graph structure, and the super-fast iteration times from the serialized string noise function encoding.

ScreenShot00067

I'm trying to resolve roundoff error issues from the noise input values being indistinguishable at super-high sampling density with these constraints:

  • No repeated data across the entire domain
  • Evaluate function at double precision coordinates
    • Adjacent sampled points on centimeter scale (with full domain at real-size planet scale) must not have stair-stepping artifacts (most likely caused by rounded-to-be-indistinguishable adjacent input coordinates)
  • Function output value can be either single or double precision
    • Single precision float maintains ~1mm accuracy at 10km, and ~1cm accuracy at 100km. For planetary terrains, elevation changes typically cap out at +-40km from sea level.
  • I personally only use the single-point-sampling for now; my sampling coordinates are not 2D cartesian so the uniform grid approach does not work for me.
  • Performance is not a major concern for me, at least initially. My generation functions are fully async.

connorjak avatar Feb 19 '22 15:02 connorjak

Hi, the approach in your first would not be that easy. Maybe just converting the scalar version to doubles/int64 would be a good enough stand in for you. The problem with doubles in SIMD is many intrinsics only support floats so there is extra work in finding work arounds for those things. That other part is the performance will be halved, there are ways around this but that requires more work again.

Most of the ground work for the new FastSIMD version is now done. I've had a bit a lull in development recently due to moving house, bit I will continue shortly

Auburn avatar Feb 19 '22 16:02 Auburn

I agree, just converting the scalar version would be enough for me for now. Do the SIMD operations benefit the output functions besides the UniformGrid ones?

connorjak avatar Feb 20 '22 00:02 connorjak

I'd just like to voice my support of this feature, I will eventually need doubles for my project :)

Srekel avatar May 02 '22 10:05 Srekel

Any news on this?

so as not to half the performance.

Since the performance of FastNoise2 seems to be around 5-7x faster than FastNoiseLite, I'd still be happy if the performance was halved tbh.

sfla avatar Mar 05 '23 12:03 sfla

@Auburn Checking in on progress here; how is the newer version of FastSIMD?

connorjak avatar Apr 28 '24 00:04 connorjak

I'm currently working on getting the 1.0 version of FastNoise 2 out, that makes use of the new FastSIMD. Once the 1.0 release is done it's on my list to look at

Auburn avatar Apr 29 '24 10:04 Auburn