gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx/libtexture fnoise.texture


From: Tuomas J. Lukka
Subject: [Gzz-commits] gzz/gfx/libtexture fnoise.texture
Date: Tue, 03 Sep 2002 09:48:52 -0400

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Tuomas J. Lukka <address@hidden>        02/09/03 09:48:52

Modified files:
        gfx/libtexture : fnoise.texture 

Log message:
        More

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/libtexture/fnoise.texture.diff?tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gzz/gfx/libtexture/fnoise.texture
diff -c gzz/gfx/libtexture/fnoise.texture:1.1 
gzz/gfx/libtexture/fnoise.texture:1.2
*** gzz/gfx/libtexture/fnoise.texture:1.1       Tue Sep  3 07:15:13 2002
--- gzz/gfx/libtexture/fnoise.texture   Tue Sep  3 09:48:52 2002
***************
*** 13,44 ****
  static void fourier_noise(int width, int height, int depth, int components, 
float *data, 
                float freq, float df) {
      int nf = (int)(2 * freq);
!     float xsin[nf][width];
      for(int i=0; i<width; i++) 
!       for(int f = 0; f < nf; f++)
!           xsin[f][i] = sin(i/(float)width * f * M_PI);
!     float ysin[nf][height];
      for(int j=0; j<width; j++) 
!       for(int f = 0; f < nf; f++)
!           ysin[f][j] = sin(j/(float)height * f * M_PI);
      
      
      if(depth < 2) {
        // 2D
        for(int xf = 0; xf < nf; xf++) {
          for(int yf = 0; yf < nf; yf++) {
-           float coeff[components];
  
            double f = sqrt(xf*xf + yf*yf);
            if(f < freq-df || f > freq+df) continue;
  
!           for(int co = 0; co < components; co++)
!               coeff[co] = drand()-0.5;
!           int ind = 0;
!           for (int j = 0; j < height; j++) {
!             for (int i = 0; i < width; i++) {
                for(int co = 0; co < components; co++)
!                   data[ind++] += xsin[xf][i] * ysin[yf][j] * coeff[co];
              }
            }
          }
--- 13,52 ----
  static void fourier_noise(int width, int height, int depth, int components, 
float *data, 
                float freq, float df) {
      int nf = (int)(2 * freq);
!     float xsin[2][nf][width];
      for(int i=0; i<width; i++) 
!       for(int f = 0; f < nf; f++) {
!           xsin[0][f][i] = sin(i/(float)width * f * M_PI * 2);
!           xsin[1][f][i] = cos(i/(float)width * f * M_PI * 2);
!     }
!     float ysin[2][nf][height];
      for(int j=0; j<width; j++) 
!       for(int f = 0; f < nf; f++) {
!           ysin[0][f][j] = sin(j/(float)height * f * M_PI * 2);
!           ysin[1][f][j] = cos(j/(float)height * f * M_PI * 2);
!     }
      
      
      if(depth < 2) {
        // 2D
        for(int xf = 0; xf < nf; xf++) {
          for(int yf = 0; yf < nf; yf++) {
  
            double f = sqrt(xf*xf + yf*yf);
            if(f < freq-df || f > freq+df) continue;
  
!           for(int xsc = 0; xsc < 2; xsc++) {
!             for(int ysc = 0; ysc < 2; ysc++) {
!               float coeff[components];
                for(int co = 0; co < components; co++)
!                   coeff[co] = drand()-0.5;
!               int ind = 0;
!               for (int j = 0; j < height; j++) {
!                 for (int i = 0; i < width; i++) {
!                   for(int co = 0; co < components; co++)
!                       data[ind++] += xsin[xsc][xf][i] * ysin[ysc][yf][j] * 
coeff[co];
!                 }
!               }
              }
            }
          }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]