/[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.5 by jvk, Mon Sep 30 16:23:21 2002 UTC revision 1.6 by jvk, Wed Oct 9 14:48:20 2002 UTC
# Line 11  static double drand() { Line 11  static double drand() {
11  /* Add a fourier noise to the data.  /* Add a fourier noise to the data.
12   */   */
13  static void fourier_noise(int width, int height, int depth, int components, float *data,  static void fourier_noise(int width, int height, int depth, int components, float *data,
14                  float freq, float df) {                  float freq, float df, float aniso = 1.0) {
15      int nf = (int)(2 * freq);      int nf = (int)(2 * (freq + df) * aniso);
16      float xsin[2][nf][width];      float xsin[2][nf][width];
17      for(int i=0; i<width; i++)      for(int i=0; i<width; i++)
18          for(int f = 0; f < nf; f++) {          for(int f = 0; f < nf; f++) {
# Line 34  static void fourier_noise(int width, int Line 34  static void fourier_noise(int width, int
34          for(int xf = 0; xf < nf; xf++) {          for(int xf = 0; xf < nf; xf++) {
35            for(int yf = 0; yf < nf; yf++) {            for(int yf = 0; yf < nf; yf++) {
36    
37              double f = sqrt(xf*xf + yf*yf);              double f = sqrt(xf*xf + yf*yf*(aniso*aniso));
38              if(f < freq-df || f > freq+df) continue;              if(f < freq-df || f > freq+df) continue;
39    
40              for(int xsc = 0; xsc < 2; xsc++) {              for(int xsc = 0; xsc < 2; xsc++) {
# Line 78  void GENERATE(TextureParam *params, int Line 78  void GENERATE(TextureParam *params, int
78      FPARAM(bias, 0);      FPARAM(bias, 0);
79      FPARAM(scale, 1);      FPARAM(scale, 1);
80      FPARAM(freq, 5);      FPARAM(freq, 5);
81        FPARAM(aniso, 1.0);
82      FPARAM(df, 2);      FPARAM(df, 2);
83      FPARAM(seed, 0);      FPARAM(seed, 0);
84      FPARAM(turb, 0);      FPARAM(turb, 0);
# Line 98  void GENERATE(TextureParam *params, int Line 99  void GENERATE(TextureParam *params, int
99        for (float f = freq; f <= freq2; f += f) {        for (float f = freq; f <= freq2; f += f) {
100          for(int i = 0; i<n; i++)          for(int i = 0; i<n; i++)
101            tmp[i] = 0;            tmp[i] = 0;
102          fourier_noise(width,height,d,components,tmp, f, df);          fourier_noise(width,height,d,components,tmp, f, df, aniso);
103    
104          float m = 1.0 / (log(f)/log(2) + 1);          float m = 1.0 / (log(f)/log(2) + 1);
105                    
# Line 111  void GENERATE(TextureParam *params, int Line 112  void GENERATE(TextureParam *params, int
112    
113      } else {      } else {
114    
115        fourier_noise(width,height,d,components,data, freq, df);        fourier_noise(width,height,d,components,data, freq, df, aniso);
116      }      }
117            
118      for(int i = 0; i<n; i++) {      for(int i = 0; i<n; i++) {

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

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