45 |
// Ripple amplitude in texture coordinates |
// Ripple amplitude in texture coordinates |
46 |
FPARAM(ripple_scale, 0.25); |
FPARAM(ripple_scale, 0.25); |
47 |
|
|
48 |
if(components != 4) return; |
float *origdata = data; |
49 |
|
if(components != 4) { |
50 |
|
if (components != 1) return; |
51 |
|
data = new float[width * height * depth * 4]; |
52 |
|
} |
53 |
|
|
54 |
if(depth != 1) return; |
if(depth != 1) return; |
55 |
if(width != height) return; |
if(width != height) return; |
56 |
|
|
63 |
char s[1000]; |
char s[1000]; |
64 |
sprintf(s, "gfx/libtexture/sawnoise.bin %d %d %d %d " |
sprintf(s, "gfx/libtexture/sawnoise.bin %d %d %d %d " |
65 |
"bias 0.5 scale 0.15 freq 1 df 2 scale2 0.25 freq2 10 df2 .5", |
"bias 0.5 scale 0.15 freq 1 df 2 scale2 0.25 freq2 10 df2 .5", |
66 |
width, height, depth, components); |
width, height, depth, 4); |
67 |
|
|
68 |
fprintf(stderr, "popen: %s", s); |
fprintf(stderr, "popen: %s", s); |
69 |
|
|
74 |
return; |
return; |
75 |
} |
} |
76 |
|
|
77 |
fread(data, sizeof(float), width * height * depth * components, f); |
fread(data, sizeof(float), width * height * depth * 4, f); |
78 |
pclose(f); |
pclose(f); |
79 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
80 |
} |
} |
98 |
} |
} |
99 |
} |
} |
100 |
|
|
101 |
|
if (components == 4) |
102 |
for (int comp = 0; comp < 3; comp++) { |
for (int comp = 0; comp < 3; comp++) { |
103 |
float dx = cos(comp * 2*M_PI / 3); |
float dx = cos(comp * 2*M_PI / 3); |
104 |
float dy = sin(comp * 2*M_PI / 3); |
float dy = sin(comp * 2*M_PI / 3); |
135 |
data[i+3]); |
data[i+3]); |
136 |
} |
} |
137 |
#endif |
#endif |
138 |
|
|
139 |
|
if (components != 4) { |
140 |
|
/* components == 1 */ |
141 |
|
for (int i = 0; i < width * height * depth; i++) |
142 |
|
origdata[i] = data[4 * i + 3]; |
143 |
|
delete[] data; |
144 |
|
} |
145 |
} |
} |
146 |
|
|
147 |
|
|