Wednesday, March 11, 2015

Passing scaled coordinate data to noise with tiling algorithm

So for the formula,

Ftileable(x, y) = ( F(x, y) * (w - x) * (h - y) + F(x - w, y) * (x) * (h - y) + F(x - w, y - h) * (x) * (y) +
       F(x, y - h) * (w - x) * (y)) / (wh)

It is important when scaling coordinate data ensuring the proper w,h values are provided.

Thus if having chosen based upon iterated integer coordinate values i,j

double x = ((double)i) / scale;
double y = ((double)j) / scale;

Ftileable formulation necessarily changes.  One because one need ensure that one chooses on a given noise coordinate position positions in the neighboring (theoretical) tile.  Thus passing the coordinate
double xp = x-512;

is not right since coordinate values are being in this incremented by 1/513 float values to the noise function, and the coordinate xp is well outside the prescribed neighboring region for the given formulation.

Instead,

double xp = x - 512.0f/scale;
and correspondingly
double yp = y - 512.0f/scale;

Also weighting factors need be adjusted accordingly.  Otherwise, noise values are weighted improperly.

double ws = w/scale for w

and

double hs =  h/scale for h.

also the factor
wh
changes to

wh/(scale*scale)

so the formula with scaling changes to

Ftileable(x, y) = ( F(x, y) * (ws - x) * (hs - y) + F(x - ws, y) * (x) * (hs- y) + F(x - ws, y - hs) * (x) * (y) +
       F(x, y - h) * (w - x) * (y)) /( (wh)/(scale*scale))

  

No comments:

Post a Comment

Oblivion

 Between the fascination of an upcoming pandemic ridden college football season, Taylor Swift, and Kim Kardashian, wildfires, crazier weathe...