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

[Book Next Week ]: Earth image texture viewing parameters don't match the code

Open D-K-E opened this issue 3 years ago • 4 comments

The listing 47 specifies the viewing parameters for the image texture as:

world = earth();
lookfrom = point3(13,2,3);
lookat = point3(0,0,0);
vfov = 20.0;

These parameters give something like the following: earth02

For awhile I thought there was a problem in the rendering code, but apparently the source code specifies different parameters:

world = earth();
background = color(0.70, 0.80, 1.00);
lookfrom = point3(0,0,12);
lookat = point3(0,0,0);
vfov = 20.0;

The white parts in the image correspond probably the white parts in the .jpg image. Once I used the parameters in the source code, I got the correct image.

D-K-E avatar Oct 20 '21 23:10 D-K-E

!!! The parameterization is obviously also messed up. Ugh.

hollasch avatar Oct 20 '21 23:10 hollasch

I have only just got image mapping to work in the "earth" world, although it always worked in the "final image". Weird huh?

I finally got it to work by changing the background to the light cyan colour instead of black; if I choose a black background that is all I see. Layers? No, I changed the order in code and got the same result.

Additionally, as a newbie to c++ I was puzzled by this line (288 in main.cc as we speak)

color background(0,0,0);

which makes no sense to me, and works without the parenthesis or their contents anyway!

So, I couldn't get image mapping to work, then I did but I don't know why what I did made any difference!

m4r35n357 avatar Feb 22 '22 14:02 m4r35n357

Regarding color background(0,0,0), this declares & defines a variable named background of type color. Implicitly, color values are initialized black (0,0,0), but we explicitly initialize here to make the color clear when reading the code.

hollasch avatar Mar 05 '22 19:03 hollasch

Thank you!

m4r35n357 avatar Mar 05 '22 20:03 m4r35n357

Just double-checked the earth rendering from ±Z, ±X, and ±Y. All looked correct, and I verified that the listing in the book matches the source code. Looks like this has been fixed somewhere along the line. Also, if there was an issue with the sphere parameterization, it also appears to be fixed now.

Ah! This was fixed coincidentally with commit 8b228b03b7f234c77b11317c1ec28364b033176e, rolling out the new scene class. See PR #811.

hollasch avatar May 11 '23 06:05 hollasch