diff options
-rw-r--r-- | flam3.h | 2 | ||||
-rw-r--r-- | interpolation.c | 16 | ||||
-rw-r--r-- | palettes.c | 5 | ||||
-rw-r--r-- | rect.c | 29 | ||||
-rw-r--r-- | vector.h | 5 |
5 files changed, 29 insertions, 28 deletions
@@ -41,7 +41,7 @@ char *flam3_version(); //typedef double flam3_palette[256][3]; typedef struct { double index; - double4 color; + double color[4]; } flam3_palette_entry; typedef flam3_palette_entry flam3_palette[256]; diff --git a/interpolation.c b/interpolation.c index 279e1a2..7e1d482 100644 --- a/interpolation.c +++ b/interpolation.c @@ -159,8 +159,8 @@ void interpolate_cmap(flam3_palette cmap, double blend, double4 t, s; double t4, s4; - s = rgb2hsv(p0[i].color); - t = rgb2hsv(p1[i].color); + s = rgb2hsv(vector_d4 (p0[i].color)); + t = rgb2hsv(vector_d4 (p1[i].color)); s[3] = p0[i].color[3]; t[3] = p1[i].color[3]; @@ -172,7 +172,10 @@ void interpolate_cmap(flam3_palette cmap, double blend, t[j] = ((1.0-blend) * s[j]) + (blend * t[j]); t4 = ((1.0-blend) * s4) + (blend * t4); - cmap[i].color = hsv2rgb(t); + const double4 c = hsv2rgb(t); + cmap[i].color[0] = c[0]; + cmap[i].color[1] = c[1]; + cmap[i].color[2] = c[2]; cmap[i].color[3] = t[3]; cmap[i].index = t4; } @@ -371,7 +374,7 @@ void flam3_interpolate_n(flam3_genome *result, int ncp, s[0] = s[1] = s[2] = s[3] = s4 = 0.0; for (k = 0; k < ncp; k++) { - t = rgb2hsv(cpi[k].palette[i].color); + t = rgb2hsv(vector_d4 (cpi[k].palette[i].color)); for (j = 0; j < 3; j++) s[j] += c[k] * t[j]; @@ -385,7 +388,10 @@ void flam3_interpolate_n(flam3_genome *result, int ncp, if (alpha1 == 1) s[3] = 1.0; - result->palette[i].color = hsv2rgb(s); + const double4 ret_color = hsv2rgb(s); + result->palette[i].color[0] = ret_color[0]; + result->palette[i].color[1] = ret_color[1]; + result->palette[i].color[2] = ret_color[2]; result->palette[i].color[3] = s[3]; result->palette[i].index = s4; @@ -184,8 +184,9 @@ int flam3_get_palette(int n, flam3_palette c, double hue_rotation, randctx * con c[i].index = i; - c[i].color = rgb; - + c[i].color[0] = rgb[0]; + c[i].color[1] = rgb[1]; + c[i].color[2] = rgb[2]; c[i].color[3] = 1.0; } @@ -31,9 +31,6 @@ typedef struct { unsigned int sub_batch_size, fuse; unsigned short *xform_distrib; - flam3_palette dmap; - unsigned int cmap_size; - /* camera stuff */ double ws0, wb0s0, hs1, hb1s1; /* shortcuts for indexing */ double bounds[4]; /* Corner coords of viewable area */ @@ -44,7 +41,7 @@ typedef struct { /* Lookup color [0,1] */ static double4 color_palette_lookup (const double color, - const color_palette_mode mode, const flam3_palette map, + const color_palette_mode mode, const flam3_palette_entry * const map, const unsigned int map_count) { assert (color >= 0.0 && color <= 1.0); @@ -56,17 +53,18 @@ static double4 color_palette_lookup (const double color, const unsigned int intix = bottomix; if (intix == map_count-1) { - return map[intix].color; + return vector_d4 (map[intix].color); } else { - return map[intix].color * (1.0-frac) + - map[intix+1].color * frac; + const double4 c1 = vector_d4 (map[intix].color); + const double4 c2 = vector_d4 (map[intix+1].color); + return c1 * (1.0-frac) + c2 * frac; } break; } case PALETTE_MODE_STEP: { - const unsigned int intix = nearbyint (color * map_count); - return map[intix].color; + const unsigned int intix = nearbyint (color * (map_count-1)); + return vector_d4 (map[intix].color); break; } @@ -137,7 +135,8 @@ static void iter_thread (flam3_genome * const input_genome, #endif double4 interpcolor = color_palette_lookup (p[2], - genome.palette_mode, c->dmap, c->cmap_size); + genome.palette_mode, input_genome->palette, + 256); const double logvis = p[3]; if (logvis != 1.0) { @@ -243,16 +242,6 @@ bool render_bucket (flam3_genome * const genome, bucket * const bucket, }; assert (c.xform_distrib != NULL); - /* compute the colormap entries. */ - /* the input colormap is 256 long with entries from 0 to 1.0 */ - for (unsigned int j = 0; j < CMAP_SIZE; j++) { - c.dmap[j].index = genome->palette[(j * 256) / CMAP_SIZE].index / 256.0; - for (unsigned int k = 0; k < 4; k++) { - c.dmap[j].color[k] = genome->palette[(j * 256) / CMAP_SIZE].color[k]; - } - } - c.cmap_size = 256; - /* compute camera */ compute_camera (genome, bucket, &c); @@ -14,3 +14,8 @@ typedef double double4 __attribute__ ((vector_size (sizeof (double)*4))); typedef unsigned int uint2 __attribute__ ((vector_size (sizeof (unsigned int)*2))); #endif +inline double4 vector_d4 (const double c[4]) { + return (double4) { c[0], c[1], c[2], c[3] }; +} + + |