Yes, this is real Perlin Noise and not plain fBm
As far as I know..
Anyway, I was using the usual fBm before but recently changed to Perlin Noise to generate my textures. For these textures to be of any use they need to be tilable.
I know all about the Perlin Noise Math FAQ where it describes seamless noise, and it''s that algorithm I use to tile my noise. It worked great when I used fBm, but now when I switched to Perlin Noise, it stopped working for some reason.
I have a screenshot. This is one octave, dimensions of 1024x1024, and with a frequency of 1/64. I set the tilable width and height to 16, as 1024/64 is 16, and that''s the "noise" width and height. Image has been scaled down for viewing.
This is my Noise loop:
float noise::FineTunedTile(float x, float y) {
float total = 0;
int tempw = w, temph = h; //only for tiling
int frequency = 1;
float pers = persistance;
for(short i=0; i<octaves; i++) {
total += Noise_Tiled(x*frequency, y*frequency)*pers;
w *= 2; //only for tiling
h *= 2; //only for tiling
frequency *= 2;
pers *= persistance;
}
w = tempw; //only for tiling
h = temph; //only for tiling
return total;
}
Noise_Tile:
float noise::Noise_Tiled(float x, float y) {
return (( GetHeight(x,y) *(w-x) * (h-y) + GetHeight((x-w),y) * x * (h-y) + GetHeight((x-w),(y-h)) * x * y + GetHeight(x, (y-h)) * (w-x) * y ) / float(w*h));
}
And finally, my GetHeight function:
float noise::GetHeight(float x, float y) {
int integer_X = (int)x;
float fractional_X = x - integer_X;
int integer_Y = (int)y;
float fractional_Y = y - integer_Y;
float s = D3DXVec2Dot(&Noise_Table(integer_X, integer_Y) , &D3DXVECTOR2(integer_X - x , integer_Y - y));
float t = D3DXVec2Dot(&Noise_Table(integer_X+1, integer_Y), &D3DXVECTOR2(integer_X+1 - x, integer_Y - y));
float u = D3DXVec2Dot(&Noise_Table(integer_X, integer_Y+1), &D3DXVECTOR2(integer_X - x, integer_Y+1 - y));
float v = D3DXVec2Dot(&Noise_Table(integer_X+1, integer_Y+1), &D3DXVECTOR2(integer_X+1 - x, integer_Y+1 - y));
float i1 = Interpolate(s, t, fractional_X);
float i2 = Interpolate(u, v, fractional_X);
return Interpolate(i1, i2, fractional_Y);
}
I don''t expect you to go through my code, but it''s there for reference. I don''t understand why it would be different with Perlin Noise. The gist is the same: It takes x,y and get a value back. Tiling just manipulates the value in different ways. Does anyone see the problem? Thanks a lot!