### Post by doug888 on Dec 31, 2019 18:12:38 GMT

Due to my own dyslexic abilities, and dancing with myself for days trying to figure out why the test in world.feature: "Shading an intersection from the inside" was failing, I figured out the issue, however, I would like to kindly suggest a remedy, and perhaps share the issue that was dogging me, and perhaps can help others.

In Ch 8 on page 115, discusses setting up the "over_point" attribute, and that we need to modify the "prepare_computations()" function that we created back in Ch7, "Making a Scene" on page 91.

Despite the comments:

# after computing and (if appropriate) negating

# the normal vector...

comps.over_point <- comps.point + comps.normalv * EPSILON

I placed this code ABOVE the aforementioned comment, like so:

comps.over_point <- comps.point + comps.normalv * EPSILON

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

Which yielded my issue with the test. Again, I must have missed the comment. Correcting, should be:

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

comps.over_point <- comps.point + comps.normalv * EPSILON

Which brings me to my observation...

I did recall when reading page 115, I was a bit puzzled ... and had to remember back to Ch7 page 94 ...which first gave the "prepare_computations" function as such:

function prepare_computations(intersection, ray)

# instantiate a data structure for storing some precomputed values

comps ← new computations data structure

# copy the intersection's properties, for convenience

comps.t ← intersection.t

comps.object ← intersection.object

# precompute some useful values

comps.point ← position(ray, comps.t)

comps.eyev ← -ray.direction

comps.normalv ← normal_at(comps.object, comps.point)

return comps

end function

THEN on page 95 describes adding the attribute "inside" and code:

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

and then in Ch8 page 115, describes adding the attribute "over_point" and the code:

# after computing and (if appropriate) negating

# the normal vector...

comps.over_point ← comps.point + comps.normalv * EPSILON

This chopped up instruction + my dyslexia is what gave me fits, which led to my getting the code order mixed up, and would kindly suggest perhaps having proper/complete pseudo code at the end of each chapter, in particular for the complete "prepare_computations" function to be like:

function prepare_computations(intersection, ray)

# instantiate a data structure for storing some precomputed values

comps ← new computations data structure

# copy the intersection's properties, for convenience

comps.t ← intersection.t

comps.object ← intersection.object

# precompute some useful values

comps.point ← position(ray, comps.t)

comps.eyev ← -ray.direction

comps.normalv ← normal_at(comps.object, comps.point)

# (from page 95)

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

#(from page 115)

# after computing and (if appropriate) negating

# the normal vector...

comps.over_point ← comps.point + comps.normalv * EPSILON

return comps

end function

This would have saved me days.

Kind Regards,

Doug

In Ch 8 on page 115, discusses setting up the "over_point" attribute, and that we need to modify the "prepare_computations()" function that we created back in Ch7, "Making a Scene" on page 91.

Despite the comments:

# after computing and (if appropriate) negating

# the normal vector...

comps.over_point <- comps.point + comps.normalv * EPSILON

I placed this code ABOVE the aforementioned comment, like so:

comps.over_point <- comps.point + comps.normalv * EPSILON

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

Which yielded my issue with the test. Again, I must have missed the comment. Correcting, should be:

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

comps.over_point <- comps.point + comps.normalv * EPSILON

Which brings me to my observation...

I did recall when reading page 115, I was a bit puzzled ... and had to remember back to Ch7 page 94 ...which first gave the "prepare_computations" function as such:

function prepare_computations(intersection, ray)

# instantiate a data structure for storing some precomputed values

comps ← new computations data structure

# copy the intersection's properties, for convenience

comps.t ← intersection.t

comps.object ← intersection.object

# precompute some useful values

comps.point ← position(ray, comps.t)

comps.eyev ← -ray.direction

comps.normalv ← normal_at(comps.object, comps.point)

return comps

end function

THEN on page 95 describes adding the attribute "inside" and code:

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

and then in Ch8 page 115, describes adding the attribute "over_point" and the code:

# after computing and (if appropriate) negating

# the normal vector...

comps.over_point ← comps.point + comps.normalv * EPSILON

This chopped up instruction + my dyslexia is what gave me fits, which led to my getting the code order mixed up, and would kindly suggest perhaps having proper/complete pseudo code at the end of each chapter, in particular for the complete "prepare_computations" function to be like:

function prepare_computations(intersection, ray)

# instantiate a data structure for storing some precomputed values

comps ← new computations data structure

# copy the intersection's properties, for convenience

comps.t ← intersection.t

comps.object ← intersection.object

# precompute some useful values

comps.point ← position(ray, comps.t)

comps.eyev ← -ray.direction

comps.normalv ← normal_at(comps.object, comps.point)

# (from page 95)

if dot(comps.normalv, comps.eyev) < 0

comps.inside ← true

comps.normalv ← -comps.normalv

else

comps.inside ← false

end if

#(from page 115)

# after computing and (if appropriate) negating

# the normal vector...

comps.over_point ← comps.point + comps.normalv * EPSILON

return comps

end function

This would have saved me days.

Kind Regards,

Doug