summaryrefslogtreecommitdiff
path: root/src/alpha.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/alpha.h')
-rw-r--r--src/alpha.h19
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;
}