Post by mk on Jun 19, 2022 0:52:05 GMT
Hello, I have really been enjoying the book so far. I've run across a bit of a hurdle on the final part of chapter 8 using the same scene from the end of chapter 7. I've re-passed every test from chapters 1-8. The proper lighting that was present in my image at the end of chapter 7 is no longer appearing.
My code is here: github.com/matt-kerr/KerrEngine
The test is setup in KerrTester.cpp and debug can be toggled in KerrEngine.h.
For any given point my t values computed from World::isShadowed always end up negative or 0, causing the function to always return true. Here is some output from a random point (from the lower 80x60 image). Thank you in advance!
My code is here: github.com/matt-kerr/KerrEngine
The test is setup in KerrTester.cpp and debug can be toggled in KerrEngine.h.
For any given point my t values computed from World::isShadowed always end up negative or 0, causing the function to always return true. Here is some output from a random point (from the lower 80x60 image). Thank you in advance!
(x=40, y=18)
Camera::rayForPixel values:
xoffset = 0.584567
yoffset = 0.267024
world_x = -0.00721688
world_y = 0.165988
pixel = point(0.00725287, 1.56648, -3.98836, 1)
returning Ray:
origin = point(0, 1.5, -5, 1)
direction = vector(0.00715402, 0.0655783, 0.997847, 0)
World::colorAt entered function, calculating world/ray intersection
World::intersectWorld entered
World::intersectWorld testing sphere 1
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -1159.74, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 0
World::intersectWorld testing sphere 2
Ray::intersectSphere entered
Ray::intersectSphere a = 4907.37
Ray::intersectSphere b = -99069.4
Ray::intersectSphere c = 500000
Ray::intersectSphere discriminant = 18710
Ray::intersectSphere t1 = 10.08
Ray::intersectSphere t2 = 10.1079
Ray::intersectSphere exiting
World::intersectWorld curr.size() = 2
World::intersectWorld xs.size() = 2
World::intersectWorld testing sphere 3
Ray::intersectSphere entered
Ray::intersectSphere a = 5050.14
Ray::intersectSphere b = -100500
Ray::intersectSphere c = 500000
Ray::intersectSphere discriminant = 19262.6
Ray::intersectSphere t1 = 9.93649
Ray::intersectSphere t2 = 9.96398
Ray::intersectSphere exiting
World::intersectWorld curr.size() = 2
World::intersectWorld xs.size() = 4
World::intersectWorld testing sphere 4
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -0.117829, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 4
World::intersectWorld testing sphere 5
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -228.981, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 4
World::intersectWorld testing sphere 6
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -1458.08, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 4
World::intersectWorld after sort:
xs[0].t = 9.93649
xs[1].t = 9.96398
xs[2].t = 10.08
xs[3].t = 10.1079
World::intersectWorld exiting
World::colorAt xs.size() = 4
World::colorAt xs[0].t = 9.93649
World::colorAt xs[1].t = 9.96398
World::colorAt xs[2].t = 10.08
World::colorAt xs[3].t = 10.1079
Computations::prepareComputations returning
t = 9.93649
obj.material.color = color(1.000000, 1.000000, 1.000000)
point = point(0.0710858, 2.15162, 4.9151, 1)
eyev = vector(-0.00715402, -0.0655783, -0.997847, 0)
normalv = vector(-0.999977, 0.000311599, -1, 0)
inside = 0
World::colorAt i.t = 9.93649
World::colorAt comps.t = 9.93649
World::colorAt calculating shadeHit = 9.93649
World::shadeHit comps.t = 9.93649
World::isShadowed entered
World::intersectWorld entered
World::intersectWorld testing sphere 1
Ray::intersectSphere entered
Ray::intersectSphere a = 2168.48
Ray::intersectSphere b = 20038.7
Ray::intersectSphere c = 46293.9
Ray::intersectSphere discriminant = 946.064
Ray::intersectSphere t1 = -4.62754
Ray::intersectSphere t2 = -4.61336
Ray::intersectSphere exiting
World::intersectWorld curr.size() = 2
World::intersectWorld xs.size() = 2
World::intersectWorld testing sphere 2
Ray::intersectSphere entered
Ray::intersectSphere a = 413.037
Ray::intersectSphere b = 448.328
Ray::intersectSphere c = 120.698
Ray::intersectSphere discriminant = 1587.41
Ray::intersectSphere t1 = -0.590952
Ray::intersectSphere t2 = -0.49449
Ray::intersectSphere exiting
World::intersectWorld curr.size() = 2
World::intersectWorld xs.size() = 4
World::intersectWorld testing sphere 3
Ray::intersectSphere entered
Ray::intersectSphere a = 10989.1
Ray::intersectSphere b = 204.755
Ray::intersectSphere c = 0
Ray::intersectSphere discriminant = 41924.7
Ray::intersectSphere t1 = -0.0186325
Ray::intersectSphere t2 = 0
Ray::intersectSphere exiting
World::intersectWorld curr.size() = 2
World::intersectWorld xs.size() = 6
World::intersectWorld testing sphere 4
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -54.2343, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 6
World::intersectWorld testing sphere 5
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -2296.53, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 6
World::intersectWorld testing sphere 6
Ray::intersectSphere entered
Ray::intersectSphere discriminant = -8502.38, returning early
World::intersectWorld curr.size() = 0
World::intersectWorld xs.size() = 6
World::intersectWorld after sort:
xs[0].t = -4.62754
xs[1].t = -4.61336
xs[2].t = -0.590952
xs[3].t = -0.49449
xs[4].t = -0.0186325
xs[5].t = 0
World::intersectWorld exiting
World::isShadowed world.light.position = point(-10, 10, -10, 1)
World::isShadowed point = point(0.0710858, 2.15162, 4.9151, 1)
World::isShadowed v = vector(-10.0711, 7.84838, -14.9151, 0)
World::isShadowed distance = 16.854
World::isShadowed direction = vector(-0.597549, 0.465669, -0.884959, 0)
World::isShadowed xs.size() = 6
World::isShadowed xs[0].t = -4.62754
World::isShadowed xs[1].t = -4.61336
World::isShadowed xs[2].t = -0.590952
World::isShadowed xs[3].t = -0.49449
World::isShadowed xs[4].t = -0.0186325
World::isShadowed xs[5].t = 0
World::isShadowed ht_adj = 0
World::isShadowed returning true
World::shadeHit comps.t = 9.93649
World::shadeHit comps.point = point(0.0710858, 2.15162, 4.9151, 1)
World::shadeHit comps.over_point = point(0.0710858, 2.15162, 4.9151, 1)
World::shadeHit shadowed = 1
World::shadeHit returning color(0.100000, 0.100000, 0.100000)