How to sample noise beyond data type size?

Started by
9 comments, last by swiftcoder 3 years, 3 months ago

I was planning to make a game with “infinite” world by saving offsets and rebasing world center for different chunks, but how should I handle Perlin/simplex noise sampling if I need to sample point that is farther than 4byte integer can handle?

Advertisement

Your points are inside one map chunk: you can assemble high precision point coordinates, for use as simplex noise inputs, from the position of the chunk in the whole map and the position of the point in the chunk (e.g. 64 bits integers from two 32 bits integers). Unsigned coordinates would probably be easier to use.

Omae Wa Mou Shindeiru

If you are talking about doing it on the CPU, just do the noise part in double precision. Another way to do it is to tile your noise. That's more conceptually simpler with Perlin noise than simplex noise, and unless you are using it for texturing it's probably not what you want since it will give you repeated terrain if you are using it for geometry.

Thanks for the suggestions that are valid approaches, sorry I was not clear with my intentions.

I'm trying to solve a problem where player can get infinitely far from center, so over time it won't fit into 4 8 16 and so on bytes, so I'm probably need a more generic solution. my world is stored as a hierarchical structure where only leaf chunks are loaded and player coordinates are rebased to them so it can scale indefenetly. But I have no idea how to sample noise without using big integer or any other arbitrary precision math to keep things performant.

@MarkNefedov How fast do players move? At walking speeds your player would die of old age before double was a problem. Perhaps I'm not understanding something but seems there is some practical limit since your base value must have a byte size too. You can use a big int as fixed point, but that seems a little much and probably quite slow. Another thing is your rarely use straight noise. You typically combine octaves in odd ways. Therefore if you tiled your base noise functions using different moduluses, the various combinations should give you different terrain most everywhere.

May I ask what's the point in having so much terrain? Even a single planet has so much terrain a player can't see it all and you can have multiple planets.

But I have no idea how to sample noise without using big integer or any other arbitrary precision math to keep things perfomant.

If you use doubles for coordinates, the noise can be done still with floats internally to help performance. Example here: https://iquilezles.org/www/articles/smoothvoronoi/smoothvoronoi.htm

Tiling should not be visible even if you use only one octave. But it's not clear if you worry about visual artifacts or about performance due to precision.

… actually i remember i can show an extreme example:

Sorry for the cracks, but for displacement i use voronoi noise, two octaves IIRC.

But it works with precomputed poisson samples, which would look much better than the jittered grid we use usually.

So i have a periodic block of poisson samples, but only 1024 samples. So the pattern repeats after only 10 bumps.

On curved surface like this, i never noticed repetition so far. But on flat surface it pops up quickly. However, with jittered grid you can use a million^3 of samples easily and with no extra cost before the pattern repeats. This will never be visible.

Maybe that's generally interesting for those working on the dream of procedural planets :D…

Here is 2D version using poisson samples:

Repetition is noticable, but the pattern looks more uniform than jittered grid:

… where samples often end up very close, giving artifacts in practice.

I have used this tool to generate the samples (which would run out of memory if i wanted more of them, haha): https://github.com/bartwronski/PoissonSamplingGenerator

But 1000 samples would fit into constant ram on GPU easily, so maybe that's worth it in some cases.

@Gnollrunner I'm mostly doing this for the sake of being, like a proof of concept. I was playing minecraft and hit world border in a week, so I want to make a “true infinite world”? just because it seems as an interesting problem to solve.

MarkNefedov said:
I want to make a “true infinite world”

You typically have two problems here.

The first is how to maintain floating point precision far from the world origin. The solution is generally pretty straightforward - you use a very high precision type (double, or even larger types, possibly implemented in software) for chunk locations, but you perform all operations in chunk-local space (i.e. subtract the chunk location before computing).

The second one, is how to have “infinite” variation. In practice perlin/simplex/etc noise just isn't very random at large scales. You can combine multiple octaves of different types of noise (I used 100+ octaves of noise for procedural planets), but even with this approach you will have repeating features long before you approach infinite.

In practice I'm not sure if anyone will notice if you just loop the world every thousand kilometres or so… That's by far the easiest solution ?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement