/[gzz]/gzz/gfx/libtexture/fnoise.texture
ViewVC logotype

Diff of /gzz/gfx/libtexture/fnoise.texture

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by jvk, Wed Oct 9 14:48:20 2002 UTC revision 1.7 by jvk, Fri Oct 25 14:20:16 2002 UTC
# Line 74  static void fourier_noise(int width, int Line 74  static void fourier_noise(int width, int
74      }      }
75  }  }
76    
77    double identity(double x) { return x; }
78    
79  void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) {  void GENERATE(TextureParam *params, int width, int height, int depth, int components, float *data) {
80      FPARAM(bias, 0);      FPARAM(bias, 0);
81      FPARAM(scale, 1);      FPARAM(scale, 1);
# Line 82  void GENERATE(TextureParam *params, int Line 84  void GENERATE(TextureParam *params, int
84      FPARAM(df, 2);      FPARAM(df, 2);
85      FPARAM(seed, 0);      FPARAM(seed, 0);
86      FPARAM(turb, 0);      FPARAM(turb, 0);
87        FPARAM(fbm, 0);
88      FPARAM(freq2, 20);      FPARAM(freq2, 20);
89            
90        double (*func)(double) = identity;
91        if (turb) func = fabs, fbm = 1;
92    
93      if (seed) srandom((long)seed);      if (seed) srandom((long)seed);
94    
95      int d = (depth==0 ? 1 : depth);      int d = (depth==0 ? 1 : depth);
# Line 93  void GENERATE(TextureParam *params, int Line 99  void GENERATE(TextureParam *params, int
99        data[i] = 0;        data[i] = 0;
100    
101    
102      if (turb) {      if (fbm) {
103        float *tmp = new float[n];        float *tmp = new float[n];
104                
105        for (float f = freq; f <= freq2; f += f) {        for (float f = freq; f <= freq2; f += f) {
# Line 104  void GENERATE(TextureParam *params, int Line 110  void GENERATE(TextureParam *params, int
110          float m = 1.0 / (log(f)/log(2) + 1);          float m = 1.0 / (log(f)/log(2) + 1);
111                    
112          for(int i = 0; i<n; i++)          for(int i = 0; i<n; i++)
113            data[i] += m * fabs(tmp[i]);            data[i] += m * func(tmp[i]);
114        }        }
115                
116        for(int i = 0; i<n; i++)        for(int i = 0; i<n; i++)

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26