Post by Richard Moss on Aug 5, 2019 16:57:39 GMT
Hello,
I really wanted to properly test different obj files, but the speed of the ray tracer in debug mode was prohibitive. I worked my way through the first half of the bonus chapter on bounding boxes to see if I could speed things up.
I had all tests passing, so I fired up my program... and was greeted with an (almost) empty scene.
For my test render, I was using the nested CSG shape from page 229 of the book, along with a plane for a floor. The plane rendered, the CSG did not.
I started inspecting the bounding boxes for each shape and noted that if the CSG contained a cylinder, the bounding box for the CSG had the values NaN for Min.X, Min.Z, Max.X and Max.Z. If said CSG was itself nested, then the bounding box for the parent was NaN for all fields.
I "think" this is because multiplying either positive or negative infinity returns in NaN, so when calling Box.Transform multiplying the transform matrix returns a tuple containing NaN properties.
I tried some of my other preset scenes and YAML files and all rendered correctly, including my attempt at creating CSG dice which is using plenty of nested CSG's and groups. All are rendering fine, it's just CSG's containing cylinders, cones or planes that cause the NaN values. Replacing these with another shape in my CSG example renders perfectly. Groups were affected the same way. Removing all transforms from all objects had no effect.
Can anyone suggest what's going wrong? If it is caused by the NaN, how do I resolve it or is it a red herring and the problem lies elsewhere?
Regards;
Richard Moss
PS: I found a typo in the chapter text "CSG objects, being aggregate shapes like groups, should behave the same way, by reporting a bounding box sufficiently large to inculde their children." - inculde should be include.
I really wanted to properly test different obj files, but the speed of the ray tracer in debug mode was prohibitive. I worked my way through the first half of the bonus chapter on bounding boxes to see if I could speed things up.
I had all tests passing, so I fired up my program... and was greeted with an (almost) empty scene.
For my test render, I was using the nested CSG shape from page 229 of the book, along with a plane for a floor. The plane rendered, the CSG did not.
I started inspecting the bounding boxes for each shape and noted that if the CSG contained a cylinder, the bounding box for the CSG had the values NaN for Min.X, Min.Z, Max.X and Max.Z. If said CSG was itself nested, then the bounding box for the parent was NaN for all fields.
I "think" this is because multiplying either positive or negative infinity returns in NaN, so when calling Box.Transform multiplying the transform matrix returns a tuple containing NaN properties.
I tried some of my other preset scenes and YAML files and all rendered correctly, including my attempt at creating CSG dice which is using plenty of nested CSG's and groups. All are rendering fine, it's just CSG's containing cylinders, cones or planes that cause the NaN values. Replacing these with another shape in my CSG example renders perfectly. Groups were affected the same way. Removing all transforms from all objects had no effect.
Can anyone suggest what's going wrong? If it is caused by the NaN, how do I resolve it or is it a red herring and the problem lies elsewhere?
Regards;
Richard Moss
PS: I found a typo in the chapter text "CSG objects, being aggregate shapes like groups, should behave the same way, by reporting a bounding box sufficiently large to inculde their children." - inculde should be include.