raytracing.github.io
raytracing.github.io copied to clipboard
[book2] listing 28 should go before generating images with spatial textures
In chapters 4.1 and 4.2 checker_texture is build and suddenly is used during creation of lambertian material (listing 24) without mentioning about it.
Looks like chapter 4.4 should go before generating scenes with checkered texture.
Duplicate of #663, fixed in dev-major branch for v4.0.0.
Ah, I mixed two issues, sorry for that. uv sphere texturing is indeed in the right order, but lambertian material change should go earlier.
Lambertian material is changed in the listing 28 but is used in the listing 23.
book1-review branch
Got it. Thanks for the catch.
The fix for this is to basically move
<div class='together'>
If we add this to our `random_scene()` function’s base sphere:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
void random_spheres(scene& scene_desc) {
...
hittable_list& world = scene_desc.world;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++ highlight
auto checker = make_shared<checker_texture>(0.32, color(.2, .3, .1), color(.9, .9, .9));
world.add(make_shared<sphere>(point3(0,-1000,0), 1000, make_shared<lambertian>(checker)));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
for (int a = -11; a < 11; a++) {
...
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[Listing [checker-example]: <kbd>[main.cc]</kbd> Checkered texture in use]
We get:

</div>
all the way to the bottom of 4.4 Texture Coordinates for Spheres
Went through book 2 progression to listing 34. Found issues (see #1446), but nothing like what was mentioned here. Looks like everything's fine in the dev branch.