|
21 | 21 |
|
22 | 22 |
|
23 | 23 | vec3 ray_color(const ray& r, hittable *world, hittable *light_shape, int depth) {
|
24 |
| - hit_record hrec; |
25 |
| - if (depth <= 0 || !world->hit(r, 0.001, infinity, hrec)) |
| 24 | + hit_record rec; |
| 25 | + if (depth <= 0 || !world->hit(r, 0.001, infinity, rec)) |
26 | 26 | return vec3(0,0,0);
|
27 | 27 |
|
28 | 28 | scatter_record srec;
|
29 |
| - vec3 emitted = hrec.mat_ptr->emitted(r, hrec, hrec.u, hrec.v, hrec.p); |
30 |
| - if (!hrec.mat_ptr->scatter(r, hrec, srec)) |
| 29 | + vec3 emitted = rec.mat_ptr->emitted(r, rec, rec.u, rec.v, rec.p); |
| 30 | + if (!rec.mat_ptr->scatter(r, rec, srec)) |
31 | 31 | return emitted;
|
32 | 32 |
|
33 | 33 | if (srec.is_specular) {
|
34 | 34 | return srec.attenuation * ray_color(srec.specular_ray, world, light_shape, depth-1);
|
35 | 35 | }
|
36 |
| - hittable_pdf plight(light_shape, hrec.p); |
| 36 | + hittable_pdf plight(light_shape, rec.p); |
37 | 37 | mixture_pdf p(&plight, srec.pdf_ptr);
|
38 |
| - ray scattered = ray(hrec.p, p.generate(), r.time()); |
| 38 | + ray scattered = ray(rec.p, p.generate(), r.time()); |
39 | 39 | auto pdf_val = p.value(scattered.direction());
|
40 | 40 | delete srec.pdf_ptr;
|
41 | 41 |
|
42 | 42 | return emitted
|
43 |
| - + srec.attenuation * hrec.mat_ptr->scattering_pdf(r, hrec, scattered) |
| 43 | + + srec.attenuation * rec.mat_ptr->scattering_pdf(r, rec, scattered) |
44 | 44 | * ray_color(scattered, world, light_shape, depth-1)
|
45 | 45 | / pdf_val;
|
46 | 46 | }
|
|
0 commit comments