有关:
我想生成可平铺的Perlin噪声。我正在使用Paul Bourke的 PerlinNoise*()
功能,如下所示:
// alpha is the "division factor" (how much to damp subsequent octaves with (usually 2))
// beta is the factor that multiplies your "jump" into the noise (usually 2)
// n is the number of "octaves" to add in
double PerlinNoise2D(double x,double y,double alpha,double beta,int n)
{
int i;
double val,sum = 0;
double p[2],scale = 1;
p[0] = x;
p[1] = y;
for (i=0;i<n;i++) {
val = noise2(p);
sum += val / scale;
scale *= alpha;
p[0] *= beta;
p[1] *= beta;
}
return(sum);
}
使用如下代码:
real val = PerlinNoise2D( x,y, 2, 2, 12 ) ; // test
return val*val*skyColor + 2*val*(1-val)*gray + (1-val)*(1-val)*cloudColor ;
给天空像
哪个是不平铺的。
像素值为0-> 256(宽度和高度),像素(0,0)使用(x,y)=(0,0),像素(256,256)使用(x,y)=(1,1)
我如何使其平铺?