|
380 | 380 | <kbd>[main.cc]</kbd> Last book's final scene, but with moving spheres]
|
381 | 381 | </div>
|
382 | 382 |
|
383 |
| -gives the following result: |
| 383 | +<div class='together'> |
| 384 | +This gives the following result: |
384 | 385 |
|
385 | 386 | 
|
386 | 387 |
|
|
1428 | 1429 | [Listing [get-sphere-uv-call]: <kbd>[sphere.h]</kbd> Sphere UV coordinates from hit]
|
1429 | 1430 | </div>
|
1430 | 1431 |
|
1431 |
| -<div class='together'> |
1432 |
| - |
1433 | 1432 | <div class='together'>
|
1434 | 1433 | Now we can make textured materials by replacing the `const color& a` with a texture pointer:
|
1435 | 1434 |
|
|
2008 | 2007 | [Listing [scale-perlin]: <kbd>[main.cc]</kbd> Perlin-textured spheres with a scale to the noise]
|
2009 | 2008 | </div>
|
2010 | 2009 |
|
2011 |
| -which gives: |
| 2010 | + |
| 2011 | +<div class='together'> |
| 2012 | +This yields the following result: |
2012 | 2013 |
|
2013 | 2014 | 
|
2014 | 2015 |
|
|
2302 | 2303 |
|
2303 | 2304 | ![Figure [quad-def]: Quadrilateral Components](../images/fig-2.05-quad-def.jpg)
|
2304 | 2305 |
|
| 2306 | +<div class='together'> |
2305 | 2307 | Quads are flat, which means that their axis-aligned bounding box can have zero thickness in one
|
2306 | 2308 | dimension (if the quad lies in one of the XY, YZ, or ZX planes). This can lead to numerical problems
|
2307 | 2309 | with ray intersection, but we can address this by padding any zero-sized dimensions of the bounding
|
|
2331 | 2333 | }
|
2332 | 2334 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2333 | 2335 | [Listing [aabb]: <kbd>[aabb.h]</kbd> New aabb::pad() method]
|
| 2336 | +</div> |
2334 | 2337 |
|
| 2338 | +<div class='together'> |
2335 | 2339 | Now we're ready for the first sketch of the new `quad` class:
|
2336 | 2340 |
|
2337 | 2341 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
|
2370 | 2374 | #endif
|
2371 | 2375 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2372 | 2376 | [Listing [quad]: <kbd>[quad.h]</kbd> 2D quadrilateral (parallelogram) class]
|
| 2377 | +</div> |
2373 | 2378 |
|
2374 | 2379 |
|
2375 | 2380 | Ray-Plane Intersection
|
|
2873 | 2878 |
|
2874 | 2879 | Adding Background Color to the Ray Color Function
|
2875 | 2880 | --------------------------------------------------
|
2876 |
| -<div class='together'> |
2877 | 2881 | Next, we want a pure black background so the only light in the scene is coming from the emitters. To
|
2878 | 2882 | do this, we’ll add a background color parameter to our `ray_color` function, and pay attention to
|
2879 | 2883 | the new `emitted` value.
|
|
2946 | 2950 | bluish-white for the whole sky. You could always pass in a boolean to switch between the previous
|
2947 | 2951 | skybox code versus the new solid color background. We're keeping it simple here.
|
2948 | 2952 |
|
2949 |
| -</div> |
2950 |
| - |
2951 | 2953 |
|
2952 | 2954 | Turning Objects into Lights
|
2953 | 2955 | ----------------------------
|
|
3349 | 3351 | 3. Change the intersection point from object space to world space
|
3350 | 3352 |
|
3351 | 3353 |
|
3352 |
| -<div class='together'> |
3353 | 3354 | Rotating an object will not only change the point of intersection, but will also change the surface
|
3354 | 3355 | normal vector, which will change the direction of reflections and refractions. So we need to change
|
3355 | 3356 | the normal as well. Fortunately, the normal will rotate similarly to a vector, so we can use the
|
|
3409 | 3410 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
3410 | 3411 | [Listing [rot-y-hit]: <kbd>[hittable.h]</kbd> Hittable rotate-Y hit function]
|
3411 | 3412 |
|
3412 |
| -</div> |
3413 | 3413 | ... and now for the rest of the class:
|
3414 | 3414 |
|
3415 | 3415 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
|
|
3528 | 3528 | $$ \text{probability} = C \cdot \Delta L $$
|
3529 | 3529 | </div>
|
3530 | 3530 |
|
3531 |
| -<div class='together'> |
3532 | 3531 | where $C$ is proportional to the optical density of the volume. If you go through all the
|
3533 | 3532 | differential equations, for a random number you get a distance where the scattering occurs. If that
|
3534 | 3533 | distance is outside the volume, then there is no “hit”. For a constant volume we just need the
|
|
3612 | 3611 | #endif
|
3613 | 3612 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
3614 | 3613 | [Listing [const-med-class]: <kbd>[constant_medium.h]</kbd> Constant medium class]
|
3615 |
| -</div> |
3616 | 3614 |
|
3617 | 3615 | <div class='together'>
|
3618 | 3616 | The scattering function of isotropic picks a uniform random direction:
|
|
3650 | 3648 |
|
3651 | 3649 | Rendering a Cornell Box with Smoke and Fog Boxes
|
3652 | 3650 | -------------------------------------------------
|
3653 |
| -<div class='together'> |
3654 | 3651 | If we replace the two blocks with smoke and fog (dark and light particles), and make the light
|
3655 | 3652 | bigger (and dimmer so it doesn’t blow out the scene) for faster convergence:
|
3656 | 3653 |
|
|
3717 | 3714 | }
|
3718 | 3715 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
3719 | 3716 | [Listing [cornell-smoke]: <kbd>[main.cc]</kbd> Cornell box, with smoke]
|
3720 |
| -</div> |
3721 | 3717 |
|
3722 | 3718 | <div class='together'>
|
3723 | 3719 | We get:
|
|
0 commit comments