|
1637 | 1637 | // Common Headers |
1638 | 1638 |
|
1639 | 1639 | #include "color.h" |
1640 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 1640 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
1641 | 1641 | #include "interval.h" |
1642 | 1642 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
1643 | 1643 | #include "ray.h" |
|
1995 | 1995 |
|
1996 | 1996 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
1997 | 1997 | #include <cmath> |
1998 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 1998 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
1999 | 1999 | #include <cstdlib> |
2000 | 2000 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
2001 | 2001 | #include <iostream> |
|
2010 | 2010 | } |
2011 | 2011 |
|
2012 | 2012 |
|
2013 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2013 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2014 | 2014 | inline double random_double() { |
2015 | 2015 | // Returns a random real in [0,1). |
2016 | 2016 | return std::rand() / (RAND_MAX + 1.0); |
|
2274 | 2274 | } |
2275 | 2275 |
|
2276 | 2276 |
|
2277 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2277 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2278 | 2278 | static vec3 random() { |
2279 | 2279 | return vec3(random_double(), random_double(), random_double()); |
2280 | 2280 | } |
|
2317 | 2317 | } |
2318 | 2318 |
|
2319 | 2319 |
|
2320 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2320 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2321 | 2321 | inline vec3 random_in_unit_sphere() { |
2322 | 2322 | while (true) { |
2323 | 2323 | auto p = vec3::random(-1,1); |
|
2349 | 2349 | } |
2350 | 2350 |
|
2351 | 2351 |
|
2352 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2352 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2353 | 2353 | inline vec3 random_unit_vector() { |
2354 | 2354 | return unit_vector(random_in_unit_sphere()); |
2355 | 2355 | } |
|
2380 | 2380 | } |
2381 | 2381 |
|
2382 | 2382 |
|
2383 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2383 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2384 | 2384 | inline vec3 random_on_hemisphere(const vec3& normal) { |
2385 | 2385 | vec3 on_unit_sphere = random_unit_vector(); |
2386 | 2386 | if (dot(on_unit_sphere, normal) > 0.0) // In the same hemisphere as the normal |
|
2905 | 2905 | }; |
2906 | 2906 |
|
2907 | 2907 |
|
2908 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2908 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2909 | 2909 | class lambertian : public material { |
2910 | 2910 | public: |
2911 | 2911 | lambertian(const color& albedo) : albedo(albedo) {} |
|
2947 | 2947 | } |
2948 | 2948 |
|
2949 | 2949 |
|
2950 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 2950 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
2951 | 2951 | bool near_zero() const { |
2952 | 2952 | // Return true if the vector is close to zero in all dimensions. |
2953 | 2953 | auto s = 1e-8; |
|
3014 | 3014 | } |
3015 | 3015 |
|
3016 | 3016 |
|
3017 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 3017 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
3018 | 3018 | inline vec3 reflect(const vec3& v, const vec3& n) { |
3019 | 3019 | return v - 2*dot(v,n)*n; |
3020 | 3020 | } |
|
3032 | 3032 | }; |
3033 | 3033 |
|
3034 | 3034 |
|
3035 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 3035 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
3036 | 3036 | class metal : public material { |
3037 | 3037 | public: |
3038 | 3038 | metal(const color& albedo) : albedo(albedo) {} |
|
3329 | 3329 | } |
3330 | 3330 |
|
3331 | 3331 |
|
3332 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 3332 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
3333 | 3333 | inline vec3 refract(const vec3& uv, const vec3& n, double etai_over_etat) { |
3334 | 3334 | auto cos_theta = std::fmin(dot(-uv, n), 1.0); |
3335 | 3335 | vec3 r_out_perp = etai_over_etat * (uv + cos_theta*n); |
|
3352 | 3352 | }; |
3353 | 3353 |
|
3354 | 3354 |
|
3355 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 3355 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
3356 | 3356 | class dielectric : public material { |
3357 | 3357 | public: |
3358 | 3358 | dielectric(double refraction_index) : refraction_index(refraction_index) {} |
|
4039 | 4039 | } |
4040 | 4040 |
|
4041 | 4041 |
|
4042 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 4042 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
4043 | 4043 | inline vec3 random_in_unit_disk() { |
4044 | 4044 | while (true) { |
4045 | 4045 | auto p = vec3(random_double(-1,1), random_double(-1,1), 0); |
|
4230 | 4230 | hittable_list world; |
4231 | 4231 |
|
4232 | 4232 |
|
4233 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 4233 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
4234 | 4234 | auto ground_material = make_shared<lambertian>(color(0.5, 0.5, 0.5)); |
4235 | 4235 | world.add(make_shared<sphere>(point3(0,-1000,0), 1000, ground_material)); |
4236 | 4236 |
|
|
4275 | 4275 | camera cam; |
4276 | 4276 |
|
4277 | 4277 |
|
4278 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ Highlight |
| 4278 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
4279 | 4279 | cam.aspect_ratio = 16.0 / 9.0; |
4280 | 4280 | cam.image_width = 1200; |
4281 | 4281 | cam.samples_per_pixel = 500; |
|
0 commit comments