From bd4250bce0b0df736f41dbfca4b5a902d7cdaf37 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Fri, 3 Jun 2011 20:09:15 -0400 Subject: 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 --- src/kernel.cu | 6 ++++++ src/materials.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 src/materials.h (limited to 'src') 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 vertices; texture triangles; +/* material/surface index lookup for each triangle */ +texture material1_index; +texture material2_index; +texture surface1_index; +texture surface2_index; + /* lower/upper bounds for the bounding box associated with each node/leaf */ texture upper_bounds; texture 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" -- cgit