Skip to content

Commit

Permalink
Render images pixelated instead of smoothed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hollasch committed Mar 24, 2020
1 parent 2460c2e commit 45e2811
Show file tree
Hide file tree
Showing 5 changed files with 238 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Change Log -- Ray Tracing in One Weekend
====================================================================================================

----------------------------------------------------------------------------------------------------
# v3.0.1 (In Progress)

- Fix: Display rendered images as pixelated instead of smoothed (#179)


----------------------------------------------------------------------------------------------------
# v3.0.0 (2020-03-23)

Expand Down
89 changes: 86 additions & 3 deletions books/RayTracingInOneWeekend.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Peter Shirley
edited by Steve Hollasch and Trevor David Black
<br>
Version 3.0.0, 2020-Mar-23
Version 3.0.1-wip, 2020-XXX-XX
<br>
Copyright 2018-2020 Peter Shirley. All rights reserved.

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

<div class="render">

![First PPM image](../images/img.first-ppm-image.png)

</div>

</div>

<div class='together'>
Expand Down Expand Up @@ -473,8 +477,12 @@

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

<div class="render">

![A blue-to-white gradient depending on ray Y coordinate](../images/img.blue-to-white.png)

</div>

</div>


Expand Down Expand Up @@ -578,8 +586,12 @@
<div class='together'>
What we get is this:

<div class="render">

![A simple red sphere](../images/img.red-sphere.png)

</div>

</div>

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

<div class="render">

![A sphere colored according to its normal vectors](../images/img.normals-sphere.png)

</div>

</div>

Let’s revisit the ray-sphere equation:
Expand Down Expand Up @@ -800,7 +816,7 @@
the sphere, the normal will point outward, but if the ray is inside the sphere, the normal will
point inward.

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

</div>

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

<div class="render">

![Resulting render of normals-colored sphere with ground](../images/img.normals-sphere-ground.png)

</div>

</div>


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

<div class="render">

![Close-up of antialiased pixels](../images/img.antialias.png)

</div>

</div>


Expand Down Expand Up @@ -1487,8 +1511,12 @@
<div class='together'>
This gives us:

<div class="render">

![First render of a diffuse sphere](../images/img.first-diffuse.jpg)

</div>

</div>

<div class='together'>
Expand Down Expand Up @@ -1525,8 +1553,12 @@
<div class='together'>
That yields light grey, as we desire:

<div class="render">

![Diffuse sphere, with gamma correction](../images/img.gamma-correct.jpg)

</div>

</div>

<div class='together'>
Expand Down Expand Up @@ -1601,8 +1633,12 @@
<div class='together'>
After rendering we get a similar image:

<div class="render">

![Correct rendering of Lambertian spheres](../images/img.correct-lambertian.png)

</div>

It's hard to tell the difference between these two diffuse methods, given that our scene of two
spheres is so simple, but you should be able to notice two important visual differences:

Expand Down Expand Up @@ -1677,8 +1713,12 @@

Gives us the following image:

<div class="render">

![Rendering of diffuse spheres with hemispherical scattering](../images/img.rand-hemispherical.png)

</div>

</div>

<div class='together'>
Expand Down Expand Up @@ -1979,8 +2019,12 @@
<div class='together'>
Which gives:

<div class="render">

![Shiny metal](../images/img.metal-shiny.png)

</div>

</div>

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

<div class="render">

![Fuzzed metal](../images/img.metal-fuzz.png)

</div>

</div>


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

![Image 10-1](../images/img.glass-first.png)
<div class="render">

![Glass first](../images/img.glass-first.png)

</div>

</div>

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

<div class="render">

![Glass sphere that always refracts](../images/img.glass-always-refract.png)

</div>
</div>


Expand Down Expand Up @@ -2262,7 +2318,11 @@

We get:

<div class="render">

![Glass sphere that sometimes refracts](../images/img.glass-sometimes-refract.png)

</div>
</div>

<div class='together'>
Expand Down Expand Up @@ -2341,8 +2401,12 @@
<div class='together'>
This gives:

<div class="render">

![A hollow glass sphere](../images/img.glass-hollow.png)

</div>

</div>


Expand Down Expand Up @@ -2414,8 +2478,12 @@

gives:

<div class="render">

![A wide-angle view](../images/img.wide-view.png)

</div>

</div>

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

to get:

<div class="render">

![A distant view](../images/img.view-distant.png)

</div>

And we can change field of view to get:

<div class="render">

![Zooming in](../images/img.view-zoom.png)

</div>

</div>


Expand Down Expand Up @@ -2639,8 +2715,12 @@

We get:

<div class="render">

![Spheres with depth-of-field](../images/img.depth-of-field.png)

</div>

</div>


Expand Down Expand Up @@ -2714,8 +2794,11 @@
<div class='together'>
This gives:

<div class="render">

![Final scene](../images/img.book1-final.jpg)

</div>
</div>

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

0 comments on commit 45e2811

Please sign in to comment.