raytracing.github.io icon indicating copy to clipboard operation
raytracing.github.io copied to clipboard

[book2] listing 28 should go before generating images with spatial textures

Open genmeblog opened this issue 3 years ago • 4 comments

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.

genmeblog avatar May 02 '22 21:05 genmeblog

Duplicate of #663, fixed in dev-major branch for v4.0.0.

hollasch avatar May 03 '22 00:05 hollasch

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

genmeblog avatar May 03 '22 07:05 genmeblog

Got it. Thanks for the catch.

hollasch avatar May 03 '22 19:05 hollasch

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:

  ![Image 2: Spheres on checkered ground](../images/img-2.02-checker-ground.png class=pixel)

</div>

all the way to the bottom of 4.4 Texture Coordinates for Spheres

trevordblack avatar Jun 19 '23 21:06 trevordblack

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.

hollasch avatar Mar 21 '24 18:03 hollasch