|
355 | 355 | cam.lookat = point3(0,0,0); |
356 | 356 | cam.vup = vec3(0,1,0); |
357 | 357 |
|
358 | | - cam.defocus_angle = 0.02; |
| 358 | + cam.defocus_angle = 0.6; |
359 | 359 | cam.focus_dist = 10.0; |
360 | 360 |
|
361 | 361 | cam.render(world); |
|
713 | 713 | class sphere : public hittable { |
714 | 714 | public: |
715 | 715 | // Stationary Sphere |
716 | | - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
717 | 716 | sphere(const point3& center, double radius, shared_ptr<material> mat) |
| 717 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
718 | 718 | : center1(center), radius(fmax(0,radius)), mat(mat), is_moving(false) |
719 | 719 | { |
720 | 720 | auto rvec = vec3(radius, radius, radius); |
|
1086 | 1086 | #include "bvh.h" |
1087 | 1087 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
1088 | 1088 | #include "camera.h" |
| 1089 | + #include "hittable.h" |
1089 | 1090 | #include "hittable_list.h" |
1090 | 1091 | #include "material.h" |
1091 | 1092 | #include "sphere.h" |
|
1251 | 1252 |
|
1252 | 1253 | class solid_color : public texture { |
1253 | 1254 | public: |
1254 | | - solid_color(const color& albedo) : color_value(albedo) {} |
| 1255 | + solid_color(const color& albedo) : albedo(albedo) {} |
1255 | 1256 |
|
1256 | 1257 | solid_color(double red, double green, double blue) : solid_color(color(red,green,blue)) {} |
1257 | 1258 |
|
1258 | 1259 | color value(double u, double v, const point3& p) const override { |
1259 | | - return color_value; |
| 1260 | + return albedo; |
1260 | 1261 | } |
1261 | 1262 |
|
1262 | 1263 | private: |
1263 | | - color color_value; |
| 1264 | + color albedo; |
1264 | 1265 | }; |
1265 | 1266 |
|
1266 | 1267 | #endif |
|
1403 | 1404 |
|
1404 | 1405 | #include "bvh.h" |
1405 | 1406 | #include "camera.h" |
| 1407 | + #include "hittable.h" |
1406 | 1408 | #include "hittable_list.h" |
1407 | 1409 | #include "material.h" |
1408 | 1410 | #include "sphere.h" |
|
1454 | 1456 |
|
1455 | 1457 | #include "bvh.h" |
1456 | 1458 | #include "camera.h" |
| 1459 | + #include "hittable.h" |
1457 | 1460 | #include "hittable_list.h" |
1458 | 1461 | #include "material.h" |
1459 | 1462 | #include "sphere.h" |
|
1493 | 1496 |
|
1494 | 1497 | #include "bvh.h" |
1495 | 1498 | #include "camera.h" |
| 1499 | + #include "hittable.h" |
1496 | 1500 | #include "hittable_list.h" |
1497 | 1501 | #include "material.h" |
1498 | 1502 | #include "sphere.h" |
|
2020 | 2024 | static int* perlin_generate_perm() { |
2021 | 2025 | auto p = new int[point_count]; |
2022 | 2026 |
|
2023 | | - for (int i = 0; i < perlin::point_count; i++) |
| 2027 | + for (int i = 0; i < point_count; i++) |
2024 | 2028 | p[i] = i; |
2025 | 2029 |
|
2026 | 2030 | permute(p, point_count); |
|
2491 | 2495 | auto weight = 1.0; |
2492 | 2496 |
|
2493 | 2497 | for (int i = 0; i < depth; i++) { |
2494 | | - accum += weight*noise(temp_p); |
| 2498 | + accum += weight * noise(temp_p); |
2495 | 2499 | weight *= 0.5; |
2496 | 2500 | temp_p *= 2; |
2497 | 2501 | } |
|
3126 | 3130 |
|
3127 | 3131 | #include "bvh.h" |
3128 | 3132 | #include "camera.h" |
3129 | | - #include "color.h" |
| 3133 | + #include "hittable.h" |
3130 | 3134 | #include "hittable_list.h" |
3131 | 3135 | #include "material.h" |
3132 | 3136 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
|
3679 | 3683 | // Move the ray backwards by the offset |
3680 | 3684 | ray offset_r(r.origin() - offset, r.direction(), r.time()); |
3681 | 3685 |
|
3682 | | - // Determine where (if any) an intersection occurs along the offset ray |
| 3686 | + // Determine whether an intersection exists along the offset ray (and if so, where) |
3683 | 3687 | if (!object->hit(offset_r, ray_t, rec)) |
3684 | 3688 | return false; |
3685 | 3689 |
|
|
3869 | 3873 |
|
3870 | 3874 | ray rotated_r(origin, direction, r.time()); |
3871 | 3875 |
|
3872 | | - // Determine where (if any) an intersection occurs in object space |
| 3876 | + // Determine whether an intersection exists in object space (and if so, where) |
3873 | 3877 | if (!object->hit(rotated_r, ray_t, rec)) |
3874 | 3878 | return false; |
3875 | 3879 |
|
|
4038 | 4042 |
|
4039 | 4043 | class constant_medium : public hittable { |
4040 | 4044 | public: |
4041 | | - constant_medium(shared_ptr<hittable> b, double d, shared_ptr<texture> a) |
4042 | | - : boundary(b), neg_inv_density(-1/d), phase_function(make_shared<isotropic>(a)) |
| 4045 | + constant_medium(shared_ptr<hittable> boundary, double density, shared_ptr<texture> tex) |
| 4046 | + : boundary(boundary), neg_inv_density(-1/density), |
| 4047 | + phase_function(make_shared<isotropic>(tex)) |
4043 | 4048 | {} |
4044 | 4049 |
|
4045 | | - constant_medium(shared_ptr<hittable> b, double d, const color& c) |
4046 | | - : boundary(b), neg_inv_density(-1/d), phase_function(make_shared<isotropic>(c)) |
| 4050 | + constant_medium(shared_ptr<hittable> boundary, double density, const color& albedo) |
| 4051 | + : boundary(boundary), neg_inv_density(-1/density), |
| 4052 | + phase_function(make_shared<isotropic>(albedo)) |
4047 | 4053 | {} |
4048 | 4054 |
|
4049 | 4055 | bool hit(const ray& r, interval ray_t, hit_record& rec) const override { |
|
4059 | 4065 | if (!boundary->hit(r, interval(rec1.t+0.0001, infinity), rec2)) |
4060 | 4066 | return false; |
4061 | 4067 |
|
4062 | | - if (debugging) std::clog << "\nray_tmin=" << rec1.t << ", ray_tmax=" << rec2.t << '\n'; |
| 4068 | + if (debugging) std::clog << "\nt_min=" << rec1.t << ", t_max=" << rec2.t << '\n'; |
4063 | 4069 |
|
4064 | 4070 | if (rec1.t < ray_t.min) rec1.t = ray_t.min; |
4065 | 4071 | if (rec2.t > ray_t.max) rec2.t = ray_t.max; |
|
4119 | 4125 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
4120 | 4126 | class isotropic : public material { |
4121 | 4127 | public: |
4122 | | - isotropic(const color& c) : tex(make_shared<solid_color>(c)) {} |
| 4128 | + isotropic(const color& albedo) : tex(make_shared<solid_color>(albedo)) {} |
4123 | 4129 | isotropic(shared_ptr<texture> tex) : tex(tex) {} |
4124 | 4130 |
|
4125 | 4131 | bool scatter(const ray& r_in, const hit_record& rec, color& attenuation, ray& scattered) |
4126 | 4132 | const override { |
4127 | | - attenuation = tex->value(rec.u, rec.v, rec.p); |
4128 | 4133 | scattered = ray(rec.p, random_unit_vector(), r_in.time()); |
| 4134 | + attenuation = tex->value(rec.u, rec.v, rec.p); |
4129 | 4135 | return true; |
4130 | 4136 | } |
4131 | 4137 |
|
|
4158 | 4164 |
|
4159 | 4165 | #include "bvh.h" |
4160 | 4166 | #include "camera.h" |
4161 | | - #include "color.h" |
4162 | 4167 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight |
4163 | 4168 | #include "constant_medium.h" |
4164 | 4169 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
| 4170 | + #include "hittable.h" |
4165 | 4171 | #include "hittable_list.h" |
4166 | 4172 | #include "material.h" |
4167 | 4173 | #include "quad.h" |
|
0 commit comments