|
802 | 802 |
|
803 | 803 | ![Figure [normal-directions]: Possible directions for sphere surface-normal geometry](../images/fig.normal-possibilities.jpg) |
804 | 804 |
|
| 805 | +</div> |
| 806 | + |
805 | 807 | We need to choose one of these possibilities because we will eventually want to determine which |
806 | 808 | side of the surface that the ray is coming from. This is important for objects that are rendered |
807 | 809 | differently on each side, like the text on a two-sided sheet of paper, or for objects that have an |
|
883 | 885 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
884 | 886 | [Listing [hittable-time-side]: <kbd>[hittable.h]</kbd> The hittable class with time and side] |
885 | 887 |
|
| 888 | +<div class='together'> |
886 | 889 | And then we add the surface side determination to the class: |
887 | 890 |
|
888 | 891 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ |
|
1026 | 1029 |
|
1027 | 1030 | ## Common Constants and Utility Functions |
1028 | 1031 |
|
1029 | | -<div class='together'></div> |
| 1032 | +<div class='together'> |
1030 | 1033 | We need some math constants that we conveniently define in their own header file. For now we only |
1031 | 1034 | need infinity, but we will also throw our own definition of pi in there, which we will need later. |
1032 | 1035 | There is no standard portable definition of pi, so we just define our own constant for it. We'll |
|
1360 | 1363 | the chapter.) |
1361 | 1364 |
|
1362 | 1365 | <div class='together'> |
1363 | | -There are two unit radius spheres tangent to the hit point $p$ of a surface. These two spheres |
1364 | | -have a center of $(p + N)$ and $(p - N)$, where $N$ is the normal of the surface. The sphere with a |
1365 | | -center at $(p - N)$ is considered _inside_ the surface, whereas the sphere with center $(p + N)$ is |
1366 | | -considered _outside_ the surface. Select the tangent unit radius sphere that is on the same side of |
1367 | | -the surface as the ray origin. Pick a random point $s$ inside this unit radius sphere and send a |
1368 | | -ray from the hit point $p$ to the random point $s$: |
| 1366 | +There are two unit radius spheres tangent to the hit point $p$ of a surface. These two spheres have |
| 1367 | +a center of $(p + \vec{N})$ and $(p - \vec{N})$, where $\vec{N}$ is the normal of the surface. The |
| 1368 | +sphere with a center at $(p - \vec{N})$ is considered _inside_ the surface, whereas the sphere with |
| 1369 | +center $(p + \vec{N})$ is considered _outside_ the surface. Select the tangent unit radius sphere |
| 1370 | +that is on the same side of the surface as the ray origin. Pick a random point $s$ inside this unit |
| 1371 | +radius sphere and send a ray from the hit point $p$ to the random point $s$ (this is the vector |
| 1372 | +$(s-p)$): |
1369 | 1373 |
|
1370 | 1374 | ![Figure [rand-vector]: Generating a random diffuse bounce ray](../images/fig.rand-vector.jpg) |
1371 | 1375 |
|
|
2757 | 2761 |
|
2758 | 2762 | - Dave Hart |
2759 | 2763 | - Jean Buckley |
| 2764 | +</div> |
2760 | 2765 |
|
2761 | 2766 | <div class="credit-list"> **Web Release** |
2762 | 2767 |
|
|
0 commit comments