diff options
author | Stan Seibert <stan@mtrr.org> | 2011-07-28 16:05:47 -0400 |
---|---|---|
committer | Stan Seibert <stan@mtrr.org> | 2011-07-28 16:05:47 -0400 |
commit | 38409568b350d6182eb1eea6433f25b4b4019bf9 (patch) | |
tree | 6b0c07f9e26fc3c1d8cd01268feb9e835011de51 /src | |
parent | 5939c3d1c154a18b650183cde5dd77420a089666 (diff) | |
download | chroma-38409568b350d6182eb1eea6433f25b4b4019bf9.tar.gz chroma-38409568b350d6182eb1eea6433f25b4b4019bf9.tar.bz2 chroma-38409568b350d6182eb1eea6433f25b4b4019bf9.zip |
Increase alpha depth for complex models. Remove intermediate rounding
to integers in alpha blending until the last step.
Diffstat (limited to 'src')
-rw-r--r-- | src/alpha.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/alpha.h b/src/alpha.h index afd7ea5..5e3e803 100644 --- a/src/alpha.h +++ b/src/alpha.h @@ -13,7 +13,7 @@ __device__ void swap(T &a, T &b) b = temp; } -#define ALPHA_DEPTH 5 +#define ALPHA_DEPTH 10 struct HitList { @@ -121,10 +121,10 @@ __device__ __noinline__ int get_color_alpha(const float3 &origin, const float3& if (h.size < 1) return 0; - float scale = 1.0; - unsigned int r = 0; - unsigned int g = 0; - unsigned int b = 0; + float scale = 1.0f; + float fr = 0.0f; + float fg = 0.0f; + float fb = 0.0f; for (i=0; i < h.size; i++) { uint4 triangle_data = g_triangles[h.indices[i]]; @@ -144,12 +144,15 @@ __device__ __noinline__ int get_color_alpha(const float3 &origin, const float3& float alpha = (255 - (0xff & (g_colors[h.indices[i]] >> 24)))/255.0f; - r += floorf(r0*scale*cos_theta*alpha); - g += floorf(g0*scale*cos_theta*alpha); - b += floorf(b0*scale*cos_theta*alpha); + fr += r0*scale*cos_theta*alpha; + fg += g0*scale*cos_theta*alpha; + fb += b0*scale*cos_theta*alpha; scale *= (1.0f-alpha); } + unsigned int r = floorf(fr); + unsigned int g = floorf(fg); + unsigned int b = floorf(fb); return r << 16 | g << 8 | b; } |