2013-12-13 1 views
0

http://image.kilho.net/?pk=1420781내가 지형을 만들 소음 펄린 사용하는 것을 시도하고있다

자연 펄린 노이즈를 생성합니다.

하지만 항상 위의 소리가납니다. 내가 싶어하는 마지막 (7) 이미지

http://image.kilho.net/?pk=1420774

.

하지만 내 노이즈 이미지는 4 번째 또는 5 번째 이미지처럼 보입니다. 당신 것 이상의 샘플 높은 주파수 1보다 작은 지속성 값이 코드를 호출하는 경우

여기 내 코드 (자바)

int seed; 

public Noise() { 
    Random ran = new Random(); 
    seed = ran.nextInt(); 
} 
/** 
* Brut noise generator using pseudo-random 
*/ 
public double noise(int x,int y) 
{ 
    x=x + y * seed; 
    x=((x<<13)^x); 
    double t=(x * (x * x * 15731 + 789221) + 1376312589) & 0x7fffffff; 
    return 1-t*0.000000000931322574615478515625; 

} 

/** 
* Smoothed noise generator using 9 brut noise 
*/ 
public double sNoise(int x,int y) 
{ 
    double corners = (noise(x-1, y-1)+noise(x+1, y-1)+noise(x-1, y+1)+noise(x+1, y+1)) * 0.0625; 
    double sides = (noise(x-1, y) +noise(x+1, y) +noise(x, y-1) +noise(x, y+1)) *0.125; 
    double center = noise(x, y) *0.25; 
    return corners + sides + center;   
} 

/** 
* Linear Interpolator 
* 
* @param a value 1 
* @param b value 2 
* @param x interpolator factor 
* 
* @return value interpolated from a to b using x factor by linear interpolation 
*/ 
public double lInterpoleLin(double a,double b,double x) 
{ 
    return a*(1-x) + b*x;  
} 


/** 
* Cosine Interpolator 
* 
* @param a value 1 
* @param b value 2 
* @param x interpolator factor 
* 
* @return value interpolated from a to b using x factor by cosin interpolation 
*/ 
public double lInterpoleCos(double a,double b,double x) 
{ 

    double ft = x * 3.1415927; 
    double f = (1 - Math.cos(ft)) * .5; 
    return a*(1-f) + b*f; 
} 

/** 
* Smooth noise generator with two input 2D 
* <br> 
* You may change the interpolation method : cosin , linear , cubic 
* </br> 
* @param x x parameter 
* @param y y parameter 
* 
* @return value of smoothed noise for 2d value x,y 
*/ 
public double iNoise(double x,double y) 
{ 
    int iX=(int)x; 
    int iY=(int)y; 
    double dX=x-iX; 
    double dY=y-iY; 
    double p1=sNoise(iX,iY); 
    double p2=sNoise(iX+1,iY); 
    double p3=sNoise(iX,iY+1); 
    double p4=sNoise(iX+1,iY+1); 
    double i1=lInterpoleLin(p1,p2,dX); 
    double i2=lInterpoleLin(p3,p4,dX); 
    return lInterpoleLin(i1,i2,dY); 
} 

/** 
* Perlin noise generator for two input 2D 
* 
* @param x x parameter 
* @param y y parameter 
* @param octave maximum octave/harmonic 
* @param persistence noise persitence 
* @return perlin noise value for given entry 
*/ 
public double pNoise(double x,double y,double persistence,int octave) 
{ 
    double result; 
    double amplitude=1; 
    int frequence=1; 
    result=0; 
    for(int n=0;n<octave;n++) 
    { 
     result+=iNoise(x*frequence,y*frequence)*amplitude; 
     frequence<<=1; 
     amplitude*=persistence; 
    } 
    return result; 
} 

}

답변

0

입니다.
당신이 사용하고있는 프랙탈/fBm 옥타브 합계 방법은 옥타브 다운 리미터입니다. 가장 지저분한 결과로 시작하여 더 넓은 피쳐 스프레드에 블렌드합니다. 지형 발생기의 경우 일반적으로 몇 가지 세부 사항이 포함 된 중간 크기의 기능을 원합니다. 기본 기능을 원활하게 수행하려면 기본 패스를 최소 5, 가능하면 20 픽셀로 만들어야한다고 들었습니다. 코드가 셀당 하나의 픽셀을 처리하고 있기 때문에 흰색의 'TV 정적 노이즈'가보고 싶은 신호보다 훨씬 강력합니다.

최종 이미지를 얻기 위해 거의 일관성 (또는 더 높은) 지속성 매개 변수를 사용하고있는 참조 샘플 갤러리를 베팅하고 싶습니다.

관련 문제