For Mr. Herman. Debuggin Perlin.

Posted on June 18, 2011

0


 

Hi Josh,
I think the including the types will help make it clear that integer division is used and help illuminate the lines that confused you (and others).
Quickly looking at your code; I cannot see a problem. The cosine interpolation may be the culprit. Put in linear interpolation, and see if your interim images look better. Otherwise, there might be a problem with the pseudocode o_0.
First, test that it is not an issue with the size of the image; test the algorithm with a power-of-two image. (I see your image has 6×6 squares, if you use a power-of-two image, You should also have a power-of-two number of squares).
Second, verify that the blend variables are calculated correctly. Make the pixel colour the same as vertical_blend; each square in the image should look the same, with a downwards ramp from black to almost white.
Do the same with horizontal_blend (in this case ramps are left to right).
Third, test that the correct pixels are sampled. Make the pixel colour the left colour. You should then have an image with blocks of different shades of grey. Save the image, and repeat the experiment, but this time, make the pixle colour the right sample point. Now compare the images – they should be the same, except translated to the left (or right) by the sample_period.
If this test passes, do the same with top and bottom.
Try that, and let me know if you find the problem.
– Herman

generateSmoothNoise() octave 7, size=512×512:

vertical_blend:

horizontal_blend:

sampling the point(i0, j0):

sampling the point(i1, j0):

(i0, j0) has been translated one square to the left in (i1, j0).

The same result can be seen when (i0, j1) and (i1, j1) are compared.

sampling top:

sampling bottom:

It isn’t clear what the relationship is between top and bottom, if there is any.

Posted in: Uncategorized