Skip to content

Commit 661bda8

Browse files
committed
Render images pixelated instead of smoothed
An incremental improvement to styling for rendered images. Smoothed images don't match actual renderings, and tend to hide single-pixel artifacts that may be important. To achieve this, wrap Markdown image includes with `<div class="render">`. Note that the div open and close tags must be separated with blank lines from the `![...](...)` Markdown directive. See #179
1 parent 004a086 commit 661bda8

File tree

5 files changed

+233
-5
lines changed

5 files changed

+233
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Change Log -- Ray Tracing in One Weekend
44
----------------------------------------------------------------------------------------------------
55
# v3.0.1 (in progress)
66

7+
- Fix: Display rendered images as pixelated instead of smoothed (#179)
78
- Change: delete old README files specific to each book (#410)
89

910

books/RayTracingInOneWeekend.html

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
Peter Shirley
88
edited by Steve Hollasch and Trevor David Black
99
<br>
10-
Version 3.0.0, 2020-Mar-23
10+
Version 3.0.1-wip, 2020-XXX-XX
1111
<br>
1212
Copyright 2018-2020 Peter Shirley. All rights reserved.
1313

@@ -130,8 +130,12 @@
130130
Opening the output file (in `ToyViewer` on my Mac, but try it in your favorite viewer and Google
131131
“ppm viewer” if your viewer doesn’t support it) shows this result:
132132

133+
<div class="render">
134+
133135
![First PPM image](../images/img.first-ppm-image.png)
134136

137+
</div>
138+
135139
</div>
136140

137141
<div class='together'>
@@ -473,8 +477,12 @@
473477

474478
with $t$ going from zero to one. In our case this produces:
475479

480+
<div class="render">
481+
476482
![A blue-to-white gradient depending on ray Y coordinate](../images/img.blue-to-white.png)
477483

484+
</div>
485+
478486
</div>
479487

480488

@@ -578,8 +586,12 @@
578586
<div class='together'>
579587
What we get is this:
580588

589+
<div class="render">
590+
581591
![A simple red sphere](../images/img.red-sphere.png)
582592

593+
</div>
594+
583595
</div>
584596

585597
Now this lacks all sorts of things -- like shading and reflection rays and more than one object --
@@ -651,8 +663,12 @@
651663
<div class='together'>
652664
And that yields this picture:
653665

666+
<div class="render">
667+
654668
![A sphere colored according to its normal vectors](../images/img.normals-sphere.png)
655669

670+
</div>
671+
656672
</div>
657673

658674
Let’s revisit the ray-sphere equation:
@@ -800,7 +816,7 @@
800816
the sphere, the normal will point outward, but if the ray is inside the sphere, the normal will
801817
point inward.
802818

803-
![Figure [normal-directions]: Possible directions for sphere surface-normal geometry](../images/fig.normal-possibilities.jpg)
819+
![Figure [normal-directions]: Possible directions for sphere surface-normal geometry](../images/fig.normal-possibilities.jpg)
804820

805821
</div>
806822

@@ -1145,8 +1161,12 @@
11451161
This yields a picture that is really just a visualization of where the spheres are along with their
11461162
surface normal. This is often a great way to look at your model for flaws and characteristics.
11471163

1164+
<div class="render">
1165+
11481166
![Resulting render of normals-colored sphere with ground](../images/img.normals-sphere-ground.png)
11491167

1168+
</div>
1169+
11501170
</div>
11511171

11521172

@@ -1326,8 +1346,12 @@
13261346
Zooming into the image that is produced, the big change is in edge pixels that are part background
13271347
and part foreground:
13281348

1349+
<div class="render">
1350+
13291351
![Close-up of antialiased pixels](../images/img.antialias.png)
13301352

1353+
</div>
1354+
13311355
</div>
13321356

13331357

@@ -1487,8 +1511,12 @@
14871511
<div class='together'>
14881512
This gives us:
14891513

1514+
<div class="render">
1515+
14901516
![First render of a diffuse sphere](../images/img.first-diffuse.jpg)
14911517

1518+
</div>
1519+
14921520
</div>
14931521

14941522
<div class='together'>
@@ -1525,8 +1553,12 @@
15251553
<div class='together'>
15261554
That yields light grey, as we desire:
15271555

1556+
<div class="render">
1557+
15281558
![Diffuse sphere, with gamma correction](../images/img.gamma-correct.jpg)
15291559

1560+
</div>
1561+
15301562
</div>
15311563

15321564
<div class='together'>
@@ -1601,8 +1633,12 @@
16011633
<div class='together'>
16021634
After rendering we get a similar image:
16031635

1636+
<div class="render">
1637+
16041638
![Correct rendering of Lambertian spheres](../images/img.correct-lambertian.png)
16051639

1640+
</div>
1641+
16061642
It's hard to tell the difference between these two diffuse methods, given that our scene of two
16071643
spheres is so simple, but you should be able to notice two important visual differences:
16081644

@@ -1677,8 +1713,12 @@
16771713

16781714
Gives us the following image:
16791715

1716+
<div class="render">
1717+
16801718
![Rendering of diffuse spheres with hemispherical scattering](../images/img.rand-hemispherical.png)
16811719

1720+
</div>
1721+
16821722
</div>
16831723

16841724
<div class='together'>
@@ -1979,8 +2019,12 @@
19792019
<div class='together'>
19802020
Which gives:
19812021

2022+
<div class="render">
2023+
19822024
![Shiny metal](../images/img.metal-shiny.png)
19832025

2026+
</div>
2027+
19842028
</div>
19852029

19862030
<div class='together'>
@@ -2029,8 +2073,12 @@
20292073
<div class='together'>
20302074
We can try that out by adding fuzziness 0.3 and 1.0 to the metals:
20312075

2076+
<div class="render">
2077+
20322078
![Fuzzed metal](../images/img.metal-fuzz.png)
20332079

2080+
</div>
2081+
20342082
</div>
20352083

20362084

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

2050-
![Image 10-1](../images/img.glass-first.png)
2098+
<div class="render">
2099+
2100+
![Glass first](../images/img.glass-first.png)
2101+
2102+
</div>
20512103

20522104
</div>
20532105

@@ -2144,7 +2196,11 @@
21442196
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21452197
[Listing [dielectric]: <kbd>[material.h]</kbd> Dielectric material class that always refracts]
21462198

2199+
<div class="render">
2200+
21472201
![Glass sphere that always refracts](../images/img.glass-always-refract.png)
2202+
2203+
</div>
21482204
</div>
21492205

21502206

@@ -2262,7 +2318,11 @@
22622318

22632319
We get:
22642320

2321+
<div class="render">
2322+
22652323
![Glass sphere that sometimes refracts](../images/img.glass-sometimes-refract.png)
2324+
2325+
</div>
22662326
</div>
22672327

22682328
<div class='together'>
@@ -2341,8 +2401,12 @@
23412401
<div class='together'>
23422402
This gives:
23432403

2404+
<div class="render">
2405+
23442406
![A hollow glass sphere](../images/img.glass-hollow.png)
23452407

2408+
</div>
2409+
23462410
</div>
23472411

23482412

@@ -2414,8 +2478,12 @@
24142478

24152479
gives:
24162480

2481+
<div class="render">
2482+
24172483
![A wide-angle view](../images/img.wide-view.png)
24182484

2485+
</div>
2486+
24192487
</div>
24202488

24212489
To get an arbitrary viewpoint, let’s first name the points we care about. We’ll call the position
@@ -2497,12 +2565,20 @@
24972565

24982566
to get:
24992567

2568+
<div class="render">
2569+
25002570
![A distant view](../images/img.view-distant.png)
25012571

2572+
</div>
2573+
25022574
And we can change field of view to get:
25032575

2576+
<div class="render">
2577+
25042578
![Zooming in](../images/img.view-zoom.png)
25052579

2580+
</div>
2581+
25062582
</div>
25072583

25082584

@@ -2639,8 +2715,12 @@
26392715

26402716
We get:
26412717

2718+
<div class="render">
2719+
26422720
![Spheres with depth-of-field](../images/img.depth-of-field.png)
26432721

2722+
</div>
2723+
26442724
</div>
26452725

26462726

@@ -2714,8 +2794,11 @@
27142794
<div class='together'>
27152795
This gives:
27162796

2797+
<div class="render">
2798+
27172799
![Final scene](../images/img.book1-final.jpg)
27182800

2801+
</div>
27192802
</div>
27202803

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

0 commit comments

Comments
 (0)