diff options
author | Anthony LaTorre <telatorre@gmail.com> | 2011-06-03 20:09:15 -0400 |
---|---|---|
committer | Anthony LaTorre <telatorre@gmail.com> | 2011-06-03 20:09:15 -0400 |
commit | bd4250bce0b0df736f41dbfca4b5a902d7cdaf37 (patch) | |
tree | 10e119553c0ea47d67ba0557f16c7d1dda25ccf5 /src | |
parent | 4118c62895ac2f011146b4233dad86ff8dc179e3 (diff) | |
download | chroma-bd4250bce0b0df736f41dbfca4b5a902d7cdaf37.tar.gz chroma-bd4250bce0b0df736f41dbfca4b5a902d7cdaf37.tar.bz2 chroma-bd4250bce0b0df736f41dbfca4b5a902d7cdaf37.zip |
load material/surface index lookup arrays to the gpu and bind them to textures. also, forgot to include the gpu code for material/surface structures
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel.cu | 6 | ||||
-rw-r--r-- | src/materials.h | 35 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/kernel.cu b/src/kernel.cu index c56bbe7..4d85f6e 100644 --- a/src/kernel.cu +++ b/src/kernel.cu @@ -14,6 +14,12 @@ texture<float4, 1, cudaReadModeElementType> vertices; texture<uint4, 1, cudaReadModeElementType> triangles; +/* material/surface index lookup for each triangle */ +texture<int, 1, cudaReadModeElementType> material1_index; +texture<int, 1, cudaReadModeElementType> material2_index; +texture<int, 1, cudaReadModeElementType> surface1_index; +texture<int, 1, cudaReadModeElementType> surface2_index; + /* lower/upper bounds for the bounding box associated with each node/leaf */ texture<float4, 1, cudaReadModeElementType> upper_bounds; texture<float4, 1, cudaReadModeElementType> lower_bounds; diff --git a/src/materials.h b/src/materials.h new file mode 100644 index 0000000..05aa121 --- /dev/null +++ b/src/materials.h @@ -0,0 +1,35 @@ +struct Material +{ + float *refractive_index; + float *absorption_length; + float *scattering_length; +}; + +struct Surface +{ + float *absorption; + float *reflection_diffuse; + float *reflection_specular; +}; + +__device__ struct Material materials[100]; +__device__ struct Surface surfaces[100]; + +extern "C" +{ + +__global__ void set_material(int material_index, float *refractive_index, float *absorption_length, float *scattering_length) +{ + materials[material_index].refractive_index = refractive_index; + materials[material_index].absorption_length = absorption_length; + materials[material_index].scattering_length = scattering_length; +} + +__global__ void set_surface(int surface_index, float *absorption, float *reflection_diffuse, float *reflection_specular) +{ + surfaces[surface_index].absorption = absorption; + surfaces[surface_index].reflection_diffuse = reflection_diffuse; + surfaces[surface_index].reflection_specular = reflection_specular; +} + +} // extern "c" |