|
49 | 49 | interval that we want.
|
50 | 50 |
|
51 | 51 |
|
52 |
| -Updating The Ray Class to Track Time |
53 |
| -------------------------------------- |
| 52 | +Introduction of SpaceTime Ray Tracing |
| 53 | +-------------------------------------- |
54 | 54 | We can get a random estimate by sending each ray at some random time when the shutter is open. As
|
55 | 55 | long as the objects are where they should be at that time, we can get the right average answer with
|
56 | 56 | a ray that is at exactly a single time. This is fundamentally why random ray tracing tends to be
|
|
96 | 96 | </div>
|
97 | 97 |
|
98 | 98 |
|
99 |
| -Updating the Camera To Simulate Motion Blur |
| 99 | +Updating the Camera to Simulate Motion Blur |
100 | 100 | --------------------------------------------
|
101 | 101 | Now we need to modify the camera to generate rays at a random time between `time1` and `time2`.
|
102 | 102 | Should the camera keep track of `time1` and `time2` or should that be up to the user of camera when
|
|
166 | 166 | [Listing [time-camera]: <kbd>[camera.h]</kbd> Camera with time information]
|
167 | 167 |
|
168 | 168 |
|
169 |
| -Moving Objects |
170 |
| ---------------- |
| 169 | +Adding Moving Spheres |
| 170 | +---------------------- |
171 | 171 | We also need a moving object. I’ll create a sphere class that has its center move linearly from
|
172 | 172 | `center0` at `time0` to `center1` at `time1`. Outside that time interval it continues on, so those
|
173 | 173 | times need not match up with the camera aperture open and close.
|
|
251 | 251 | </div>
|
252 | 252 |
|
253 | 253 |
|
254 |
| -Tracking The Time Of Ray Intersection |
| 254 | +Tracking the Time of Ray Intersection |
255 | 255 | --------------------------------------
|
256 | 256 | <div class='together'>
|
257 | 257 | Be sure that in the materials you have the scattered rays be at the time of the incident ray.
|
|
377 | 377 | models.
|
378 | 378 |
|
379 | 379 |
|
380 |
| -Creating Bounding Volumes |
381 |
| --------------------------- |
| 380 | +The Key Idea |
| 381 | +------------- |
382 | 382 | <div class='together'>
|
383 | 383 | The key idea of a bounding volume over a set of primitives is to find a volume that fully encloses
|
384 | 384 | (bounds) all the objects. For example, suppose you computed a bounding sphere of 10 objects. Any ray
|
|
493 | 493 | </div>
|
494 | 494 |
|
495 | 495 |
|
496 |
| -Determining If a Ray Intersects an AABB |
497 |
| ----------------------------------------- |
| 496 | +Ray Intersection with an AABB |
| 497 | +------------------------------ |
498 | 498 | <div class='together'>
|
499 |
| -What the question “do the t intervals in the slabs overlap?” would look like in code is something |
500 |
| -like this: |
| 499 | +The following pseudocode determines whether the $t$ intervals in the slab overlap: |
501 | 500 |
|
502 | 501 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
503 | 502 | compute (tx0, tx1)
|
|
637 | 636 | </div>
|
638 | 637 |
|
639 | 638 |
|
640 |
| -Constructing Bounding Boxes For Hittables |
| 639 | +Constructing Bounding Boxes for Hittables |
641 | 640 | ------------------------------------------
|
642 | 641 | <div class='together'>
|
643 | 642 | We now need to add a function to compute the bounding boxes of all the hittables. Then we will make
|
|
1055 | 1054 | </div>
|
1056 | 1055 |
|
1057 | 1056 |
|
1058 |
| -Rendering A Scene With A Checkered Texture |
| 1057 | +Rendering a Scene with a Checkered Texture |
1059 | 1058 | -------------------------------------------
|
1060 | 1059 | <div class='together'>
|
1061 | 1060 | If we add a new scene:
|
|
1283 | 1282 | </div>
|
1284 | 1283 |
|
1285 | 1284 |
|
1286 |
| -Smoothing Out The Result |
| 1285 | +Smoothing out the Result |
1287 | 1286 | -------------------------
|
1288 | 1287 | <div class='together'>
|
1289 | 1288 | To make it smooth, we can linearly interpolate:
|
|
1342 | 1341 | </div>
|
1343 | 1342 |
|
1344 | 1343 |
|
1345 |
| -Another Approach to Smoothing |
1346 |
| ------------------------------- |
| 1344 | +Improvement with Hermitian Smoothing |
| 1345 | +------------------------------------- |
1347 | 1346 | <div class='together'>
|
1348 | 1347 | Smoothing yields an improved result, but there are obvious grid features in there. Some of it is
|
1349 | 1348 | Mach bands, a known perceptual artifact of linear interpolation of color. A standard trick is to use
|
|
1419 | 1418 | </div>
|
1420 | 1419 |
|
1421 | 1420 |
|
1422 |
| -Using Random Vectors On The Lattice Points |
| 1421 | +Using Random Vectors on the Lattice Points |
1423 | 1422 | -------------------------------------------
|
1424 | 1423 | <div class='together'>
|
1425 | 1424 | This is still a bit blocky looking, probably because the min and max of the pattern always lands
|
|
1669 | 1668 | record.
|
1670 | 1669 |
|
1671 | 1670 |
|
1672 |
| -Texture Coordinates For Spheres |
| 1671 | +Texture Coordinates for Spheres |
1673 | 1672 | --------------------------------
|
1674 | 1673 | For spheres, this is usually based on some form of longitude and latitude, _i.e._, spherical
|
1675 | 1674 | coordinates. So if we have a $(\theta,\phi)$ in spherical coordinates, we just need to scale
|
|
1787 | 1786 | [Listing [incl-stb-img]: Including the STB image package]
|
1788 | 1787 | </div>
|
1789 | 1788 |
|
| 1789 | + |
| 1790 | +Using an Image Texture |
| 1791 | +----------------------- |
1790 | 1792 | <div class='together'>
|
| 1793 | +I just grabbed a random earth map from the web -- any standard projection will do for our purposes. |
1791 | 1794 |
|
1792 | 1795 | <div class="render">
|
1793 | 1796 |
|
1794 | 1797 | 
|
1795 | 1798 |
|
1796 | 1799 | </div>
|
1797 | 1800 |
|
| 1801 | +</div> |
1798 | 1802 |
|
1799 |
| -Using An Image Texture |
1800 |
| ------------------------ |
1801 |
| -To read an image from a file earthmap.jpg (I just grabbed a random earth map from the web -- any |
1802 |
| -standard projection will do for our purposes), and then assign it to a diffuse material, the code |
1803 |
| -is: |
| 1803 | +<div class='together'> |
| 1804 | +Here's the code to read an image from a file and then assign it to a diffuse material: |
1804 | 1805 |
|
1805 | 1806 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
1806 | 1807 | hittable_list earth() {
|
|
1836 | 1837 |
|
1837 | 1838 | Rectangles and Lights
|
1838 | 1839 | ====================================================================================================
|
| 1840 | +Lighting is a key component of raytracing. Early simple raytracers used abstract light sources, like |
| 1841 | +points in space, or directions. Modern approaches have more physically-based lights, which have |
| 1842 | +position and size. To create such light sources, we need to be able to take any regular object and |
| 1843 | +turn it into something that emits light into our scene. |
| 1844 | + |
1839 | 1845 |
|
1840 | 1846 | Emissive Materials
|
1841 | 1847 | -------------------
|
|
1888 | 1894 | </div>
|
1889 | 1895 |
|
1890 | 1896 |
|
1891 |
| -Adding Background Color to The Ray Color Function |
| 1897 | +Adding Background Color to the Ray Color Function |
1892 | 1898 | --------------------------------------------------
|
1893 | 1899 | <div class='together'>
|
1894 | 1900 | Next, we want a pure black background so the only light in the scene is coming from the emitters. To
|
|
2013 | 2019 | </div>
|
2014 | 2020 |
|
2015 | 2021 |
|
2016 |
| -Turning Objects Into Lights |
| 2022 | +Turning Objects into Lights |
2017 | 2023 | ----------------------------
|
2018 | 2024 | <div class='together'>
|
2019 | 2025 | If we set up a rectangle as a light:
|
|
2154 | 2160 | </div>
|
2155 | 2161 |
|
2156 | 2162 |
|
2157 |
| -Creating An Empty “Cornell Box” |
| 2163 | +Creating an Empty “Cornell Box” |
2158 | 2164 | --------------------------------
|
2159 | 2165 | <div class='together'>
|
2160 | 2166 | The “Cornell Box” was introduced in 1984 to model the interaction of light between diffuse surfaces.
|
|
2740 | 2746 | handles arbitrary shapes, but we'll leave that as an exercise for the reader.
|
2741 | 2747 |
|
2742 | 2748 |
|
2743 |
| -Rendering a Cornell Box With Smoke and Fog Boxes |
| 2749 | +Rendering a Cornell Box with Smoke and Fog Boxes |
2744 | 2750 | -------------------------------------------------
|
2745 | 2751 | <div class='together'>
|
2746 | 2752 | If we replace the two blocks with smoke and fog (dark and light particles) and make the light bigger
|
|
0 commit comments