├── img2.ppm ├── docs ├── html │ ├── doc.png │ ├── bc_s.png │ ├── bdwn.png │ ├── closed.png │ ├── nav_f.png │ ├── nav_g.png │ ├── nav_h.png │ ├── open.png │ ├── tab_a.png │ ├── tab_b.png │ ├── tab_h.png │ ├── tab_s.png │ ├── doxygen.png │ ├── splitbar.png │ ├── sync_off.png │ ├── sync_on.png │ ├── classMetal.png │ ├── classSphere.png │ ├── folderopen.png │ ├── classBvhNode.png │ ├── classHittable.png │ ├── classMaterial.png │ ├── classTexture.png │ ├── folderclosed.png │ ├── search │ │ ├── all_0.js │ │ ├── all_b.js │ │ ├── all_e.js │ │ ├── classes_b.js │ │ ├── close.png │ │ ├── all_a.js │ │ ├── classes_0.js │ │ ├── classes_e.js │ │ ├── mag_sel.png │ │ ├── search_l.png │ │ ├── search_m.png │ │ ├── search_r.png │ │ ├── all_1.js │ │ ├── all_d.js │ │ ├── classes_a.js │ │ ├── all_6.js │ │ ├── classes_1.js │ │ ├── classes_d.js │ │ ├── all_3.js │ │ ├── all_7.js │ │ ├── classes_6.js │ │ ├── all_5.js │ │ ├── all_9.js │ │ ├── classes_3.js │ │ ├── classes_7.js │ │ ├── classes_5.js │ │ ├── classes_9.js │ │ ├── all_2.js │ │ ├── classes_2.js │ │ ├── all_4.js │ │ ├── all_8.js │ │ ├── classes_8.js │ │ ├── classes_4.js │ │ ├── all_c.js │ │ ├── classes_c.js │ │ ├── searchdata.js │ │ ├── nomatches.html │ │ ├── all_0.html │ │ ├── all_1.html │ │ ├── all_2.html │ │ ├── all_3.html │ │ ├── all_4.html │ │ ├── all_5.html │ │ ├── all_6.html │ │ ├── all_7.html │ │ ├── all_8.html │ │ ├── all_9.html │ │ ├── all_a.html │ │ ├── all_b.html │ │ ├── all_c.html │ │ ├── all_d.html │ │ ├── all_e.html │ │ ├── classes_0.html │ │ ├── classes_1.html │ │ ├── classes_2.html │ │ ├── classes_3.html │ │ ├── classes_4.html │ │ ├── classes_5.html │ │ ├── classes_6.html │ │ ├── classes_7.html │ │ ├── classes_8.html │ │ ├── classes_9.html │ │ ├── classes_a.html │ │ ├── classes_b.html │ │ ├── classes_c.html │ │ ├── classes_d.html │ │ └── classes_e.html │ ├── classDielectric.png │ ├── classHittables.png │ ├── classLambertian.png │ ├── classSolidColor.png │ ├── classImageTexture.png │ ├── classMovingSphere.png │ ├── classNoiseTexture.png │ ├── classCheckerTexture.png │ ├── menudata.js │ ├── index.html │ ├── menu.js │ ├── dir_c9e4cb2c20911002ee1815db3792ebfc.html │ ├── dir_a034f12e10456ed9baa6c2174620f736.html │ ├── dir_cb5a55d9e9c1b47934843b044d803335.html │ ├── dir_b5ed2bba80ecaac353b1d8be0f5c3722.html │ ├── dir_68267d1309a1af8e8297ef4c3efbcdba.html │ ├── dir_d44c64559bbebec7f509842c48db8b23.html │ ├── classTexture-members.html │ ├── classMaterial-members.html │ ├── structKernelArg-members.html │ ├── structstbi__io__callbacks-members.html │ ├── classSolidColor-members.html │ ├── classPerlin-members.html │ ├── classHittable-members.html │ ├── classNoiseTexture-members.html │ ├── structstbi__io__callbacks.html │ ├── classPerlin.html │ ├── classTexture.html │ ├── dynsections.js │ ├── classDielectric-members.html │ ├── structKernelArg.html │ └── structHitRecord-members.html └── doxygen_sqlite3.db ├── images ├── final.png ├── final2.png ├── final3.png ├── final4.png ├── final5.png └── cornell_smoke.png ├── include ├── oneweekend │ ├── external.hpp │ ├── color.hpp │ ├── hittable.cuh │ ├── debug.hpp │ ├── ray.cuh │ ├── hittables.cuh │ ├── camera.cuh │ ├── sphere.cuh │ └── material.cuh └── nextweek │ ├── color.hpp │ ├── ray.cuh │ ├── external.hpp │ ├── debug.hpp │ ├── knn.cuh │ ├── camera.cuh │ ├── triangle.cuh │ ├── box.cuh │ ├── cbuffer.hpp │ ├── kernels │ └── trace.cuh │ ├── aabb.cuh │ ├── mediumc.cuh │ ├── perlin.cuh │ ├── hittables.cuh │ └── sphere.cuh ├── src └── main.cpp ├── .gitignore ├── CMakeLists.txt └── README.md /img2.ppm: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/html/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/doc.png -------------------------------------------------------------------------------- /images/final.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/images/final.png -------------------------------------------------------------------------------- /images/final2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/images/final2.png -------------------------------------------------------------------------------- /images/final3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/images/final3.png -------------------------------------------------------------------------------- /images/final4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/images/final4.png -------------------------------------------------------------------------------- /images/final5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/images/final5.png -------------------------------------------------------------------------------- /docs/html/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/bc_s.png -------------------------------------------------------------------------------- /docs/html/bdwn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/bdwn.png -------------------------------------------------------------------------------- /docs/html/closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/closed.png -------------------------------------------------------------------------------- /docs/html/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/nav_f.png -------------------------------------------------------------------------------- /docs/html/nav_g.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/nav_g.png -------------------------------------------------------------------------------- /docs/html/nav_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/nav_h.png -------------------------------------------------------------------------------- /docs/html/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/open.png -------------------------------------------------------------------------------- /docs/html/tab_a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/tab_a.png -------------------------------------------------------------------------------- /docs/html/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/tab_b.png -------------------------------------------------------------------------------- /docs/html/tab_h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/tab_h.png -------------------------------------------------------------------------------- /docs/html/tab_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/tab_s.png -------------------------------------------------------------------------------- /docs/html/doxygen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/doxygen.png -------------------------------------------------------------------------------- /docs/html/splitbar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/splitbar.png -------------------------------------------------------------------------------- /docs/html/sync_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/sync_off.png -------------------------------------------------------------------------------- /docs/html/sync_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/sync_on.png -------------------------------------------------------------------------------- /docs/doxygen_sqlite3.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/doxygen_sqlite3.db -------------------------------------------------------------------------------- /docs/html/classMetal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classMetal.png -------------------------------------------------------------------------------- /docs/html/classSphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classSphere.png -------------------------------------------------------------------------------- /docs/html/folderopen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/folderopen.png -------------------------------------------------------------------------------- /images/cornell_smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/images/cornell_smoke.png -------------------------------------------------------------------------------- /docs/html/classBvhNode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classBvhNode.png -------------------------------------------------------------------------------- /docs/html/classHittable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classHittable.png -------------------------------------------------------------------------------- /docs/html/classMaterial.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classMaterial.png -------------------------------------------------------------------------------- /docs/html/classTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classTexture.png -------------------------------------------------------------------------------- /docs/html/folderclosed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/folderclosed.png -------------------------------------------------------------------------------- /docs/html/search/all_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['aabb_0',['Aabb',['../classAabb.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_b.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['ray_16',['Ray',['../classRay.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_e.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['vec3_21',['Vec3',['../classVec3.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_b.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['ray_38',['Ray',['../classRay.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/search/close.png -------------------------------------------------------------------------------- /docs/html/classDielectric.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classDielectric.png -------------------------------------------------------------------------------- /docs/html/classHittables.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classHittables.png -------------------------------------------------------------------------------- /docs/html/classLambertian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classLambertian.png -------------------------------------------------------------------------------- /docs/html/classSolidColor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classSolidColor.png -------------------------------------------------------------------------------- /docs/html/search/all_a.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['perlin_15',['Perlin',['../classPerlin.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_0.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['aabb_22',['Aabb',['../classAabb.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_e.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['vec3_43',['Vec3',['../classVec3.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/mag_sel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/search/mag_sel.png -------------------------------------------------------------------------------- /docs/html/search/search_l.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/search/search_l.png -------------------------------------------------------------------------------- /docs/html/search/search_m.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/search/search_m.png -------------------------------------------------------------------------------- /docs/html/search/search_r.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/search/search_r.png -------------------------------------------------------------------------------- /docs/html/classImageTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classImageTexture.png -------------------------------------------------------------------------------- /docs/html/classMovingSphere.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classMovingSphere.png -------------------------------------------------------------------------------- /docs/html/classNoiseTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classNoiseTexture.png -------------------------------------------------------------------------------- /docs/html/search/all_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['bvhnode_1',['BvhNode',['../classBvhNode.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_d.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['texture_20',['Texture',['../classTexture.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_a.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['perlin_37',['Perlin',['../classPerlin.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/classCheckerTexture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/D-K-E/cuda-raytracer/master/docs/html/classCheckerTexture.png -------------------------------------------------------------------------------- /docs/html/search/all_6.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['kernelarg_9',['KernelArg',['../structKernelArg.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_1.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['bvhnode_23',['BvhNode',['../classBvhNode.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_d.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['texture_42',['Texture',['../classTexture.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_3.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['dielectric_4',['Dielectric',['../classDielectric.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_7.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['lambertian_10',['Lambertian',['../classLambertian.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_6.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['kernelarg_31',['KernelArg',['../structKernelArg.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_5.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['imagetexture_8',['ImageTexture',['../classImageTexture.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_9.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['noisetexture_14',['NoiseTexture',['../classNoiseTexture.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_3.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['dielectric_26',['Dielectric',['../classDielectric.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_7.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['lambertian_32',['Lambertian',['../classLambertian.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_5.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['imagetexture_30',['ImageTexture',['../classImageTexture.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/classes_9.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['noisetexture_36',['NoiseTexture',['../classNoiseTexture.html',1,'']]] 4 | ]; 5 | -------------------------------------------------------------------------------- /docs/html/search/all_2.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['camera_2',['Camera',['../classCamera.html',1,'']]], 4 | ['checkertexture_3',['CheckerTexture',['../classCheckerTexture.html',1,'']]] 5 | ]; 6 | -------------------------------------------------------------------------------- /docs/html/search/classes_2.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['camera_24',['Camera',['../classCamera.html',1,'']]], 4 | ['checkertexture_25',['CheckerTexture',['../classCheckerTexture.html',1,'']]] 5 | ]; 6 | -------------------------------------------------------------------------------- /docs/html/search/all_4.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['hitrecord_5',['HitRecord',['../structHitRecord.html',1,'']]], 4 | ['hittable_6',['Hittable',['../classHittable.html',1,'']]], 5 | ['hittables_7',['Hittables',['../classHittables.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/html/search/all_8.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['material_11',['Material',['../classMaterial.html',1,'']]], 4 | ['metal_12',['Metal',['../classMetal.html',1,'']]], 5 | ['movingsphere_13',['MovingSphere',['../classMovingSphere.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/html/search/classes_8.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['material_33',['Material',['../classMaterial.html',1,'']]], 4 | ['metal_34',['Metal',['../classMetal.html',1,'']]], 5 | ['movingsphere_35',['MovingSphere',['../classMovingSphere.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/html/search/classes_4.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['hitrecord_27',['HitRecord',['../structHitRecord.html',1,'']]], 4 | ['hittable_28',['Hittable',['../classHittable.html',1,'']]], 5 | ['hittables_29',['Hittables',['../classHittables.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/html/search/all_c.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['solidcolor_17',['SolidColor',['../classSolidColor.html',1,'']]], 4 | ['sphere_18',['Sphere',['../classSphere.html',1,'']]], 5 | ['stbi_5fio_5fcallbacks_19',['stbi_io_callbacks',['../structstbi__io__callbacks.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/html/search/classes_c.js: -------------------------------------------------------------------------------- 1 | var searchData= 2 | [ 3 | ['solidcolor_39',['SolidColor',['../classSolidColor.html',1,'']]], 4 | ['sphere_40',['Sphere',['../classSphere.html',1,'']]], 5 | ['stbi_5fio_5fcallbacks_41',['stbi_io_callbacks',['../structstbi__io__callbacks.html',1,'']]] 6 | ]; 7 | -------------------------------------------------------------------------------- /docs/html/search/searchdata.js: -------------------------------------------------------------------------------- 1 | var indexSectionsWithContent = 2 | { 3 | 0: "abcdhiklmnprstv", 4 | 1: "abcdhiklmnprstv" 5 | }; 6 | 7 | var indexSectionNames = 8 | { 9 | 0: "all", 10 | 1: "classes" 11 | }; 12 | 13 | var indexSectionLabels = 14 | { 15 | 0: "All", 16 | 1: "Classes" 17 | }; 18 | 19 | -------------------------------------------------------------------------------- /include/oneweekend/external.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXTERNAL_HPP 2 | #define EXTERNAL_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/nextweek/color.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_HPP 2 | #define COLOR_HPP 3 | 4 | #include 5 | #include 6 | 7 | void write_color(std::ostream &out, Color pixel_color) { 8 | // Write the translated [0,255] value of each color component. 9 | out << static_cast(255.999 * pixel_color.x()) << " " 10 | << static_cast(255.999 * pixel_color.y()) << " " 11 | << static_cast(255.999 * pixel_color.z()) << std::endl; 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/oneweekend/color.hpp: -------------------------------------------------------------------------------- 1 | #ifndef COLOR_HPP 2 | #define COLOR_HPP 3 | 4 | #include 5 | #include 6 | 7 | void write_color(std::ostream &out, Color pixel_color) { 8 | // Write the translated [0,255] value of each color component. 9 | out << static_cast(255.999 * pixel_color.x()) << " " 10 | << static_cast(255.999 * pixel_color.y()) << " " 11 | << static_cast(255.999 * pixel_color.z()) << std::endl; 12 | } 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /include/oneweekend/hittable.cuh: -------------------------------------------------------------------------------- 1 | #ifndef HITTABLE_CUH 2 | #define HITTABLE_CUH 3 | 4 | #include 5 | 6 | class Material; 7 | 8 | struct HitRecord { 9 | float t; 10 | Point3 p; 11 | Vec3 normal; 12 | Material *mat_ptr; 13 | }; 14 | 15 | class Hittable { 16 | public: 17 | Material *mat_ptr; 18 | 19 | public: 20 | __device__ virtual bool hit(const Ray &r, float d_min, 21 | float d_max, 22 | HitRecord &rec) const = 0; 23 | }; 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /docs/html/search/nomatches.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 |
No Matches
10 |
11 | 12 | 13 | -------------------------------------------------------------------------------- /include/oneweekend/debug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_HPP 2 | #define DEBUG_HPP 3 | #include 4 | void cuda_control(cudaError_t res, const char *const fn, const char *const f, 5 | const int l) { 6 | if (res != cudaSuccess) { 7 | std::cerr << "CUDA ERROR :: " << static_cast(res) << " " 8 | << cudaGetErrorName(res) << " file: " << f << " line: " << l 9 | << " function: " << fn << std::endl; 10 | cudaDeviceReset(); 11 | exit(99); 12 | } 13 | } 14 | 15 | #define CUDA_CONTROL(v) cuda_control((v), #v, __FILE__, __LINE__) 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /include/oneweekend/ray.cuh: -------------------------------------------------------------------------------- 1 | #ifndef RAY_CUH 2 | #define RAY_CUH 3 | #include 4 | 5 | class Ray { 6 | public: 7 | Vec3 dir; 8 | Vec3 orig; 9 | float tm; 10 | 11 | public: 12 | __device__ Ray() {} 13 | __device__ Ray(const Point3 &p1, const Vec3 &d1, 14 | float time = 0.0f) 15 | : orig(p1), dir(d1), tm(time) {} 16 | __device__ Point3 origin() const { return orig; } 17 | __device__ Vec3 direction() const { return dir; } 18 | __device__ float time() const { return tm; } 19 | __device__ Point3 at(float t) const { 20 | return orig + dir * t; 21 | } 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/nextweek/ray.cuh: -------------------------------------------------------------------------------- 1 | #ifndef RAY_CUH 2 | #define RAY_CUH 3 | #include 4 | 5 | class Ray { 6 | public: 7 | Vec3 dir; 8 | Vec3 orig; 9 | float tm; 10 | 11 | public: 12 | __host__ __device__ Ray() {} 13 | __host__ __device__ Ray(const Point3 &p1, const Vec3 &d1, 14 | float time = 0.0f) 15 | : orig(p1), dir(d1), tm(time) {} 16 | __host__ __device__ Point3 origin() const { return orig; } 17 | __host__ __device__ Vec3 direction() const { return dir; } 18 | __host__ __device__ float time() const { return tm; } 19 | __host__ __device__ Point3 at(float t) const { 20 | return orig + dir * t; 21 | } 22 | }; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /include/nextweek/external.hpp: -------------------------------------------------------------------------------- 1 | #ifndef EXTERNAL_HPP 2 | #define EXTERNAL_HPP 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | 23 | // stb image read & write 24 | #define STB_IMAGE_IMPLEMENTATION 25 | #include 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | 5 | // Image 6 | 7 | const int image_width = 256; 8 | const int image_height = 256; 9 | 10 | // Render 11 | 12 | std::cout << "P3\n" << image_width << ' ' << image_height << "\n255\n"; 13 | 14 | for (int j = image_height - 1; j >= 0; --j) { 15 | for (int i = 0; i < image_width; ++i) { 16 | auto r = double(i) / (image_width - 1); 17 | auto g = double(j) / (image_height - 1); 18 | auto b = 0.25; 19 | 20 | int ir = static_cast(255.999 * r); 21 | int ig = static_cast(255.999 * g); 22 | int ib = static_cast(255.999 * b); 23 | 24 | std::cout << ir << ' ' << ig << ' ' << ib << '\n'; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | # cuda 35 | *.i 36 | *.ii 37 | *.gpu 38 | *.ptx 39 | *.cubin 40 | *.fatbin 41 | 42 | # cmake 43 | CMakeLists.txt.user 44 | CMakeCache.txt 45 | CMakeFiles 46 | CMakeScripts 47 | Testing 48 | Makefile 49 | cmake_install.cmake 50 | install_manifest.txt 51 | compile_commands.json 52 | CTestTestfile.cmake 53 | 54 | # custom 55 | **/bin/** 56 | -------------------------------------------------------------------------------- /include/nextweek/debug.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DEBUG_HPP 2 | #define DEBUG_HPP 3 | 4 | #include 5 | 6 | void cuda_control(cudaError_t res, const char *const fn, 7 | const char *const f, const int l) { 8 | if (res != cudaSuccess) { 9 | std::stringstream ss; 10 | ss << "CUDA ERROR :: " << static_cast(res) 11 | << std::endl 12 | << cudaGetErrorName(res) << " file: " << f 13 | << std::endl 14 | << " line: " << l << std::endl 15 | << " function: " << fn << std::endl; 16 | cudaDeviceReset(); 17 | std::string s = ss.str(); 18 | throw std::runtime_error(s.c_str()); 19 | exit(99); 20 | } 21 | } 22 | 23 | #define CUDA_CONTROL(v) \ 24 | cuda_control((v), #v, __FILE__, __LINE__) 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /include/oneweekend/hittables.cuh: -------------------------------------------------------------------------------- 1 | #ifndef HITTABLES_CUH 2 | #define HITTABLES_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | 9 | class Hittables : public Hittable { 10 | public: 11 | Hittable** list; 12 | int list_size; 13 | 14 | public: 15 | __device__ Hittables() {} 16 | __device__ 17 | Hittables(Hittable** hlist, int size){ 18 | list_size = size; 19 | list = hlist; 20 | } 21 | __device__ ~Hittables(){ 22 | delete list; 23 | } 24 | 25 | __device__ bool hit(const Ray &r, float d_min, float d_max, 26 | HitRecord &rec) const override { 27 | HitRecord temp; 28 | bool hit_anything = false; 29 | float closest_far = d_max; 30 | for (int i = 0; i < list_size; i++) { 31 | Hittable* h = list[i]; 32 | bool isHit = h->hit(r, d_min, closest_far, temp); 33 | if (isHit == true) { 34 | hit_anything = true; 35 | closest_far = temp.t; 36 | rec = temp; 37 | } 38 | } 39 | return hit_anything; 40 | } 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /include/oneweekend/camera.cuh: -------------------------------------------------------------------------------- 1 | #ifndef CAMERA_CUH 2 | #define CAMERA_CUH 3 | 4 | #include 5 | 6 | class Camera { 7 | public: 8 | __device__ Camera(Vec3 orig, Vec3 target, Vec3 vup, 9 | float vfov, float aspect, 10 | float aperture, float focus_dist, 11 | float t0 = 0.0f, float t1 = 0.0f) { 12 | lens_radius = aperture / 2; 13 | time0 = t0; 14 | time1 = t1; 15 | float theta = vfov * M_PI / 180; 16 | float half_height = tan(theta / 2); 17 | float half_width = aspect * half_height; 18 | origin = orig; 19 | w = to_unit(orig - target); 20 | u = to_unit(cross(vup, w)); 21 | v = cross(w, u); 22 | lower_left_corner = 23 | origin - half_width * focus_dist * u - 24 | half_height * focus_dist * v - focus_dist * w; 25 | horizontal = 2 * half_width * focus_dist * u; 26 | vertical = 2 * half_height * focus_dist * v; 27 | } 28 | __device__ Ray get_ray(float s, float t, 29 | curandState *lo) const { 30 | Vec3 rd = lens_radius * random_in_unit_disk(lo); 31 | Vec3 offset = u * rd.x() + v * rd.y(); 32 | return Ray(origin + offset, 33 | lower_left_corner + s * horizontal + 34 | t * vertical - origin - offset, 35 | random_float(lo, time0, time1)); 36 | } 37 | 38 | Vec3 origin; 39 | Vec3 lower_left_corner; 40 | Vec3 horizontal; 41 | Vec3 vertical; 42 | Vec3 u, v, w; 43 | float lens_radius; 44 | float time0, time1; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.18 FATAL_ERROR) 2 | project("CudaIsinIzleyici" LANGUAGES CXX CUDA) 3 | 4 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON) 5 | 6 | set(CMAKE_CXX_COMPILER "clang") 7 | 8 | include_directories( 9 | "./include/" 10 | ) 11 | add_executable( 12 | oneweekend.out 13 | "src/oneweekend/main.cu" 14 | ) 15 | 16 | add_executable( 17 | nextweek.out 18 | "src/nextweek/main.cu" 19 | ) 20 | 21 | add_executable( 22 | main_c.out 23 | "src/main.cpp" 24 | ) 25 | 26 | find_package(CUDA REQUIRED) 27 | #find_package(Thrust REQUIRED) 28 | #thrust_create_target(Thrust) 29 | 30 | set(CMAKE_CXX_STANDARD 14) 31 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 32 | 33 | set(CMAKE_CXX_FLAGS "-lstdc++ -ldl -ggdb -Wall -Wextra -pedantic -Wextra-tokens") 34 | 35 | 36 | set(CMAKE_CUDA_FLAGS "-ccbin clang++ -g -gencode arch=compute_50,code=sm_50") 37 | 38 | #target_compile_features(main PUBLIC cxx_std_11) 39 | 40 | set_target_properties( oneweekend.out 41 | PROPERTIES CUDA_SEPARABLE_COMPILATION ON 42 | ) 43 | set_target_properties(oneweekend.out 44 | PROPERTIES LINKER_LANGUAGE CUDA) 45 | 46 | set_target_properties( nextweek.out 47 | PROPERTIES CUDA_SEPARABLE_COMPILATION ON 48 | ) 49 | set_target_properties(nextweek.out 50 | PROPERTIES LINKER_LANGUAGE CUDA) 51 | 52 | install(TARGETS oneweekend.out DESTINATION "${PROJECT_SOURCE_DIR}/bin") 53 | 54 | install(TARGETS nextweek.out DESTINATION "${PROJECT_SOURCE_DIR}/bin") 55 | 56 | install(TARGETS main_c.out DESTINATION "${PROJECT_SOURCE_DIR}/bin") 57 | -------------------------------------------------------------------------------- /docs/html/search/all_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_b.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/all_e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_0.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_9.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_a.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_b.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_c.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_d.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /docs/html/search/classes_e.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 |
Loading...
12 |
13 | 18 |
Searching...
19 |
No Matches
20 | 34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /include/nextweek/knn.cuh: -------------------------------------------------------------------------------- 1 | #ifndef KNN_CUH 2 | #define KNN_CUH 3 | // k nearest neighbour acceleration structure 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | // 10 | class KNN { 11 | public: 12 | const unsigned int k; 13 | Point3 centers[k]; 14 | Hittable **groups; 15 | const int group_size; 16 | curandState *rState; 17 | const float err_margin; 18 | const int mxX, mxY, mxZ; 19 | static const int max_iter_size = 5000; 20 | 21 | public: 22 | __device__ KNN() : k(0) {} 23 | __device__ KNN(unsigned int knb, Hittable **&gs, 24 | float err, curandState *randState, 25 | float maxX, float maxY, float maxZ, 26 | int gsize) 27 | : k(knb), groups(gs), err_margin(err), 28 | rState(randState), mxX(maxX), mxY(maxY), mxZ(maxZ), 29 | group_size(gsize) { 30 | Point3 *cnts = new Point3[k]; 31 | for (int i = 0; i < k; i++) { 32 | cnts[i] = random_vec(rState, mxX, mxY, mxZ); 33 | } 34 | centers = cnts; 35 | } 36 | 37 | __device__ Point3 bbox_center(int index) { 38 | Hittable *h = groups[index]; 39 | Aabb temp; 40 | if (h->bounding_box(0, 1, temp)) { 41 | return temp.center(); 42 | } else { 43 | return random_vec(rState, mxX, mxY, mxZ); 44 | } 45 | } 46 | 47 | __device__ float distance_to_point(Point3 p1, Point3 p2) { 48 | return distance(p1, p2); 49 | } 50 | __device__ float hittable_to_center_distance(int index, 51 | Point3 c) { 52 | Point3 hcenter = bbox_center(index); 53 | return distance_to_point(hcenter, c); 54 | } 55 | }; 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /docs/html/menudata.js: -------------------------------------------------------------------------------- 1 | /* 2 | @licstart The following is the entire license notice for the JavaScript code in this file. 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (C) 1997-2020 by Dimitri van Heesch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 | and associated documentation files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or 15 | substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | @licend The above is the entire license notice for the JavaScript code in this file 24 | */ 25 | var menudata={children:[ 26 | {text:"Main Page",url:"index.html"}, 27 | {text:"Classes",url:"annotated.html",children:[ 28 | {text:"Class List",url:"annotated.html"}, 29 | {text:"Class Index",url:"classes.html"}, 30 | {text:"Class Hierarchy",url:"hierarchy.html"}]}, 31 | {text:"Files",url:"files.html",children:[ 32 | {text:"File List",url:"files.html"}]}]} 33 | -------------------------------------------------------------------------------- /include/nextweek/camera.cuh: -------------------------------------------------------------------------------- 1 | #ifndef CAMERA_CUH 2 | #define CAMERA_CUH 3 | 4 | #include 5 | #include 6 | 7 | 8 | /** A simple Camera specification object that can be instantiated both 9 | on host and on device. 10 | */ 11 | class Camera { 12 | public: 13 | __host__ __device__ Camera(Vec3 orig, Vec3 target, 14 | Vec3 vup, float vfov, 15 | float aspect, float aperture, 16 | float focus_dist, 17 | float t0 = 0.0f, 18 | float t1 = 0.0f) { 19 | lens_radius = aperture / 2; 20 | time0 = t0; 21 | time1 = t1; 22 | float theta = vfov * M_PI / 180; 23 | float half_height = tan(theta / 2); 24 | float half_width = aspect * half_height; 25 | origin = orig; 26 | w = to_unit(orig - target); 27 | u = to_unit(cross(vup, w)); 28 | v = cross(w, u); 29 | lower_left_corner = 30 | origin - half_width * focus_dist * u - 31 | half_height * focus_dist * v - focus_dist * w; 32 | horizontal = 2 * half_width * focus_dist * u; 33 | vertical = 2 * half_height * focus_dist * v; 34 | } 35 | 36 | __device__ Ray get_ray(float s, float t, 37 | curandState *lo) const { 38 | Vec3 rd = lens_radius * random_in_unit_disk(lo); 39 | Vec3 offset = u * rd.x() + v * rd.y(); 40 | return Ray(origin + offset, 41 | lower_left_corner + s * horizontal + 42 | t * vertical - origin - offset, 43 | random_float(lo, time0, time1)); 44 | } 45 | 46 | Vec3 origin; 47 | Vec3 lower_left_corner; 48 | Vec3 horizontal; 49 | Vec3 vertical; 50 | Vec3 u, v, w; 51 | float lens_radius; 52 | float time0, time1; 53 | }; 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /include/nextweek/triangle.cuh: -------------------------------------------------------------------------------- 1 | #ifndef TRIANGLE_CUH 2 | #define TRIANGLE_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class Triangle : public Hittable { 12 | public: 13 | Point3 p1, p2, p3; 14 | Material *mat_ptr; 15 | __host__ __device__ bool hit(const Ray &r, float d_min, 16 | float d_max, 17 | HitRecord &rec) const override { 18 | // implementing moller from wikipedia 19 | // https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm 20 | const float eps = 0.000001f; 21 | Vec3 edge1 = p1 - p2; 22 | Vec3 edge2 = p3 - p2; 23 | Vec3 h = cross(r.direction(), edge2); 24 | float a = dot(edge1, h); 25 | if (a > eps && a < eps) 26 | return false; // ray parallel to triangle 27 | float f = 1.0f / a; 28 | Vec3 rToP2 = r.origin() - p2; 29 | float u = f * dot(rToP2, h); 30 | if (u < 0.0f || u > 1.0f) 31 | return false; 32 | 33 | Vec3 q = cross(rToP2, edge1); 34 | float v = f * dot(edge2, q); 35 | if (v < 0.0f || v > 1.0f) 36 | return false; 37 | 38 | float t = f * dot(r.direction(), q); 39 | if (t < eps) 40 | return false; 41 | 42 | rec.v = v; 43 | rec.u = u; 44 | rec.t = t; 45 | rec.p = r.at(rec.t); 46 | Vec3 outnormal = cross(edge1, edge2); 47 | rec.set_front_face(r, outnormal); 48 | rec.mat_ptr = mat_ptr; 49 | } 50 | __host__ __device__ bool 51 | bounding_box(float t0, float t1, 52 | Aabb &output_box) const override { 53 | Point3 pmin = min_vec(p1, p2); 54 | pmin = min_vec(pmin, p3); 55 | 56 | Point3 pmax = max_vec(p1, p2); 57 | pmax = max_vec(pmax, p3); 58 | output_box = Aabb(pmin, pmax); 59 | return true; 60 | } 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/nextweek/box.cuh: -------------------------------------------------------------------------------- 1 | #ifndef BOX_CUH 2 | #define BOX_CUH 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | enum State : int { SOLID, LIQUID, GAS }; 10 | 11 | class Box : public HittableGroup { 12 | public: 13 | __host__ __device__ Box() : HittableGroup() {} 14 | __host__ __device__ Box(const Point3 &p0, 15 | const Point3 &p1, Material *mptr, 16 | Hittable **&ss, int &k) 17 | : HittableGroup(ss, k, k + hittable_size) { 18 | box_min = p0; 19 | box_max = p1; 20 | 21 | ss[k] = new XYRect(p0.x(), p1.x(), p0.y(), p1.y(), 22 | p1.z(), mptr); 23 | k++; 24 | ss[k] = new XYRect(p0.x(), p1.x(), p0.y(), p1.y(), 25 | p0.z(), mptr); 26 | k++; 27 | ss[k] = new XZRect(p0.x(), p1.x(), p0.z(), p1.z(), 28 | p1.y(), mptr); 29 | k++; 30 | ss[k] = new XZRect(p0.x(), p1.x(), p0.z(), p1.z(), 31 | p0.y(), mptr); 32 | 33 | k++; 34 | ss[k] = new YZRect(p0.y(), p1.y(), p0.z(), p1.z(), 35 | p1.x(), mptr); 36 | k++; 37 | ss[k] = new YZRect(p0.y(), p1.y(), p0.z(), p1.z(), 38 | p0.x(), mptr); 39 | list = ss; 40 | } 41 | 42 | __host__ __device__ void translate(Hittable **&ss, 43 | const Point3 &p) { 44 | for (int i = start_index; i < end_index; i++) { 45 | list[i] = new Translate(list[i], p); 46 | ss[i] = list[i]; 47 | } 48 | } 49 | __host__ __device__ void rotate_y(Hittable **&ss, 50 | float angle) { 51 | for (int i = start_index; i < end_index; i++) { 52 | list[i] = new RotateY(list[i], angle); 53 | ss[i] = list[i]; 54 | } 55 | } 56 | 57 | public: 58 | Point3 box_min; 59 | Point3 box_max; 60 | static const int hittable_size = 6; 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /include/nextweek/cbuffer.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CBUFFER_HPP 2 | #define CBUFFER_HPP 3 | 4 | #include 5 | #include 6 | 7 | template 8 | void upload_to_device(thrust::device_ptr &d_ptr, 9 | T *h_ptr, int size) { 10 | d_ptr = thrust::device_malloc(size); 11 | for (int i = 0; i < size; i++) { 12 | d_ptr[i] = h_ptr[i]; 13 | } 14 | } 15 | template 16 | void upload_to_device(thrust::device_ptr &d_ptr, 17 | std::vector &h_ptr) { 18 | d_ptr = thrust::device_ptr(h_ptr.data()); 19 | } 20 | template 21 | void download_to_host(T *d_ptr, T *h_ptr, int size) { 22 | CUDA_CONTROL( 23 | cudaMemcpy((void *)h_ptr, (const void *)d_ptr, 24 | sizeof(T) * size, cudaMemcpyDeviceToHost)); 25 | } 26 | 27 | template 28 | thrust::device_vector 29 | to_device_vec(thrust::host_vector hvec) { 30 | thrust::device_vector dvec = hvec; 31 | return dvec; 32 | } 33 | template 34 | thrust::device_vector to_device_vec(T &h) { 35 | thrust::host_vector hvec; 36 | hvec.push_back(h); 37 | return to_device_vec(hvec); 38 | } 39 | template 40 | thrust::device_vector to_device_vec(T *hs, int size) { 41 | thrust::host_vector hvec; 42 | for (int i = 0; i < size; i++) { 43 | hvec.push_back(hs[i]); 44 | } 45 | return to_device_vec(hvec); 46 | } 47 | 48 | template struct KernelArg { 49 | // based on the code 50 | // https://codeyarns.com/2011/04/09/how-to-pass-thrust-device-vector-to-kernel/ 51 | T *arg; 52 | int length; 53 | __host__ void free() { cudaFree(arg); } 54 | }; 55 | template 56 | KernelArg mkKernelArg(thrust::device_vector &dvec) { 57 | KernelArg karg; 58 | karg.arg = thrust::raw_pointer_cast(&dvec[0]); 59 | karg.length = (int)dvec.size(); 60 | return karg; 61 | } 62 | template 63 | KernelArg mkKernelArg(thrust::host_vector hvec) { 64 | return mkKernelArg(to_device_vec(hvec)); 65 | } 66 | 67 | template 68 | KernelArg mkKernelArg(T *hs, int size) { 69 | return mkKernelArg(to_device_vec(hs, size)); 70 | } 71 | 72 | template KernelArg mkKernelArg(T &h) { 73 | return mkKernelArg(to_device_vec(h)); 74 | } 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /include/nextweek/kernels/trace.cuh: -------------------------------------------------------------------------------- 1 | // trace kernel 2 | #pragma once 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | /** 13 | @param Ray r is the incoming ray. 14 | @param Hittables** world pointer to list of hittables 15 | */ 16 | __device__ Color ray_color(const Ray &r, Hittables **world, 17 | curandState *local_rand_state, 18 | int bounceNb) { 19 | Ray current_ray = r; 20 | Vec3 current_attenuation = Vec3(1.0f); 21 | Vec3 result = Vec3(0.0f); 22 | while (bounceNb > 0) { 23 | HitRecord rec; 24 | bool anyHit = 25 | world[0]->hit(current_ray, 0.001f, FLT_MAX, rec); 26 | if (anyHit) { 27 | Color emittedColor = 28 | rec.mat_ptr->emitted(rec.u, rec.v, rec.p); 29 | Ray scattered; 30 | Vec3 attenuation; 31 | bool isScattered = rec.mat_ptr->scatter( 32 | current_ray, rec, attenuation, scattered, 33 | local_rand_state); 34 | if (isScattered) { 35 | bounceNb--; 36 | result += (current_attenuation * emittedColor); 37 | current_attenuation *= attenuation; 38 | current_ray = scattered; 39 | } else { 40 | result += (current_attenuation * emittedColor); 41 | return result; 42 | } 43 | } else { 44 | return Color(0.0); 45 | } 46 | } 47 | return Vec3(0.0f); // background color 48 | } 49 | __global__ void render(Vec3 *fb, int maximum_x, 50 | int maximum_y, int sample_nb, 51 | int bounceNb, Camera dcam, 52 | Hittables **world, 53 | curandState *randState) { 54 | int i = threadIdx.x + blockIdx.x * blockDim.x; 55 | int j = threadIdx.y + blockIdx.y * blockDim.y; 56 | 57 | if ((i >= maximum_x) || (j >= maximum_y)) { 58 | return; 59 | } 60 | int pixel_index = j * maximum_x + i; 61 | curandState localS = randState[pixel_index]; 62 | Vec3 rcolor(0.0f); 63 | Camera cam = dcam; 64 | for (int s = 0; s < sample_nb; s++) { 65 | float u = float(i + curand_uniform(&localS)) / 66 | float(maximum_x); 67 | float v = float(j + curand_uniform(&localS)) / 68 | float(maximum_y); 69 | Ray r = cam.get_ray(u, v, &localS); 70 | // 71 | rcolor += ray_color(r, world, &localS, bounceNb); 72 | } 73 | // fix the bounce depth 74 | randState[pixel_index] = localS; 75 | rcolor /= float(sample_nb); 76 | rcolor.e[0] = sqrt(rcolor.x()); 77 | rcolor.e[1] = sqrt(rcolor.y()); 78 | rcolor.e[2] = sqrt(rcolor.z()); 79 | fb[pixel_index] = rcolor; 80 | } 81 | -------------------------------------------------------------------------------- /docs/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Main Page 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 | 21 | 22 | 23 | 27 | 28 | 29 |
24 |
Cuda Ray Tracer 25 |
26 |
30 |
31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 |
49 | 50 |
54 |
55 | 56 | 57 |
58 | 61 |
62 | 63 |
64 |
65 |
Cuda Ray Tracer Documentation
66 |
67 |
68 |
69 | 70 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /include/oneweekend/sphere.cuh: -------------------------------------------------------------------------------- 1 | #ifndef SPHERE_CUH 2 | #define SPHERE_CUH 3 | 4 | #include 5 | #include 6 | 7 | class Sphere : public Hittable { 8 | public: 9 | __device__ Sphere() {} 10 | __device__ Sphere(Point3 cen, float r, Material *mat_ptr_) 11 | : center(cen), radius(r), mat_ptr(mat_ptr_){}; 12 | __device__ ~Sphere() { delete mat_ptr; } 13 | __device__ bool hit(const Ray &r, float d_min, 14 | float d_max, 15 | HitRecord &rec) const override { 16 | Vec3 oc = r.origin() - center; 17 | float a = dot(r.direction(), r.direction()); 18 | float b = dot(oc, r.direction()); 19 | float c = dot(oc, oc) - radius * radius; 20 | float discriminant = b * b - a * c; 21 | if (discriminant > 0) { 22 | float temp = (-b - sqrt(discriminant)) / a; 23 | if (temp < d_max && temp > d_min) { 24 | rec.t = temp; 25 | rec.p = r.at(rec.t); 26 | rec.normal = (rec.p - center) / radius; 27 | rec.mat_ptr = mat_ptr; 28 | return true; 29 | } 30 | temp = (-b + sqrt(discriminant)) / a; 31 | if (temp < d_max && temp > d_min) { 32 | rec.t = temp; 33 | rec.p = r.at(rec.t); 34 | rec.normal = (rec.p - center) / radius; 35 | rec.mat_ptr = mat_ptr; 36 | return true; 37 | } 38 | } 39 | return false; 40 | } 41 | 42 | public: 43 | Vec3 center; 44 | float radius; 45 | Material *mat_ptr; 46 | }; 47 | 48 | class MovingSphere : public Hittable { 49 | public: 50 | Point3 center1, center2; 51 | float time0, time1, radius; 52 | Material *mat_ptr; 53 | 54 | public: 55 | __device__ MovingSphere(); 56 | __device__ ~MovingSphere() { delete mat_ptr; }; 57 | __device__ MovingSphere(Point3 c1, Point3 c2, float t0, 58 | float t1, float rad, 59 | Material *mat) 60 | : center1(c1), center2(c2), time0(t0), time1(t1), 61 | radius(rad), mat_ptr(mat) {} 62 | __device__ Point3 center(float time) const { 63 | return center1 + 64 | ((time - time0) / (time1 - time0)) * 65 | (center2 - center1); 66 | } 67 | __device__ bool hit(const Ray &r, float d_min, 68 | float d_max, 69 | HitRecord &rec) const override { 70 | Point3 scenter = center(r.time()); 71 | Vec3 oc = r.origin() - scenter; 72 | float a = dot(r.direction(), r.direction()); 73 | float b = dot(oc, r.direction()); 74 | float c = dot(oc, oc) - radius * radius; 75 | float discriminant = b * b - a * c; 76 | if (discriminant > 0) { 77 | float temp = (-b - sqrt(discriminant)) / a; 78 | if (temp < d_max && temp > d_min) { 79 | rec.t = temp; 80 | rec.p = r.at(rec.t); 81 | rec.normal = (rec.p - scenter) / radius; 82 | rec.mat_ptr = mat_ptr; 83 | return true; 84 | } 85 | temp = (-b + sqrt(discriminant)) / a; 86 | if (temp < d_max && temp > d_min) { 87 | rec.t = temp; 88 | rec.p = r.at(rec.t); 89 | rec.normal = (rec.p - scenter) / radius; 90 | rec.mat_ptr = mat_ptr; 91 | return true; 92 | } 93 | } 94 | return false; 95 | } 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /include/nextweek/aabb.cuh: -------------------------------------------------------------------------------- 1 | #ifndef AABB_CUH 2 | #define AABB_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | /** 10 | @brief axis aligned bounding box 11 | 12 | A simple acceleration structure that helps us to organize 13 | the scene in what is know as an axis aligned bounding box. 14 | A good description is given in P. 16 | Shirley's text. 17 | The main idea is the following for objects that inside the 18 | same Aabb, when a 19 | hit occurs, their hit distance overlaps. We check that to 20 | ensure we have a 21 | hit or not. Basically instead of checking all objects 22 | inside the Aabb, by 23 | simply checking maximum and minimum point we check if a 24 | hit occurred. 25 | */ 26 | class Aabb { 27 | public: 28 | __host__ __device__ Aabb() {} 29 | __host__ __device__ Aabb(const Point3 &a, 30 | const Point3 &b) { 31 | _min = a; 32 | _max = b; 33 | cent = (_max - _min) / 2.0; 34 | volume = compute_box_volume(a, b); 35 | } 36 | 37 | __host__ __device__ Point3 min() const { return _min; } 38 | __host__ __device__ Point3 max() const { return _max; } 39 | __host__ __device__ float 40 | compute_box_volume(const Point3 &a, 41 | const Point3 &b) const { 42 | // from 43 | // Agoston (Max), Computer Graphics and Geometric 44 | // Modeling: Mathematics, London, 2005. ISBN : 45 | // 1-85233-817-2. page 256 46 | Vec3 minv(dfmin(a.x(), b.x()), dfmin(a.y(), b.y()), 47 | dfmin(a.z(), b.z())); 48 | Vec3 maxv(dfmax(a.x(), b.x()), dfmax(a.y(), b.y()), 49 | dfmax(a.z(), b.z())); 50 | return (maxv.x() - minv.x()) * (maxv.y() - minv.y()) * 51 | (maxv.z() - minv.z()); 52 | } 53 | __host__ __device__ bool hit(const Ray &r, float tmin, 54 | float tmax) const { 55 | for (int a = 0; a < 3; a++) { 56 | float t0 = dfmin( 57 | (_min[a] - r.origin()[a]) / r.direction()[a], 58 | (_max[a] - r.origin()[a]) / r.direction()[a]); 59 | float t1 = dfmax( 60 | (_min[a] - r.origin()[a]) / r.direction()[a], 61 | (_max[a] - r.origin()[a]) / r.direction()[a]); 62 | tmin = dfmax(t0, tmin); 63 | tmax = dfmin(t1, tmax); 64 | if (tmax <= tmin) 65 | return false; 66 | } 67 | return true; 68 | } 69 | __host__ __device__ Point3 center() const { return cent; } 70 | 71 | public: 72 | Point3 _min; 73 | Point3 _max; 74 | float volume; 75 | Point3 cent; // center 76 | }; 77 | 78 | __host__ __device__ Aabb surrounding_box(Aabb b1, Aabb b2) { 79 | Point3 b1min = b1.min(); 80 | Point3 b2min = b2.min(); 81 | Point3 small(dfmin(b1min.x(), b2min.x()), 82 | dfmin(b1min.y(), b2min.y()), 83 | dfmin(b1min.z(), b2min.z())); 84 | 85 | Point3 b1max = b1.max(); 86 | Point3 b2max = b2.max(); 87 | 88 | Point3 big(dfmax(b1max.x(), b2max.x()), 89 | dfmax(b1max.y(), b2max.y()), 90 | dfmax(b1max.z(), b2max.z())); 91 | 92 | return Aabb(small, big); 93 | } 94 | 95 | #endif 96 | -------------------------------------------------------------------------------- /docs/html/menu.js: -------------------------------------------------------------------------------- 1 | /* 2 | @licstart The following is the entire license notice for the JavaScript code in this file. 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (C) 1997-2020 by Dimitri van Heesch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 | and associated documentation files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or 15 | substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | @licend The above is the entire license notice for the JavaScript code in this file 24 | */ 25 | function initMenu(relPath,searchEnabled,serverSide,searchPage,search) { 26 | function makeTree(data,relPath) { 27 | var result=''; 28 | if ('children' in data) { 29 | result+=''; 36 | } 37 | return result; 38 | } 39 | 40 | $('#main-nav').append(makeTree(menudata,relPath)); 41 | $('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu'); 42 | if (searchEnabled) { 43 | if (serverSide) { 44 | $('#main-menu').append('
  • '); 45 | } else { 46 | $('#main-menu').append('
  • '); 47 | } 48 | } 49 | $('#main-menu').smartmenus(); 50 | } 51 | /* @license-end */ 52 | -------------------------------------------------------------------------------- /docs/html/dir_c9e4cb2c20911002ee1815db3792ebfc.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: /media/kaan/Data7510/GitProjects/cuda-raytracer/src/nextweek Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 | 66 |
    67 |
    68 |
    69 |
    nextweek Directory Reference
    70 |
    71 |
    72 |
    73 | 74 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/html/dir_a034f12e10456ed9baa6c2174620f736.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: /media/kaan/Data7510/GitProjects/cuda-raytracer/include/nextweek Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 | 66 |
    67 |
    68 |
    69 |
    nextweek Directory Reference
    70 |
    71 |
    72 |
    73 | 74 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/html/dir_cb5a55d9e9c1b47934843b044d803335.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: /media/kaan/Data7510/GitProjects/cuda-raytracer/src/oneweekend Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 | 66 |
    67 |
    68 |
    69 |
    oneweekend Directory Reference
    70 |
    71 |
    72 |
    73 | 74 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /docs/html/dir_b5ed2bba80ecaac353b1d8be0f5c3722.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: /media/kaan/Data7510/GitProjects/cuda-raytracer/include/oneweekend Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 | 66 |
    67 |
    68 |
    69 |
    oneweekend Directory Reference
    70 |
    71 |
    72 |
    73 | 74 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /include/nextweek/mediumc.cuh: -------------------------------------------------------------------------------- 1 | #ifndef MEDIUMC_CUH 2 | #define MEDIUMC_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | class ConstantMedium : public Hittable { 14 | public: 15 | __host__ __device__ ConstantMedium(Hittable *&b, float d, 16 | Texture *a) 17 | : boundary(b), neg_inv_density(-1 / d), 18 | phase_function(new Isotropic(a)) {} 19 | 20 | __device__ ConstantMedium(Hittable *&b, float d, 21 | Texture *a, curandState *s) 22 | : boundary(b), neg_inv_density(-1 / d), 23 | phase_function(new Isotropic(a)), rState(s) {} 24 | 25 | __host__ __device__ ConstantMedium(Hittable *&b, float d, 26 | Color c) 27 | : boundary(b), neg_inv_density(-1 / d), 28 | phase_function(new Isotropic(c)) {} 29 | 30 | __device__ ConstantMedium(Hittable *b, float d, Color c, 31 | curandState *s) 32 | : boundary(b), neg_inv_density(-1 / d), 33 | phase_function(new Isotropic(c)), rState(s) {} 34 | 35 | __device__ bool hit(const Ray &r, float t_min, 36 | float t_max, 37 | HitRecord &rec) const override { 38 | // 39 | // Print occasional samples when debugging. To enable, 40 | // set enableDebug true. 41 | const bool enableDebug = false; 42 | 43 | const bool debugging = 44 | enableDebug && curand_uniform(rState) < 0.00001; 45 | 46 | HitRecord rec1, rec2; 47 | 48 | if (!boundary->hit(r, -FLT_MAX, FLT_MAX, rec1)) 49 | return false; 50 | 51 | if (!boundary->hit(r, rec1.t + 0.0001f, FLT_MAX, rec2)) 52 | return false; 53 | 54 | if (debugging) { 55 | printf("\nt0= %f", rec1.t); 56 | printf(", t1= %f\n", rec2.t); 57 | } 58 | 59 | if (rec1.t < t_min) 60 | rec1.t = t_min; 61 | if (rec2.t > t_max) 62 | rec2.t = t_max; 63 | 64 | if (rec1.t >= rec2.t) 65 | return false; 66 | 67 | if (rec1.t < 0) 68 | rec1.t = 0; 69 | 70 | const float ray_length = r.direction().length(); 71 | const float distance_inside_boundary = 72 | (rec2.t - rec1.t) * ray_length; 73 | const float hit_distance = 74 | neg_inv_density * log(curand_uniform(rState)); 75 | 76 | if (hit_distance > distance_inside_boundary) 77 | return false; 78 | 79 | rec.t = rec1.t + hit_distance / ray_length; 80 | rec.p = r.at(rec.t); 81 | 82 | if (debugging) { 83 | printf("hit_distance = %f\n", hit_distance); 84 | printf("rec.t = %f\n", rec.t); 85 | printf("rec.p = %f ", rec.p.x()); 86 | printf("%f ", rec.p.y()); 87 | printf("%f ", rec.p.z()); 88 | } 89 | 90 | rec.normal = Vec3(1, 0, 0); // arbitrary 91 | rec.front_face = true; // also arbitrary 92 | rec.mat_ptr = phase_function; 93 | 94 | return true; 95 | } 96 | 97 | __host__ __device__ bool 98 | bounding_box(float t0, float t1, 99 | Aabb &output_box) const override { 100 | return boundary->bounding_box(t0, t1, output_box); 101 | } 102 | 103 | public: 104 | const Hittable *boundary; 105 | Material *phase_function; 106 | float neg_inv_density; 107 | curandState *rState; 108 | }; 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /docs/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: /media/kaan/Data7510/GitProjects/cuda-raytracer/src Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 | 66 |
    67 |
    68 |
    69 |
    src Directory Reference
    70 |
    71 |
    72 | 73 | 75 |

    74 | Directories

    76 |
    77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /include/nextweek/perlin.cuh: -------------------------------------------------------------------------------- 1 | #ifndef PERLIN_CUH 2 | #define PERLIN_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class Perlin { 9 | public: 10 | __host__ __device__ Perlin() {} 11 | __device__ Perlin(curandState *loc) { 12 | ranvec = new Vec3[point_count]; 13 | for (int i = 0; i < point_count; ++i) { 14 | ranvec[i] = to_unit(random_vec(loc, -1.0f, 1.0f)); 15 | } 16 | 17 | int *px = new int[point_count]; 18 | perlin_generate_perm(loc, px); 19 | perm_x = px; 20 | int *py = new int[point_count]; 21 | perlin_generate_perm(loc, py); 22 | perm_y = py; 23 | int *pz = new int[point_count]; 24 | perlin_generate_perm(loc, pz); 25 | perm_z = pz; 26 | } 27 | 28 | __host__ __device__ ~Perlin() { 29 | delete[] ranvec; 30 | delete[] perm_x; 31 | delete[] perm_y; 32 | delete[] perm_z; 33 | } 34 | 35 | __host__ __device__ float noise(const Point3 &p) const { 36 | float u = p.x() - floor(p.x()); 37 | float v = p.y() - floor(p.y()); 38 | float w = p.z() - floor(p.z()); 39 | int i = (int)(floor(p.x())); 40 | int j = (int)(floor(p.y())); 41 | int k = (int)(floor(p.z())); 42 | Vec3 c[2][2][2]; 43 | 44 | for (int di = 0; di < 2; di++) 45 | for (int dj = 0; dj < 2; dj++) 46 | for (int dk = 0; dk < 2; dk++) 47 | c[di][dj][dk] = ranvec[perm_x[(i + di) & 255] ^ 48 | perm_y[(j + dj) & 255] ^ 49 | perm_z[(k + dk) & 255]]; 50 | 51 | return perlin_interp(c, u, v, w); 52 | } 53 | 54 | __host__ __device__ float turb(const Point3 &p, 55 | int depth = 7) const { 56 | float accum = 0.0f; 57 | Point3 temp_p = p; 58 | float weight = 1.0; 59 | 60 | for (int i = 0; i < depth; i++) { 61 | accum += weight * noise(temp_p); 62 | weight *= 0.5; 63 | temp_p *= 2; 64 | } 65 | 66 | return fabs(accum); 67 | } 68 | 69 | private: 70 | static const int point_count = 256; 71 | Vec3 *ranvec; 72 | int *perm_x; 73 | int *perm_y; 74 | int *perm_z; 75 | 76 | __device__ static void 77 | perlin_generate_perm(curandState *loc, int *p) { 78 | 79 | for (int i = 0; i < point_count; i++) 80 | p[i] = i; 81 | 82 | permute(p, point_count, loc); 83 | } 84 | 85 | __device__ static void permute(int *p, int n, 86 | curandState *loc) { 87 | for (int i = n - 1; i > 0; i--) { 88 | int target = random_int(loc,0, i); 89 | // int target = randint((unsigned int)i,0, i); 90 | int tmp = p[i]; 91 | p[i] = p[target]; 92 | p[target] = tmp; 93 | } 94 | } 95 | 96 | __host__ __device__ inline static double 97 | perlin_interp(Vec3 c[2][2][2], float u, float v, 98 | float w) { 99 | auto uu = u * u * (3 - 2 * u); 100 | auto vv = v * v * (3 - 2 * v); 101 | auto ww = w * w * (3 - 2 * w); 102 | auto accum = 0.0; 103 | 104 | for (int i = 0; i < 2; i++) 105 | for (int j = 0; j < 2; j++) 106 | for (int k = 0; k < 2; k++) { 107 | Vec3 weight_v(u - i, v - j, w - k); 108 | accum += (i * uu + (1 - i) * (1 - uu)) * 109 | (j * vv + (1 - j) * (1 - vv)) * 110 | (k * ww + (1 - k) * (1 - ww)) * 111 | dot(c[i][j][k], weight_v); 112 | } 113 | 114 | return accum; 115 | } 116 | }; 117 | 118 | #endif 119 | -------------------------------------------------------------------------------- /docs/html/dir_d44c64559bbebec7f509842c48db8b23.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: /media/kaan/Data7510/GitProjects/cuda-raytracer/include Directory Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 | 66 |
    67 |
    68 |
    69 |
    include Directory Reference
    70 |
    71 |
    72 | 73 | 75 |

    74 | Directories

    76 |
    77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/html/classTexture-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    Texture Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for Texture, including all inherited members.

    70 | 71 | 72 |
    value(float u, float v, const Point3 &p) const =0 (defined in Texture)Texturepure virtual
    73 | 74 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /include/nextweek/hittables.cuh: -------------------------------------------------------------------------------- 1 | #ifndef HITTABLES_CUH 2 | #define HITTABLES_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | class HittableGroup : public Hittable { 9 | public: 10 | Hittable **list; 11 | const int start_index; 12 | const int end_index; 13 | 14 | public: 15 | __host__ __device__ HittableGroup() 16 | : start_index(0), end_index(0), list(nullptr) {} 17 | __host__ __device__ HittableGroup(Hittable **&hlist, 18 | int size) 19 | : list(hlist), start_index(0), end_index(size) {} 20 | __host__ __device__ HittableGroup(Hittable **&hlist, 21 | int si, int ei) 22 | : list(hlist), start_index(si), end_index(ei) {} 23 | 24 | __host__ __device__ ~HittableGroup() { delete list; } 25 | 26 | /** 27 | @brief check if there is any object that is hit by 28 | incoming ray. 29 | 30 | The main method that checks if a ray hits something. 31 | It is in most cases the most time consuming part of the 32 | algorithm due to traversing of the entire scene. Most of 33 | the acceleration structures try to find ways of 34 | iterating the scene more efficiently. They thus try to 35 | come up with a way to circumvent the simple iteration 36 | that we are doing here. I have also implemented a couple 37 | of them in cpu. The general strategy seems to be 38 | implement and construct everything on cpu and traverse 39 | everything on gpu. 40 | 41 | See also the documentation of Hittable"::"hit() 42 | 43 | @param r incoming ray. Essentially this the ray that is 44 | either generated 45 | by the camera or that is scattered from a surface. 46 | 47 | @param d_min minimum distance. 48 | @param d_max maximum distance 49 | @param rec struct that would hold all the necessary 50 | information for evaluating a bsdf. 51 | */ 52 | __device__ bool hit(const Ray &r, float d_min, 53 | float d_max, 54 | HitRecord &rec) const override { 55 | return hit_to_hittables(list, start_index, end_index, r, 56 | d_min, d_max, rec); 57 | } 58 | 59 | /** 60 | @brief compute bounding box of the entire scene 61 | 62 | See the documentation of Hittable"::"bounding_box() 63 | 64 | @param t0 time0 65 | @param t1 time1 66 | */ 67 | __host__ __device__ bool 68 | bounding_box(float t0, float t1, 69 | Aabb &output_box) const override { 70 | return bounding_box_to_hittables( 71 | list, start_index, end_index, t0, t1, output_box); 72 | } 73 | }; 74 | class SafeHittableGroup : public HittableGroup { 75 | public: 76 | __host__ __device__ SafeHittableGroup() 77 | : HittableGroup() {} 78 | __host__ __device__ SafeHittableGroup(Hittable **hlist, 79 | int size) 80 | : HittableGroup(hlist, size) {} 81 | __host__ __device__ SafeHittableGroup(Hittable **hlist, 82 | int si, int ei) 83 | : HittableGroup(hlist, si, ei) {} 84 | }; 85 | 86 | /** 87 | @brief Scene object that gathers all of the object in the 88 | scene. 89 | 90 | Currently this is just a list of Hittable objects with a 91 | current number of 92 | objects. 93 | */ 94 | class Hittables : public SafeHittableGroup { 95 | 96 | public: 97 | __host__ __device__ Hittables() {} 98 | __host__ __device__ Hittables(Hittable **hlist, int size) 99 | : SafeHittableGroup(hlist, size) {} 100 | }; 101 | 102 | #endif 103 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cuda-raytracer 2 | Simple Port of Raytracing in Series to CUDA 3 | 4 | This project is largely insipired from 5 | [Roger Allen's work](https://github.com/rogerallen/raytracinginoneweekendincuda). 6 | 7 | It humbly diverges from it with respect to 2 aspects: 8 | 9 | - Build system is now CMake instead of a simple `Makefile`. 10 | - `thrust` is used for handling host side pointers. 11 | 12 | With `thrust` the code looks a little more readable in my opinion, 13 | but for the relatively small scope of this project, I'm not sure if it 14 | makes that much of a difference. 15 | 16 | Beware that you would need a relatively new version of CMake (3.18). 17 | 18 | The branches of the repository is divided into small chunks to facilitate 19 | the digestion of newly coded material as per the project of Roger Allen. 20 | 21 | The overall project structure is also arranged to make it easier to 22 | integrate with other projects. 23 | 24 | ## Building 25 | 26 | Assuming you have clang 9+, cmake 3.18+, a recent cuda compatible 27 | hardware, and CUDA toolkit (the code base is developped with CUDA 11 but it 28 | should be compatible with previous versions as well, no range reserving, or 29 | managed cudaMallocManaged etc). 30 | 31 | - `cd build` 32 | 33 | - `ccmake ..` 34 | 35 | Choose your compiler (clang++) and cuda toolkit location. Then configure and 36 | generate. 37 | 38 | - `make install` 39 | 40 | Depending on your compute capability gpu card you should modify 41 | `CMakeLists.txt` file. 42 | 43 | All of the images below are realized with the following specs: 44 | 45 | - Device name: Quadro M2000M 46 | - Memory Clock Rate (KHz): 2505000 47 | - Memory Bus Width (bits): 128 48 | - Peak Memory Bandwidth (GB/s): 80.16 49 | 50 | **WARNING: MOST OF THE TIMINGS HERE ARE WRONG**, see `Known Issues`. 51 | 52 | Renders the screenshot below at 800 x 600 in 64.8672 seconds with 50 samples 53 | per pixel and 50 bounces per ray. 54 | 55 | final screenshot 56 | 57 | The one in below at 640x360 in 30.4133 seconds with 20 samples and 10 bounces. 58 | final screenshot second version 59 | 60 | 61 | I don't remember the settings for this one. But it includes perlin noise so. 62 | final screenshot third version 63 | 64 | 65 | The one in below at 800x450 in 49.5292 seconds with 500 samples and 500 66 | bounces. 67 | final screenshot fourth version 68 | 69 | The one in below at 640x360 in 106.365 seconds with 500 samples and 500 70 | bounces 71 | final screenshot fifth version 72 | 73 | The one in below at 480x270 in 101.325 seconds with 40 samples and 20 74 | bounces 75 | final screenshot sixth version 76 | 77 | 78 | ## Features 79 | 80 | - Most of what you get in Ray Tracing In One Weekend and in Next Week. 81 | 82 | - Multiple images in different sizes and channels. 83 | 84 | - Perlin Noise 85 | 86 | - Constant Medium Volume Rendering 87 | 88 | - A simple GPU friendly acceleration structure, a.k.a DA List, Foley et. al., 89 | 2013, p. 1081. 90 | 91 | ## Planned 92 | 93 | - Asset loading with assimp. 94 | - Hopefully pdf handling in near feature. 95 | - Background handling. 96 | 97 | 98 | ## Known Issues 99 | 100 | I managed to fix the rng problem around nw-final branch. It was such a simple 101 | fix that i kind of feel stupid to let it sit there for so long. 102 | 103 | For previous branches, just change the line 104 | 105 | - `rcolor += ray_color(r, world, randState, bounceNb);` to 106 | 107 | - `rcolor += ray_color(r, world, &localS, bounceNb);` 108 | 109 | This increased significantly the rendering times so all of the rendering times 110 | above are compromised. By significantly, I mean it increases about two times 111 | more. 112 | 113 | 114 | 115 | Cheers 116 | -------------------------------------------------------------------------------- /docs/html/classMaterial-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    Material Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for Material, including all inherited members.

    70 | 71 | 72 | 73 |
    scatter(const Ray &r_in, const HitRecord &rec, Vec3 &attenuation, Ray &scattered, curandState *local_rand_state) const =0 (defined in Material)Materialpure virtual
    scatter(const Ray &r_in, const HitRecord &rec, Vec3 &attenuation, Ray &scattered, curandState *local_rand_state) const =0 (defined in Material)Materialpure virtual
    74 | 75 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /docs/html/structKernelArg-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    KernelArg< T > Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for KernelArg< T >, including all inherited members.

    70 | 71 | 72 | 73 | 74 |
    arg (defined in KernelArg< T >)KernelArg< T >
    free() (defined in KernelArg< T >)KernelArg< T >inline
    length (defined in KernelArg< T >)KernelArg< T >
    75 | 76 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /docs/html/structstbi__io__callbacks-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    stbi_io_callbacks Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for stbi_io_callbacks, including all inherited members.

    70 | 71 | 72 | 73 | 74 |
    eof (defined in stbi_io_callbacks)stbi_io_callbacks
    read (defined in stbi_io_callbacks)stbi_io_callbacks
    skip (defined in stbi_io_callbacks)stbi_io_callbacks
    75 | 76 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /include/nextweek/sphere.cuh: -------------------------------------------------------------------------------- 1 | #ifndef SPHERE_CUH 2 | #define SPHERE_CUH 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | __host__ __device__ void get_sphere_uv(const Vec3 &p, 10 | float &u, float &v) { 11 | auto phi = atan2(p.z(), p.x()); 12 | auto theta = asin(p.y()); 13 | u = 1 - (phi + M_PI) / (2 * M_PI); 14 | v = (theta + M_PI / 2) / M_PI; 15 | } 16 | 17 | class Sphere : public Hittable { 18 | public: 19 | __host__ __device__ Sphere() {} 20 | __host__ __device__ Sphere(Point3 cen, float r, 21 | Material *mat_ptr_) 22 | : center(cen), radius(r), mat_ptr(mat_ptr_){}; 23 | __host__ __device__ ~Sphere() { delete mat_ptr; } 24 | __device__ bool hit(const Ray &r, float d_min, 25 | float d_max, 26 | HitRecord &rec) const override { 27 | Vec3 oc = r.origin() - center; 28 | float a = dot(r.direction(), r.direction()); 29 | float b = dot(oc, r.direction()); 30 | float c = dot(oc, oc) - radius * radius; 31 | float discriminant = b * b - a * c; 32 | if (discriminant > 0) { 33 | float temp = (-b - sqrt(discriminant)) / a; 34 | if (temp < d_max && temp > d_min) { 35 | rec.t = temp; 36 | rec.p = r.at(rec.t); 37 | Vec3 normal = (rec.p - center) / radius; 38 | rec.set_front_face(r, normal); 39 | get_sphere_uv(normal, rec.u, rec.v); 40 | rec.mat_ptr = mat_ptr; 41 | return true; 42 | } 43 | temp = (-b + sqrt(discriminant)) / a; 44 | if (temp < d_max && temp > d_min) { 45 | rec.t = temp; 46 | rec.p = r.at(rec.t); 47 | Vec3 normal = (rec.p - center) / radius; 48 | rec.set_front_face(r, normal); 49 | get_sphere_uv(normal, rec.u, rec.v); 50 | rec.mat_ptr = mat_ptr; 51 | return true; 52 | } 53 | } 54 | return false; 55 | } 56 | __host__ __device__ bool 57 | bounding_box(float t0, float t1, 58 | Aabb &output_box) const override { 59 | output_box = 60 | Aabb(center - Vec3(radius), center + Vec3(radius)); 61 | return true; 62 | } 63 | 64 | public: 65 | Vec3 center; 66 | float radius; 67 | Material *mat_ptr; 68 | }; 69 | 70 | class MovingSphere : public Hittable { 71 | public: 72 | Point3 center1, center2; 73 | float time0, time1, radius; 74 | Material *mat_ptr; 75 | 76 | public: 77 | __host__ __device__ MovingSphere(); 78 | __host__ __device__ ~MovingSphere() { delete mat_ptr; }; 79 | __host__ __device__ MovingSphere(Point3 c1, Point3 c2, 80 | float t0, float t1, 81 | float rad, Material *mat) 82 | : center1(c1), center2(c2), time0(t0), time1(t1), 83 | radius(rad), mat_ptr(mat) {} 84 | __host__ __device__ Point3 center(float time) const { 85 | return center1 + 86 | ((time - time0) / (time1 - time0)) * 87 | (center2 - center1); 88 | } 89 | __device__ bool hit(const Ray &r, float d_min, 90 | float d_max, 91 | HitRecord &rec) const override { 92 | Point3 scenter = center(r.time()); 93 | Vec3 oc = r.origin() - scenter; 94 | float a = dot(r.direction(), r.direction()); 95 | float b = dot(oc, r.direction()); 96 | float c = dot(oc, oc) - radius * radius; 97 | float discriminant = b * b - a * c; 98 | if (discriminant > 0) { 99 | float temp = (-b - sqrt(discriminant)) / a; 100 | if (temp < d_max && temp > d_min) { 101 | rec.t = temp; 102 | rec.p = r.at(rec.t); 103 | rec.normal = (rec.p - scenter) / radius; 104 | rec.mat_ptr = mat_ptr; 105 | return true; 106 | } 107 | temp = (-b + sqrt(discriminant)) / a; 108 | if (temp < d_max && temp > d_min) { 109 | rec.t = temp; 110 | rec.p = r.at(rec.t); 111 | rec.normal = (rec.p - scenter) / radius; 112 | rec.mat_ptr = mat_ptr; 113 | return true; 114 | } 115 | } 116 | return false; 117 | } 118 | 119 | __host__ __device__ bool 120 | bounding_box(float t0, float t1, 121 | Aabb &output_box) const override { 122 | // NOT CORRECT 123 | output_box = Aabb(center1 - Vec3(radius), 124 | center1 + Vec3(radius)); 125 | return true; 126 | } 127 | }; 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /include/oneweekend/material.cuh: -------------------------------------------------------------------------------- 1 | #ifndef MATERIAL_CUH 2 | #define MATERIAL_CUH 3 | 4 | #include 5 | #include 6 | 7 | struct HitRecord; 8 | 9 | __device__ float fresnelCT(float costheta, float ridx) { 10 | // cook torrence fresnel equation 11 | float etao = 1 + sqrt(ridx); 12 | float etau = 1 - sqrt(ridx); 13 | float eta = etao / etau; 14 | float g = sqrt(pow(eta, 2) + pow(costheta, 2) - 1); 15 | float g_c = g - costheta; 16 | float gplusc = g + costheta; 17 | float gplus_cc = (gplusc * costheta) - 1; 18 | float g_cc = (g_c * costheta) + 1; 19 | float oneplus_gcc = 1 + pow(gplus_cc / g_cc, 2); 20 | float half_plus_minus = 0.5 * pow(g_c / gplusc, 2); 21 | return half_plus_minus * oneplus_gcc; 22 | } 23 | 24 | __device__ bool refract(const Vec3 &v, const Vec3 &n, 25 | float ni_over_nt, Vec3 &refracted) { 26 | Vec3 uv = to_unit(v); 27 | float dt = dot(uv, n); 28 | float discriminant = 29 | 1.0f - ni_over_nt * ni_over_nt * (1 - dt * dt); 30 | if (discriminant > 0) { 31 | refracted = 32 | ni_over_nt * (uv - n * dt) - n * sqrt(discriminant); 33 | return true; 34 | } else { 35 | return false; 36 | } 37 | } 38 | 39 | __device__ Vec3 reflect(const Vec3 &v, const Vec3 &n) { 40 | return v - 2.0f * dot(v, n) * n; 41 | } 42 | class Material { 43 | public: 44 | __device__ virtual bool 45 | scatter(const Ray &r_in, const HitRecord &rec, 46 | Vec3 &attenuation, Ray &scattered, 47 | curandState *local_rand_state) const = 0; 48 | }; 49 | 50 | class Lambertian : public Material { 51 | public: 52 | __device__ Lambertian(const Vec3 &a) : albedo(a) {} 53 | __device__ bool 54 | scatter(const Ray &r_in, const HitRecord &rec, 55 | Vec3 &attenuation, Ray &scattered, 56 | curandState *local_rand_state) const override { 57 | Vec3 target = rec.p + rec.normal + 58 | random_in_unit_sphere(local_rand_state); 59 | scattered = Ray(rec.p, target - rec.p, r_in.time()); 60 | attenuation = albedo; 61 | return true; 62 | } 63 | 64 | Vec3 albedo; 65 | }; 66 | 67 | class Metal : public Material { 68 | public: 69 | __device__ Metal(const Vec3 &a, float f) : albedo(a) { 70 | if (f < 1) 71 | fuzz = f; 72 | else 73 | fuzz = 1; 74 | } 75 | __device__ bool 76 | scatter(const Ray &r_in, const HitRecord &rec, 77 | Vec3 &attenuation, Ray &scattered, 78 | curandState *local_rand_state) const override { 79 | Vec3 reflected = 80 | reflect(to_unit(r_in.direction()), rec.normal); 81 | scattered = Ray(rec.p, reflected + 82 | fuzz * random_in_unit_sphere( 83 | local_rand_state), 84 | r_in.time()); 85 | attenuation = albedo; 86 | return (dot(scattered.direction(), rec.normal) > 0.0f); 87 | } 88 | Vec3 albedo; 89 | float fuzz; 90 | }; 91 | 92 | class Dielectric : public Material { 93 | public: 94 | __device__ Dielectric(float ri) : ref_idx(ri) {} 95 | __device__ bool 96 | scatter(const Ray &r_in, const HitRecord &rec, 97 | Vec3 &attenuation, Ray &scattered, 98 | curandState *local_rand_state) const override { 99 | Vec3 outward_normal; 100 | Vec3 reflected = reflect(r_in.direction(), rec.normal); 101 | float ni_over_nt; 102 | attenuation = Vec3(1.0); 103 | Vec3 refracted; 104 | float reflect_prob; 105 | float cosine; 106 | if (dot(r_in.direction(), rec.normal) > 0.0f) { 107 | outward_normal = -rec.normal; 108 | ni_over_nt = ref_idx; 109 | cosine = dot(r_in.direction(), rec.normal) / 110 | r_in.direction().length(); 111 | cosine = sqrt( 112 | 1.0f - ref_idx * ref_idx * (1 - cosine * cosine)); 113 | } else { 114 | outward_normal = rec.normal; 115 | ni_over_nt = 1.0f / ref_idx; 116 | cosine = -dot(r_in.direction(), rec.normal) / 117 | r_in.direction().length(); 118 | } 119 | if (refract(r_in.direction(), outward_normal, 120 | ni_over_nt, refracted)) 121 | reflect_prob = fresnelCT(cosine, ref_idx); 122 | else 123 | reflect_prob = 1.0f; 124 | if (curand_uniform(local_rand_state) < reflect_prob) 125 | scattered = Ray(rec.p, reflected, r_in.time()); 126 | else 127 | scattered = Ray(rec.p, refracted, r_in.time()); 128 | return true; 129 | } 130 | float ref_idx; 131 | }; 132 | 133 | #endif 134 | -------------------------------------------------------------------------------- /docs/html/classSolidColor-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    SolidColor Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for SolidColor, including all inherited members.

    70 | 71 | 72 | 73 | 74 | 75 |
    SolidColor() (defined in SolidColor)SolidColorinline
    SolidColor(Color c) (defined in SolidColor)SolidColorinline
    SolidColor(float red, float green, float blue) (defined in SolidColor)SolidColorinline
    value(float u, float v, const Point3 &p) const override (defined in SolidColor)SolidColorinlinevirtual
    76 | 77 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /docs/html/classPerlin-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    Perlin Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for Perlin, including all inherited members.

    70 | 71 | 72 | 73 | 74 | 75 | 76 |
    noise(const Point3 &p) const (defined in Perlin)Perlininline
    Perlin() (defined in Perlin)Perlininline
    Perlin(curandState *loc) (defined in Perlin)Perlininline
    turb(const Point3 &p, int depth=7) const (defined in Perlin)Perlininline
    ~Perlin() (defined in Perlin)Perlininline
    77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/html/classHittable-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    Hittable Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for Hittable, including all inherited members.

    70 | 71 | 72 | 73 | 74 | 75 | 76 |
    bounding_box(float t0, float t1, Aabb &output_box) const =0 (defined in Hittable)Hittablepure virtual
    center (defined in Hittable)Hittable
    hit(const Ray &r, float d_min, float d_max, HitRecord &rec) const =0 (defined in Hittable)Hittablepure virtual
    hit(const Ray &r, float d_min, float d_max, HitRecord &rec) const =0 (defined in Hittable)Hittablepure virtual
    mat_ptr (defined in Hittable)Hittable
    77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/html/classNoiseTexture-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    NoiseTexture Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for NoiseTexture, including all inherited members.

    70 | 71 | 72 | 73 | 74 | 75 | 76 |
    noise (defined in NoiseTexture)NoiseTexture
    NoiseTexture() (defined in NoiseTexture)NoiseTextureinline
    NoiseTexture(float s, curandState *loc) (defined in NoiseTexture)NoiseTextureinline
    scale (defined in NoiseTexture)NoiseTexture
    value(float u, float v, const Point3 &p) const override (defined in NoiseTexture)NoiseTextureinlinevirtual
    77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/html/structstbi__io__callbacks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: stbi_io_callbacks Struct Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 | 67 |
    68 |
    stbi_io_callbacks Struct Reference
    69 |
    70 |
    71 | 72 | 74 | 76 | 77 | 79 | 80 | 82 | 83 |

    73 | Public Attributes

    75 | int(* read )(void *user, char *data, int size)
     
    78 | void(* skip )(void *user, int n)
     
    81 | int(* eof )(void *user)
     
    84 |
    The documentation for this struct was generated from the following file:
      85 |
    • /media/kaan/Data7510/GitProjects/cuda-raytracer/include/nextweek/stb_image.h
    • 86 |
    87 |
    88 | 89 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /docs/html/classPerlin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Perlin Class Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 | 67 |
    68 |
    Perlin Class Reference
    69 |
    70 |
    71 | 72 | 74 | 76 | 77 | 79 | 80 | 82 | 83 |

    73 | Public Member Functions

    75 | __device__ Perlin (curandState *loc)
     
    78 | __device__ float noise (const Point3 &p) const
     
    81 | __device__ float turb (const Point3 &p, int depth=7) const
     
    84 |
    The documentation for this class was generated from the following file:
      85 |
    • /media/kaan/Data7510/GitProjects/cuda-raytracer/include/nextweek/perlin.cuh
    • 86 |
    87 |
    88 | 89 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /docs/html/classTexture.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Texture Class Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 | 67 |
    68 |
    Texture Class Referenceabstract
    69 |
    70 |
    71 |
    72 | Inheritance diagram for Texture:
    73 |
    74 |
    75 | 76 | 77 | CheckerTexture 78 | ImageTexture 79 | NoiseTexture 80 | SolidColor 81 | 82 |
    83 | 84 | 86 | 88 | 89 |

    85 | Public Member Functions

    87 | virtual __device__ Color value (float u, float v, const Point3 &p) const =0
     
    90 |
    The documentation for this class was generated from the following file:
      91 |
    • /media/kaan/Data7510/GitProjects/cuda-raytracer/include/nextweek/texture.cuh
    • 92 |
    93 |
    94 | 95 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /docs/html/dynsections.js: -------------------------------------------------------------------------------- 1 | /* 2 | @licstart The following is the entire license notice for the JavaScript code in this file. 3 | 4 | The MIT License (MIT) 5 | 6 | Copyright (C) 1997-2020 by Dimitri van Heesch 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software 9 | and associated documentation files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, publish, distribute, 11 | sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all copies or 15 | substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 18 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 20 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | @licend The above is the entire license notice for the JavaScript code in this file 24 | */ 25 | function toggleVisibility(linkObj) 26 | { 27 | var base = $(linkObj).attr('id'); 28 | var summary = $('#'+base+'-summary'); 29 | var content = $('#'+base+'-content'); 30 | var trigger = $('#'+base+'-trigger'); 31 | var src=$(trigger).attr('src'); 32 | if (content.is(':visible')===true) { 33 | content.hide(); 34 | summary.show(); 35 | $(linkObj).addClass('closed').removeClass('opened'); 36 | $(trigger).attr('src',src.substring(0,src.length-8)+'closed.png'); 37 | } else { 38 | content.show(); 39 | summary.hide(); 40 | $(linkObj).removeClass('closed').addClass('opened'); 41 | $(trigger).attr('src',src.substring(0,src.length-10)+'open.png'); 42 | } 43 | return false; 44 | } 45 | 46 | function updateStripes() 47 | { 48 | $('table.directory tr'). 49 | removeClass('even').filter(':visible:even').addClass('even'); 50 | } 51 | 52 | function toggleLevel(level) 53 | { 54 | $('table.directory tr').each(function() { 55 | var l = this.id.split('_').length-1; 56 | var i = $('#img'+this.id.substring(3)); 57 | var a = $('#arr'+this.id.substring(3)); 58 | if (l 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    Dielectric Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for Dielectric, including all inherited members.

    70 | 71 | 72 | 73 | 74 | 75 | 76 |
    Dielectric(float ri) (defined in Dielectric)Dielectricinline
    Dielectric(float ri) (defined in Dielectric)Dielectricinline
    ref_idx (defined in Dielectric)Dielectric
    scatter(const Ray &r_in, const HitRecord &rec, Vec3 &attenuation, Ray &scattered, curandState *local_rand_state) const override (defined in Dielectric)Dielectricinlinevirtual
    scatter(const Ray &r_in, const HitRecord &rec, Vec3 &attenuation, Ray &scattered, curandState *local_rand_state) const override (defined in Dielectric)Dielectricinlinevirtual
    77 | 78 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /docs/html/structKernelArg.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: KernelArg< T > Struct Template Reference 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 | 68 |
    69 |
    KernelArg< T > Struct Template Reference
    70 |
    71 |
    72 | 73 | 75 | 77 | 78 |

    74 | Public Member Functions

    76 | __host__ void free ()
     
    79 | 81 | 83 | 84 | 86 | 87 |

    80 | Public Attributes

    82 | T * arg
     
    85 | int length
     
    88 |
    The documentation for this struct was generated from the following file:
      89 |
    • /media/kaan/Data7510/GitProjects/cuda-raytracer/include/nextweek/cbuffer.hpp
    • 90 |
    91 |
    92 | 93 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /docs/html/structHitRecord-members.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Cuda Ray Tracer: Member List 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
    19 |
    20 | 21 | 22 | 23 | 27 | 28 | 29 |
    24 |
    Cuda Ray Tracer 25 |
    26 |
    30 |
    31 | 32 | 33 | 38 | 39 | 40 | 47 | 48 | 49 |
    53 |
    54 | 55 | 56 |
    57 | 60 |
    61 | 62 |
    63 |
    64 |
    65 |
    HitRecord Member List
    66 |
    67 |
    68 | 69 |

    This is the complete list of members for HitRecord, including all inherited members.

    70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 |
    front_face (defined in HitRecord)HitRecord
    mat_ptr (defined in HitRecord)HitRecord
    normal (defined in HitRecord)HitRecord
    p (defined in HitRecord)HitRecord
    set_front_face(const Ray &r, const Vec3 &norm) (defined in HitRecord)HitRecordinline
    t (defined in HitRecord)HitRecord
    u (defined in HitRecord)HitRecord
    v (defined in HitRecord)HitRecord
    80 | 81 | 86 | 87 | 88 | --------------------------------------------------------------------------------