/[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.4 by jvk, Mon Oct 21 12:41:30 2002 UTC revision 1.5 by jvk, Mon Oct 21 12:53:56 2002 UTC
# Line 3  Line 3 
3    
4  #define FPARAM(name, default) float name = params->getFloat(#name, default);  #define FPARAM(name, default) float name = params->getFloat(#name, default);
5    
6    #define INVERT(i, x) ((i) + 2 * (0.5 - (i)) * (x))
7    
8  float func(float x, float y) {  float func(float x, float y) {
9      float t = x*10;      float t = x*10;
10      float u = y*10;      float u = y*10;
11      return .5 + .2 * sin(x*M_PI*2*4) - .2*(t-floor(t)) + .2*sin(y*M_PI*2)      return  .5 + .2 * sin(x*M_PI*2*4) - .2*(t-floor(t)) + .2*sin(y*M_PI*2)
12          +  .2*(u-floor(u));          + .2*(u-floor(u));
13  }  }
14    
15  float filter(float *data, int w, int h, int c, float x, float y) {  float filter(float *data, int w, int h, int c, float x, float y) {
# Line 32  void GENERATE(TextureParam *params, int Line 34  void GENERATE(TextureParam *params, int
34      FPARAM(bias, 0);      FPARAM(bias, 0);
35      FPARAM(scale, 1);      FPARAM(scale, 1);
36      FPARAM(eps, .25);      FPARAM(eps, .25);
37        FPARAM(invert, 0);
38            
39      // Note: radius is specified in texels      // Note: radius is specified in texels
40      FPARAM(radius, 2);      FPARAM(radius, 2);
# Line 50  void GENERATE(TextureParam *params, int Line 53  void GENERATE(TextureParam *params, int
53      ind = 3;      ind = 3;
54      for (j = 0, y = 0; j < height; j++, y += ystep) {        for (j = 0, y = 0; j < height; j++, y += ystep) {  
55          for (i = 0, x = 0; i < width; i++, x += xstep) {          for (i = 0, x = 0; i < width; i++, x += xstep) {
56              data[ind] = func(x,y) * scale + bias;              data[ind] = INVERT(invert, func(x,y)) * scale + bias;
57    
58              // Add outer edge to quantized inner edge              // Add outer edge to quantized inner edge
59              data[ind] = floor(data[ind] * 255.0 + 0.5) / 255.0;              data[ind] = floor(data[ind] * 255.0 + 0.5) / 255.0;

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

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