Archived

This topic is now archived and is closed to further replies.

Ramius

How does one generate tileable, 2D procedural textures?

Recommended Posts

So I''ve got this nifty little cloud generation algorithm figured out, at the heart of which is a 2D Perlin Noise generator. I can create a tileable version (ie. repeatable with no visible seams) of any texture it spits out in one dimension by variably blending the target section of texture with an axis-adjacent section of equal size. For an example, think of a single 200x100 pixel bitmap that displays a nice seamless view of partially clouded sky. Now let''s say that we just want the rightmost 100x100 half of the bitmap, but we want it in such a way as to be tileable along the x-axis. In other words, if we were to put ten instances of this smaller texture side-by-side horizontally, they should appear to be one seamless pattern (repetitious yes, but seamlessly so ). Now the most obvious way to accomplish this is to iteratively blend the pixel columns of the rightmost 100x100 section with the pixel columns of the leftmost 100x100 section, starting with 100% opacity for the rightmost piece and 0% opacity for the left-most piece, and then linearly inverting the opacity of each section as we move from left-to-right (ending up with 0% opacity for the rightmost, 100% for the leftmost). If you didn''t follow that, I apologize, as I can be pretty bad at explaining things. Anyways, this method works fairly well for procedural-type images, and has of course been implemented in many a paint program. What I can''t seem to be able to figure out for the life of me is how to expand this method to encompass more than a single dimension. I''m sure there''s some incredibly obvious concept that I''ll soon be beating myself over the head for not realizing earlier, but I''ve spent too much time on this already (I''ve still got a ton of other things to code ), so I figured it would be more efficient to cry for help. My thanks in advance to whoever responds. - Daniel Roth, Programmer / Web Developer (www.rothware.com, www.cwu.edu)

Share this post


Link to post
Share on other sites
I wouldn''t even use that method for one dimension. At the heart of your Perlin noise function, there is a function that assigns random values to points with integer coordinates. Just use the modulus operator to force the integer to repeat every, say, 32 steps. That should generate an image that repeats with period 32, and then you can easily extract a tile. This method limits a little bit what you can do when combining multiple octaves (no rotations allowed, for instance).

Share this post


Link to post
Share on other sites
quote:
I wouldn't even use that method for one dimension.


Well, in my defense, the method I described will work on any bitmap data regardless of how it was created (with varying degrees of success of course).

quote:
At the heart of your Perlin noise function, there is a function that assigns random values to points with integer coordinates. Just use the modulus operator to force the integer to repeat every, say, 32 steps.


But... I just knew I was missing some obvious solution such as this. I had thought of something along these lines before, but had erroneously concluded that it would create a "choppy" pattern. On closer inspection, and having remembered that the Perlin Noise algorithm has built in smoothing (interpolation, whatever ), I've decided that this just might work acceptably.

I'll do a trial implementation immediately, and let you know how it goes. Thanks for the help. ^_^

Update: I've got it up and running (somewhat), and while it does add a degree of "chunkiness" to the texture (probably due to each octave using the same period), I think I can negate the effect with some increased post-processing.

- Daniel Roth,
Programmer / Web Developer

(www.rothware.com, www.cwu.edu)

[edited by - Ramius on January 5, 2004 11:46:13 PM]

Share this post


Link to post
Share on other sites