Skip to content

Commit 094f74b

Browse files
committed
Merge branch 'dev-minor' into write-color
2 parents 837c26b + de29d24 commit 094f74b

15 files changed

+148
-358
lines changed

CHANGELOG.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@ Change Log -- Ray Tracing in One Weekend
66

77
### Common
88
- Fix: Scattered improvements to the text.
9-
- New: subchapters throughout all three books (#267)
9+
- New: Subchapters throughout all three books (#267)
10+
- New: Add explanation for padding `aarect` in the zero dimension (#488)
1011
- Change: Minor change to use new `point3` and `color` type aliases for `vec3` (#422)
1112
- Change: Renamed `constant_texture` to `solid_color`, add RGB constructor (#452)
1213
- Change: Moved `vec3::write_color()` method to utility function in `color.h` header (#502)
14+
- Change: Math notation to bold uppercase points, bold lowercase no-barb vectors (#412)
15+
- Change: Switch from `ffmin`/`ffmax` to standard `fmin`/`fmax` (#444, #491)
1316

1417
### _In One Weekend_
1518
- Fix: Update image and size for first PPM image

books/RayTracingInOneWeekend.html

+32-110
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@
137137
Opening the output file (in `ToyViewer` on my Mac, but try it in your favorite viewer and Google
138138
“ppm viewer” if your viewer doesn’t support it) shows this result:
139139

140-
<div class="render">
141-
142-
![First PPM image](../images/img.first-ppm-image.png)
143-
144-
</div>
140+
![First PPM image](../images/img.first-ppm-image.png class=pixel)
145141

146142
</div>
147143

@@ -234,8 +230,11 @@
234230
#ifndef VEC3_H
235231
#define VEC3_H
236232

233+
#include <cmath>
237234
#include <iostream>
238235

236+
using std::sqrt;
237+
239238
class vec3 {
240239
public:
241240
vec3() : e{0,0,0} {}
@@ -537,11 +536,8 @@
537536

538537
with $t$ going from zero to one. In our case this produces:
539538

540-
<div class="render">
541-
542-
![A blue-to-white gradient depending on ray Y coordinate](../images/img.blue-to-white.png)
543-
544-
</div>
539+
![A blue-to-white gradient depending on ray Y coordinate
540+
](../images/img.blue-to-white.png class=pixel)
545541

546542
</div>
547543

@@ -655,11 +651,7 @@
655651
<div class='together'>
656652
What we get is this:
657653

658-
<div class="render">
659-
660-
![A simple red sphere](../images/img.red-sphere.png)
661-
662-
</div>
654+
![A simple red sphere](../images/img.red-sphere.png class=pixel)
663655

664656
</div>
665657

@@ -735,11 +727,7 @@
735727
<div class='together'>
736728
And that yields this picture:
737729

738-
<div class="render">
739-
740-
![A sphere colored according to its normal vectors](../images/img.normals-sphere.png)
741-
742-
</div>
730+
![A sphere colored according to its normal vectors](../images/img.normals-sphere.png class=pixel)
743731

744732
</div>
745733

@@ -898,7 +886,8 @@
898886
the sphere, the normal will point outward, but if the ray is inside the sphere, the normal will
899887
point inward.
900888

901-
![Figure [normal-directions]: Possible directions for sphere surface-normal geometry](../images/fig.normal-possibilities.jpg)
889+
![Figure [normal-directions]: Possible directions for sphere surface-normal geometry
890+
](../images/fig.normal-possibilities.jpg)
902891

903892
</div>
904893

@@ -1155,6 +1144,7 @@
11551144

11561145
using std::shared_ptr;
11571146
using std::make_shared;
1147+
using std::sqrt;
11581148

11591149
// Constants
11601150

@@ -1167,9 +1157,6 @@
11671157
return degrees * pi / 180;
11681158
}
11691159

1170-
inline double ffmin(double a, double b) { return a <= b ? a : b; }
1171-
inline double ffmax(double a, double b) { return a >= b ? a : b; }
1172-
11731160
// Common Headers
11741161

11751162
#include "ray.h"
@@ -1252,11 +1239,8 @@
12521239
This yields a picture that is really just a visualization of where the spheres are along with their
12531240
surface normal. This is often a great way to look at your model for flaws and characteristics.
12541241

1255-
<div class="render">
1256-
1257-
![Resulting render of normals-colored sphere with ground](../images/img.normals-sphere-ground.png)
1258-
1259-
</div>
1242+
![Resulting render of normals-colored sphere with ground
1243+
](../images/img.normals-sphere-ground.png class=pixel)
12601244

12611245
</div>
12621246

@@ -1447,11 +1431,7 @@
14471431
Zooming into the image that is produced, the big change is in edge pixels that are part background
14481432
and part foreground:
14491433

1450-
<div class="render">
1451-
1452-
![Close-up of antialiased pixels](../images/img.antialias.png)
1453-
1454-
</div>
1434+
![Close-up of antialiased pixels](../images/img.antialias.png class=pixel)
14551435

14561436
</div>
14571437

@@ -1626,11 +1606,7 @@
16261606
<div class='together'>
16271607
This gives us:
16281608

1629-
<div class="render">
1630-
1631-
![First render of a diffuse sphere](../images/img.first-diffuse.jpg)
1632-
1633-
</div>
1609+
![First render of a diffuse sphere](../images/img.first-diffuse.jpg class=pixel)
16341610

16351611
</div>
16361612

@@ -1674,11 +1650,7 @@
16741650
<div class='together'>
16751651
That yields light grey, as we desire:
16761652

1677-
<div class="render">
1678-
1679-
![Diffuse sphere, with gamma correction](../images/img.gamma-correct.jpg)
1680-
1681-
</div>
1653+
![Diffuse sphere, with gamma correction](../images/img.gamma-correct.jpg class=pixel)
16821654

16831655
</div>
16841656

@@ -1758,11 +1730,7 @@
17581730
<div class='together'>
17591731
After rendering we get a similar image:
17601732

1761-
<div class="render">
1762-
1763-
![Correct rendering of Lambertian spheres](../images/img.correct-lambertian.png)
1764-
1765-
</div>
1733+
![Correct rendering of Lambertian spheres](../images/img.correct-lambertian.png class=pixel)
17661734

17671735
It's hard to tell the difference between these two diffuse methods, given that our scene of two
17681736
spheres is so simple, but you should be able to notice two important visual differences:
@@ -1841,11 +1809,8 @@
18411809

18421810
Gives us the following image:
18431811

1844-
<div class="render">
1845-
1846-
![Rendering of diffuse spheres with hemispherical scattering](../images/img.rand-hemispherical.png)
1847-
1848-
</div>
1812+
![Rendering of diffuse spheres with hemispherical scattering
1813+
](../images/img.rand-hemispherical.png class=pixel)
18491814

18501815
</div>
18511816

@@ -2168,11 +2133,7 @@
21682133
<div class='together'>
21692134
Which gives:
21702135

2171-
<div class="render">
2172-
2173-
![Shiny metal](../images/img.metal-shiny.png)
2174-
2175-
</div>
2136+
![Shiny metal](../images/img.metal-shiny.png class=pixel)
21762137

21772138
</div>
21782139

@@ -2225,11 +2186,7 @@
22252186
<div class='together'>
22262187
We can try that out by adding fuzziness 0.3 and 1.0 to the metals:
22272188

2228-
<div class="render">
2229-
2230-
![Fuzzed metal](../images/img.metal-fuzz.png)
2231-
2232-
</div>
2189+
![Fuzzed metal](../images/img.metal-fuzz.png class=pixel)
22332190

22342191
</div>
22352192

@@ -2250,11 +2207,7 @@
22502207
there is a refraction ray at all. For this project, I tried to put two glass balls in our scene, and
22512208
I got this (I have not told you how to do this right or wrong yet, but soon!):
22522209

2253-
<div class="render">
2254-
2255-
![Glass first](../images/img.glass-first.png)
2256-
2257-
</div>
2210+
![Glass first](../images/img.glass-first.png class=pixel)
22582211

22592212
</div>
22602213

@@ -2358,11 +2311,7 @@
23582311

23592312
This gives us the following result:
23602313

2361-
<div class="render">
2362-
2363-
![Glass sphere that always refracts](../images/img.glass-always-refract.png)
2364-
2365-
</div>
2314+
![Glass sphere that always refracts](../images/img.glass-always-refract.png class=pixel)
23662315

23672316

23682317
Total Internal Reflection
@@ -2413,7 +2362,7 @@
24132362
$$ \cos\theta = \mathbf{R} \cdot \mathbf{n} $$
24142363

24152364
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
2416-
double cos_theta = ffmin(dot(-unit_direction, rec.normal), 1.0);
2365+
double cos_theta = fmin(dot(-unit_direction, rec.normal), 1.0);
24172366
double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
24182367
if(etai_over_etat * sin_theta > 1.0) {
24192368
// Must Reflect
@@ -2444,7 +2393,7 @@
24442393

24452394
vec3 unit_direction = unit_vector(r_in.direction());
24462395
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
2447-
double cos_theta = ffmin(dot(-unit_direction, rec.normal), 1.0);
2396+
double cos_theta = fmin(dot(-unit_direction, rec.normal), 1.0);
24482397
double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
24492398
if (etai_over_etat * sin_theta > 1.0 ) {
24502399
vec3 reflected = reflect(unit_direction, rec.normal);
@@ -2483,11 +2432,7 @@
24832432

24842433
We get:
24852434

2486-
<div class="render">
2487-
2488-
![Glass sphere that sometimes refracts](../images/img.glass-sometimes-refract.png)
2489-
2490-
</div>
2435+
![Glass sphere that sometimes refracts](../images/img.glass-sometimes-refract.png class=pixel)
24912436

24922437
</div>
24932438

@@ -2523,7 +2468,7 @@
25232468
double etai_over_etat = (rec.front_face) ? (1.0 / ref_idx) : (ref_idx);
25242469

25252470
vec3 unit_direction = unit_vector(r_in.direction());
2526-
double cos_theta = ffmin(dot(-unit_direction, rec.normal), 1.0);
2471+
double cos_theta = fmin(dot(-unit_direction, rec.normal), 1.0);
25272472
double sin_theta = sqrt(1.0 - cos_theta*cos_theta);
25282473
if (etai_over_etat * sin_theta > 1.0 ) {
25292474
vec3 reflected = reflect(unit_direction, rec.normal);
@@ -2572,11 +2517,7 @@
25722517
<div class='together'>
25732518
This gives:
25742519

2575-
<div class="render">
2576-
2577-
![A hollow glass sphere](../images/img.glass-hollow.png)
2578-
2579-
</div>
2520+
![A hollow glass sphere](../images/img.glass-hollow.png class=pixel)
25802521

25812522
</div>
25822523

@@ -2653,11 +2594,7 @@
26532594

26542595
gives:
26552596

2656-
<div class="render">
2657-
2658-
![A wide-angle view](../images/img.wide-view.png)
2659-
2660-
</div>
2597+
![A wide-angle view](../images/img.wide-view.png class=pixel)
26612598

26622599
</div>
26632600

@@ -2741,11 +2678,7 @@
27412678

27422679
to get:
27432680

2744-
<div class="render">
2745-
2746-
![A distant view](../images/img.view-distant.png)
2747-
2748-
</div>
2681+
![A distant view](../images/img.view-distant.png class=pixel)
27492682

27502683
And we can change field of view:
27512684

@@ -2756,11 +2689,7 @@
27562689

27572690
to get:
27582691

2759-
<div class="render">
2760-
2761-
![Zooming in](../images/img.view-zoom.png)
2762-
2763-
</div>
2692+
![Zooming in](../images/img.view-zoom.png class=pixel)
27642693

27652694
</div>
27662695

@@ -2902,11 +2831,7 @@
29022831

29032832
We get:
29042833

2905-
<div class="render">
2906-
2907-
![Spheres with depth-of-field](../images/img.depth-of-field.png)
2908-
2909-
</div>
2834+
![Spheres with depth-of-field](../images/img.depth-of-field.png class=pixel)
29102835

29112836
</div>
29122837

@@ -2983,11 +2908,8 @@
29832908
<div class='together'>
29842909
This gives:
29852910

2986-
<div class="render">
2987-
29882911
![Final scene](../images/img.book1-final.jpg)
29892912

2990-
</div>
29912913
</div>
29922914

29932915
An interesting thing you might note is the glass balls don’t really have shadows which makes them

0 commit comments

Comments
 (0)