Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 32 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Noiz is not:

| Bevy version | noiz version |
|--------------|--------------|
| 0.16 | 0.1 |
| 0.16 | 0.1, 0.2 |

## What Makes Noiz Unique?

Expand Down Expand Up @@ -233,15 +233,15 @@ Time (milliseconds) per 1024 ^ 2 = 1048576 samples. Lower is better.
| Noise Type | noiz | noise | libnoise | fastnoise_lite |
|-----------------------|-------------|--------------|----------------|-----------------|
| value | 1.7365 ✅ | 3.1 | 1.8831 ✅ | 14.8 |
| value fbm 2 octave | 7.0 | 8.6 | 5.8 ✅ | 31.4 |
| value fbm 8 octave | 28.6 | 33.4 | 22.0 ✅ | 112.0 |
| perlin | 3.1 ✅ | 8.8 | 3.0 ✅ | 8.1 |
| perlin fbm 2 octave | 8.0 ✅ | 18.4 | 8.1 ✅ | 17.2 |
| perlin fbm 8 octave | 33.5 | 71.8 | 31.1 ✅ | 58.0 |
| simplex | 6.8 ✅ | 8.6 | 8.1 | 10.6 |
| simplex fbm 2 octave | 14.5 ✅ | 22.3 | 17.7 | 21.6 |
| simplex fbm 8 octave | 56.3 ✅ | 108.5 | 89.2 | 116.0 |
| worley | 5.6 ✅ | 24.5 | 11.8 | 17.8 |
| value fbm 2 octave | 7.1 | 8.6 | 5.8 ✅ | 31.4 |
| value fbm 8 octave | 29.5 | 33.4 | 22.0 ✅ | 112.0 |
| perlin | 3.4 ✅ | 8.8 | 3.0 ✅ | 8.1 |
| perlin fbm 2 octave | 8.6 ✅ | 18.4 | 8.1 ✅ | 17.2 |
| perlin fbm 8 octave | 36.7 | 71.8 | 31.1 ✅ | 58.0 |
| simplex | 7.0 ✅ | 8.6 | 8.1 | 10.6 |
| simplex fbm 2 octave | 14.7 ✅ | 22.3 | 17.7 | 21.6 |
| simplex fbm 8 octave | 57.8 ✅ | 108.5 | 89.2 | 116.0 |
| worley | 5.7 ✅ | 24.5 | 11.8 | 17.8 |
| worley approximate | 2.8 ✅ | --- | --- | --- |

### 3D
Expand All @@ -250,17 +250,17 @@ Time (milliseconds) per 101 ^ 3 = 1030301 samples. Lower is better.

| Noise Type | noiz | noiz `Vec3A` | noise | libnoise | fastnoise_lite |
|-----------------------|-------------|--------------|----------------|-----------------|-----------------|
| value | 3.0 | 7.4 | 11.4 | 2.7 ✅ | 39.6 |
| value fbm 2 octave | 11.8 | 15.8 | 22.5 | 8.2 ✅ | 85.7 |
| value fbm 8 octave | 55.3 | 61.4 | 89.3 | 33.5 ✅ | 336.6 |
| perlin | 7.1 | 9.9 | 76.9 | 6.4 ✅ | 13.8 |
| perlin fbm 2 octave | 19.6 | 20.1 | 28.5 | 15.8 ✅ | 29.7 |
| perlin fbm 8 octave | 80.3 | 75.4 | 368.9 | 69.7 ✅ | 132.0 |
| simplex | 12.6 ✅ | 17.0 | 14.2 | 16.3 | 20.1 |
| simplex fbm 2 octave | 26.7 ✅ | 32.9 | 51.8 | 25.9 ✅ | 43.0 |
| simplex fbm 8 octave | 106.9 ✅ | 126.2 | 207.8 | 181.7 | 175.1 |
| worley | 53.3 | 53.6 | 78.9 | 52.9 | 42.3 ✅ |
| worley approximate | 6.2 ✅ | 13.6 | --- | --- | --- |
| value | 3.0 | 7.8 | 11.4 | 2.7 ✅ | 39.6 |
| value fbm 2 octave | 13.2 | 16.0 | 22.5 | 8.2 ✅ | 85.7 |
| value fbm 8 octave | 56.8 | 60.7 | 89.3 | 33.5 ✅ | 336.6 |
| perlin | 7.1 | 11.4 | 76.9 | 6.4 ✅ | 13.8 |
| perlin fbm 2 octave | 17.4 | 23.0 | 28.5 | 15.8 ✅ | 29.7 |
| perlin fbm 8 octave | 76.4 | 86.4 | 368.9 | 69.7 ✅ | 132.0 |
| simplex | 12.9 ✅ | 17.6 | 14.2 | 16.3 | 20.1 |
| simplex fbm 2 octave | 27.3 ✅ | 33.5 | 51.8 | 25.9 ✅ | 43.0 |
| simplex fbm 8 octave | 108.7 ✅ | 129.8 | 207.8 | 181.7 | 175.1 |
| worley | 54.8 | 57.4 | 78.9 | 52.9 | 42.3 ✅ |
| worley approximate | 6.2 ✅ | 14.9 | --- | --- | --- |

`Vec3A` is an aligned 3d type from `bevy_math` (glam). It enables SIMD instructions, but uses more memory to do so.
As you can see, it's not worth it here.
Expand All @@ -271,17 +271,17 @@ Time (milliseconds) per 32 ^ 4 = 1048576 samples. Lower is better.

| Noise Type | noiz | noise | libnoise | fastnoise_lite |
|-----------------------|-------------|--------------|----------------|-----------------|
| value | 13.5 | 21.2 | 3.9 ✅ | --- |
| value fbm 2 octave | 27.5 | 46.0 | 14.3 ✅ | --- |
| value fbm 8 octave | 106.7 | 167.3 | 57.3 ✅ | --- |
| perlin | 16.9 ✅ | 177.6 | 17.6 | --- |
| perlin fbm 2 octave | 37.3 ✅ | 53.5 | 38.4 | --- |
| perlin fbm 8 octave | 141.5 ✅ | 824.2 | 203.1 | --- |
| simplex | 18.2 ✅ | 35.5 | 29.5 | --- |
| simplex fbm 2 octave | 35.7 ✅ | 108.8 | 41.0 | --- |
| simplex fbm 8 octave | 137.1 ✅ | 421.0 | 234.4 | --- |
| worley | 185.3 | 156.3 ✅ | 205.8 | --- |
| worley approximate | 26.6 ✅ | --- | --- | --- |
| value | 13.8 | 21.2 | 3.9 ✅ | --- |
| value fbm 2 octave | 27.7 | 46.0 | 14.3 ✅ | --- |
| value fbm 8 octave | 109.0 | 167.3 | 57.3 ✅ | --- |
| perlin | 17.5 ✅ | 177.6 | 17.6 | --- |
| perlin fbm 2 octave | 38.3 ✅ | 53.5 | 38.4 | --- |
| perlin fbm 8 octave | 146.1 ✅ | 824.2 | 203.1 | --- |
| simplex | 18.8 ✅ | 35.5 | 29.5 | --- |
| simplex fbm 2 octave | 36.6 ✅ | 108.8 | 41.0 | --- |
| simplex fbm 8 octave | 139.3 ✅ | 421.0 | 234.4 | --- |
| worley | 186.8 | 156.3 ✅ | 205.8 | --- |
| worley approximate | 26.3 ✅ | --- | --- | --- |

### Summary

Expand Down Expand Up @@ -319,10 +319,3 @@ Use `libnoise` if you don't need a ton of configuration, are using relatively sm
If you absolutely need `f64` support, use `libnoise`, but again, the permutation table rng makes the large domain kinda a moot point. Same goes for `noise`.
If you are integrating with `bevy`, need lots of customization, need general, high performance, or need serialization and reflection, use `noiz`.
I am not aware of a reason to use `noise` (though there may well be one I'm missing).

## Rough Roadmap

- [ ] Optimize with fastmath coming in rust 1.88
- [ ] Add dynamic types to switch between noise functions via reflection.
- [ ] (Maybe) Let noise types generate WESL code. (Specify noise in rust, build to WESL.) Possible, but maybe not worth it.
- [ ] Any reasonable suggestions that come in.
70 changes: 70 additions & 0 deletions changelog/release_0-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Release 0.2

This is a small release, mostly focusing on rounding some rough edges from 0.1.
If there are any issues you run across, please don't hesitate to open an issue!

## Enhancements

When collecting results of layered noise, `Normed` and `NormedByDerivative` can now collect gradients. Ex: `Normed<WithGradient<f32, Vec2>>`.
This is the proper way to collect gradient information of fractal layered noise and is very useful for things like analytical normals for mesh generation.

A new noise function, `WithGradientOf`, can now be used to "fudge" a gradient value.
Although this will not be correct, it can be artistically useful when paired with `NormedByDerivative`, or other systems that use gradient information to affect the output.

A new `Lerped` curve now allows interpolating between vector space values.
This is particularly helpful when combined with the new `RemapCurve` noise function.

A noise function, `Translated`, has been added to replace the `Offset<Constant>` pattern.

The `prelude::common_noise` module has been expanded to include derivatives of common noise.
In general, I prefer to use the noise types directly, rather than these aliases; that opens up more customization and demystifies the actual algorithm.
However, in some places, shorter names are preferred, and now derivatives are possible there too.

## Bug Fixes

It's hard to define a "bug" when it comes to noise, since there's no real correct vs incorrect for most systems; just whether or not it "feels" random enough in the right ways.
That said, there were a few bug-like fixes over 0.1.

Some gradients were not mathematically rigorous; they were often "good enough", but they weren't correct.
Many of these are now fixed, including simplex noise, fractal noise, masked noise, and linearly mapped noise (like `UNormToSNorm`).
Notably, `Abs`, `Billow`, and `NormedByDerivative` are still not mathematically rigorous.
These do not appear to be classically differentiable, but "good enough" implementations are still provided.

Perlin noise is now normalized to ±1; it was ±(1/√N) where N was the number of dimensions.
This was previously not normalized for performance (it's a linear scale, which the user will configure anyway), but it has been fixed to help with usability.
With fast-math coming in rust 1.88, this will be made zero cost in the future.

## Migration Guide

`Blender` and `DiferentiableGradientBlender` have been replaced by `ValueBlender`, `DifferentiableValueBlender`, `GradientBlender`, and `DifferentiableGradientBlender`.
The functionality of these traits remains the same, but this separation allows more specific implementations.

The `LayerOperationFor` trait has been expanded over the new `LayerResultContextFor`.
This will not affect most users, but if you were making custom layers, this will need to be migrated.

`Scaled` now scales directly rather than going through a nested noise function.
If you want the previous behavior, use `Masked`.

I have deliberately kept this brief, as these changes are unlikely to affect anyone, but if you have any trouble migrating, please open an issue!

## What's next

It's hard to predict the future here, as I have limited time, and lots of my ideas here depend on other projects.
However, there are some things I'd like to explore for the future:

- 64 bit support: Noiz is powered by bevy_math, which is growing to support 64 bit precision.
When that work is complete, Noiz will upgrade to support `f64` based inputs and outputs.
- even faster: Rust 1.88 brings support for fast-math, offering some insane performance opportunities at the cost of precision.
This will probably be an opt-out feature, as it is not without downsides, but this is still up for debate.
- Other rng backends: Noiz is powered by a *very* specialized and optimized random number generator.
Some power users may want to make their own generators to either sacrifice quality for speed or speed for quality.
- GPU support: This is especially tricky to think about.
Some forms of noise don't even make sense on the GPU (but lots do!).
As projects like WESL and rust GPU make more progress, I'd like to explore getting noiz on the GPU.
This is still a long way off but is something I'm looking into.
- Reflection noise types: As bevy editor prototypes and progress continues, making the noise types more customizable and changeable at runtime is important.
Adding more reflection support will help with this.
Designing this features is difficult without compromising speed, so don't expect this too soon, but know that it is in the works!

If you have any other requests, please open an issue or PR!
Feedback is always welcome as I work to make this the "go to" noise library for bevy and rust.