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 |
} |
} |
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 |
} |
} |
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], |