├── Peter-Shirley-Project Code ├── .idea │ ├── .name │ ├── dictionaries │ │ └── SeeKHit.xml │ ├── Peter-Shirley-Project Code.iml │ ├── misc.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ └── modules.xml ├── cmake-build-debug │ ├── CMakeFiles │ │ ├── Progress │ │ │ ├── 1 │ │ │ └── count.txt │ │ ├── progress.marks │ │ ├── Peter_Shirley_Project_Code.dir │ │ │ ├── progress.make │ │ │ ├── link.txt │ │ │ ├── flags.make │ │ │ ├── cmake_clean.cmake │ │ │ ├── depend.make │ │ │ ├── DependInfo.cmake │ │ │ ├── depend.internal │ │ │ ├── CXX.includecache │ │ │ └── build.make │ │ ├── clion-environment.txt │ │ ├── cmake.check_cache │ │ ├── feature_tests.bin │ │ ├── 3.8.2 │ │ │ ├── CompilerIdC │ │ │ │ ├── a.out │ │ │ │ └── CMakeCCompilerId.c │ │ │ ├── CompilerIdCXX │ │ │ │ ├── a.out │ │ │ │ └── CMakeCXXCompilerId.cpp │ │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ │ ├── CMakeSystem.cmake │ │ │ ├── CMakeCCompiler.cmake │ │ │ └── CMakeCXXCompiler.cmake │ │ ├── clion-log.txt │ │ ├── TargetDirectories.txt │ │ ├── CMakeDirectoryInformation.cmake │ │ ├── feature_tests.c │ │ ├── Makefile.cmake │ │ ├── Makefile2 │ │ ├── feature_tests.cxx │ │ └── CMakeOutput.log │ ├── Peter_Shirley_Project_Code │ ├── cmake_install.cmake │ ├── Makefile │ └── Peter_Shirley_Project_Code.cbp ├── CMakeLists.txt ├── hitable.h ├── ray.h ├── hitable_list.h ├── sphere.h ├── camera.h ├── material.h ├── vec3.h └── main.cpp ├── In-One-Weekend ├── Chapter02_The vec3 class.cpp ├── Chapter01_Output an image.cpp ├── Chapter03_Rays,simple camera,and background.cpp ├── Chapter04_Adding a sphere.cpp ├── Chapter05_Surface normals and multiple objects 2.cpp ├── Chapter05_Surface normals and multiple objects.cpp ├── Chapter06_Antialiasing.cpp ├── Chapter07_Diffuse Materials.cpp ├── Chapter08_Metal.cpp └── Chapter10_Positionable camera.cpp └── README.md /Peter-Shirley-Project Code/.idea/.name: -------------------------------------------------------------------------------- 1 | Peter_Shirley_Project_Code -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Progress/1: -------------------------------------------------------------------------------- 1 | empty -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/progress.marks: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Progress/count.txt: -------------------------------------------------------------------------------- 1 | 2 2 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/.idea/dictionaries/SeeKHit.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir/progress.make: -------------------------------------------------------------------------------- 1 | CMAKE_PROGRESS_1 = 1 2 | CMAKE_PROGRESS_2 = 2 3 | 4 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/clion-environment.txt: -------------------------------------------------------------------------------- 1 | Options: 2 | CMake: 3.8.2@/Applications/CLion.app/Contents/bin/cmake/bin/cmake 3 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/.idea/Peter-Shirley-Project Code.iml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/Peter_Shirley_Project_Code: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend/HEAD/Peter-Shirley-Project Code/cmake-build-debug/Peter_Shirley_Project_Code -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend/HEAD/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend/HEAD/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdC/a.out -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend/HEAD/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend/HEAD/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend/HEAD/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir/link.txt: -------------------------------------------------------------------------------- 1 | /Library/Developer/CommandLineTools/usr/bin/c++ -g -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o -o Peter_Shirley_Project_Code 2 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.8) 2 | project(Peter_Shirley_Project_Code) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | set(SOURCE_FILES main.cpp vec3.h ray.h hitable.h sphere.h hitable_list.h camera.h material.h) 7 | add_executable(Peter_Shirley_Project_Code ${SOURCE_FILES}) -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir/flags.make: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.8 3 | 4 | # compile CXX with /Library/Developer/CommandLineTools/usr/bin/c++ 5 | CXX_FLAGS = -g -std=gnu++11 6 | 7 | CXX_DEFINES = 8 | 9 | CXX_INCLUDES = 10 | 11 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir/cmake_clean.cmake: -------------------------------------------------------------------------------- 1 | file(REMOVE_RECURSE 2 | "CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o" 3 | "Peter_Shirley_Project_Code.pdb" 4 | "Peter_Shirley_Project_Code" 5 | ) 6 | 7 | # Per-language clean rules from dependency scanning. 8 | foreach(lang CXX) 9 | include(CMakeFiles/Peter_Shirley_Project_Code.dir/cmake_clean_${lang}.cmake OPTIONAL) 10 | endforeach() 11 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/clion-log.txt: -------------------------------------------------------------------------------- 1 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code" 2 | -- Configuring done 3 | -- Generating done 4 | -- Build files have been written to: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug 5 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Darwin-17.4.0") 2 | set(CMAKE_HOST_SYSTEM_NAME "Darwin") 3 | set(CMAKE_HOST_SYSTEM_VERSION "17.4.0") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | 7 | 8 | set(CMAKE_SYSTEM "Darwin-17.4.0") 9 | set(CMAKE_SYSTEM_NAME "Darwin") 10 | set(CMAKE_SYSTEM_VERSION "17.4.0") 11 | set(CMAKE_SYSTEM_PROCESSOR "x86_64") 12 | 13 | set(CMAKE_CROSSCOMPILING "FALSE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/TargetDirectories.txt: -------------------------------------------------------------------------------- 1 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/rebuild_cache.dir 2 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/edit_cache.dir 3 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir 4 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/hitable.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SeeKHit on 2018/8/10. 3 | // 4 | 5 | #ifndef PETER_SHIRLEY_PROJECT_CODE_HITABLE_H 6 | #define PETER_SHIRLEY_PROJECT_CODE_HITABLE_H 7 | 8 | #include "ray.h" 9 | 10 | class material; 11 | 12 | struct hit_record 13 | { 14 | float t; 15 | vec3 p; 16 | vec3 normal; 17 | material *mat_ptr; 18 | }; 19 | 20 | class hitable 21 | { 22 | public: 23 | virtual bool hit(const ray& r,float t_min,float t_max,hit_record & rec)const =0; 24 | }; 25 | 26 | 27 | #endif //PETER_SHIRLEY_PROJECT_CODE_HITABLE_H 28 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/ray.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SeeKHit on 2018/8/2. 3 | // 4 | 5 | #ifndef PETER_SHIRLEY_PROJECT_CODE_RAY_H 6 | #define PETER_SHIRLEY_PROJECT_CODE_RAY_H 7 | 8 | 9 | #include "vec3.h" 10 | 11 | class ray 12 | { 13 | public: 14 | ray(){} 15 | ray(const vec3& a, const vec3 & b){ A =a; B = b;} 16 | vec3 origin() const { return A;} 17 | vec3 direction() const { return B;} 18 | vec3 point_at_parameter(float t) const { return A+t*B;} 19 | 20 | vec3 A; 21 | vec3 B; 22 | 23 | }; 24 | 25 | #endif //PETER_SHIRLEY_PROJECT_CODE_RAY_H 26 | -------------------------------------------------------------------------------- /In-One-Weekend/Chapter02_The vec3 class.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | int main() 7 | { 8 | int nx =200; 9 | int ny=100; 10 | cout<<"P3\n"<=0;j--) 12 | { 13 | for(int i=0;i 2 | 3 | using namespace std; 4 | 5 | 6 | int main() 7 | { 8 | int nx =200; 9 | int ny=100; 10 | cout<<"P3\n"<=0;j--) 12 | { 13 | for(int i=0;i= 400 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/hitable_list.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SeeKHit on 2018/8/10. 3 | // 4 | 5 | #ifndef PETER_SHIRLEY_PROJECT_CODE_HITABLE_LIST_H 6 | #define PETER_SHIRLEY_PROJECT_CODE_HITABLE_LIST_H 7 | 8 | #include "hitable.h" 9 | 10 | class hitable_list: public hitable { 11 | public: 12 | hitable_list() {} 13 | hitable_list(hitable **l, int n) {list = l; list_size = n; } 14 | virtual bool hit(const ray& r, float tmin, float tmax, hit_record& rec) const; 15 | hitable **list; 16 | int list_size; 17 | }; 18 | 19 | bool hitable_list::hit(const ray& r, float t_min, float t_max, hit_record& rec) const { 20 | hit_record temp_rec; 21 | bool hit_anything = false; 22 | double closest_so_far = t_max; 23 | for (int i = 0; i < list_size; i++) { 24 | if (list[i]->hit(r, t_min, closest_so_far, temp_rec)) { 25 | hit_anything = true; 26 | closest_so_far = temp_rec.t; 27 | rec = temp_rec; 28 | } 29 | } 30 | return hit_anything; 31 | } 32 | 33 | 34 | #endif //PETER_SHIRLEY_PROJECT_CODE_HITABLE_LIST_H 35 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir/depend.internal: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.8 3 | 4 | CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o 5 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/camera.h 6 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable.h 7 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable_list.h 8 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/main.cpp 9 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/material.h 10 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/ray.h 11 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/sphere.h 12 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/vec3.h 13 | -------------------------------------------------------------------------------- /In-One-Weekend/Chapter03_Rays,simple camera,and background.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "vec3.h" 3 | #include "ray.h" 4 | 5 | using namespace std; 6 | 7 | vec3 color(const ray& r) 8 | { 9 | vec3 unit_direction = unit_vector(r.direction()); 10 | float t = 0.5 *(unit_direction.y() + 1.0); 11 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 12 | } 13 | 14 | int main() 15 | { 16 | int nx =200; 17 | int ny=100; 18 | cout<<"P3\n"<=0;j--) 25 | { 26 | for(int i=0;i 2 | #include "vec3.h" 3 | #include "ray.h" 4 | 5 | using namespace std; 6 | 7 | bool hit_sphere(const vec3 & center, float radius,const ray& r) 8 | { 9 | vec3 oc = r.origin() -center; 10 | float a = dot(r.direction(), r.direction()); 11 | float b = 2.0 * dot(oc,r.direction()); 12 | float c = dot(oc,oc) -radius*radius; 13 | float discriminant = b*b - 4*a*c; 14 | return (discriminant>0); 15 | } 16 | 17 | vec3 color(const ray& r) 18 | { 19 | if(hit_sphere(vec3(0,0,-1),0.5,r)) 20 | return vec3(1.0,0,0); 21 | 22 | vec3 unit_direction = unit_vector(r.direction()); 23 | float t = 0.5 *(unit_direction.y() + 1.0); 24 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 25 | } 26 | 27 | int main() 28 | { 29 | int nx =200; 30 | int ny=100; 31 | cout<<"P3\n"<=0;j--) 38 | { 39 | for(int i=0;i 0) { 27 | float temp = (-b - sqrt(discriminant))/a; 28 | if (temp < t_max && temp > t_min) { 29 | rec.t = temp; 30 | rec.p = r.point_at_parameter(rec.t); 31 | rec.normal = (rec.p - center) / radius; 32 | rec.mat_ptr = mat_ptr; 33 | return true; 34 | } 35 | temp = (-b + sqrt(discriminant)) / a; 36 | if (temp < t_max && temp > t_min) { 37 | rec.t = temp; 38 | rec.p = r.point_at_parameter(rec.t); 39 | rec.normal = (rec.p - center) / radius; 40 | rec.mat_ptr = mat_ptr; 41 | return true; 42 | } 43 | } 44 | return false; 45 | } 46 | 47 | 48 | #endif //PETER_SHIRLEY_PROJECT_CODE_SPHERE_H 49 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/camera.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SeeKHit on 2018/8/12. 3 | // 4 | 5 | #ifndef PETER_SHIRLEY_PROJECT_CODE_CAMERA_H 6 | #define PETER_SHIRLEY_PROJECT_CODE_CAMERA_H 7 | 8 | #include "ray.h" 9 | 10 | class camera 11 | { 12 | vec3 origin; 13 | vec3 u,v,w; 14 | vec3 horizontal; 15 | vec3 vertical; 16 | vec3 lower_left_corner; 17 | float len_radius; 18 | 19 | public : 20 | camera(vec3 lookfrom, vec3 lookat, vec3 vup, float vfov, float aspect, float aperture, float focus_dist) 21 | { 22 | len_radius = aperture/2; 23 | float theta = vfov*M_PI/180; 24 | float half_height = tan(theta/2); 25 | float half_width = aspect * half_height; 26 | origin = lookfrom; 27 | 28 | w = unit_vector(lookfrom - lookat); 29 | u = unit_vector(cross(vup, w)); 30 | v = cross(w,u); 31 | 32 | lower_left_corner = origin - half_width*focus_dist*u - half_height*focus_dist*v - focus_dist*w; 33 | horizontal = 2*half_width*focus_dist*u; 34 | vertical = 2*half_height*focus_dist*v; 35 | } 36 | 37 | ray get_ray(float s,float t) 38 | { 39 | vec3 rd = len_radius * random_in_unit_disk(); 40 | vec3 offset = u * rd.x() +v*rd.y(); 41 | return ray(origin + offset,lower_left_corner+s*horizontal + t*vertical - origin - offset); 42 | } 43 | 44 | vec3 random_in_unit_disk() 45 | { 46 | vec3 p; 47 | do{ 48 | p = 2.0*vec3(drand48(),drand48(),0)-vec3(1,1,0); 49 | }while (dot(p,p)>=1.0); 50 | return p; 51 | } 52 | 53 | }; 54 | 55 | #endif //PETER_SHIRLEY_PROJECT_CODE_CAMERA_H 56 | -------------------------------------------------------------------------------- /In-One-Weekend/Chapter05_Surface normals and multiple objects 2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "sphere.h" 3 | #include "hitable_list.h" 4 | #include "float.h" 5 | 6 | using namespace std; 7 | 8 | 9 | vec3 color(const ray& r,hitable *world) 10 | { 11 | hit_record rec; 12 | if(world->hit(r,0.0,MAXFLOAT,rec)) 13 | return 0.5*vec3(rec.normal.x()+1,rec.normal.y()+1,rec.normal.z()+1); 14 | else 15 | { 16 | vec3 unit_direction = unit_vector(r.direction()); 17 | float t = 0.5 *(unit_direction.y() + 1.0); 18 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 19 | } 20 | } 21 | 22 | int main() 23 | { 24 | int nx =200; 25 | int ny=100; 26 | cout<<"P3\n"<=0;j--) 40 | { 41 | for(int i=0;i 2 | #include "vec3.h" 3 | #include "ray.h" 4 | 5 | using namespace std; 6 | 7 | // 本章 hit_Sphere的返回值改为float了 8 | float hit_sphere(const vec3 & center, float radius,const ray& r) 9 | { 10 | vec3 oc = r.origin() -center; 11 | float a = dot(r.direction(), r.direction()); 12 | float b = 2.0 * dot(oc,r.direction()); 13 | float c = dot(oc,oc) -radius*radius; 14 | float discriminant = b*b - 4*a*c; 15 | if(discriminant<0) 16 | return -1.0; 17 | else 18 | return (-b-sqrt(discriminant))/(2.0*a); 19 | } 20 | 21 | vec3 color(const ray& r) 22 | { 23 | float t = hit_sphere(vec3(0,0,-1),0.5,r); 24 | if(t>0.0) 25 | { 26 | // 球心到hitpoint的单位法向量 27 | vec3 N = unit_vector(r.point_at_parameter(t)-vec3(0,0,-1)); 28 | return 0.5*vec3(N.x() +1,N.y()+1,N.z()+1); 29 | } 30 | 31 | vec3 unit_direction = unit_vector(r.direction()); 32 | t = 0.5 *(unit_direction.y() + 1.0); 33 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 34 | } 35 | 36 | int main() 37 | { 38 | int nx =200; 39 | int ny=100; 40 | cout<<"P3\n"<=0;j--) 47 | { 48 | for(int i=0;i 2 | #include "sphere.h" 3 | #include "hitable_list.h" 4 | #include "float.h" 5 | #include "camera.h" 6 | #include "random" 7 | #define random(a,b) (rand()%(b-a+1)+a) 8 | 9 | using namespace std; 10 | 11 | vec3 color(const ray& r,hitable *world) 12 | { 13 | hit_record rec; 14 | if(world->hit(r,0.0,MAXFLOAT,rec)) 15 | return 0.5*vec3(rec.normal.x()+1,rec.normal.y()+1,rec.normal.z()+1); 16 | else 17 | { 18 | vec3 unit_direction = unit_vector(r.direction()); 19 | float t = 0.5 *(unit_direction.y() + 1.0); 20 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 21 | } 22 | } 23 | 24 | int main() 25 | { 26 | int nx =200; 27 | int ny=100; 28 | // 采样数量ns 29 | int ns = 100; 30 | cout<<"P3\n"<=0;j--) 44 | { 45 | for(int i=0;i 2 | #include "sphere.h" 3 | #include "hitable_list.h" 4 | #include "float.h" 5 | #include "camera.h" 6 | #include "random" 7 | #define random(a,b) (rand()%(b-a+1)+a) 8 | #define random1 (float((rand()%(100)))/100.0f) 9 | 10 | using namespace std; 11 | 12 | // 单位cube随机取点,返回一个在球内的点 13 | vec3 random_in_unit_sphere() 14 | { 15 | vec3 p; 16 | do{ 17 | p = 2.0*vec3(random1,random1,random1) - vec3(1,1,1); 18 | }while (dot(p,p) >= 1.0); 19 | return p; 20 | } 21 | 22 | vec3 color(const ray& r,hitable *world) 23 | { 24 | hit_record rec; 25 | if(world->hit(r,0.0,MAXFLOAT,rec)) 26 | { 27 | vec3 target = rec.p + rec.normal + random_in_unit_sphere(); 28 | return 0.5* color(ray(rec.p, target - rec.p), world); 29 | } 30 | else 31 | { 32 | vec3 unit_direction = unit_vector(r.direction()); 33 | float t = 0.5 *(unit_direction.y() + 1.0); 34 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 35 | } 36 | } 37 | 38 | int main() 39 | { 40 | int nx =200; 41 | int ny=100; 42 | // 采样数量ns 43 | int ns = 100; 44 | cout<<"P3\n"<=0;j--) 58 | { 59 | for(int i=0;i 2 | #include "sphere.h" 3 | #include "hitable_list.h" 4 | #include "float.h" 5 | #include "camera.h" 6 | #include "random" 7 | #include "material.h" 8 | #define random(a,b) (rand()%(b-a+1)+a) 9 | 10 | using namespace std; 11 | 12 | vec3 color(const ray& r,hitable *world, int depth) 13 | { 14 | hit_record rec; 15 | if(world->hit(r,0.0,MAXFLOAT,rec)) 16 | { 17 | // 散射后的光线 18 | ray scattered; 19 | // 衰减 20 | vec3 attenuation; 21 | 22 | if(depth<50 && rec.mat_ptr->scatter(r,rec,attenuation,scattered)) 23 | { 24 | // 递归 衰减 25 | return attenuation * color(scattered, world, depth+1); 26 | } else 27 | { 28 | return vec3(0,0,0); 29 | } 30 | } 31 | else 32 | { 33 | vec3 unit_direction = unit_vector(r.direction()); 34 | float t = 0.5 *(unit_direction.y() + 1.0); 35 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 36 | } 37 | } 38 | 39 | int main() 40 | { 41 | int nx =200; 42 | int ny =100; 43 | // 采样数量ns 44 | int ns = 100; 45 | cout<<"P3\n"<=0;j--) 60 | { 61 | for(int i=0;i 2 | #include "sphere.h" 3 | #include "hitable_list.h" 4 | #include "float.h" 5 | #include "camera.h" 6 | #include "random" 7 | #include "material.h" 8 | #define random(a,b) (rand()%(b-a+1)+a) 9 | 10 | using namespace std; 11 | 12 | vec3 color(const ray& r,hitable *world, int depth) 13 | { 14 | hit_record rec; 15 | if(world->hit(r,0.0,MAXFLOAT,rec)) 16 | { 17 | // 散射后的光线 18 | ray scattered; 19 | // 衰减 20 | vec3 attenuation; 21 | 22 | if(depth<50 && rec.mat_ptr->scatter(r,rec,attenuation,scattered)) 23 | { 24 | // 递归 衰减 25 | return attenuation * color(scattered, world, depth+1); 26 | } else 27 | { 28 | return vec3(0,0,0); 29 | } 30 | } 31 | else 32 | { 33 | vec3 unit_direction = unit_vector(r.direction()); 34 | float t = 0.5 *(unit_direction.y() + 1.0); 35 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 36 | } 37 | } 38 | int main() 39 | { 40 | int nx =200; 41 | int ny =100; 42 | // 采样数量ns 43 | int ns = 100; 44 | cout<<"P3\n"<=0;j--) 59 | { 60 | for(int i=0;i]+)([">]) 2 | 3 | #IncludeRegexScan: ^.*$ 4 | 5 | #IncludeRegexComplain: ^$ 6 | 7 | #IncludeRegexTransform: 8 | 9 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/camera.h 10 | ray.h 11 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/ray.h 12 | 13 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable.h 14 | ray.h 15 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/ray.h 16 | 17 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable_list.h 18 | hitable.h 19 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable.h 20 | 21 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/main.cpp 22 | fstream 23 | - 24 | iostream 25 | - 26 | sphere.h 27 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/sphere.h 28 | hitable_list.h 29 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable_list.h 30 | float.h 31 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/float.h 32 | camera.h 33 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/camera.h 34 | random 35 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/random 36 | material.h 37 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/material.h 38 | 39 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/material.h 40 | ray.h 41 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/ray.h 42 | hitable.h 43 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable.h 44 | 45 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/ray.h 46 | vec3.h 47 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/vec3.h 48 | 49 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/sphere.h 50 | hitable.h 51 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/hitable.h 52 | 53 | /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/vec3.h 54 | math.h 55 | - 56 | stdlib.h 57 | - 58 | iostream 59 | - 60 | 61 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Makefile.cmake: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.8 3 | 4 | # The generator used is: 5 | set(CMAKE_DEPENDS_GENERATOR "Unix Makefiles") 6 | 7 | # The top level Makefile was generated from the following files: 8 | set(CMAKE_MAKEFILE_DEPENDS 9 | "CMakeCache.txt" 10 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCInformation.cmake" 11 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCXXInformation.cmake" 12 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCommonLanguageInclude.cmake" 13 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeExtraGeneratorDetermineCompilerMacrosAndIncludeDirs.cmake" 14 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeFindCodeBlocks.cmake" 15 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeGenericSystem.cmake" 16 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeLanguageInformation.cmake" 17 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeSystemSpecificInformation.cmake" 18 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeSystemSpecificInitialize.cmake" 19 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Compiler/AppleClang-C.cmake" 20 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Compiler/AppleClang-CXX.cmake" 21 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Compiler/Clang.cmake" 22 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Compiler/GNU.cmake" 23 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin-AppleClang-C.cmake" 24 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin-AppleClang-CXX.cmake" 25 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin-Clang-C.cmake" 26 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin-Clang-CXX.cmake" 27 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin-Clang.cmake" 28 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin-Initialize.cmake" 29 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/Darwin.cmake" 30 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/Platform/UnixPaths.cmake" 31 | "/Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/ProcessorCount.cmake" 32 | "../CMakeLists.txt" 33 | "CMakeFiles/3.8.2/CMakeCCompiler.cmake" 34 | "CMakeFiles/3.8.2/CMakeCXXCompiler.cmake" 35 | "CMakeFiles/3.8.2/CMakeSystem.cmake" 36 | ) 37 | 38 | # The corresponding makefile is: 39 | set(CMAKE_MAKEFILE_OUTPUTS 40 | "Makefile" 41 | "CMakeFiles/cmake.check_cache" 42 | ) 43 | 44 | # Byproducts of CMake generate step: 45 | set(CMAKE_MAKEFILE_PRODUCTS 46 | "CMakeFiles/CMakeDirectoryInformation.cmake" 47 | ) 48 | 49 | # Dependency information for all targets: 50 | set(CMAKE_DEPEND_INFO_FILES 51 | "CMakeFiles/Peter_Shirley_Project_Code.dir/DependInfo.cmake" 52 | ) 53 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/material.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SeeKHit on 2018/8/12. 3 | // 4 | 5 | #ifndef PETER_SHIRLEY_PROJECT_CODE_MATERIAL_H 6 | #define PETER_SHIRLEY_PROJECT_CODE_MATERIAL_H 7 | 8 | 9 | struct hit_record; 10 | 11 | #include "ray.h" 12 | #include "hitable.h" 13 | 14 | 15 | float schlick(float cosine, float ref_idx) { 16 | float r0 = (1-ref_idx) / (1+ref_idx); 17 | r0 = r0*r0; 18 | return r0 + (1-r0)*pow((1 - cosine),5); 19 | } 20 | 21 | bool refract(const vec3& v, const vec3& n, float ni_over_nt, vec3& refracted) { 22 | vec3 uv = unit_vector(v); 23 | float dt = dot(uv, n); 24 | float discriminant = 1.0 - ni_over_nt*ni_over_nt*(1-dt*dt); 25 | if (discriminant > 0) { 26 | refracted = ni_over_nt*(uv - n*dt) - n*sqrt(discriminant); 27 | return true; 28 | } 29 | else 30 | return false; 31 | } 32 | 33 | 34 | vec3 reflect(const vec3& v, const vec3& n) { 35 | return v - 2*dot(v,n)*n; 36 | } 37 | 38 | // 单位cube随机取点,返回一个在球内的点 39 | vec3 random_in_unit_sphere() { 40 | vec3 p; 41 | do { 42 | p = 2.0*vec3(drand48(),drand48(),drand48()) - vec3(1,1,1); 43 | } while (p.squared_length() >= 1.0); 44 | return p; 45 | } 46 | 47 | 48 | class material { 49 | public: 50 | // 散射虚函数 51 | // 参数:r_in 入射的光线, rec hit的记录, attenuation v3的衰减,scattered 散射后的光线 52 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const = 0; 53 | }; 54 | 55 | 56 | class lambertian : public material { 57 | public: 58 | lambertian(const vec3& a) : albedo(a) {} 59 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const { 60 | vec3 target = rec.p + rec.normal + random_in_unit_sphere(); 61 | scattered = ray(rec.p, target-rec.p); 62 | attenuation = albedo; 63 | return true; 64 | } 65 | 66 | vec3 albedo; // 反射率 67 | }; 68 | 69 | class metal : public material { 70 | public: 71 | metal(const vec3& a, float f) : albedo(a) { if (f < 1) fuzz = f; else fuzz = 1; } 72 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const { 73 | vec3 reflected = reflect(unit_vector(r_in.direction()), rec.normal); 74 | scattered = ray(rec.p, reflected + fuzz*random_in_unit_sphere()); 75 | attenuation = albedo; 76 | return (dot(scattered.direction(), rec.normal) > 0); 77 | } 78 | vec3 albedo; 79 | float fuzz; 80 | }; 81 | 82 | class dielectric : public material { 83 | public: 84 | dielectric(float ri) : ref_idx(ri) {} 85 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const { 86 | vec3 outward_normal; 87 | vec3 reflected = reflect(r_in.direction(), rec.normal); 88 | float ni_over_nt; 89 | attenuation = vec3(1.0, 1.0, 1.0); 90 | vec3 refracted; 91 | float reflect_prob; 92 | float cosine; 93 | if (dot(r_in.direction(), rec.normal) > 0) { 94 | outward_normal = -rec.normal; 95 | ni_over_nt = ref_idx; 96 | // cosine = ref_idx * dot(r_in.direction(), rec.normal) / r_in.direction().length(); 97 | cosine = dot(r_in.direction(), rec.normal) / r_in.direction().length(); 98 | cosine = sqrt(1 - ref_idx*ref_idx*(1-cosine*cosine)); 99 | } 100 | else { 101 | outward_normal = rec.normal; 102 | ni_over_nt = 1.0 / ref_idx; 103 | cosine = -dot(r_in.direction(), rec.normal) / r_in.direction().length(); 104 | } 105 | if (refract(r_in.direction(), outward_normal, ni_over_nt, refracted)) 106 | reflect_prob = schlick(cosine, ref_idx); 107 | else 108 | reflect_prob = 1.0; 109 | // 随机数小与反射系数,设为反射光线,反之为折射光线 110 | if (drand48() < reflect_prob) 111 | scattered = ray(rec.p, reflected); 112 | else 113 | scattered = ray(rec.p, refracted); 114 | return true; 115 | } 116 | 117 | float ref_idx; 118 | }; 119 | 120 | #endif //PETER_SHIRLEY_PROJECT_CODE_MATERIAL_H 121 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/vec3.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by SeeKHit on 29/05/2018. 3 | // 4 | 5 | #ifndef PETER_SHIRLEY_PROJECT_CODE_VEC3_H 6 | #define PETER_SHIRLEY_PROJECT_CODE_VEC3_H 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | class vec3 { 13 | public: 14 | vec3() {} 15 | vec3(float e0, float e1, float e2) { e[0] = e0; e[1] = e1; e[2] = e2; } 16 | inline float x() const { return e[0]; } 17 | inline float y() const { return e[1]; } 18 | inline float z() const { return e[2]; } 19 | inline float r() const { return e[0]; } 20 | inline float g() const { return e[1]; } 21 | inline float b() const { return e[2]; } 22 | 23 | inline const vec3& operator+() const { return *this; } 24 | inline vec3 operator-() const { return vec3(-e[0], -e[1], -e[2]); } 25 | inline float operator[](int i) const { return e[i]; } 26 | inline float& operator[](int i) { return e[i]; }; 27 | 28 | inline vec3& operator+=(const vec3 &v2); 29 | inline vec3& operator-=(const vec3 &v2); 30 | inline vec3& operator*=(const vec3 &v2); 31 | inline vec3& operator/=(const vec3 &v2); 32 | inline vec3& operator*=(const float t); 33 | inline vec3& operator/=(const float t); 34 | 35 | inline float length() const { return sqrt(e[0]*e[0] + e[1]*e[1] + e[2]*e[2]); } 36 | inline float squared_length() const { return e[0]*e[0] + e[1]*e[1] + e[2]*e[2]; } 37 | inline void make_unit_vector(); 38 | 39 | 40 | float e[3]; 41 | }; 42 | 43 | 44 | 45 | inline std::istream& operator>>(std::istream &is, vec3 &t) { 46 | is >> t.e[0] >> t.e[1] >> t.e[2]; 47 | return is; 48 | } 49 | 50 | inline std::ostream& operator<<(std::ostream &os, const vec3 &t) { 51 | os << t.e[0] << " " << t.e[1] << " " << t.e[2]; 52 | return os; 53 | } 54 | 55 | inline void vec3::make_unit_vector() { 56 | float k = 1.0 / sqrt(e[0]*e[0] + e[1]*e[1] + e[2]*e[2]); 57 | e[0] *= k; e[1] *= k; e[2] *= k; 58 | } 59 | 60 | inline vec3 operator+(const vec3 &v1, const vec3 &v2) { 61 | return vec3(v1.e[0] + v2.e[0], v1.e[1] + v2.e[1], v1.e[2] + v2.e[2]); 62 | } 63 | 64 | inline vec3 operator-(const vec3 &v1, const vec3 &v2) { 65 | return vec3(v1.e[0] - v2.e[0], v1.e[1] - v2.e[1], v1.e[2] - v2.e[2]); 66 | } 67 | 68 | inline vec3 operator*(const vec3 &v1, const vec3 &v2) { 69 | return vec3(v1.e[0] * v2.e[0], v1.e[1] * v2.e[1], v1.e[2] * v2.e[2]); 70 | } 71 | 72 | inline vec3 operator/(const vec3 &v1, const vec3 &v2) { 73 | return vec3(v1.e[0] / v2.e[0], v1.e[1] / v2.e[1], v1.e[2] / v2.e[2]); 74 | } 75 | 76 | inline vec3 operator*(float t, const vec3 &v) { 77 | return vec3(t*v.e[0], t*v.e[1], t*v.e[2]); 78 | } 79 | 80 | inline vec3 operator/(vec3 v, float t) { 81 | return vec3(v.e[0]/t, v.e[1]/t, v.e[2]/t); 82 | } 83 | 84 | inline vec3 operator*(const vec3 &v, float t) { 85 | return vec3(t*v.e[0], t*v.e[1], t*v.e[2]); 86 | } 87 | 88 | inline float dot(const vec3 &v1, const vec3 &v2) { 89 | return v1.e[0] *v2.e[0] + v1.e[1] *v2.e[1] + v1.e[2] *v2.e[2]; 90 | } 91 | 92 | inline vec3 cross(const vec3 &v1, const vec3 &v2) { 93 | return vec3( (v1.e[1]*v2.e[2] - v1.e[2]*v2.e[1]), 94 | (-(v1.e[0]*v2.e[2] - v1.e[2]*v2.e[0])), 95 | (v1.e[0]*v2.e[1] - v1.e[1]*v2.e[0])); 96 | } 97 | 98 | 99 | inline vec3& vec3::operator+=(const vec3 &v){ 100 | e[0] += v.e[0]; 101 | e[1] += v.e[1]; 102 | e[2] += v.e[2]; 103 | return *this; 104 | } 105 | 106 | inline vec3& vec3::operator*=(const vec3 &v){ 107 | e[0] *= v.e[0]; 108 | e[1] *= v.e[1]; 109 | e[2] *= v.e[2]; 110 | return *this; 111 | } 112 | 113 | inline vec3& vec3::operator/=(const vec3 &v){ 114 | e[0] /= v.e[0]; 115 | e[1] /= v.e[1]; 116 | e[2] /= v.e[2]; 117 | return *this; 118 | } 119 | 120 | inline vec3& vec3::operator-=(const vec3& v) { 121 | e[0] -= v.e[0]; 122 | e[1] -= v.e[1]; 123 | e[2] -= v.e[2]; 124 | return *this; 125 | } 126 | 127 | inline vec3& vec3::operator*=(const float t) { 128 | e[0] *= t; 129 | e[1] *= t; 130 | e[2] *= t; 131 | return *this; 132 | } 133 | 134 | inline vec3& vec3::operator/=(const float t) { 135 | float k = 1.0/t; 136 | 137 | e[0] *= k; 138 | e[1] *= k; 139 | e[2] *= k; 140 | return *this; 141 | } 142 | 143 | inline vec3 unit_vector(vec3 v) { 144 | return v / v.length(); 145 | } 146 | 147 | 148 | #endif //PETER_SHIRLEY_PROJECT_CODE_VEC3_H 149 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Makefile2: -------------------------------------------------------------------------------- 1 | # CMAKE generated file: DO NOT EDIT! 2 | # Generated by "Unix Makefiles" Generator, CMake Version 3.8 3 | 4 | # Default target executed when no arguments are given to make. 5 | default_target: all 6 | 7 | .PHONY : default_target 8 | 9 | # The main recursive all target 10 | all: 11 | 12 | .PHONY : all 13 | 14 | # The main recursive preinstall target 15 | preinstall: 16 | 17 | .PHONY : preinstall 18 | 19 | #============================================================================= 20 | # Special targets provided by cmake. 21 | 22 | # Disable implicit rules so canonical targets will work. 23 | .SUFFIXES: 24 | 25 | 26 | # Remove some rules from gmake that .SUFFIXES does not remove. 27 | SUFFIXES = 28 | 29 | .SUFFIXES: .hpux_make_needs_suffix_list 30 | 31 | 32 | # Suppress display of executed commands. 33 | $(VERBOSE).SILENT: 34 | 35 | 36 | # A target that is always out of date. 37 | cmake_force: 38 | 39 | .PHONY : cmake_force 40 | 41 | #============================================================================= 42 | # Set environment variables for the build. 43 | 44 | # The shell in which to execute make rules. 45 | SHELL = /bin/sh 46 | 47 | # The CMake executable. 48 | CMAKE_COMMAND = /Applications/CLion.app/Contents/bin/cmake/bin/cmake 49 | 50 | # The command to remove a file. 51 | RM = /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E remove -f 52 | 53 | # Escaping for special characters. 54 | EQUALS = = 55 | 56 | # The top-level source directory on which CMake was run. 57 | CMAKE_SOURCE_DIR = "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code" 58 | 59 | # The top-level build directory on which CMake was run. 60 | CMAKE_BINARY_DIR = "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug" 61 | 62 | #============================================================================= 63 | # Target rules for target CMakeFiles/Peter_Shirley_Project_Code.dir 64 | 65 | # All Build rule for target. 66 | CMakeFiles/Peter_Shirley_Project_Code.dir/all: 67 | $(MAKE) -f CMakeFiles/Peter_Shirley_Project_Code.dir/build.make CMakeFiles/Peter_Shirley_Project_Code.dir/depend 68 | $(MAKE) -f CMakeFiles/Peter_Shirley_Project_Code.dir/build.make CMakeFiles/Peter_Shirley_Project_Code.dir/build 69 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --progress-dir="/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles" --progress-num=1,2 "Built target Peter_Shirley_Project_Code" 70 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/all 71 | 72 | # Include target in all. 73 | all: CMakeFiles/Peter_Shirley_Project_Code.dir/all 74 | 75 | .PHONY : all 76 | 77 | # Build rule for subdir invocation for target. 78 | CMakeFiles/Peter_Shirley_Project_Code.dir/rule: cmake_check_build_system 79 | $(CMAKE_COMMAND) -E cmake_progress_start "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles" 2 80 | $(MAKE) -f CMakeFiles/Makefile2 CMakeFiles/Peter_Shirley_Project_Code.dir/all 81 | $(CMAKE_COMMAND) -E cmake_progress_start "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles" 0 82 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/rule 83 | 84 | # Convenience name for target. 85 | Peter_Shirley_Project_Code: CMakeFiles/Peter_Shirley_Project_Code.dir/rule 86 | 87 | .PHONY : Peter_Shirley_Project_Code 88 | 89 | # clean rule for target. 90 | CMakeFiles/Peter_Shirley_Project_Code.dir/clean: 91 | $(MAKE) -f CMakeFiles/Peter_Shirley_Project_Code.dir/build.make CMakeFiles/Peter_Shirley_Project_Code.dir/clean 92 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/clean 93 | 94 | # clean rule for target. 95 | clean: CMakeFiles/Peter_Shirley_Project_Code.dir/clean 96 | 97 | .PHONY : clean 98 | 99 | #============================================================================= 100 | # Special targets to cleanup operation of make. 101 | 102 | # Special rule to run CMake to check the build system integrity. 103 | # No rule that depends on this can have commands that come from listfiles 104 | # because they might be regenerated. 105 | cmake_check_build_system: 106 | $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 107 | .PHONY : cmake_check_build_system 108 | 109 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "sphere.h" 4 | #include "hitable_list.h" 5 | #include "float.h" 6 | #include "camera.h" 7 | #include "random" 8 | #include "material.h" 9 | #define random(a,b) (rand()%(b-a+1)+a) 10 | 11 | using namespace std; 12 | 13 | vec3 color(const ray& r,hitable *world, int depth) 14 | { 15 | hit_record rec; 16 | if(world->hit(r,0.0,MAXFLOAT,rec)) 17 | { 18 | // 散射后的光线 19 | ray scattered; 20 | // 衰减 21 | vec3 attenuation; 22 | 23 | if(depth<50 && rec.mat_ptr->scatter(r,rec,attenuation,scattered)) 24 | { 25 | // 递归 衰减 26 | return attenuation * color(scattered, world, depth+1); 27 | } else 28 | { 29 | return vec3(0,0,0); 30 | } 31 | } 32 | else 33 | { 34 | vec3 unit_direction = unit_vector(r.direction()); 35 | float t = 0.5 *(unit_direction.y() + 1.0); 36 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 37 | } 38 | } 39 | 40 | 41 | hitable *random_scene() { 42 | int n = 500; 43 | hitable **list = new hitable*[n+1]; 44 | list[0] = new sphere(vec3(0,-700,0), 700, new lambertian(vec3(0.5, 0.5, 0.5))); 45 | int i = 1; 46 | for (int a = -11; a < 11; a++) { 47 | for (int b = -11; b < 11; b++) { 48 | float choose_mat = drand48(); 49 | vec3 center(a+0.9*drand48(),0.2,b+0.9*drand48()); 50 | if ((center-vec3(4,0.2,0)).length() > 0.9) { 51 | if (choose_mat < 0.8) { // diffuse 52 | list[i++] = new sphere(center, 0.2, new lambertian(vec3(drand48()*drand48(), drand48()*drand48(), drand48()*drand48()))); 53 | } 54 | else if (choose_mat < 0.95) { // metal 55 | list[i++] = new sphere(center, 0.2, 56 | new metal(vec3(0.5*(1 + drand48()), 0.5*(1 + drand48()), 0.5*(1 + drand48())), 0.5*drand48())); 57 | } 58 | else { // glass 59 | list[i++] = new sphere(center, 0.2, new dielectric(1.5)); 60 | } 61 | } 62 | } 63 | } 64 | 65 | list[i++] = new sphere(vec3(0, 1, 0), 1.0, new dielectric(2.5)); 66 | list[i++] = new sphere(vec3(-4, 1, 0), 1.0, new lambertian(vec3(0.4, 0.2, 0.1))); 67 | list[i++] = new sphere(vec3(4, 1, 0), 1.0, new metal(vec3(1, 1, 1), 0.0)); 68 | 69 | return new hitable_list(list,i); 70 | } 71 | 72 | 73 | int main() 74 | { 75 | string str = ""; 76 | 77 | int nx = 1500; 78 | int ny = 900; 79 | // 采样数量ns 80 | int ns = 100; 81 | 82 | 83 | vec3 lookfrom(13,2,3); 84 | vec3 lookat(0,0,0); 85 | float dist_to_focus = 10.0; 86 | float aperture = 0.1; 87 | camera cam(lookfrom,lookat,vec3(0,1,0),20,float(nx)/float(ny),aperture,dist_to_focus); 88 | 89 | 90 | 91 | hitable *list[2]; 92 | // 球1,2,3,4; 2个lambertian ,2个metal 93 | list[0] = new sphere(vec3(0,0,-1),0.5,new lambertian(vec3(0.8,0.3,0.3))); 94 | list[1] = new sphere(vec3(0,-100.5,-1),100,new lambertian(vec3(0.8,0.8,0.0))); 95 | list[2] = new sphere(vec3(1,0,-1),0.5,new metal(vec3(0.8,0.6,0.2),0.0)); 96 | list[3] = new sphere(vec3(-1,0,-1),0.5,new dielectric(1.5)); 97 | list[4] = new sphere(vec3(-1,0,-1), -0.45, new dielectric(1.5)); 98 | hitable *world = new hitable_list(list,5); 99 | world = random_scene(); 100 | 101 | random_device rd; 102 | 103 | ofstream OutFile("Test.ppm"); //利用构造函数创建txt文本,并且打开该文本 104 | 105 | OutFile<<"P3\n"<=0;j--) 108 | { 109 | str = ""; 110 | for(int i=0;i CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.i 68 | 69 | CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.s: cmake_force 70 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Compiling CXX source to assembly CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.s" 71 | /Library/Developer/CommandLineTools/usr/bin/c++ $(CXX_DEFINES) $(CXX_INCLUDES) $(CXX_FLAGS) -S "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/main.cpp" -o CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.s 72 | 73 | CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.requires: 74 | 75 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.requires 76 | 77 | CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.provides: CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.requires 78 | $(MAKE) -f CMakeFiles/Peter_Shirley_Project_Code.dir/build.make CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.provides.build 79 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.provides 80 | 81 | CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.provides.build: CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o 82 | 83 | 84 | # Object files for target Peter_Shirley_Project_Code 85 | Peter_Shirley_Project_Code_OBJECTS = \ 86 | "CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o" 87 | 88 | # External object files for target Peter_Shirley_Project_Code 89 | Peter_Shirley_Project_Code_EXTERNAL_OBJECTS = 90 | 91 | Peter_Shirley_Project_Code: CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o 92 | Peter_Shirley_Project_Code: CMakeFiles/Peter_Shirley_Project_Code.dir/build.make 93 | Peter_Shirley_Project_Code: CMakeFiles/Peter_Shirley_Project_Code.dir/link.txt 94 | @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green --bold --progress-dir="/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles" --progress-num=$(CMAKE_PROGRESS_2) "Linking CXX executable Peter_Shirley_Project_Code" 95 | $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/Peter_Shirley_Project_Code.dir/link.txt --verbose=$(VERBOSE) 96 | 97 | # Rule to build all files generated by this target. 98 | CMakeFiles/Peter_Shirley_Project_Code.dir/build: Peter_Shirley_Project_Code 99 | 100 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/build 101 | 102 | CMakeFiles/Peter_Shirley_Project_Code.dir/requires: CMakeFiles/Peter_Shirley_Project_Code.dir/main.cpp.o.requires 103 | 104 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/requires 105 | 106 | CMakeFiles/Peter_Shirley_Project_Code.dir/clean: 107 | $(CMAKE_COMMAND) -P CMakeFiles/Peter_Shirley_Project_Code.dir/cmake_clean.cmake 108 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/clean 109 | 110 | CMakeFiles/Peter_Shirley_Project_Code.dir/depend: 111 | cd "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug" && $(CMAKE_COMMAND) -E cmake_depends "Unix Makefiles" "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code" "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code" "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug" "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug" "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/Peter_Shirley_Project_Code.dir/DependInfo.cmake" --color=$(COLOR) 112 | .PHONY : CMakeFiles/Peter_Shirley_Project_Code.dir/depend 113 | 114 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/Peter_Shirley_Project_Code.cbp: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 113 | 114 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.cxx: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "CXX_FEATURE:" 4 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_aggregate_nsdmi) 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "cxx_aggregate_default_initializers\n" 10 | "CXX_FEATURE:" 11 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_alias_templates) 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "cxx_alias_templates\n" 17 | "CXX_FEATURE:" 18 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_alignas) 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "cxx_alignas\n" 24 | "CXX_FEATURE:" 25 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_alignas) 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "cxx_alignof\n" 31 | "CXX_FEATURE:" 32 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_attributes) 33 | "1" 34 | #else 35 | "0" 36 | #endif 37 | "cxx_attributes\n" 38 | "CXX_FEATURE:" 39 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 40 | "1" 41 | #else 42 | "0" 43 | #endif 44 | "cxx_attribute_deprecated\n" 45 | "CXX_FEATURE:" 46 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_auto_type) 47 | "1" 48 | #else 49 | "0" 50 | #endif 51 | "cxx_auto_type\n" 52 | "CXX_FEATURE:" 53 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_binary_literals) 54 | "1" 55 | #else 56 | "0" 57 | #endif 58 | "cxx_binary_literals\n" 59 | "CXX_FEATURE:" 60 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_constexpr) 61 | "1" 62 | #else 63 | "0" 64 | #endif 65 | "cxx_constexpr\n" 66 | "CXX_FEATURE:" 67 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_contextual_conversions) 68 | "1" 69 | #else 70 | "0" 71 | #endif 72 | "cxx_contextual_conversions\n" 73 | "CXX_FEATURE:" 74 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_decltype) 75 | "1" 76 | #else 77 | "0" 78 | #endif 79 | "cxx_decltype\n" 80 | "CXX_FEATURE:" 81 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 82 | "1" 83 | #else 84 | "0" 85 | #endif 86 | "cxx_decltype_auto\n" 87 | "CXX_FEATURE:" 88 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_decltype_incomplete_return_types) 89 | "1" 90 | #else 91 | "0" 92 | #endif 93 | "cxx_decltype_incomplete_return_types\n" 94 | "CXX_FEATURE:" 95 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_default_function_template_args) 96 | "1" 97 | #else 98 | "0" 99 | #endif 100 | "cxx_default_function_template_args\n" 101 | "CXX_FEATURE:" 102 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_defaulted_functions) 103 | "1" 104 | #else 105 | "0" 106 | #endif 107 | "cxx_defaulted_functions\n" 108 | "CXX_FEATURE:" 109 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_defaulted_functions) 110 | "1" 111 | #else 112 | "0" 113 | #endif 114 | "cxx_defaulted_move_initializers\n" 115 | "CXX_FEATURE:" 116 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_delegating_constructors) 117 | "1" 118 | #else 119 | "0" 120 | #endif 121 | "cxx_delegating_constructors\n" 122 | "CXX_FEATURE:" 123 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_deleted_functions) 124 | "1" 125 | #else 126 | "0" 127 | #endif 128 | "cxx_deleted_functions\n" 129 | "CXX_FEATURE:" 130 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 131 | "1" 132 | #else 133 | "0" 134 | #endif 135 | "cxx_digit_separators\n" 136 | "CXX_FEATURE:" 137 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 138 | "1" 139 | #else 140 | "0" 141 | #endif 142 | "cxx_enum_forward_declarations\n" 143 | "CXX_FEATURE:" 144 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_explicit_conversions) 145 | "1" 146 | #else 147 | "0" 148 | #endif 149 | "cxx_explicit_conversions\n" 150 | "CXX_FEATURE:" 151 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 152 | "1" 153 | #else 154 | "0" 155 | #endif 156 | "cxx_extended_friend_declarations\n" 157 | "CXX_FEATURE:" 158 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 159 | "1" 160 | #else 161 | "0" 162 | #endif 163 | "cxx_extern_templates\n" 164 | "CXX_FEATURE:" 165 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_override_control) 166 | "1" 167 | #else 168 | "0" 169 | #endif 170 | "cxx_final\n" 171 | "CXX_FEATURE:" 172 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 173 | "1" 174 | #else 175 | "0" 176 | #endif 177 | "cxx_func_identifier\n" 178 | "CXX_FEATURE:" 179 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_generalized_initializers) 180 | "1" 181 | #else 182 | "0" 183 | #endif 184 | "cxx_generalized_initializers\n" 185 | "CXX_FEATURE:" 186 | #if ((__clang_major__ * 100) + __clang_minor__) >= 501 && __cplusplus > 201103L 187 | "1" 188 | #else 189 | "0" 190 | #endif 191 | "cxx_generic_lambdas\n" 192 | "CXX_FEATURE:" 193 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_inheriting_constructors) 194 | "1" 195 | #else 196 | "0" 197 | #endif 198 | "cxx_inheriting_constructors\n" 199 | "CXX_FEATURE:" 200 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 201 | "1" 202 | #else 203 | "0" 204 | #endif 205 | "cxx_inline_namespaces\n" 206 | "CXX_FEATURE:" 207 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_lambdas) 208 | "1" 209 | #else 210 | "0" 211 | #endif 212 | "cxx_lambdas\n" 213 | "CXX_FEATURE:" 214 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_init_captures) 215 | "1" 216 | #else 217 | "0" 218 | #endif 219 | "cxx_lambda_init_captures\n" 220 | "CXX_FEATURE:" 221 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_local_type_template_args) 222 | "1" 223 | #else 224 | "0" 225 | #endif 226 | "cxx_local_type_template_args\n" 227 | "CXX_FEATURE:" 228 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 229 | "1" 230 | #else 231 | "0" 232 | #endif 233 | "cxx_long_long_type\n" 234 | "CXX_FEATURE:" 235 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_noexcept) 236 | "1" 237 | #else 238 | "0" 239 | #endif 240 | "cxx_noexcept\n" 241 | "CXX_FEATURE:" 242 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_nonstatic_member_init) 243 | "1" 244 | #else 245 | "0" 246 | #endif 247 | "cxx_nonstatic_member_init\n" 248 | "CXX_FEATURE:" 249 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_nullptr) 250 | "1" 251 | #else 252 | "0" 253 | #endif 254 | "cxx_nullptr\n" 255 | "CXX_FEATURE:" 256 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_override_control) 257 | "1" 258 | #else 259 | "0" 260 | #endif 261 | "cxx_override\n" 262 | "CXX_FEATURE:" 263 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_range_for) 264 | "1" 265 | #else 266 | "0" 267 | #endif 268 | "cxx_range_for\n" 269 | "CXX_FEATURE:" 270 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_raw_string_literals) 271 | "1" 272 | #else 273 | "0" 274 | #endif 275 | "cxx_raw_string_literals\n" 276 | "CXX_FEATURE:" 277 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_reference_qualified_functions) 278 | "1" 279 | #else 280 | "0" 281 | #endif 282 | "cxx_reference_qualified_functions\n" 283 | "CXX_FEATURE:" 284 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_relaxed_constexpr) 285 | "1" 286 | #else 287 | "0" 288 | #endif 289 | "cxx_relaxed_constexpr\n" 290 | "CXX_FEATURE:" 291 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_return_type_deduction) 292 | "1" 293 | #else 294 | "0" 295 | #endif 296 | "cxx_return_type_deduction\n" 297 | "CXX_FEATURE:" 298 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 299 | "1" 300 | #else 301 | "0" 302 | #endif 303 | "cxx_right_angle_brackets\n" 304 | "CXX_FEATURE:" 305 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_rvalue_references) 306 | "1" 307 | #else 308 | "0" 309 | #endif 310 | "cxx_rvalue_references\n" 311 | "CXX_FEATURE:" 312 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 313 | "1" 314 | #else 315 | "0" 316 | #endif 317 | "cxx_sizeof_member\n" 318 | "CXX_FEATURE:" 319 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_static_assert) 320 | "1" 321 | #else 322 | "0" 323 | #endif 324 | "cxx_static_assert\n" 325 | "CXX_FEATURE:" 326 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_strong_enums) 327 | "1" 328 | #else 329 | "0" 330 | #endif 331 | "cxx_strong_enums\n" 332 | "CXX_FEATURE:" 333 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 199711L 334 | "1" 335 | #else 336 | "0" 337 | #endif 338 | "cxx_template_template_parameters\n" 339 | "CXX_FEATURE:" 340 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_thread_local) 341 | "1" 342 | #else 343 | "0" 344 | #endif 345 | "cxx_thread_local\n" 346 | "CXX_FEATURE:" 347 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_trailing_return) 348 | "1" 349 | #else 350 | "0" 351 | #endif 352 | "cxx_trailing_return_types\n" 353 | "CXX_FEATURE:" 354 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_unicode_literals) 355 | "1" 356 | #else 357 | "0" 358 | #endif 359 | "cxx_unicode_literals\n" 360 | "CXX_FEATURE:" 361 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_generalized_initializers) 362 | "1" 363 | #else 364 | "0" 365 | #endif 366 | "cxx_uniform_initialization\n" 367 | "CXX_FEATURE:" 368 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_unrestricted_unions) 369 | "1" 370 | #else 371 | "0" 372 | #endif 373 | "cxx_unrestricted_unions\n" 374 | "CXX_FEATURE:" 375 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_user_literals) 376 | "1" 377 | #else 378 | "0" 379 | #endif 380 | "cxx_user_literals\n" 381 | "CXX_FEATURE:" 382 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_variable_templates) 383 | "1" 384 | #else 385 | "0" 386 | #endif 387 | "cxx_variable_templates\n" 388 | "CXX_FEATURE:" 389 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __cplusplus >= 201103L 390 | "1" 391 | #else 392 | "0" 393 | #endif 394 | "cxx_variadic_macros\n" 395 | "CXX_FEATURE:" 396 | #if ((__clang_major__ * 100) + __clang_minor__) >= 400 && __has_feature(cxx_variadic_templates) 397 | "1" 398 | #else 399 | "0" 400 | #endif 401 | "cxx_variadic_templates\n" 402 | 403 | }; 404 | 405 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 406 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdCXX/CMakeCXXCompilerId.cpp: -------------------------------------------------------------------------------- 1 | /* This source file must have a .cpp extension so that all C++ compilers 2 | recognize the extension without flags. Borland does not know .cxx for 3 | example. */ 4 | #ifndef __cplusplus 5 | # error "A C compiler has been selected for C++." 6 | #endif 7 | 8 | 9 | /* Version number components: V=Version, R=Revision, P=Patch 10 | Version date components: YYYY=Year, MM=Month, DD=Day */ 11 | 12 | #if defined(__COMO__) 13 | # define COMPILER_ID "Comeau" 14 | /* __COMO_VERSION__ = VRR */ 15 | # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) 16 | # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) 17 | 18 | #elif defined(__INTEL_COMPILER) || defined(__ICC) 19 | # define COMPILER_ID "Intel" 20 | # if defined(_MSC_VER) 21 | # define SIMULATE_ID "MSVC" 22 | # endif 23 | /* __INTEL_COMPILER = VRP */ 24 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 25 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 26 | # if defined(__INTEL_COMPILER_UPDATE) 27 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) 28 | # else 29 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 30 | # endif 31 | # if defined(__INTEL_COMPILER_BUILD_DATE) 32 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 33 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 34 | # endif 35 | # if defined(_MSC_VER) 36 | /* _MSC_VER = VVRR */ 37 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 38 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 39 | # endif 40 | 41 | #elif defined(__PATHCC__) 42 | # define COMPILER_ID "PathScale" 43 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 44 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 45 | # if defined(__PATHCC_PATCHLEVEL__) 46 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 47 | # endif 48 | 49 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 50 | # define COMPILER_ID "Embarcadero" 51 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 52 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 53 | # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) 54 | 55 | #elif defined(__BORLANDC__) 56 | # define COMPILER_ID "Borland" 57 | /* __BORLANDC__ = 0xVRR */ 58 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 59 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 60 | 61 | #elif defined(__WATCOMC__) && __WATCOMC__ < 1200 62 | # define COMPILER_ID "Watcom" 63 | /* __WATCOMC__ = VVRR */ 64 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 65 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 66 | # if (__WATCOMC__ % 10) > 0 67 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 68 | # endif 69 | 70 | #elif defined(__WATCOMC__) 71 | # define COMPILER_ID "OpenWatcom" 72 | /* __WATCOMC__ = VVRP + 1100 */ 73 | # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) 74 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 75 | # if (__WATCOMC__ % 10) > 0 76 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 77 | # endif 78 | 79 | #elif defined(__SUNPRO_CC) 80 | # define COMPILER_ID "SunPro" 81 | # if __SUNPRO_CC >= 0x5100 82 | /* __SUNPRO_CC = 0xVRRP */ 83 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) 84 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) 85 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 86 | # else 87 | /* __SUNPRO_CC = 0xVRP */ 88 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) 89 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) 90 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 91 | # endif 92 | 93 | #elif defined(__HP_aCC) 94 | # define COMPILER_ID "HP" 95 | /* __HP_aCC = VVRRPP */ 96 | # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) 97 | # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) 98 | # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) 99 | 100 | #elif defined(__DECCXX) 101 | # define COMPILER_ID "Compaq" 102 | /* __DECCXX_VER = VVRRTPPPP */ 103 | # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) 104 | # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) 105 | # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) 106 | 107 | #elif defined(__IBMCPP__) && defined(__COMPILER_VER__) 108 | # define COMPILER_ID "zOS" 109 | /* __IBMCPP__ = VRP */ 110 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 111 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 112 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 113 | 114 | #elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 115 | # define COMPILER_ID "XL" 116 | /* __IBMCPP__ = VRP */ 117 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 118 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 119 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 120 | 121 | #elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 122 | # define COMPILER_ID "VisualAge" 123 | /* __IBMCPP__ = VRP */ 124 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 125 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 126 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 127 | 128 | #elif defined(__PGI) 129 | # define COMPILER_ID "PGI" 130 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 131 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 132 | # if defined(__PGIC_PATCHLEVEL__) 133 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 134 | # endif 135 | 136 | #elif defined(_CRAYC) 137 | # define COMPILER_ID "Cray" 138 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) 139 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 140 | 141 | #elif defined(__TI_COMPILER_VERSION__) 142 | # define COMPILER_ID "TI" 143 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 144 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 145 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 146 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 147 | 148 | #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) 149 | # define COMPILER_ID "Fujitsu" 150 | 151 | #elif defined(__SCO_VERSION__) 152 | # define COMPILER_ID "SCO" 153 | 154 | #elif defined(__clang__) && defined(__apple_build_version__) 155 | # define COMPILER_ID "AppleClang" 156 | # if defined(_MSC_VER) 157 | # define SIMULATE_ID "MSVC" 158 | # endif 159 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 160 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 161 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 162 | # if defined(_MSC_VER) 163 | /* _MSC_VER = VVRR */ 164 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 165 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 166 | # endif 167 | # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) 168 | 169 | #elif defined(__clang__) 170 | # define COMPILER_ID "Clang" 171 | # if defined(_MSC_VER) 172 | # define SIMULATE_ID "MSVC" 173 | # endif 174 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 175 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 176 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 177 | # if defined(_MSC_VER) 178 | /* _MSC_VER = VVRR */ 179 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 180 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 181 | # endif 182 | 183 | #elif defined(__GNUC__) || defined(__GNUG__) 184 | # define COMPILER_ID "GNU" 185 | # if defined(__GNUC__) 186 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 187 | # else 188 | # define COMPILER_VERSION_MAJOR DEC(__GNUG__) 189 | # endif 190 | # if defined(__GNUC_MINOR__) 191 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 192 | # endif 193 | # if defined(__GNUC_PATCHLEVEL__) 194 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 195 | # endif 196 | 197 | #elif defined(_MSC_VER) 198 | # define COMPILER_ID "MSVC" 199 | /* _MSC_VER = VVRR */ 200 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 201 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 202 | # if defined(_MSC_FULL_VER) 203 | # if _MSC_VER >= 1400 204 | /* _MSC_FULL_VER = VVRRPPPPP */ 205 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 206 | # else 207 | /* _MSC_FULL_VER = VVRRPPPP */ 208 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 209 | # endif 210 | # endif 211 | # if defined(_MSC_BUILD) 212 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 213 | # endif 214 | 215 | #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 216 | # define COMPILER_ID "ADSP" 217 | #if defined(__VISUALDSPVERSION__) 218 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 219 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 220 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 221 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 222 | #endif 223 | 224 | #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) 225 | # define COMPILER_ID "IAR" 226 | 227 | #elif defined(__ARMCC_VERSION) 228 | # define COMPILER_ID "ARMCC" 229 | #if __ARMCC_VERSION >= 1000000 230 | /* __ARMCC_VERSION = VRRPPPP */ 231 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) 232 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) 233 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 234 | #else 235 | /* __ARMCC_VERSION = VRPPPP */ 236 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) 237 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) 238 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 239 | #endif 240 | 241 | 242 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 243 | # define COMPILER_ID "MIPSpro" 244 | # if defined(_SGI_COMPILER_VERSION) 245 | /* _SGI_COMPILER_VERSION = VRP */ 246 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 247 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 248 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 249 | # else 250 | /* _COMPILER_VERSION = VRP */ 251 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 252 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 253 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 254 | # endif 255 | 256 | 257 | /* These compilers are either not known or too old to define an 258 | identification macro. Try to identify the platform and guess that 259 | it is the native compiler. */ 260 | #elif defined(__sgi) 261 | # define COMPILER_ID "MIPSpro" 262 | 263 | #elif defined(__hpux) || defined(__hpua) 264 | # define COMPILER_ID "HP" 265 | 266 | #else /* unknown compiler */ 267 | # define COMPILER_ID "" 268 | #endif 269 | 270 | /* Construct the string literal in pieces to prevent the source from 271 | getting matched. Store it in a pointer rather than an array 272 | because some compilers will just produce instructions to fill the 273 | array rather than assigning a pointer to a static array. */ 274 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 275 | #ifdef SIMULATE_ID 276 | char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; 277 | #endif 278 | 279 | #ifdef __QNXNTO__ 280 | char const* qnxnto = "INFO" ":" "qnxnto[]"; 281 | #endif 282 | 283 | #if defined(__CRAYXE) || defined(__CRAYXC) 284 | char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; 285 | #endif 286 | 287 | #define STRINGIFY_HELPER(X) #X 288 | #define STRINGIFY(X) STRINGIFY_HELPER(X) 289 | 290 | /* Identify known platforms by name. */ 291 | #if defined(__linux) || defined(__linux__) || defined(linux) 292 | # define PLATFORM_ID "Linux" 293 | 294 | #elif defined(__CYGWIN__) 295 | # define PLATFORM_ID "Cygwin" 296 | 297 | #elif defined(__MINGW32__) 298 | # define PLATFORM_ID "MinGW" 299 | 300 | #elif defined(__APPLE__) 301 | # define PLATFORM_ID "Darwin" 302 | 303 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 304 | # define PLATFORM_ID "Windows" 305 | 306 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 307 | # define PLATFORM_ID "FreeBSD" 308 | 309 | #elif defined(__NetBSD__) || defined(__NetBSD) 310 | # define PLATFORM_ID "NetBSD" 311 | 312 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 313 | # define PLATFORM_ID "OpenBSD" 314 | 315 | #elif defined(__sun) || defined(sun) 316 | # define PLATFORM_ID "SunOS" 317 | 318 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 319 | # define PLATFORM_ID "AIX" 320 | 321 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 322 | # define PLATFORM_ID "IRIX" 323 | 324 | #elif defined(__hpux) || defined(__hpux__) 325 | # define PLATFORM_ID "HP-UX" 326 | 327 | #elif defined(__HAIKU__) 328 | # define PLATFORM_ID "Haiku" 329 | 330 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 331 | # define PLATFORM_ID "BeOS" 332 | 333 | #elif defined(__QNX__) || defined(__QNXNTO__) 334 | # define PLATFORM_ID "QNX" 335 | 336 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 337 | # define PLATFORM_ID "Tru64" 338 | 339 | #elif defined(__riscos) || defined(__riscos__) 340 | # define PLATFORM_ID "RISCos" 341 | 342 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 343 | # define PLATFORM_ID "SINIX" 344 | 345 | #elif defined(__UNIX_SV__) 346 | # define PLATFORM_ID "UNIX_SV" 347 | 348 | #elif defined(__bsdos__) 349 | # define PLATFORM_ID "BSDOS" 350 | 351 | #elif defined(_MPRAS) || defined(MPRAS) 352 | # define PLATFORM_ID "MP-RAS" 353 | 354 | #elif defined(__osf) || defined(__osf__) 355 | # define PLATFORM_ID "OSF1" 356 | 357 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 358 | # define PLATFORM_ID "SCO_SV" 359 | 360 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 361 | # define PLATFORM_ID "ULTRIX" 362 | 363 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 364 | # define PLATFORM_ID "Xenix" 365 | 366 | #elif defined(__WATCOMC__) 367 | # if defined(__LINUX__) 368 | # define PLATFORM_ID "Linux" 369 | 370 | # elif defined(__DOS__) 371 | # define PLATFORM_ID "DOS" 372 | 373 | # elif defined(__OS2__) 374 | # define PLATFORM_ID "OS2" 375 | 376 | # elif defined(__WINDOWS__) 377 | # define PLATFORM_ID "Windows3x" 378 | 379 | # else /* unknown platform */ 380 | # define PLATFORM_ID 381 | # endif 382 | 383 | #else /* unknown platform */ 384 | # define PLATFORM_ID 385 | 386 | #endif 387 | 388 | /* For windows compilers MSVC and Intel we can determine 389 | the architecture of the compiler being used. This is because 390 | the compilers do not have flags that can change the architecture, 391 | but rather depend on which compiler is being used 392 | */ 393 | #if defined(_WIN32) && defined(_MSC_VER) 394 | # if defined(_M_IA64) 395 | # define ARCHITECTURE_ID "IA64" 396 | 397 | # elif defined(_M_X64) || defined(_M_AMD64) 398 | # define ARCHITECTURE_ID "x64" 399 | 400 | # elif defined(_M_IX86) 401 | # define ARCHITECTURE_ID "X86" 402 | 403 | # elif defined(_M_ARM) 404 | # if _M_ARM == 4 405 | # define ARCHITECTURE_ID "ARMV4I" 406 | # elif _M_ARM == 5 407 | # define ARCHITECTURE_ID "ARMV5I" 408 | # else 409 | # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) 410 | # endif 411 | 412 | # elif defined(_M_MIPS) 413 | # define ARCHITECTURE_ID "MIPS" 414 | 415 | # elif defined(_M_SH) 416 | # define ARCHITECTURE_ID "SHx" 417 | 418 | # else /* unknown architecture */ 419 | # define ARCHITECTURE_ID "" 420 | # endif 421 | 422 | #elif defined(__WATCOMC__) 423 | # if defined(_M_I86) 424 | # define ARCHITECTURE_ID "I86" 425 | 426 | # elif defined(_M_IX86) 427 | # define ARCHITECTURE_ID "X86" 428 | 429 | # else /* unknown architecture */ 430 | # define ARCHITECTURE_ID "" 431 | # endif 432 | 433 | #else 434 | # define ARCHITECTURE_ID 435 | #endif 436 | 437 | /* Convert integer to decimal digit literals. */ 438 | #define DEC(n) \ 439 | ('0' + (((n) / 10000000)%10)), \ 440 | ('0' + (((n) / 1000000)%10)), \ 441 | ('0' + (((n) / 100000)%10)), \ 442 | ('0' + (((n) / 10000)%10)), \ 443 | ('0' + (((n) / 1000)%10)), \ 444 | ('0' + (((n) / 100)%10)), \ 445 | ('0' + (((n) / 10)%10)), \ 446 | ('0' + ((n) % 10)) 447 | 448 | /* Convert integer to hex digit literals. */ 449 | #define HEX(n) \ 450 | ('0' + ((n)>>28 & 0xF)), \ 451 | ('0' + ((n)>>24 & 0xF)), \ 452 | ('0' + ((n)>>20 & 0xF)), \ 453 | ('0' + ((n)>>16 & 0xF)), \ 454 | ('0' + ((n)>>12 & 0xF)), \ 455 | ('0' + ((n)>>8 & 0xF)), \ 456 | ('0' + ((n)>>4 & 0xF)), \ 457 | ('0' + ((n) & 0xF)) 458 | 459 | /* Construct a string literal encoding the version number components. */ 460 | #ifdef COMPILER_VERSION_MAJOR 461 | char const info_version[] = { 462 | 'I', 'N', 'F', 'O', ':', 463 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 464 | COMPILER_VERSION_MAJOR, 465 | # ifdef COMPILER_VERSION_MINOR 466 | '.', COMPILER_VERSION_MINOR, 467 | # ifdef COMPILER_VERSION_PATCH 468 | '.', COMPILER_VERSION_PATCH, 469 | # ifdef COMPILER_VERSION_TWEAK 470 | '.', COMPILER_VERSION_TWEAK, 471 | # endif 472 | # endif 473 | # endif 474 | ']','\0'}; 475 | #endif 476 | 477 | /* Construct a string literal encoding the version number components. */ 478 | #ifdef SIMULATE_VERSION_MAJOR 479 | char const info_simulate_version[] = { 480 | 'I', 'N', 'F', 'O', ':', 481 | 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', 482 | SIMULATE_VERSION_MAJOR, 483 | # ifdef SIMULATE_VERSION_MINOR 484 | '.', SIMULATE_VERSION_MINOR, 485 | # ifdef SIMULATE_VERSION_PATCH 486 | '.', SIMULATE_VERSION_PATCH, 487 | # ifdef SIMULATE_VERSION_TWEAK 488 | '.', SIMULATE_VERSION_TWEAK, 489 | # endif 490 | # endif 491 | # endif 492 | ']','\0'}; 493 | #endif 494 | 495 | /* Construct the string literal in pieces to prevent the source from 496 | getting matched. Store it in a pointer rather than an array 497 | because some compilers will just produce instructions to fill the 498 | array rather than assigning a pointer to a static array. */ 499 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 500 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 501 | 502 | 503 | 504 | 505 | const char* info_language_dialect_default = "INFO" ":" "dialect_default[" 506 | #if __cplusplus > 201402L 507 | "17" 508 | #elif __cplusplus >= 201402L 509 | "14" 510 | #elif __cplusplus >= 201103L 511 | "11" 512 | #else 513 | "98" 514 | #endif 515 | "]"; 516 | 517 | /*--------------------------------------------------------------------------*/ 518 | 519 | int main(int argc, char* argv[]) 520 | { 521 | int require = 0; 522 | require += info_compiler[argc]; 523 | require += info_platform[argc]; 524 | #ifdef COMPILER_VERSION_MAJOR 525 | require += info_version[argc]; 526 | #endif 527 | #ifdef SIMULATE_ID 528 | require += info_simulate[argc]; 529 | #endif 530 | #ifdef SIMULATE_VERSION_MAJOR 531 | require += info_simulate_version[argc]; 532 | #endif 533 | #if defined(__CRAYXE) || defined(__CRAYXC) 534 | require += info_cray[argc]; 535 | #endif 536 | require += info_language_dialect_default[argc]; 537 | (void)argv; 538 | return require; 539 | } 540 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdC/CMakeCCompilerId.c: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | # error "A C++ compiler has been selected for C." 3 | #endif 4 | 5 | #if defined(__18CXX) 6 | # define ID_VOID_MAIN 7 | #endif 8 | #if defined(__CLASSIC_C__) 9 | /* cv-qualifiers did not exist in K&R C */ 10 | # define const 11 | # define volatile 12 | #endif 13 | 14 | 15 | /* Version number components: V=Version, R=Revision, P=Patch 16 | Version date components: YYYY=Year, MM=Month, DD=Day */ 17 | 18 | #if defined(__INTEL_COMPILER) || defined(__ICC) 19 | # define COMPILER_ID "Intel" 20 | # if defined(_MSC_VER) 21 | # define SIMULATE_ID "MSVC" 22 | # endif 23 | /* __INTEL_COMPILER = VRP */ 24 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 25 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 26 | # if defined(__INTEL_COMPILER_UPDATE) 27 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) 28 | # else 29 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 30 | # endif 31 | # if defined(__INTEL_COMPILER_BUILD_DATE) 32 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 33 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 34 | # endif 35 | # if defined(_MSC_VER) 36 | /* _MSC_VER = VVRR */ 37 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 38 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 39 | # endif 40 | 41 | #elif defined(__PATHCC__) 42 | # define COMPILER_ID "PathScale" 43 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 44 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 45 | # if defined(__PATHCC_PATCHLEVEL__) 46 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 47 | # endif 48 | 49 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 50 | # define COMPILER_ID "Embarcadero" 51 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 52 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 53 | # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) 54 | 55 | #elif defined(__BORLANDC__) 56 | # define COMPILER_ID "Borland" 57 | /* __BORLANDC__ = 0xVRR */ 58 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 59 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 60 | 61 | #elif defined(__WATCOMC__) && __WATCOMC__ < 1200 62 | # define COMPILER_ID "Watcom" 63 | /* __WATCOMC__ = VVRR */ 64 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 65 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 66 | # if (__WATCOMC__ % 10) > 0 67 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 68 | # endif 69 | 70 | #elif defined(__WATCOMC__) 71 | # define COMPILER_ID "OpenWatcom" 72 | /* __WATCOMC__ = VVRP + 1100 */ 73 | # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) 74 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 75 | # if (__WATCOMC__ % 10) > 0 76 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 77 | # endif 78 | 79 | #elif defined(__SUNPRO_C) 80 | # define COMPILER_ID "SunPro" 81 | # if __SUNPRO_C >= 0x5100 82 | /* __SUNPRO_C = 0xVRRP */ 83 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12) 84 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF) 85 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) 86 | # else 87 | /* __SUNPRO_CC = 0xVRP */ 88 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8) 89 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF) 90 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF) 91 | # endif 92 | 93 | #elif defined(__HP_cc) 94 | # define COMPILER_ID "HP" 95 | /* __HP_cc = VVRRPP */ 96 | # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000) 97 | # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100) 98 | # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100) 99 | 100 | #elif defined(__DECC) 101 | # define COMPILER_ID "Compaq" 102 | /* __DECC_VER = VVRRTPPPP */ 103 | # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000) 104 | # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100) 105 | # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000) 106 | 107 | #elif defined(__IBMC__) && defined(__COMPILER_VER__) 108 | # define COMPILER_ID "zOS" 109 | /* __IBMC__ = VRP */ 110 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 111 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 112 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 113 | 114 | #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ >= 800 115 | # define COMPILER_ID "XL" 116 | /* __IBMC__ = VRP */ 117 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 118 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 119 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 120 | 121 | #elif defined(__IBMC__) && !defined(__COMPILER_VER__) && __IBMC__ < 800 122 | # define COMPILER_ID "VisualAge" 123 | /* __IBMC__ = VRP */ 124 | # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100) 125 | # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10) 126 | # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10) 127 | 128 | #elif defined(__PGI) 129 | # define COMPILER_ID "PGI" 130 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 131 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 132 | # if defined(__PGIC_PATCHLEVEL__) 133 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 134 | # endif 135 | 136 | #elif defined(_CRAYC) 137 | # define COMPILER_ID "Cray" 138 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) 139 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 140 | 141 | #elif defined(__TI_COMPILER_VERSION__) 142 | # define COMPILER_ID "TI" 143 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 144 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 145 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 146 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 147 | 148 | #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) 149 | # define COMPILER_ID "Fujitsu" 150 | 151 | #elif defined(__TINYC__) 152 | # define COMPILER_ID "TinyCC" 153 | 154 | #elif defined(__BCC__) 155 | # define COMPILER_ID "Bruce" 156 | 157 | #elif defined(__SCO_VERSION__) 158 | # define COMPILER_ID "SCO" 159 | 160 | #elif defined(__clang__) && defined(__apple_build_version__) 161 | # define COMPILER_ID "AppleClang" 162 | # if defined(_MSC_VER) 163 | # define SIMULATE_ID "MSVC" 164 | # endif 165 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 166 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 167 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 168 | # if defined(_MSC_VER) 169 | /* _MSC_VER = VVRR */ 170 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 171 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 172 | # endif 173 | # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) 174 | 175 | #elif defined(__clang__) 176 | # define COMPILER_ID "Clang" 177 | # if defined(_MSC_VER) 178 | # define SIMULATE_ID "MSVC" 179 | # endif 180 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 181 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 182 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 183 | # if defined(_MSC_VER) 184 | /* _MSC_VER = VVRR */ 185 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 186 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 187 | # endif 188 | 189 | #elif defined(__GNUC__) 190 | # define COMPILER_ID "GNU" 191 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 192 | # if defined(__GNUC_MINOR__) 193 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 194 | # endif 195 | # if defined(__GNUC_PATCHLEVEL__) 196 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 197 | # endif 198 | 199 | #elif defined(_MSC_VER) 200 | # define COMPILER_ID "MSVC" 201 | /* _MSC_VER = VVRR */ 202 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 203 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 204 | # if defined(_MSC_FULL_VER) 205 | # if _MSC_VER >= 1400 206 | /* _MSC_FULL_VER = VVRRPPPPP */ 207 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 208 | # else 209 | /* _MSC_FULL_VER = VVRRPPPP */ 210 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 211 | # endif 212 | # endif 213 | # if defined(_MSC_BUILD) 214 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 215 | # endif 216 | 217 | #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 218 | # define COMPILER_ID "ADSP" 219 | #if defined(__VISUALDSPVERSION__) 220 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 221 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 222 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 223 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 224 | #endif 225 | 226 | #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) 227 | # define COMPILER_ID "IAR" 228 | 229 | #elif defined(__ARMCC_VERSION) 230 | # define COMPILER_ID "ARMCC" 231 | #if __ARMCC_VERSION >= 1000000 232 | /* __ARMCC_VERSION = VRRPPPP */ 233 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) 234 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) 235 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 236 | #else 237 | /* __ARMCC_VERSION = VRPPPP */ 238 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) 239 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) 240 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 241 | #endif 242 | 243 | 244 | #elif defined(__SDCC_VERSION_MAJOR) || defined(SDCC) 245 | # define COMPILER_ID "SDCC" 246 | # if defined(__SDCC_VERSION_MAJOR) 247 | # define COMPILER_VERSION_MAJOR DEC(__SDCC_VERSION_MAJOR) 248 | # define COMPILER_VERSION_MINOR DEC(__SDCC_VERSION_MINOR) 249 | # define COMPILER_VERSION_PATCH DEC(__SDCC_VERSION_PATCH) 250 | # else 251 | /* SDCC = VRP */ 252 | # define COMPILER_VERSION_MAJOR DEC(SDCC/100) 253 | # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10) 254 | # define COMPILER_VERSION_PATCH DEC(SDCC % 10) 255 | # endif 256 | 257 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 258 | # define COMPILER_ID "MIPSpro" 259 | # if defined(_SGI_COMPILER_VERSION) 260 | /* _SGI_COMPILER_VERSION = VRP */ 261 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 262 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 263 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 264 | # else 265 | /* _COMPILER_VERSION = VRP */ 266 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 267 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 268 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 269 | # endif 270 | 271 | 272 | /* These compilers are either not known or too old to define an 273 | identification macro. Try to identify the platform and guess that 274 | it is the native compiler. */ 275 | #elif defined(__sgi) 276 | # define COMPILER_ID "MIPSpro" 277 | 278 | #elif defined(__hpux) || defined(__hpua) 279 | # define COMPILER_ID "HP" 280 | 281 | #else /* unknown compiler */ 282 | # define COMPILER_ID "" 283 | #endif 284 | 285 | /* Construct the string literal in pieces to prevent the source from 286 | getting matched. Store it in a pointer rather than an array 287 | because some compilers will just produce instructions to fill the 288 | array rather than assigning a pointer to a static array. */ 289 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 290 | #ifdef SIMULATE_ID 291 | char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; 292 | #endif 293 | 294 | #ifdef __QNXNTO__ 295 | char const* qnxnto = "INFO" ":" "qnxnto[]"; 296 | #endif 297 | 298 | #if defined(__CRAYXE) || defined(__CRAYXC) 299 | char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; 300 | #endif 301 | 302 | #define STRINGIFY_HELPER(X) #X 303 | #define STRINGIFY(X) STRINGIFY_HELPER(X) 304 | 305 | /* Identify known platforms by name. */ 306 | #if defined(__linux) || defined(__linux__) || defined(linux) 307 | # define PLATFORM_ID "Linux" 308 | 309 | #elif defined(__CYGWIN__) 310 | # define PLATFORM_ID "Cygwin" 311 | 312 | #elif defined(__MINGW32__) 313 | # define PLATFORM_ID "MinGW" 314 | 315 | #elif defined(__APPLE__) 316 | # define PLATFORM_ID "Darwin" 317 | 318 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 319 | # define PLATFORM_ID "Windows" 320 | 321 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 322 | # define PLATFORM_ID "FreeBSD" 323 | 324 | #elif defined(__NetBSD__) || defined(__NetBSD) 325 | # define PLATFORM_ID "NetBSD" 326 | 327 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 328 | # define PLATFORM_ID "OpenBSD" 329 | 330 | #elif defined(__sun) || defined(sun) 331 | # define PLATFORM_ID "SunOS" 332 | 333 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 334 | # define PLATFORM_ID "AIX" 335 | 336 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 337 | # define PLATFORM_ID "IRIX" 338 | 339 | #elif defined(__hpux) || defined(__hpux__) 340 | # define PLATFORM_ID "HP-UX" 341 | 342 | #elif defined(__HAIKU__) 343 | # define PLATFORM_ID "Haiku" 344 | 345 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 346 | # define PLATFORM_ID "BeOS" 347 | 348 | #elif defined(__QNX__) || defined(__QNXNTO__) 349 | # define PLATFORM_ID "QNX" 350 | 351 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 352 | # define PLATFORM_ID "Tru64" 353 | 354 | #elif defined(__riscos) || defined(__riscos__) 355 | # define PLATFORM_ID "RISCos" 356 | 357 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 358 | # define PLATFORM_ID "SINIX" 359 | 360 | #elif defined(__UNIX_SV__) 361 | # define PLATFORM_ID "UNIX_SV" 362 | 363 | #elif defined(__bsdos__) 364 | # define PLATFORM_ID "BSDOS" 365 | 366 | #elif defined(_MPRAS) || defined(MPRAS) 367 | # define PLATFORM_ID "MP-RAS" 368 | 369 | #elif defined(__osf) || defined(__osf__) 370 | # define PLATFORM_ID "OSF1" 371 | 372 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 373 | # define PLATFORM_ID "SCO_SV" 374 | 375 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 376 | # define PLATFORM_ID "ULTRIX" 377 | 378 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 379 | # define PLATFORM_ID "Xenix" 380 | 381 | #elif defined(__WATCOMC__) 382 | # if defined(__LINUX__) 383 | # define PLATFORM_ID "Linux" 384 | 385 | # elif defined(__DOS__) 386 | # define PLATFORM_ID "DOS" 387 | 388 | # elif defined(__OS2__) 389 | # define PLATFORM_ID "OS2" 390 | 391 | # elif defined(__WINDOWS__) 392 | # define PLATFORM_ID "Windows3x" 393 | 394 | # else /* unknown platform */ 395 | # define PLATFORM_ID 396 | # endif 397 | 398 | #else /* unknown platform */ 399 | # define PLATFORM_ID 400 | 401 | #endif 402 | 403 | /* For windows compilers MSVC and Intel we can determine 404 | the architecture of the compiler being used. This is because 405 | the compilers do not have flags that can change the architecture, 406 | but rather depend on which compiler is being used 407 | */ 408 | #if defined(_WIN32) && defined(_MSC_VER) 409 | # if defined(_M_IA64) 410 | # define ARCHITECTURE_ID "IA64" 411 | 412 | # elif defined(_M_X64) || defined(_M_AMD64) 413 | # define ARCHITECTURE_ID "x64" 414 | 415 | # elif defined(_M_IX86) 416 | # define ARCHITECTURE_ID "X86" 417 | 418 | # elif defined(_M_ARM) 419 | # if _M_ARM == 4 420 | # define ARCHITECTURE_ID "ARMV4I" 421 | # elif _M_ARM == 5 422 | # define ARCHITECTURE_ID "ARMV5I" 423 | # else 424 | # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) 425 | # endif 426 | 427 | # elif defined(_M_MIPS) 428 | # define ARCHITECTURE_ID "MIPS" 429 | 430 | # elif defined(_M_SH) 431 | # define ARCHITECTURE_ID "SHx" 432 | 433 | # else /* unknown architecture */ 434 | # define ARCHITECTURE_ID "" 435 | # endif 436 | 437 | #elif defined(__WATCOMC__) 438 | # if defined(_M_I86) 439 | # define ARCHITECTURE_ID "I86" 440 | 441 | # elif defined(_M_IX86) 442 | # define ARCHITECTURE_ID "X86" 443 | 444 | # else /* unknown architecture */ 445 | # define ARCHITECTURE_ID "" 446 | # endif 447 | 448 | #else 449 | # define ARCHITECTURE_ID 450 | #endif 451 | 452 | /* Convert integer to decimal digit literals. */ 453 | #define DEC(n) \ 454 | ('0' + (((n) / 10000000)%10)), \ 455 | ('0' + (((n) / 1000000)%10)), \ 456 | ('0' + (((n) / 100000)%10)), \ 457 | ('0' + (((n) / 10000)%10)), \ 458 | ('0' + (((n) / 1000)%10)), \ 459 | ('0' + (((n) / 100)%10)), \ 460 | ('0' + (((n) / 10)%10)), \ 461 | ('0' + ((n) % 10)) 462 | 463 | /* Convert integer to hex digit literals. */ 464 | #define HEX(n) \ 465 | ('0' + ((n)>>28 & 0xF)), \ 466 | ('0' + ((n)>>24 & 0xF)), \ 467 | ('0' + ((n)>>20 & 0xF)), \ 468 | ('0' + ((n)>>16 & 0xF)), \ 469 | ('0' + ((n)>>12 & 0xF)), \ 470 | ('0' + ((n)>>8 & 0xF)), \ 471 | ('0' + ((n)>>4 & 0xF)), \ 472 | ('0' + ((n) & 0xF)) 473 | 474 | /* Construct a string literal encoding the version number components. */ 475 | #ifdef COMPILER_VERSION_MAJOR 476 | char const info_version[] = { 477 | 'I', 'N', 'F', 'O', ':', 478 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 479 | COMPILER_VERSION_MAJOR, 480 | # ifdef COMPILER_VERSION_MINOR 481 | '.', COMPILER_VERSION_MINOR, 482 | # ifdef COMPILER_VERSION_PATCH 483 | '.', COMPILER_VERSION_PATCH, 484 | # ifdef COMPILER_VERSION_TWEAK 485 | '.', COMPILER_VERSION_TWEAK, 486 | # endif 487 | # endif 488 | # endif 489 | ']','\0'}; 490 | #endif 491 | 492 | /* Construct a string literal encoding the version number components. */ 493 | #ifdef SIMULATE_VERSION_MAJOR 494 | char const info_simulate_version[] = { 495 | 'I', 'N', 'F', 'O', ':', 496 | 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', 497 | SIMULATE_VERSION_MAJOR, 498 | # ifdef SIMULATE_VERSION_MINOR 499 | '.', SIMULATE_VERSION_MINOR, 500 | # ifdef SIMULATE_VERSION_PATCH 501 | '.', SIMULATE_VERSION_PATCH, 502 | # ifdef SIMULATE_VERSION_TWEAK 503 | '.', SIMULATE_VERSION_TWEAK, 504 | # endif 505 | # endif 506 | # endif 507 | ']','\0'}; 508 | #endif 509 | 510 | /* Construct the string literal in pieces to prevent the source from 511 | getting matched. Store it in a pointer rather than an array 512 | because some compilers will just produce instructions to fill the 513 | array rather than assigning a pointer to a static array. */ 514 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 515 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 516 | 517 | 518 | 519 | 520 | #if !defined(__STDC__) 521 | # if defined(_MSC_VER) && !defined(__clang__) 522 | # define C_DIALECT "90" 523 | # else 524 | # define C_DIALECT 525 | # endif 526 | #elif __STDC_VERSION__ >= 201000L 527 | # define C_DIALECT "11" 528 | #elif __STDC_VERSION__ >= 199901L 529 | # define C_DIALECT "99" 530 | #else 531 | # define C_DIALECT "90" 532 | #endif 533 | const char* info_language_dialect_default = 534 | "INFO" ":" "dialect_default[" C_DIALECT "]"; 535 | 536 | /*--------------------------------------------------------------------------*/ 537 | 538 | #ifdef ID_VOID_MAIN 539 | void main() {} 540 | #else 541 | # if defined(__CLASSIC_C__) 542 | int main(argc, argv) int argc; char *argv[]; 543 | # else 544 | int main(int argc, char* argv[]) 545 | # endif 546 | { 547 | int require = 0; 548 | require += info_compiler[argc]; 549 | require += info_platform[argc]; 550 | require += info_arch[argc]; 551 | #ifdef COMPILER_VERSION_MAJOR 552 | require += info_version[argc]; 553 | #endif 554 | #ifdef SIMULATE_ID 555 | require += info_simulate[argc]; 556 | #endif 557 | #ifdef SIMULATE_VERSION_MAJOR 558 | require += info_simulate_version[argc]; 559 | #endif 560 | #if defined(__CRAYXE) || defined(__CRAYXC) 561 | require += info_cray[argc]; 562 | #endif 563 | require += info_language_dialect_default[argc]; 564 | (void)argv; 565 | return require; 566 | } 567 | #endif 568 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Peter Shirley-Ray Tracing in One Weekend (2016) 2 | 3 | 原著:Peter Shirley 4 | 5 | 本书是Peter Shirley ray tracing系列三部曲的第一本,也是学习ray tracing 入门比较容易的一本书,自己照着书上的内容,抄了一遍,Github有完整的代码,和每一章学习过程的代码,部分代码加了注释。 6 | 7 | [英文原著地址](https://pan.baidu.com/s/1b5CvAdElCcXAO2R4lNFgkA) 密码: urji 8 | 9 | [Github地址](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend) 10 | 11 | 12 | 13 | ## 目录: 14 | - [x] [Chapter1:Output an image](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter1output-an-image) 15 | - [x] [Chapter2:The vec3 class](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter2the-vec3-class) 16 | - [x] [Chapter3:Rays, a simple camera, and background](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter3rays-a-simple-camera-and-background) 17 | - [x] [Chapter4:Adding a sphere](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter4adding-a-sphere) 18 | - [x] [Chapter5:Surface normals and multiple objects](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter5surface-normals-and-multiple-objects) 19 | - [x] [Chapter6:Antialiasing](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter6antialiasing) 20 | - [x] [Chapter7:Diffuse Materials](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter7diffuse-materials) 21 | - [x] [Chapter8:Metal](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter8metalADD) 22 | - [x] [Chapter9:Dielectrics](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter9dielectrics) 23 | - [x] [Chapter10:Positionable camera](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter10positionable-camera) 24 | - [x] [Chapter11:Defocus](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter11defocus-blur) 25 | - [x] [Chapter12:Where next?](https://github.com/EStormLynn/Peter-Shirley-Ray-Tracing-in-one-weenkend#chapter12where-next) 26 | 27 | 28 | ## Chapter1:Output an image 29 | 使用ppm渲染到图片 30 | 31 | ```c++ 32 | #include 33 | 34 | using namespace std; 35 | 36 | 37 | int main() 38 | { 39 | int nx =200; 40 | int ny=100; 41 | cout<<"P3\n"<=0;j--) 43 | { 44 | for(int i=0;i 66 | 67 | ## Chapter2:The vec3 class 68 | 用于几何向量计算和颜色计算,包含颜色,向量,位置坐标,偏移,主要包含重写操作符,以及点乘、叉乘等操作。 69 | ```c++ 70 | class vec3 { 71 | public: 72 | vec3() {} 73 | vec3(float e0, float e1, float e2) { e[0] = e0; e[1] = e1; e[2] = e2; } 74 | inline float x() const { return e[0]; } 75 | inline float y() const { return e[1]; } 76 | inline float z() const { return e[2]; } 77 | inline float r() const { return e[0]; } 78 | inline float g() const { return e[1]; } 79 | inline float b() const { return e[2]; } 80 | 81 | inline const vec3& operator+() const { return *this; } 82 | inline vec3 operator-() const { return vec3(-e[0], -e[1], -e[2]); } 83 | inline float operator[](int i) const { return e[i]; } 84 | inline float& operator[](int i) { return e[i]; }; 85 | 86 | inline vec3& operator+=(const vec3 &v2); 87 | inline vec3& operator-=(const vec3 &v2); 88 | inline vec3& operator*=(const vec3 &v2); 89 | inline vec3& operator/=(const vec3 &v2); 90 | inline vec3& operator*=(const float t); 91 | inline vec3& operator/=(const float t); 92 | 93 | inline float length() const { return sqrt(e[0]*e[0] + e[1]*e[1] + e[2]*e[2]); } 94 | inline float squared_length() const { return e[0]*e[0] + e[1]*e[1] + e[2]*e[2]; } 95 | inline void make_unit_vector(); 96 | 97 | float e[3]; 98 | }; 99 | 100 | ``` 101 | 102 | ## Chapter3:Rays, a simple camera, and background 103 | 所有的ray tracers 都是以ray类为基础,计算颜色 104 | p(t) = A + t*B 105 | 其中A是光源点,B是ray的方向,t是具体float值,空间中确定一条线,不同的t,可以到达不同地方。 106 | 107 |
108 | 109 | 110 | p(t)称为点A关于t的函数。Ray tracing的本质是通过发射射线,计算像素点的颜色。在ray tracing之前需要有个摄像机,建立坐标系,显示背景色,以及ray hit的点的颜色。 111 | 112 | 假设摄像机的位置就是眼睛位置,看到的内容为ppm显示的东西,简历坐标系,z轴正方向,垂直平面向外,x向右,y向上, 113 | 114 | 115 |
116 | 117 | 118 | 计算公式: 119 | 120 | blended_value = (1-t)*start_value + t*end_value 121 | 122 |
123 | 124 | 125 | ## Chapter4:Adding a sphere 126 | 127 | 球的公式: 128 | 129 | x*x + y*y +z*z = R*R 130 | 131 | 对于任意xyz,如果满足球面公式,(x,y,z)为球面的一个点。 132 | 133 | 如果球心位置为(cx,cy,cz),公式为 134 | 135 | (x-cx)*(x-cx) + (y-cy)*(y-cy) + (z-cz)*(z-cz) = R*R 136 | 137 | 用向量表示,球面点P,球心点C,半径可以表示为向量PC 138 | 139 | dot((p-C)(p-C)) = (x-cx)*(x-cx) + (y-cy)*(y-cy) + (z-cz)*(z-cz) 140 | 141 | 等价于 142 | 143 | dot((A + t*B - C),(A + t*B - C)) = R*R 144 | 145 | 展开之后 146 | 147 | t*t*dot(B,B) + 2*t*dot(A-C,A-C) + dot(C,C) - R*R = 0 148 | 149 | ABC已知,这里是一个关于t的一元二次方程,对于t无解,有一个解,有两个解的情况,即为下图 150 | 151 |
152 | 153 | 154 | 通过打印颜色,利用红色的射线,ray hit 圆,hit到的地方显示红色 155 | 156 | ```c++ 157 | bool hit_sphere(const vec3 & center, float radius,const ray& r) 158 | { 159 | vec3 oc = r.origin() -center; 160 | float a = dot(r.direction(), r.direction()); 161 | float b = 2.0 * dot(oc,r.direction()); 162 | float c = dot(oc,oc) -radius*radius; 163 | float discriminant = b*b - 4*a*c; 164 | return (discriminant>0); 165 | } 166 | 167 | vec3 color(const ray& r) 168 | { 169 | if(hit_sphere(vec3(0,0,-1),0.5,r)) 170 | return vec3(1.0,0,0); 171 | 172 | vec3 unit_direction = unit_vector(r.direction()); 173 | float t = 0.5 *(unit_direction.y() + 1.0); 174 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 175 | } 176 | ``` 177 | 178 | 179 |
180 | 181 | 182 | ## Chapter5:Surface normals and multiple objects 183 | 184 | 法线是垂直与物体表面的一个向量,对于上一节提到的球,他的法线方向是,从球心出发,射向hitpoint的。就像在地球上,地面的法向是从地心出发,射向你站立的点的。 185 | 186 |
187 | 188 | 189 | 假设N是长度在[-1,1]之间的单位向量,映射到去见[0,1]之间,再映射x/y/z到r/g/b,通常除了须要知道是否hit点,还要拿到hit point的数据。 190 | 191 | ```C++ 192 | // 本章 hit_Sphere的返回值改为float了 193 | float hit_sphere(const vec3 & center, float radius,const ray& r) 194 | { 195 | vec3 oc = r.origin() -center; 196 | float a = dot(r.direction(), r.direction()); 197 | float b = 2.0 * dot(oc,r.direction()); 198 | float c = dot(oc,oc) -radius*radius; 199 | float discriminant = b*b - 4*a*c; 200 | if(discriminant<0) 201 | return -1.0; 202 | else 203 | return (-b-sqrt(discriminant))/(2.0*a); 204 | } 205 | 206 | vec3 color(const ray& r) 207 | { 208 | float t = hit_sphere(vec3(0,0,-1),0.5,r); 209 | if(t>0.0) 210 | { 211 | // 球心到hitpoint的单位法向量 212 | vec3 N = unit_vector(r.point_at_parameter(t)-vec3(0,0,-1)); 213 | return 0.5*vec3(N.x() +1,N.y()+1,N.z()+1); 214 | } 215 | 216 | vec3 unit_direction = unit_vector(r.direction()); 217 | t = 0.5 *(unit_direction.y() + 1.0); 218 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 219 | } 220 | 221 | ``` 222 | 223 | 224 |
225 | 226 | 当场景中有多个可以被击中的物体的时候,需要一个Hitable的抽象类,包含抽象方法hit 是否击中,以及记录hit到的数据,包括hit的位置,hit点的法向,以及距离t 227 | 228 | 通过距离t 229 | tmin< t < tmax 230 | 来控制hit到物体的距离远近,因为hit到之后将不再往后ray tracing。 231 | 232 | ```C++ 233 | #include "ray.h" 234 | 235 | struct hit_record 236 | { 237 | float t; 238 | vec3 p; 239 | vec3 normal; 240 | }; 241 | 242 | class hitable 243 | { 244 | public: 245 | virtual bool hit(const ray& r,float t_min,float t_max,hit_record & rec)const =0; 246 | }; 247 | ``` 248 | 249 | 对于sphere类基础hitable抽象类,实现自己的hit方法,去判断是否击中了球的对象 250 | 251 | ```C++ 252 | 253 | #include "hitable.h" 254 | 255 | class sphere: public hitable { 256 | public: 257 | sphere() {} 258 | sphere(vec3 cen, float r) : center(cen), radius(r) {}; 259 | virtual bool hit(const ray& r, float tmin, float tmax, hit_record& rec) const; 260 | vec3 center; 261 | float radius; 262 | }; 263 | 264 | bool sphere::hit(const ray& r, float t_min, float t_max, hit_record& rec) const { 265 | vec3 oc = r.origin() - center; 266 | float a = dot(r.direction(), r.direction()); 267 | float b = dot(oc, r.direction()); 268 | float c = dot(oc, oc) - radius*radius; 269 | float discriminant = b*b - a*c; 270 | if (discriminant > 0) { 271 | float temp = (-b - sqrt(discriminant))/a; 272 | if (temp < t_max && temp > t_min) { 273 | rec.t = temp; 274 | rec.p = r.point_at_parameter(rec.t); 275 | rec.normal = (rec.p - center) / radius; 276 | return true; 277 | } 278 | temp = (-b + sqrt(discriminant)) / a; 279 | if (temp < t_max && temp > t_min) { 280 | rec.t = temp; 281 | rec.p = r.point_at_parameter(rec.t); 282 | rec.normal = (rec.p - center) / radius; 283 | return true; 284 | } 285 | } 286 | return false; 287 | } 288 | ``` 289 | 290 | 还需要一个hitable list去记录击中所有的物体,也是继承hitable类,实现hit方法,去找出最近的物体。 291 | 292 | ```C++ 293 | 294 | #include "hitable.h" 295 | 296 | class hitable_list: public hitable { 297 | public: 298 | hitable_list() {} 299 | hitable_list(hitable **l, int n) {list = l; list_size = n; } 300 | virtual bool hit(const ray& r, float tmin, float tmax, hit_record& rec) const; 301 | hitable **list; 302 | int list_size; 303 | }; 304 | 305 | bool hitable_list::hit(const ray& r, float t_min, float t_max, hit_record& rec) const { 306 | hit_record temp_rec; 307 | bool hit_anything = false; 308 | double closest_so_far = t_max; 309 | for (int i = 0; i < list_size; i++) { 310 | if (list[i]->hit(r, t_min, closest_so_far, temp_rec)) { 311 | hit_anything = true; 312 | closest_so_far = temp_rec.t; 313 | rec = temp_rec; 314 | } 315 | } 316 | return hit_anything; 317 | } 318 | ``` 319 | 320 | 本章新的main函数如下 321 | ```C++ 322 | #include 323 | #include "sphere.h" 324 | #include "hitable_list.h" 325 | #include "float.h" 326 | 327 | using namespace std; 328 | 329 | 330 | vec3 color(const ray& r,hitable *world) 331 | { 332 | hit_record rec; 333 | if(world->hit(r,0.0,MAXFLOAT,rec)) 334 | return 0.5*vec3(rec.normal.x()+1,rec.normal.y()+1,rec.normal.z()+1); 335 | else 336 | { 337 | vec3 unit_direction = unit_vector(r.direction()); 338 | float t = 0.5 *(unit_direction.y() + 1.0); 339 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 340 | } 341 | } 342 | 343 | int main() 344 | { 345 | int nx =200; 346 | int ny=100; 347 | cout<<"P3\n"<=0;j--) 361 | { 362 | for(int i=0;i 382 | 383 | ## Chapter6:Antialiasing 384 | 385 | 真实世界中,照相机拍照时,一边边缘部分没有锯齿,因为每个像素,前景和背景在边缘的地方进行的混合。我们可以通过平均多个像素的值,达到一样的效果。我们的做法是,抽象camera类,后面再写颜色的部分。 386 | 387 | 还需要写个随机数的生成器,用来控制采样点的位置,范围是在[0,1]之间。这里我定义了一个宏 388 | 389 | #define random(a,b) (rand()%(b-a+1)+a) 390 | 391 | 使用rand()程序运行时每次生成的随机数和上一次相同,便于调试。 392 | 393 | 对于给的一个像素,我们有好几个采样点在像素内,对每个采样点进行ray tracer,再平均每个采样点的color。 394 | 395 | 396 |
397 | 398 | 399 | camera类 400 | ```c++ 401 | class camera 402 | { 403 | vec3 origin; 404 | vec3 horizontal; 405 | vec3 vertical; 406 | vec3 lower_left_corner; 407 | 408 | public : 409 | camera() 410 | { 411 | lower_left_corner = vec3 (-2.0,-1.0,-1.0); 412 | horizontal = vec3(4.0,0.0,0.0); 413 | vertical = vec3(0.0,2.0,0.0); 414 | origin = vec3(0.0,0.0,0.0); 415 | } 416 | 417 | ray get_ray(float u,float v) 418 | { 419 | return ray(origin,lower_left_corner+u*horizontal + v*vertical - origin); 420 | } 421 | 422 | }; 423 | ``` 424 | 425 | main函数 426 | ```C++ 427 | #include 428 | #include "sphere.h" 429 | #include "hitable_list.h" 430 | #include "float.h" 431 | #include "camera.h" 432 | #include "random" 433 | #define random(a,b) (rand()%(b-a+1)+a) 434 | 435 | using namespace std; 436 | 437 | vec3 color(const ray& r,hitable *world) 438 | { 439 | hit_record rec; 440 | if(world->hit(r,0.0,MAXFLOAT,rec)) 441 | return 0.5*vec3(rec.normal.x()+1,rec.normal.y()+1,rec.normal.z()+1); 442 | else 443 | { 444 | vec3 unit_direction = unit_vector(r.direction()); 445 | float t = 0.5 *(unit_direction.y() + 1.0); 446 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 447 | } 448 | } 449 | 450 | int main() 451 | { 452 | int nx =200; 453 | int ny=100; 454 | // 采样数量ns 455 | int ns = 100; 456 | cout<<"P3\n"<=0;j--) 470 | { 471 | for(int i=0;i 500 | 501 | 502 | ## Chapter7:Diffuse Materials 503 | 之前已经实现了多个object 和每个像素多个采样,本章将实现漫反射材质。首先需要明确的一点是,物体和材质的关系,我们假设球体有一个自己的材质,通常在渲染中,每个物体都有自己的材质。 504 | 505 | 不发光的物体,漫反射是吸收周围的颜色,显示出来,物体表面反射周围的光线的方向是随机的,如下图,在2个不同的物体的漫反射表面间,发射了3条光线,三条光线的漫反射之后的路径各不相同: 506 | 507 |
508 | 509 | 漫反射物体的表面,也可能会吸收部分光线,表面越暗,吸收的光线越多,吸收之后看起来就像一个哑光的表面。 510 | 511 | 选择一个随机的点切一个单位半径的球,这个点就是hitpoint,在球上选个随机点s,从p到s做一条线,作为漫反射的方向,这个球的球心是(p + N),N是hitpoitn的法向。 512 | 513 |
514 | 515 | 关于球面上s点如何区,这里的做法是,在单位cube中,选一个点,x、y、z都在[-1,1]之间,如果这个点不在球内,继续选点,直到满足在球内的这个条件。 516 | 517 | ```C++ 518 | // 单位cube随机取点,返回一个在球内的点 519 | vec3 random_in_unit_sphere() 520 | { 521 | vec3 p; 522 | do{ 523 | p = 2.0*vec3(random1,random1,random1) - vec3(1,1,1); 524 | }while (dot(p,p) >= 1.0); 525 | return p; 526 | } 527 | 528 | vec3 color(const ray& r,hitable *world) 529 | { 530 | hit_record rec; 531 | if(world->hit(r,0.0,MAXFLOAT,rec)) 532 | { 533 | vec3 target = rec.p + rec.normal + random_in_unit_sphere(); 534 | return 0.5* color(ray(rec.p, target - rec.p), world); 535 | } 536 | else 537 | { 538 | vec3 unit_direction = unit_vector(r.direction()); 539 | float t = 0.5 *(unit_direction.y() + 1.0); 540 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 541 | } 542 | } 543 | ``` 544 | 545 | 得到的图像如下: 546 |
547 | 548 | 球和地板的交界处的颜色可能不明显,是因为吸收的光太多了,可以通多将颜色开放的方法,来提高物体表面的亮度,减少吸收的光 549 | 550 | col = vec3(sqrt(col[0]),sqrt(col[1]),sqrt(col[2])); 551 | 552 | 这样就可以看清楚交界处的阴影效果了,如下图: 553 | 554 |
555 | 556 | ## Chapter8:Metal 557 | 对于不同的物体,可能有不同的材质,所以就需要设计一个材质抽象类,包含一些参数。对于程序而言,材质需要做的事情包括 558 | 559 | * 1.产生一个散射体(或者表示吸收了多少光线) 560 | * 2.如果发生散射,表达出光线应该衰减多少 561 | 562 | 抽象类如下: 563 | ```C++ 564 | class material { 565 | public: 566 | // 散射虚函数 567 | // 参数:r_in 入射的光线, rec hit的记录, attenuation v3的衰减,scattered 散射后的光线 568 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const = 0; 569 | }; 570 | ``` 571 | 572 | hitables 和material须要知道对方的数据,所以在c++代码中,hit_record中加了一个指针 * mat_ptr 指向material这个类。 573 | 574 | ```C++ 575 | struct hit_record 576 | { 577 | float t; 578 | vec3 p; 579 | vec3 normal; 580 | material *mat_ptr; 581 | }; 582 | ``` 583 | 584 | lambertian 材质,主要是漫反射,通过attenuation衰减,来控制散射之后的光线强度,散射的方向用random_in_unit_sphere()控制,albedo表示反射率 585 | 586 | ```C++ 587 | class lambertian : public material { 588 | public: 589 | lambertian(const vec3& a) : albedo(a) {} 590 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const { 591 | vec3 target = rec.p + rec.normal + random_in_unit_sphere(); 592 | scattered = ray(rec.p, target-rec.p); 593 | attenuation = albedo; 594 | return true; 595 | } 596 | 597 | vec3 albedo; // 反射率 598 | }; 599 | ``` 600 | 601 | 对于光滑表面的物体,ray不会随机的散射,物理规律是反射角等于入射角,会发生镜面反射,向量的说明如下: 602 | 603 |
604 | 605 | 红色的是反射光线,向量表示是(v+2B),N是单位法向量,v是入射光线的方向向量,B的模是v和N的点乘 dot(v,N)。公式为: 606 | 607 | vec3 reflect(const vec3& v, const vec3& n) { 608 | return v - 2*dot(v,n)*n; 609 | } 610 | 611 | metal材质只反射光线,代码如下: 612 | ```C++ 613 | class metal : public material { 614 | public: 615 | metal(const vec3& a, float f) : albedo(a) { if (f < 1) fuzz = f; else fuzz = 1; } 616 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const { 617 | vec3 reflected = reflect(unit_vector(r_in.direction()), rec.normal); 618 | scattered = ray(rec.p, reflected + fuzz*random_in_unit_sphere()); 619 | attenuation = albedo; 620 | return (dot(scattered.direction(), rec.normal) > 0); 621 | } 622 | vec3 albedo; 623 | float fuzz; 624 | }; 625 | ``` 626 | 627 | 修改color方法,对散射进行递归,求color 628 | ```C++ 629 | 630 | vec3 color(const ray& r,hitable *world, int depth) 631 | { 632 | hit_record rec; 633 | if(world->hit(r,0.0,MAXFLOAT,rec)) 634 | { 635 | // 散射后的光线 636 | ray scattered; 637 | // 衰减 638 | vec3 attenuation; 639 | 640 | if(depth<50 && rec.mat_ptr->scatter(r,rec,attenuation,scattered)) 641 | { 642 | // 递归 衰减 643 | return attenuation * color(scattered, world, depth+1); 644 | } else 645 | { 646 | return vec3(0,0,0); 647 | } 648 | } 649 | else 650 | { 651 | vec3 unit_direction = unit_vector(r.direction()); 652 | float t = 0.5 *(unit_direction.y() + 1.0); 653 | return (1.0-t)*vec3(1.0,1.0,1.0) + t*vec3(0.5,0.7,1.0); 654 | } 655 | } 656 | ``` 657 | 658 | 再在场景中添加2个metal材质的球,main函数如下 659 | 注意因为加了hitrecord添加了material ,sphere的hit函数须要将hit_record的引用传出来,须要在函数内形参的指针指向material的matptr。 660 | ```C++ 661 | int main() 662 | { 663 | int nx =200; 664 | int ny =100; 665 | // 采样数量ns 666 | int ns = 100; 667 | cout<<"P3\n"<=0;j--) 682 | { 683 | for(int i=0;i 711 | 712 | 关于metal的反射,也可以用一个随机性的反射方向,来做微量的偏移,相当于一个小球上选endpoint。fuzzinss就相当于这个小球的半径,可以决定反射偏移的多少。fuzz取值在[0,1]之间 713 | 714 |
715 | 716 | 最后效果如下,注意两边的metal sphere中反射的边界模糊。 717 | 718 |
719 | 720 | ## Chapter9:Dielectrics 721 | 722 | 透明的物体,比如水,玻璃,钻石是电介质,当光射入的时候,不仅发生反射,还会发生折射。折射光线是ray tracer中比较难debug的部分。本章节在场景中放入了2个玻璃球,渲染出来的画面是这样的: 723 | 724 |
725 | 726 | 光从一种介质进入另一种介质时,实际上,有一部分光会折射进入另一种介质,有另一部分光则会反射回来。反射系数=反射光振幅(能量)/入射光振幅(能量)。 727 | 728 | 反射系数的求解是是一个非常复杂的过程,Christophe Schlick这个人提供一个逼近公式,这个公式被称为“ChristopheSchlick’s Approximation”。Wiki链接: 729 | 730 | https://en.wikipedia.org/wiki/Schlick%27s_approximation 731 | 732 | 当反射系数为0,只有折射,没有反射。 733 | 734 | 折射满足 斯涅尔定律(Snell law) 735 | 736 | n * sin(theta) = n' * sin(theat') 737 | 738 | 折射系数(air= 1,glass = 1.3-1.7, diamond = 2.4) 739 | 740 |
741 | 742 | 折射部分的代码如下: 743 | 744 | ```C++ 745 | bool refract(const vec3& v, const vec3& n, float ni_over_nt, vec3& refracted) { 746 | vec3 uv = unit_vector(v); 747 | float dt = dot(uv, n); 748 | float discriminant = 1.0 - ni_over_nt*ni_over_nt*(1-dt*dt); 749 | if (discriminant > 0) { 750 | refracted = ni_over_nt*(uv - n*dt) - n*sqrt(discriminant); 751 | return true; 752 | } 753 | else 754 | return false; 755 | } 756 | ``` 757 | 758 | 电解质材质总是会发生折射,所以材质类中派生dielectric类。 759 | 760 | ```C++ 761 | 762 | class dielectric : public material { 763 | public: 764 | dielectric(float ri) : ref_idx(ri) {} 765 | virtual bool scatter(const ray& r_in, const hit_record& rec, vec3& attenuation, ray& scattered) const { 766 | vec3 outward_normal; 767 | vec3 reflected = reflect(r_in.direction(), rec.normal); 768 | float ni_over_nt; 769 | attenuation = vec3(1.0, 1.0, 1.0); 770 | vec3 refracted; 771 | float reflect_prob; 772 | float cosine; 773 | if (dot(r_in.direction(), rec.normal) > 0) { 774 | outward_normal = -rec.normal; 775 | ni_over_nt = ref_idx; 776 | // cosine = ref_idx * dot(r_in.direction(), rec.normal) / r_in.direction().length(); 777 | cosine = dot(r_in.direction(), rec.normal) / r_in.direction().length(); 778 | cosine = sqrt(1 - ref_idx*ref_idx*(1-cosine*cosine)); 779 | } 780 | else { 781 | outward_normal = rec.normal; 782 | ni_over_nt = 1.0 / ref_idx; 783 | cosine = -dot(r_in.direction(), rec.normal) / r_in.direction().length(); 784 | } 785 | if (refract(r_in.direction(), outward_normal, ni_over_nt, refracted)) 786 | reflect_prob = schlick(cosine, ref_idx); 787 | else 788 | reflect_prob = 1.0; 789 | 790 | // 随机数小与反射系数,设为反射光线,反之为折射光线 791 | if (drand48() < reflect_prob) 792 | scattered = ray(rec.p, reflected); 793 | else 794 | scattered = ray(rec.p, refracted); 795 | return true; 796 | } 797 | 798 | float ref_idx; 799 | }; 800 | ``` 801 | 衰减始终是1,玻璃表面不吸收任何光线。 802 | 803 | 当场景中添加4个球,渲染出来的画面是这样的 804 | ```c++ 805 | list[0] = new sphere(vec3(0,0,-1),0.5,new lambertian(vec3(0.8,0.3,0.3))); 806 | list[1] = new sphere(vec3(0,-100.5,-1),100,new lambertian(vec3(0.8,0.8,0.0))); 807 | list[2] = new sphere(vec3(1,0,-1),0.5,new metal(vec3(0.8,0.6,0.2),0.3)); 808 | list[3] = new sphere(vec3(-1,0,-1),0.5,new dielectric(1.5)); 809 | ``` 810 | 811 |
812 | 813 | 如果对于电介质的球内部再加一个半径为 负的球,得到的效果如下(感觉是不同介质之间负负得正了): 814 | 815 | ```c++ 816 | list[0] = new sphere(vec3(0,0,-1),0.5,new lambertian(vec3(0.8,0.3,0.3))); 817 | list[1] = new sphere(vec3(0,-100.5,-1),100,new lambertian(vec3(0.8,0.8,0.0))); 818 | list[2] = new sphere(vec3(1,0,-1),0.5,new metal(vec3(0.8,0.6,0.2),0.3)); 819 | list[3] = new sphere(vec3(-1,0,-1),0.5,new dielectric(1.5)); 820 | list[4] = new sphere(vec3(-1,0,-1),-0.45,new dielectric(1.5)); 821 | ``` 822 | 823 |
824 | 825 | ## Chapter10:Positionable camera 826 | 827 | 自由位置的camera,首先有了解FOV(Field of view)视场的概念,相当于视力看到的一定角度的内容。 828 | 829 | 从射线源点的位置,射向z=-1的平面,可以看到的高度h,满足: 830 | 831 | h = tan(theta/2) 832 | 833 |
834 | 835 | 修改camera部分的代码,增加fov 和aspect来控制可以看到的宽和高。 836 | 837 | 设置好camera的viewpoint之后,viewpoint就是lookfrom的点,看向的点就是lookat,还需要确定看过去水平方向的视野宽度,和竖直方向的视野宽度,camera所在平面竖直向上的向量"view up” vup,通过叉乘,拿到uvw,刚好相当于一个相机的坐标系。 838 | 839 | ```C++ 840 | class camera 841 | { 842 | vec3 origin; 843 | vec3 horizontal; 844 | vec3 vertical; 845 | vec3 lower_left_corner; 846 | 847 | public : 848 | camera(vec3 lookfrom, vec3 lookat, vec3 vup, float vfov, float aspect) 849 | { 850 | vec3 u,v,w; 851 | float theta = vfov*M_PI/180; 852 | float half_height = tan(theta/2); 853 | float half_width = aspect * half_height; 854 | origin = lookfrom; 855 | 856 | w = unit_vector(lookfrom - lookat); 857 | u = unit_vector(cross(vup, w)); 858 | v = cross(w,u); 859 | 860 | lower_left_corner = vec3 (-half_width,-half_height,-1.0); 861 | lower_left_corner = origin - half_width*u - half_height*v - w; 862 | horizontal = 2*half_width*u; 863 | vertical = 2*half_height*v; 864 | } 865 | 866 | ray get_ray(float u,float v) 867 | { 868 | return ray(origin,lower_left_corner+u*horizontal + v*vertical - origin); 869 | } 870 | 871 | }; 872 | 873 | ``` 874 | 875 | 876 | 877 |
878 | 879 | 设置新的摄像机,fov分别设置90和30°,得到的画面如下: 880 | 881 | 882 |
883 | 884 |
885 | 886 | 887 | 888 | ## Chapter11:Defocus Blur 889 | 890 | 散焦模糊(虚化),拍照的时候,我们经常会制造出虚化的效果,主题清晰,背景或者前景模糊,这是因为摄像机具有焦距,会有一个成像面,在有效焦距内的物体才能清晰成像,通过光圈控制进光量也可以控制虚化的范围。大光圈和长焦端,都可以制造出浅景深的效果。 891 | 892 |
893 | 894 |
895 | 896 | 本章引入aperture(光圈),focus_dist(焦距) 2个参数,来实现画面的虚化效果。 897 | ```C++ 898 | 899 | class camera 900 | { 901 | vec3 origin; 902 | vec3 u,v,w; 903 | vec3 horizontal; 904 | vec3 vertical; 905 | vec3 lower_left_corner; 906 | float len_radius; 907 | 908 | public : 909 | camera(vec3 lookfrom, vec3 lookat, vec3 vup, float vfov, float aspect, float aperture, float focus_dist) 910 | { 911 | len_radius = aperture/2; 912 | float theta = vfov*M_PI/180; 913 | float half_height = tan(theta/2); 914 | float half_width = aspect * half_height; 915 | origin = lookfrom; 916 | 917 | w = unit_vector(lookfrom - lookat); 918 | u = unit_vector(cross(vup, w)); 919 | v = cross(w,u); 920 | 921 | lower_left_corner = origin - half_width*focus_dist*u - half_height*focus_dist*v - focus_dist*w; 922 | horizontal = 2*half_width*focus_dist*u; 923 | vertical = 2*half_height*focus_dist*v; 924 | } 925 | 926 | ray get_ray(float s,float t) 927 | { 928 | vec3 rd = len_radius * random_in_unit_disk(); 929 | vec3 offset = u * rd.x() +v*rd.y(); 930 | return ray(origin + offset,lower_left_corner+s*horizontal + t*vertical - origin - offset); 931 | } 932 | 933 | vec3 random_in_unit_disk() 934 | { 935 | vec3 p; 936 | do{ 937 | p = 2.0*vec3(drand48(),drand48(),0)-vec3(1,1,0); 938 | }while (dot(p,p)>=1.0); 939 | return p; 940 | } 941 | 942 | }; 943 | ``` 944 | 945 | 946 | 改变camera的参数,设置光圈和焦距 947 | ```C++ 948 | vec3 lookfrom(3,3,2); 949 | vec3 lookat(0,0,-1); 950 | float dist_to_focus = (lookfrom-lookat).length(); 951 | float aperture = 2.0; 952 | camera cam(lookfrom,lookat,vec3(0,1,0),20,float(nx)/float(ny),aperture,dist_to_focus); 953 | ``` 954 | 955 | 拿到的效果如下: 956 | 957 |
958 | 959 | ## Chapter12:Where next? 960 | 961 | 这张主要运用本书学到的知识,完成封面上的图片的渲染。 962 | 963 | 通过添加一个随机生成的世界,达到很多个小球的效果 964 | ```C++ 965 | 966 | hitable *random_scene() { 967 | int n = 500; 968 | hitable **list = new hitable*[n+1]; 969 | list[0] = new sphere(vec3(0,-700,0), 700, new lambertian(vec3(0.5, 0.5, 0.5))); 970 | int i = 1; 971 | for (int a = -11; a < 11; a++) { 972 | for (int b = -11; b < 11; b++) { 973 | float choose_mat = drand48(); 974 | vec3 center(a+0.9*drand48(),0.2,b+0.9*drand48()); 975 | if ((center-vec3(4,0.2,0)).length() > 0.9) { 976 | if (choose_mat < 0.8) { // diffuse 977 | list[i++] = new sphere(center, 0.2, new lambertian(vec3(drand48()*drand48(), drand48()*drand48(), drand48()*drand48()))); 978 | } 979 | else if (choose_mat < 0.95) { // metal 980 | list[i++] = new sphere(center, 0.2, 981 | new metal(vec3(0.5*(1 + drand48()), 0.5*(1 + drand48()), 0.5*(1 + drand48())), 0.5*drand48())); 982 | } 983 | else { // glass 984 | list[i++] = new sphere(center, 0.2, new dielectric(1.5)); 985 | } 986 | } 987 | } 988 | } 989 | 990 | list[i++] = new sphere(vec3(0, 1, 0), 1.0, new dielectric(2.5)); 991 | list[i++] = new sphere(vec3(-4, 1, 0), 1.0, new lambertian(vec3(0.4, 0.2, 0.1))); 992 | list[i++] = new sphere(vec3(4, 1, 0), 1.0, new metal(vec3(1, 1, 1), 0.0)); 993 | 994 | return new hitable_list(list,i); 995 | } 996 | ``` 997 | 998 |
999 | 1000 | 下一本书Peter Shirley-Ray Tracing The Next Week (2016) 将会从以下几个方面继续学习光追。 1001 | 1002 | * Motion Blur 1003 | 1004 | 运动模糊。跟上面的DOF一样,暴力多渲几帧,每帧用不同的位置就行。 1005 | * Bounding Volume Hierarchies 1006 | 1007 | 包围盒树。加速相交检测计算的。这方面另外有一大把更好的资料。 1008 | * 贴图 1009 | 1010 | 形状里定义好UV,然后用UV来采样贴图。当然采样方法有多种。 1011 | * Perlin Noise 1012 | 1013 | 柏林噪声。这里重点对采样结果做了Filtering,已经简单介绍了Turb(N重噪声产生的大理石纹理) 1014 | * 光源 1015 | 1016 | 把光源当成Emissive材质就搞定了。 1017 | * 物件的摆放 1018 | 1019 | 之前都是写绝对坐标的,这里在形状的体系里面加了一层Transform,只要通过那个Transform把Ray变换到物体的局部空间就可以像之前一样进行相交检测了。 1020 | * 体(Volume / Participating Media) 1021 | 1022 | 依然暴力的把Ray一点点插进Volume里面进行采样,每个采样点上取得Volume自身的颜色,并把Ray四散开去即可。 1023 | -------------------------------------------------------------------------------- /Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeOutput.log: -------------------------------------------------------------------------------- 1 | The system is: Darwin - 17.4.0 - x86_64 2 | Compiling the C compiler identification source file "CMakeCCompilerId.c" succeeded. 3 | Compiler: /Library/Developer/CommandLineTools/usr/bin/cc 4 | Build flags: 5 | Id flags: 6 | 7 | The output was: 8 | 0 9 | 10 | 11 | Compilation of the C compiler identification source "CMakeCCompilerId.c" produced "a.out" 12 | 13 | The C compiler identification is AppleClang, found in "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdC/a.out" 14 | 15 | Compiling the CXX compiler identification source file "CMakeCXXCompilerId.cpp" succeeded. 16 | Compiler: /Library/Developer/CommandLineTools/usr/bin/c++ 17 | Build flags: 18 | Id flags: 19 | 20 | The output was: 21 | 0 22 | 23 | 24 | Compilation of the CXX compiler identification source "CMakeCXXCompilerId.cpp" produced "a.out" 25 | 26 | The CXX compiler identification is AppleClang, found in "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/3.8.2/CompilerIdCXX/a.out" 27 | 28 | Determining if the C compiler works passed with the following output: 29 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 30 | 31 | Run Build Command:"/usr/bin/make" "cmTC_deac5/fast" 32 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_deac5.dir/build.make CMakeFiles/cmTC_deac5.dir/build 33 | Building C object CMakeFiles/cmTC_deac5.dir/testCCompiler.c.o 34 | /Library/Developer/CommandLineTools/usr/bin/cc -o CMakeFiles/cmTC_deac5.dir/testCCompiler.c.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp/testCCompiler.c" 35 | Linking C executable cmTC_deac5 36 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_deac5.dir/link.txt --verbose=1 37 | /Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_deac5.dir/testCCompiler.c.o -o cmTC_deac5 38 | 39 | 40 | Detecting C compiler ABI info compiled with the following output: 41 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 42 | 43 | Run Build Command:"/usr/bin/make" "cmTC_9fb68/fast" 44 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_9fb68.dir/build.make CMakeFiles/cmTC_9fb68.dir/build 45 | Building C object CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o 46 | /Library/Developer/CommandLineTools/usr/bin/cc -o CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o -c /Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCCompilerABI.c 47 | Linking C executable cmTC_9fb68 48 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9fb68.dir/link.txt --verbose=1 49 | /Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o -o cmTC_9fb68 50 | Apple LLVM version 9.1.0 (clang-902.0.39.1) 51 | Target: x86_64-apple-darwin17.4.0 52 | Thread model: posix 53 | InstalledDir: /Library/Developer/CommandLineTools/usr/bin 54 | "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o cmTC_9fb68 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a 55 | @(#)PROGRAM:ld PROJECT:ld64-351.8 56 | configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) 57 | Library search paths: 58 | /usr/lib 59 | /usr/local/lib 60 | Framework search paths: 61 | /Library/Frameworks/ 62 | /System/Library/Frameworks/ 63 | 64 | 65 | Parsed C implicit link information from above output: 66 | link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)] 67 | ignore line: [Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp] 68 | ignore line: [] 69 | ignore line: [Run Build Command:"/usr/bin/make" "cmTC_9fb68/fast"] 70 | ignore line: [/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_9fb68.dir/build.make CMakeFiles/cmTC_9fb68.dir/build] 71 | ignore line: [Building C object CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o] 72 | ignore line: [/Library/Developer/CommandLineTools/usr/bin/cc -o CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o -c /Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCCompilerABI.c] 73 | ignore line: [Linking C executable cmTC_9fb68] 74 | ignore line: [/Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9fb68.dir/link.txt --verbose=1] 75 | ignore line: [/Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o -o cmTC_9fb68 ] 76 | ignore line: [Apple LLVM version 9.1.0 (clang-902.0.39.1)] 77 | ignore line: [Target: x86_64-apple-darwin17.4.0] 78 | ignore line: [Thread model: posix] 79 | ignore line: [InstalledDir: /Library/Developer/CommandLineTools/usr/bin] 80 | link line: [ "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o cmTC_9fb68 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] 81 | arg [/Library/Developer/CommandLineTools/usr/bin/ld] ==> ignore 82 | arg [-demangle] ==> ignore 83 | arg [-lto_library] ==> ignore, skip following value 84 | arg [/Library/Developer/CommandLineTools/usr/lib/libLTO.dylib] ==> skip value of -lto_library 85 | arg [-dynamic] ==> ignore 86 | arg [-arch] ==> ignore 87 | arg [x86_64] ==> ignore 88 | arg [-macosx_version_min] ==> ignore 89 | arg [10.13.0] ==> ignore 90 | arg [-o] ==> ignore 91 | arg [cmTC_9fb68] ==> ignore 92 | arg [-search_paths_first] ==> ignore 93 | arg [-headerpad_max_install_names] ==> ignore 94 | arg [-v] ==> ignore 95 | arg [CMakeFiles/cmTC_9fb68.dir/CMakeCCompilerABI.c.o] ==> ignore 96 | arg [-lSystem] ==> lib [System] 97 | arg [/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] ==> lib [/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] 98 | Library search paths: [;/usr/lib;/usr/local/lib] 99 | Framework search paths: [;/Library/Frameworks/;/System/Library/Frameworks/] 100 | remove lib [System] 101 | remove lib [/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] 102 | collapse library dir [/usr/lib] ==> [/usr/lib] 103 | collapse library dir [/usr/local/lib] ==> [/usr/local/lib] 104 | collapse framework dir [/Library/Frameworks/] ==> [/Library/Frameworks] 105 | collapse framework dir [/System/Library/Frameworks/] ==> [/System/Library/Frameworks] 106 | implicit libs: [] 107 | implicit dirs: [/usr/lib;/usr/local/lib] 108 | implicit fwks: [/Library/Frameworks;/System/Library/Frameworks] 109 | 110 | 111 | 112 | 113 | Detecting C [-std=c11] compiler features compiled with the following output: 114 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 115 | 116 | Run Build Command:"/usr/bin/make" "cmTC_63e10/fast" 117 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_63e10.dir/build.make CMakeFiles/cmTC_63e10.dir/build 118 | Building C object CMakeFiles/cmTC_63e10.dir/feature_tests.c.o 119 | /Library/Developer/CommandLineTools/usr/bin/cc -std=c11 -o CMakeFiles/cmTC_63e10.dir/feature_tests.c.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.c" 120 | Linking C executable cmTC_63e10 121 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_63e10.dir/link.txt --verbose=1 122 | /Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_63e10.dir/feature_tests.c.o -o cmTC_63e10 123 | 124 | 125 | Feature record: C_FEATURE:1c_function_prototypes 126 | Feature record: C_FEATURE:1c_restrict 127 | Feature record: C_FEATURE:1c_static_assert 128 | Feature record: C_FEATURE:1c_variadic_macros 129 | 130 | 131 | Detecting C [-std=c99] compiler features compiled with the following output: 132 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 133 | 134 | Run Build Command:"/usr/bin/make" "cmTC_74181/fast" 135 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_74181.dir/build.make CMakeFiles/cmTC_74181.dir/build 136 | Building C object CMakeFiles/cmTC_74181.dir/feature_tests.c.o 137 | /Library/Developer/CommandLineTools/usr/bin/cc -std=c99 -o CMakeFiles/cmTC_74181.dir/feature_tests.c.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.c" 138 | Linking C executable cmTC_74181 139 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_74181.dir/link.txt --verbose=1 140 | /Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_74181.dir/feature_tests.c.o -o cmTC_74181 141 | 142 | 143 | Feature record: C_FEATURE:1c_function_prototypes 144 | Feature record: C_FEATURE:1c_restrict 145 | Feature record: C_FEATURE:0c_static_assert 146 | Feature record: C_FEATURE:1c_variadic_macros 147 | 148 | 149 | Detecting C [-std=c90] compiler features compiled with the following output: 150 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 151 | 152 | Run Build Command:"/usr/bin/make" "cmTC_6a375/fast" 153 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_6a375.dir/build.make CMakeFiles/cmTC_6a375.dir/build 154 | Building C object CMakeFiles/cmTC_6a375.dir/feature_tests.c.o 155 | /Library/Developer/CommandLineTools/usr/bin/cc -std=c90 -o CMakeFiles/cmTC_6a375.dir/feature_tests.c.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.c" 156 | Linking C executable cmTC_6a375 157 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_6a375.dir/link.txt --verbose=1 158 | /Library/Developer/CommandLineTools/usr/bin/cc -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_6a375.dir/feature_tests.c.o -o cmTC_6a375 159 | 160 | 161 | Feature record: C_FEATURE:1c_function_prototypes 162 | Feature record: C_FEATURE:0c_restrict 163 | Feature record: C_FEATURE:0c_static_assert 164 | Feature record: C_FEATURE:0c_variadic_macros 165 | Determining if the CXX compiler works passed with the following output: 166 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 167 | 168 | Run Build Command:"/usr/bin/make" "cmTC_94ef9/fast" 169 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_94ef9.dir/build.make CMakeFiles/cmTC_94ef9.dir/build 170 | Building CXX object CMakeFiles/cmTC_94ef9.dir/testCXXCompiler.cxx.o 171 | /Library/Developer/CommandLineTools/usr/bin/c++ -o CMakeFiles/cmTC_94ef9.dir/testCXXCompiler.cxx.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx" 172 | Linking CXX executable cmTC_94ef9 173 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_94ef9.dir/link.txt --verbose=1 174 | /Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_94ef9.dir/testCXXCompiler.cxx.o -o cmTC_94ef9 175 | 176 | 177 | Detecting CXX compiler ABI info compiled with the following output: 178 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 179 | 180 | Run Build Command:"/usr/bin/make" "cmTC_a4a87/fast" 181 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_a4a87.dir/build.make CMakeFiles/cmTC_a4a87.dir/build 182 | Building CXX object CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o 183 | /Library/Developer/CommandLineTools/usr/bin/c++ -o CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o -c /Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCXXCompilerABI.cpp 184 | Linking CXX executable cmTC_a4a87 185 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a4a87.dir/link.txt --verbose=1 186 | /Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a4a87 187 | Apple LLVM version 9.1.0 (clang-902.0.39.1) 188 | Target: x86_64-apple-darwin17.4.0 189 | Thread model: posix 190 | InstalledDir: /Library/Developer/CommandLineTools/usr/bin 191 | "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o cmTC_a4a87 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a 192 | @(#)PROGRAM:ld PROJECT:ld64-351.8 193 | configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em (tvOS) 194 | Library search paths: 195 | /usr/lib 196 | /usr/local/lib 197 | Framework search paths: 198 | /Library/Frameworks/ 199 | /System/Library/Frameworks/ 200 | 201 | 202 | Parsed CXX implicit link information from above output: 203 | link line regex: [^( *|.*[/\])(ld|([^/\]+-)?ld|collect2)[^/\]*( |$)] 204 | ignore line: [Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp] 205 | ignore line: [] 206 | ignore line: [Run Build Command:"/usr/bin/make" "cmTC_a4a87/fast"] 207 | ignore line: [/Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_a4a87.dir/build.make CMakeFiles/cmTC_a4a87.dir/build] 208 | ignore line: [Building CXX object CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o] 209 | ignore line: [/Library/Developer/CommandLineTools/usr/bin/c++ -o CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o -c /Applications/CLion.app/Contents/bin/cmake/share/cmake-3.8/Modules/CMakeCXXCompilerABI.cpp] 210 | ignore line: [Linking CXX executable cmTC_a4a87] 211 | ignore line: [/Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_a4a87.dir/link.txt --verbose=1] 212 | ignore line: [/Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names -v -Wl,-v CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o -o cmTC_a4a87 ] 213 | ignore line: [Apple LLVM version 9.1.0 (clang-902.0.39.1)] 214 | ignore line: [Target: x86_64-apple-darwin17.4.0] 215 | ignore line: [Thread model: posix] 216 | ignore line: [InstalledDir: /Library/Developer/CommandLineTools/usr/bin] 217 | link line: [ "/Library/Developer/CommandLineTools/usr/bin/ld" -demangle -lto_library /Library/Developer/CommandLineTools/usr/lib/libLTO.dylib -dynamic -arch x86_64 -macosx_version_min 10.13.0 -o cmTC_a4a87 -search_paths_first -headerpad_max_install_names -v CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o -lc++ -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] 218 | arg [/Library/Developer/CommandLineTools/usr/bin/ld] ==> ignore 219 | arg [-demangle] ==> ignore 220 | arg [-lto_library] ==> ignore, skip following value 221 | arg [/Library/Developer/CommandLineTools/usr/lib/libLTO.dylib] ==> skip value of -lto_library 222 | arg [-dynamic] ==> ignore 223 | arg [-arch] ==> ignore 224 | arg [x86_64] ==> ignore 225 | arg [-macosx_version_min] ==> ignore 226 | arg [10.13.0] ==> ignore 227 | arg [-o] ==> ignore 228 | arg [cmTC_a4a87] ==> ignore 229 | arg [-search_paths_first] ==> ignore 230 | arg [-headerpad_max_install_names] ==> ignore 231 | arg [-v] ==> ignore 232 | arg [CMakeFiles/cmTC_a4a87.dir/CMakeCXXCompilerABI.cpp.o] ==> ignore 233 | arg [-lc++] ==> lib [c++] 234 | arg [-lSystem] ==> lib [System] 235 | arg [/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] ==> lib [/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] 236 | Library search paths: [;/usr/lib;/usr/local/lib] 237 | Framework search paths: [;/Library/Frameworks/;/System/Library/Frameworks/] 238 | remove lib [System] 239 | remove lib [/Library/Developer/CommandLineTools/usr/lib/clang/9.1.0/lib/darwin/libclang_rt.osx.a] 240 | collapse library dir [/usr/lib] ==> [/usr/lib] 241 | collapse library dir [/usr/local/lib] ==> [/usr/local/lib] 242 | collapse framework dir [/Library/Frameworks/] ==> [/Library/Frameworks] 243 | collapse framework dir [/System/Library/Frameworks/] ==> [/System/Library/Frameworks] 244 | implicit libs: [c++] 245 | implicit dirs: [/usr/lib;/usr/local/lib] 246 | implicit fwks: [/Library/Frameworks;/System/Library/Frameworks] 247 | 248 | 249 | 250 | 251 | Detecting CXX [-std=c++1z] compiler features compiled with the following output: 252 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 253 | 254 | Run Build Command:"/usr/bin/make" "cmTC_095c7/fast" 255 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_095c7.dir/build.make CMakeFiles/cmTC_095c7.dir/build 256 | Building CXX object CMakeFiles/cmTC_095c7.dir/feature_tests.cxx.o 257 | /Library/Developer/CommandLineTools/usr/bin/c++ -std=c++1z -o CMakeFiles/cmTC_095c7.dir/feature_tests.cxx.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.cxx" 258 | Linking CXX executable cmTC_095c7 259 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_095c7.dir/link.txt --verbose=1 260 | /Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_095c7.dir/feature_tests.cxx.o -o cmTC_095c7 261 | 262 | 263 | Feature record: CXX_FEATURE:1cxx_aggregate_default_initializers 264 | Feature record: CXX_FEATURE:1cxx_alias_templates 265 | Feature record: CXX_FEATURE:1cxx_alignas 266 | Feature record: CXX_FEATURE:1cxx_alignof 267 | Feature record: CXX_FEATURE:1cxx_attributes 268 | Feature record: CXX_FEATURE:1cxx_attribute_deprecated 269 | Feature record: CXX_FEATURE:1cxx_auto_type 270 | Feature record: CXX_FEATURE:1cxx_binary_literals 271 | Feature record: CXX_FEATURE:1cxx_constexpr 272 | Feature record: CXX_FEATURE:1cxx_contextual_conversions 273 | Feature record: CXX_FEATURE:1cxx_decltype 274 | Feature record: CXX_FEATURE:1cxx_decltype_auto 275 | Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types 276 | Feature record: CXX_FEATURE:1cxx_default_function_template_args 277 | Feature record: CXX_FEATURE:1cxx_defaulted_functions 278 | Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers 279 | Feature record: CXX_FEATURE:1cxx_delegating_constructors 280 | Feature record: CXX_FEATURE:1cxx_deleted_functions 281 | Feature record: CXX_FEATURE:1cxx_digit_separators 282 | Feature record: CXX_FEATURE:1cxx_enum_forward_declarations 283 | Feature record: CXX_FEATURE:1cxx_explicit_conversions 284 | Feature record: CXX_FEATURE:1cxx_extended_friend_declarations 285 | Feature record: CXX_FEATURE:1cxx_extern_templates 286 | Feature record: CXX_FEATURE:1cxx_final 287 | Feature record: CXX_FEATURE:1cxx_func_identifier 288 | Feature record: CXX_FEATURE:1cxx_generalized_initializers 289 | Feature record: CXX_FEATURE:1cxx_generic_lambdas 290 | Feature record: CXX_FEATURE:1cxx_inheriting_constructors 291 | Feature record: CXX_FEATURE:1cxx_inline_namespaces 292 | Feature record: CXX_FEATURE:1cxx_lambdas 293 | Feature record: CXX_FEATURE:1cxx_lambda_init_captures 294 | Feature record: CXX_FEATURE:1cxx_local_type_template_args 295 | Feature record: CXX_FEATURE:1cxx_long_long_type 296 | Feature record: CXX_FEATURE:1cxx_noexcept 297 | Feature record: CXX_FEATURE:1cxx_nonstatic_member_init 298 | Feature record: CXX_FEATURE:1cxx_nullptr 299 | Feature record: CXX_FEATURE:1cxx_override 300 | Feature record: CXX_FEATURE:1cxx_range_for 301 | Feature record: CXX_FEATURE:1cxx_raw_string_literals 302 | Feature record: CXX_FEATURE:1cxx_reference_qualified_functions 303 | Feature record: CXX_FEATURE:1cxx_relaxed_constexpr 304 | Feature record: CXX_FEATURE:1cxx_return_type_deduction 305 | Feature record: CXX_FEATURE:1cxx_right_angle_brackets 306 | Feature record: CXX_FEATURE:1cxx_rvalue_references 307 | Feature record: CXX_FEATURE:1cxx_sizeof_member 308 | Feature record: CXX_FEATURE:1cxx_static_assert 309 | Feature record: CXX_FEATURE:1cxx_strong_enums 310 | Feature record: CXX_FEATURE:1cxx_template_template_parameters 311 | Feature record: CXX_FEATURE:1cxx_thread_local 312 | Feature record: CXX_FEATURE:1cxx_trailing_return_types 313 | Feature record: CXX_FEATURE:1cxx_unicode_literals 314 | Feature record: CXX_FEATURE:1cxx_uniform_initialization 315 | Feature record: CXX_FEATURE:1cxx_unrestricted_unions 316 | Feature record: CXX_FEATURE:1cxx_user_literals 317 | Feature record: CXX_FEATURE:1cxx_variable_templates 318 | Feature record: CXX_FEATURE:1cxx_variadic_macros 319 | Feature record: CXX_FEATURE:1cxx_variadic_templates 320 | 321 | 322 | Detecting CXX [-std=c++14] compiler features compiled with the following output: 323 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 324 | 325 | Run Build Command:"/usr/bin/make" "cmTC_d7a86/fast" 326 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_d7a86.dir/build.make CMakeFiles/cmTC_d7a86.dir/build 327 | Building CXX object CMakeFiles/cmTC_d7a86.dir/feature_tests.cxx.o 328 | /Library/Developer/CommandLineTools/usr/bin/c++ -std=c++14 -o CMakeFiles/cmTC_d7a86.dir/feature_tests.cxx.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.cxx" 329 | Linking CXX executable cmTC_d7a86 330 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_d7a86.dir/link.txt --verbose=1 331 | /Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_d7a86.dir/feature_tests.cxx.o -o cmTC_d7a86 332 | 333 | 334 | Feature record: CXX_FEATURE:1cxx_aggregate_default_initializers 335 | Feature record: CXX_FEATURE:1cxx_alias_templates 336 | Feature record: CXX_FEATURE:1cxx_alignas 337 | Feature record: CXX_FEATURE:1cxx_alignof 338 | Feature record: CXX_FEATURE:1cxx_attributes 339 | Feature record: CXX_FEATURE:1cxx_attribute_deprecated 340 | Feature record: CXX_FEATURE:1cxx_auto_type 341 | Feature record: CXX_FEATURE:1cxx_binary_literals 342 | Feature record: CXX_FEATURE:1cxx_constexpr 343 | Feature record: CXX_FEATURE:1cxx_contextual_conversions 344 | Feature record: CXX_FEATURE:1cxx_decltype 345 | Feature record: CXX_FEATURE:1cxx_decltype_auto 346 | Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types 347 | Feature record: CXX_FEATURE:1cxx_default_function_template_args 348 | Feature record: CXX_FEATURE:1cxx_defaulted_functions 349 | Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers 350 | Feature record: CXX_FEATURE:1cxx_delegating_constructors 351 | Feature record: CXX_FEATURE:1cxx_deleted_functions 352 | Feature record: CXX_FEATURE:1cxx_digit_separators 353 | Feature record: CXX_FEATURE:1cxx_enum_forward_declarations 354 | Feature record: CXX_FEATURE:1cxx_explicit_conversions 355 | Feature record: CXX_FEATURE:1cxx_extended_friend_declarations 356 | Feature record: CXX_FEATURE:1cxx_extern_templates 357 | Feature record: CXX_FEATURE:1cxx_final 358 | Feature record: CXX_FEATURE:1cxx_func_identifier 359 | Feature record: CXX_FEATURE:1cxx_generalized_initializers 360 | Feature record: CXX_FEATURE:1cxx_generic_lambdas 361 | Feature record: CXX_FEATURE:1cxx_inheriting_constructors 362 | Feature record: CXX_FEATURE:1cxx_inline_namespaces 363 | Feature record: CXX_FEATURE:1cxx_lambdas 364 | Feature record: CXX_FEATURE:1cxx_lambda_init_captures 365 | Feature record: CXX_FEATURE:1cxx_local_type_template_args 366 | Feature record: CXX_FEATURE:1cxx_long_long_type 367 | Feature record: CXX_FEATURE:1cxx_noexcept 368 | Feature record: CXX_FEATURE:1cxx_nonstatic_member_init 369 | Feature record: CXX_FEATURE:1cxx_nullptr 370 | Feature record: CXX_FEATURE:1cxx_override 371 | Feature record: CXX_FEATURE:1cxx_range_for 372 | Feature record: CXX_FEATURE:1cxx_raw_string_literals 373 | Feature record: CXX_FEATURE:1cxx_reference_qualified_functions 374 | Feature record: CXX_FEATURE:1cxx_relaxed_constexpr 375 | Feature record: CXX_FEATURE:1cxx_return_type_deduction 376 | Feature record: CXX_FEATURE:1cxx_right_angle_brackets 377 | Feature record: CXX_FEATURE:1cxx_rvalue_references 378 | Feature record: CXX_FEATURE:1cxx_sizeof_member 379 | Feature record: CXX_FEATURE:1cxx_static_assert 380 | Feature record: CXX_FEATURE:1cxx_strong_enums 381 | Feature record: CXX_FEATURE:1cxx_template_template_parameters 382 | Feature record: CXX_FEATURE:1cxx_thread_local 383 | Feature record: CXX_FEATURE:1cxx_trailing_return_types 384 | Feature record: CXX_FEATURE:1cxx_unicode_literals 385 | Feature record: CXX_FEATURE:1cxx_uniform_initialization 386 | Feature record: CXX_FEATURE:1cxx_unrestricted_unions 387 | Feature record: CXX_FEATURE:1cxx_user_literals 388 | Feature record: CXX_FEATURE:1cxx_variable_templates 389 | Feature record: CXX_FEATURE:1cxx_variadic_macros 390 | Feature record: CXX_FEATURE:1cxx_variadic_templates 391 | 392 | 393 | Detecting CXX [-std=c++11] compiler features compiled with the following output: 394 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 395 | 396 | Run Build Command:"/usr/bin/make" "cmTC_c6bd6/fast" 397 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_c6bd6.dir/build.make CMakeFiles/cmTC_c6bd6.dir/build 398 | Building CXX object CMakeFiles/cmTC_c6bd6.dir/feature_tests.cxx.o 399 | /Library/Developer/CommandLineTools/usr/bin/c++ -std=c++11 -o CMakeFiles/cmTC_c6bd6.dir/feature_tests.cxx.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.cxx" 400 | Linking CXX executable cmTC_c6bd6 401 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c6bd6.dir/link.txt --verbose=1 402 | /Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_c6bd6.dir/feature_tests.cxx.o -o cmTC_c6bd6 403 | 404 | 405 | Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers 406 | Feature record: CXX_FEATURE:1cxx_alias_templates 407 | Feature record: CXX_FEATURE:1cxx_alignas 408 | Feature record: CXX_FEATURE:1cxx_alignof 409 | Feature record: CXX_FEATURE:1cxx_attributes 410 | Feature record: CXX_FEATURE:0cxx_attribute_deprecated 411 | Feature record: CXX_FEATURE:1cxx_auto_type 412 | Feature record: CXX_FEATURE:0cxx_binary_literals 413 | Feature record: CXX_FEATURE:1cxx_constexpr 414 | Feature record: CXX_FEATURE:0cxx_contextual_conversions 415 | Feature record: CXX_FEATURE:1cxx_decltype 416 | Feature record: CXX_FEATURE:0cxx_decltype_auto 417 | Feature record: CXX_FEATURE:1cxx_decltype_incomplete_return_types 418 | Feature record: CXX_FEATURE:1cxx_default_function_template_args 419 | Feature record: CXX_FEATURE:1cxx_defaulted_functions 420 | Feature record: CXX_FEATURE:1cxx_defaulted_move_initializers 421 | Feature record: CXX_FEATURE:1cxx_delegating_constructors 422 | Feature record: CXX_FEATURE:1cxx_deleted_functions 423 | Feature record: CXX_FEATURE:0cxx_digit_separators 424 | Feature record: CXX_FEATURE:1cxx_enum_forward_declarations 425 | Feature record: CXX_FEATURE:1cxx_explicit_conversions 426 | Feature record: CXX_FEATURE:1cxx_extended_friend_declarations 427 | Feature record: CXX_FEATURE:1cxx_extern_templates 428 | Feature record: CXX_FEATURE:1cxx_final 429 | Feature record: CXX_FEATURE:1cxx_func_identifier 430 | Feature record: CXX_FEATURE:1cxx_generalized_initializers 431 | Feature record: CXX_FEATURE:0cxx_generic_lambdas 432 | Feature record: CXX_FEATURE:1cxx_inheriting_constructors 433 | Feature record: CXX_FEATURE:1cxx_inline_namespaces 434 | Feature record: CXX_FEATURE:1cxx_lambdas 435 | Feature record: CXX_FEATURE:0cxx_lambda_init_captures 436 | Feature record: CXX_FEATURE:1cxx_local_type_template_args 437 | Feature record: CXX_FEATURE:1cxx_long_long_type 438 | Feature record: CXX_FEATURE:1cxx_noexcept 439 | Feature record: CXX_FEATURE:1cxx_nonstatic_member_init 440 | Feature record: CXX_FEATURE:1cxx_nullptr 441 | Feature record: CXX_FEATURE:1cxx_override 442 | Feature record: CXX_FEATURE:1cxx_range_for 443 | Feature record: CXX_FEATURE:1cxx_raw_string_literals 444 | Feature record: CXX_FEATURE:1cxx_reference_qualified_functions 445 | Feature record: CXX_FEATURE:0cxx_relaxed_constexpr 446 | Feature record: CXX_FEATURE:0cxx_return_type_deduction 447 | Feature record: CXX_FEATURE:1cxx_right_angle_brackets 448 | Feature record: CXX_FEATURE:1cxx_rvalue_references 449 | Feature record: CXX_FEATURE:1cxx_sizeof_member 450 | Feature record: CXX_FEATURE:1cxx_static_assert 451 | Feature record: CXX_FEATURE:1cxx_strong_enums 452 | Feature record: CXX_FEATURE:1cxx_template_template_parameters 453 | Feature record: CXX_FEATURE:1cxx_thread_local 454 | Feature record: CXX_FEATURE:1cxx_trailing_return_types 455 | Feature record: CXX_FEATURE:1cxx_unicode_literals 456 | Feature record: CXX_FEATURE:1cxx_uniform_initialization 457 | Feature record: CXX_FEATURE:1cxx_unrestricted_unions 458 | Feature record: CXX_FEATURE:1cxx_user_literals 459 | Feature record: CXX_FEATURE:0cxx_variable_templates 460 | Feature record: CXX_FEATURE:1cxx_variadic_macros 461 | Feature record: CXX_FEATURE:1cxx_variadic_templates 462 | 463 | 464 | Detecting CXX [-std=c++98] compiler features compiled with the following output: 465 | Change Dir: /Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/CMakeTmp 466 | 467 | Run Build Command:"/usr/bin/make" "cmTC_58013/fast" 468 | /Library/Developer/CommandLineTools/usr/bin/make -f CMakeFiles/cmTC_58013.dir/build.make CMakeFiles/cmTC_58013.dir/build 469 | Building CXX object CMakeFiles/cmTC_58013.dir/feature_tests.cxx.o 470 | /Library/Developer/CommandLineTools/usr/bin/c++ -std=c++98 -o CMakeFiles/cmTC_58013.dir/feature_tests.cxx.o -c "/Users/SeeKHit/Project/Peter-Shirley-Ray-Tracing-in-one-weenkend/Peter-Shirley-Project Code/cmake-build-debug/CMakeFiles/feature_tests.cxx" 471 | Linking CXX executable cmTC_58013 472 | /Applications/CLion.app/Contents/bin/cmake/bin/cmake -E cmake_link_script CMakeFiles/cmTC_58013.dir/link.txt --verbose=1 473 | /Library/Developer/CommandLineTools/usr/bin/c++ -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/cmTC_58013.dir/feature_tests.cxx.o -o cmTC_58013 474 | 475 | 476 | Feature record: CXX_FEATURE:0cxx_aggregate_default_initializers 477 | Feature record: CXX_FEATURE:0cxx_alias_templates 478 | Feature record: CXX_FEATURE:0cxx_alignas 479 | Feature record: CXX_FEATURE:0cxx_alignof 480 | Feature record: CXX_FEATURE:0cxx_attributes 481 | Feature record: CXX_FEATURE:0cxx_attribute_deprecated 482 | Feature record: CXX_FEATURE:0cxx_auto_type 483 | Feature record: CXX_FEATURE:0cxx_binary_literals 484 | Feature record: CXX_FEATURE:0cxx_constexpr 485 | Feature record: CXX_FEATURE:0cxx_contextual_conversions 486 | Feature record: CXX_FEATURE:0cxx_decltype 487 | Feature record: CXX_FEATURE:0cxx_decltype_auto 488 | Feature record: CXX_FEATURE:0cxx_decltype_incomplete_return_types 489 | Feature record: CXX_FEATURE:0cxx_default_function_template_args 490 | Feature record: CXX_FEATURE:0cxx_defaulted_functions 491 | Feature record: CXX_FEATURE:0cxx_defaulted_move_initializers 492 | Feature record: CXX_FEATURE:0cxx_delegating_constructors 493 | Feature record: CXX_FEATURE:0cxx_deleted_functions 494 | Feature record: CXX_FEATURE:0cxx_digit_separators 495 | Feature record: CXX_FEATURE:0cxx_enum_forward_declarations 496 | Feature record: CXX_FEATURE:0cxx_explicit_conversions 497 | Feature record: CXX_FEATURE:0cxx_extended_friend_declarations 498 | Feature record: CXX_FEATURE:0cxx_extern_templates 499 | Feature record: CXX_FEATURE:0cxx_final 500 | Feature record: CXX_FEATURE:0cxx_func_identifier 501 | Feature record: CXX_FEATURE:0cxx_generalized_initializers 502 | Feature record: CXX_FEATURE:0cxx_generic_lambdas 503 | Feature record: CXX_FEATURE:0cxx_inheriting_constructors 504 | Feature record: CXX_FEATURE:0cxx_inline_namespaces 505 | Feature record: CXX_FEATURE:0cxx_lambdas 506 | Feature record: CXX_FEATURE:0cxx_lambda_init_captures 507 | Feature record: CXX_FEATURE:0cxx_local_type_template_args 508 | Feature record: CXX_FEATURE:0cxx_long_long_type 509 | Feature record: CXX_FEATURE:0cxx_noexcept 510 | Feature record: CXX_FEATURE:0cxx_nonstatic_member_init 511 | Feature record: CXX_FEATURE:0cxx_nullptr 512 | Feature record: CXX_FEATURE:0cxx_override 513 | Feature record: CXX_FEATURE:0cxx_range_for 514 | Feature record: CXX_FEATURE:0cxx_raw_string_literals 515 | Feature record: CXX_FEATURE:0cxx_reference_qualified_functions 516 | Feature record: CXX_FEATURE:0cxx_relaxed_constexpr 517 | Feature record: CXX_FEATURE:0cxx_return_type_deduction 518 | Feature record: CXX_FEATURE:0cxx_right_angle_brackets 519 | Feature record: CXX_FEATURE:0cxx_rvalue_references 520 | Feature record: CXX_FEATURE:0cxx_sizeof_member 521 | Feature record: CXX_FEATURE:0cxx_static_assert 522 | Feature record: CXX_FEATURE:0cxx_strong_enums 523 | Feature record: CXX_FEATURE:1cxx_template_template_parameters 524 | Feature record: CXX_FEATURE:0cxx_thread_local 525 | Feature record: CXX_FEATURE:0cxx_trailing_return_types 526 | Feature record: CXX_FEATURE:0cxx_unicode_literals 527 | Feature record: CXX_FEATURE:0cxx_uniform_initialization 528 | Feature record: CXX_FEATURE:0cxx_unrestricted_unions 529 | Feature record: CXX_FEATURE:0cxx_user_literals 530 | Feature record: CXX_FEATURE:0cxx_variable_templates 531 | Feature record: CXX_FEATURE:0cxx_variadic_macros 532 | Feature record: CXX_FEATURE:0cxx_variadic_templates 533 | --------------------------------------------------------------------------------