diff options
author | Anthony LaTorre <telatorre@gmail.com> | 2011-05-15 16:28:00 -0400 |
---|---|---|
committer | Anthony LaTorre <telatorre@gmail.com> | 2011-05-15 16:28:00 -0400 |
commit | 8ea783d053e817568b3e7d04f28a6fd2583f18cf (patch) | |
tree | 9529ff81a9e8b0b986cd125d310f65bbcb9df2b0 /src | |
parent | 6df4500c56bd5f8c90ed18c07eac6eae1ca7e9fb (diff) | |
download | chroma-8ea783d053e817568b3e7d04f28a6fd2583f18cf.tar.gz chroma-8ea783d053e817568b3e7d04f28a6fd2583f18cf.tar.bz2 chroma-8ea783d053e817568b3e7d04f28a6fd2583f18cf.zip |
new geometry class. beginning to implement physics by defining a material class; each triangle will have a material linked to both of its sides
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel.cu (renamed from src/intersect.cu) | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/intersect.cu b/src/kernel.cu index 73b4483..02c52cf 100644 --- a/src/intersect.cu +++ b/src/kernel.cu @@ -7,6 +7,8 @@ texture<float4, 1, cudaReadModeElementType> mesh; + + texture<float4, 1, cudaReadModeElementType> upper_bound_arr; texture<float4, 1, cudaReadModeElementType> lower_bound_arr; @@ -51,7 +53,13 @@ __device__ bool intersect_triangle(const float3 &origin, const float3 &direction __device__ int get_color(const float3 &direction, const float3 &v0, const float3& v1, const float3 &v2) { - int rgb = floorf(255*dot(normalize(cross(v1-v0,v2-v0)),-direction)); + float scale = 255*dot(normalize(cross(v1-v0,v2-v0)),-direction); + if (scale < 0.0f) + scale = 255*dot(-normalize(cross(v1-v0,v2-v0)),-direction); + + + int rgb = floorf(scale); + return rgb << 16 | rgb << 8 | rgb; } @@ -189,6 +197,8 @@ __global__ void intersect_mesh(int max_idx, float3 *origin_arr, float3 *directio int i; + bool show_leafs = false; + do { int child_map = tex1Dfetch(child_map_arr, *node); @@ -206,6 +216,12 @@ __global__ void intersect_mesh(int max_idx, float3 *origin_arr, float3 *directio node--; } + else if (show_leafs) + { + hit = true; + *pixel = 255; + node--; + } else // node is a leaf { for (i=0; i < child_len; i++) |