Computable 2D random-ish function with scale-invariant features

33 Views Asked by At

I'm looking for a function; probably vaguely related to fractals, the Weierstrass function, etc. Here's the motivation. Say I'm developing a game, similar in ways to Minecraft: there's an infinite world, randomly generated. However, my overall impression in Minecraft is that once you zoom out a ways, the world becomes kindof uniform. I could be wrong, but I don't think there are any hugely massive deserts or the like. I wish to see if it can be done differently. What I would like, what I suspect exists, but what I'm not sure how to generate, is a function $F:R^n\rightarrow R$ with ideally the following properties:

  1. Features at any scale
  2. Continuous
  3. Random-ish
  4. Computable

Suppose that I use such a function over $R^n$ to determine, say, the "corruption" of an area in the game. You might be in a relatively fine area, with a few small patches of slight corruption scattered around nearby, and a few hundred feet away there'd be a larger area of deeper corruption, and a billion blocks away there's a massive sinkhole of horrible corruption a million blocks in diameter - and maybe this is all taking place in the foothills of a trillion-block-diameter mountain of holy land or something. Since the function is computable, each block can determine its own level of corruption without having to look to one of its neighbors, which would make million-block-diameter features infeasible. Is there a function that could work for this? Can I contort the Weierstrass function into a usable form, perhaps, or is there something more inherently appropriate?

1

There are 1 best solutions below

0
On

One way to do this is to hash grid coordinates for use as parameters for Perlin noise. Combine a few "octaves" of noise at different frequencies to get fractal structure. It's deterministic noise because the hashing from coordinates (used as pseudo-random number generator) is deterministic. I found some example code with images, there is also the libnoise coherent noise library.