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

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

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

revision 1.2 by jvk, Mon Oct 21 07:07:15 2002 UTC revision 1.3 by jvk, Mon Oct 21 07:33:48 2002 UTC
# Line 50  void GENERATE(TextureParam *params, int Line 50  void GENERATE(TextureParam *params, int
50      ind = 3;      ind = 3;
51      for (j = 0, y = 0; j < height; j++, y += ystep) {        for (j = 0, y = 0; j < height; j++, y += ystep) {  
52          for (i = 0, x = 0; i < width; i++, x += xstep) {          for (i = 0, x = 0; i < width; i++, x += xstep) {
53              data[ind] = func(x,y);              data[ind] = func(x,y) * scale + bias;
54    
55                // Add outer edge to quantized inner edge
56                data[ind] = floor(data[ind] * 255.0 + 0.5) / 255.0;
57              ind += 4;              ind += 4;
58          }                }      
59      }      }
# Line 63  void GENERATE(TextureParam *params, int Line 66  void GENERATE(TextureParam *params, int
66          for (j = 0, y = 0; j < height; j++, y += ystep) {                for (j = 0, y = 0; j < height; j++, y += ystep) {      
67              for (i = 0, x = 0; i < width; i++, x += xstep) {              for (i = 0, x = 0; i < width; i++, x += xstep) {
68    
69                  float scale = 1.0 / (width * ripple_scale);                  float m = scale / (width * ripple_scale);
70                                    
71                  float maxh = -1E+10;                  float maxh = -1E+10;
72                  for (float r = -radius; r <= radius; r += eps) {                  for (float r = -radius; r <= radius; r += eps) {
73                      float h = filter(data + 3, width, height, components,                      float h = filter(data + 3, width, height, components,
74                                       i + dx * r, j + dy * r);                                       i + dx * r, j + dy * r);
75    
76                      h += sqrt(radius * radius - r * r) * scale;                      h += sqrt(radius * radius - r * r) * m;
77                      //h += radius * scale;                      //h += radius * scale;
78                      if (h > maxh) maxh = h;                      if (h > maxh) maxh = h;
79                  }                  }
# Line 82  void GENERATE(TextureParam *params, int Line 85  void GENERATE(TextureParam *params, int
85    
86      }      }
87    
88      for(int i = 0; i<width*height*components; i++) {  #if 0
         data[i] *= scale;  
         data[i] += bias;  
     }  
   
 #if 0      
89      for(int i = 0; i<width*components; i += 4) {      for(int i = 0; i<width*components; i += 4) {
90          fprintf(stderr, "%.2f %.2f %.2f %.2f\n",          fprintf(stderr, "%.3f %.3f %.3f %.3f\n",
91                  data[i+0],                  data[i+0],
92                  data[i+1],                  data[i+1],
93                  data[i+2],                  data[i+2],

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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