20160921

Parallel Noise Generation

Re a related Twitter Post ...

Concerning making tile-able textures for grain or noise, and getting various desired properties. My preference is towards algorithms which parallelize trivially. The shadertoy referenced in the tweet generates a noise pattern, by starting out with some poor non-random noise, then applying filters (ending with a high-pass) to transform it into something which is pleasing to the eye. I'd advise always using the technique I outlined in this GPUOpen Post which remaps the texture to a perfect distribution of values (see the follow up post as well) while maintaining it's original form (this applies to both techniques in this post).

A second technique I've leveraged in the past is to work with one {x,y} coordinate for a grain position distributed in a regular grid array of grains. Starting with the perfect honeycomb distribution (start from a regular grid position, where every other row is shifted to the left or right, and make the grid have proper aspect ratio for honeycomb),

_x_x_x_x_x_x_x_x
x_x_x_x_x_x_x_x_
_x_x_x_x_x_x_x_x
x_x_x_x_x_x_x_x_
_x_x_x_x_x_x_x_x
x_x_x_x_x_x_x_x_
_x_x_x_x_x_x_x_x
x_x_x_x_x_x_x_x_


Then permuting grain position by some function (which could be a noise function with various distributions based on frequency, or perhaps do some kind of clustered rotation of points by nearest cluster, etc). This process typically results in undesired look. Then applying various passes on the array where the position of each grain is filtered against the positions of the pre-filtered neighbors (only dependent on prior pass). The point being to re-shape the array into something which has a more visually pleasing feel. The filter can work with a hex neighborhood (neighbors depend on if the pixel is on a even or odd row),

_x_x_ ... ab_ ... _ab
x_x_x ... cde ... cde
_x_x_ ... ef_ ... _ef


Could be something as easy as relaxing the position of the point (push the point in the direction towards being equal distance from neighbors, but not so much that one resets to a honeycomb). After getting grains distributed as desired, can use for {x,y} coordinates, or transform back into an image of grain (which could be a different resolution image).

1 comment:

  1. "transform back into an image of grain" - would that be by splatting 2D-gaussians or similar at the positions?

    There are plenty of algorithms out there to generate blue noise sample-points, but I haven't been able to do a good conversion to bitmaps (matrix/array in litterature). Seems it should be doable...

    ReplyDelete