diff options
author | Stan Seibert <stan@mtrr.org> | 2011-08-16 17:11:34 -0400 |
---|---|---|
committer | Stan Seibert <stan@mtrr.org> | 2011-08-16 17:11:34 -0400 |
commit | 96f20d671e92c103f8437d6d311fa87d5779db11 (patch) | |
tree | 6d6d55c4600a570830777056f37c7e94377c5a5b /src/intersect.h | |
parent | 85f9f1d23f74ed9679d879c32f7e3c72c7e7ce8f (diff) | |
parent | 56ebfae1830cba926fd5fd4054b2dd555cf83ae9 (diff) | |
download | chroma-96f20d671e92c103f8437d6d311fa87d5779db11.tar.gz chroma-96f20d671e92c103f8437d6d311fa87d5779db11.tar.bz2 chroma-96f20d671e92c103f8437d6d311fa87d5779db11.zip |
merge
Diffstat (limited to 'src/intersect.h')
-rw-r--r-- | src/intersect.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/intersect.h b/src/intersect.h index d2f54ce..26e1d7e 100644 --- a/src/intersect.h +++ b/src/intersect.h @@ -60,17 +60,20 @@ __device__ bool intersect_triangle(const float3 &origin, const float3 &direction angle between the ray and the plane normal to determine the brightness. `direction` must be normalized. */ -__device__ unsigned int get_color(const float3 &direction, const float3 &v0, const float3& v1, const float3 &v2, const unsigned int base_color=0xFFFFFFFF) +__device__ unsigned int get_color(const float3 &direction, const float3 &v0, const float3& v1, const float3 &v2, unsigned int base_color=0xFFFFFF) { float scale = dot(normalize(cross(v1-v0,v2-v1)),-direction); + if (scale < 0.0f) + { + base_color = 0xff0000; + scale = dot(-normalize(cross(v1-v0,v2-v1)),-direction); + } + unsigned int r = 0xFF & (base_color >> 16); unsigned int g = 0xFF & (base_color >> 8); unsigned int b = 0xFF & base_color; - if (scale < 0.0f) - scale = dot(-normalize(cross(v1-v0,v2-v1)),-direction); - r = floorf(r*scale); g = floorf(g*scale); b = floorf(b*scale); |