|
Post by budgiep on Mar 5, 2024 2:43:29 GMT
Hello,
I just finished chapter 16 and tried making a dice CSG object by combining cylinders, spheres, and cubes via union to form a cube with smooth edges. To make the dimples in the dice surface I subtracted spheres from the cube surface.
My rendered image looked like this: This left me perplexed because the dice looks fine when the smooth cube is replaced with a regular cube and the object also looks good when using the union operation exclusively. After a day of digging around I think I found the root cause of the problem.
When a ray hits an open cylinder from a high angle, it only produces one intersection (this can also be true for any shape that does not enclose a volume; like a plane, for example). As this ray subsequently intersects with the sphere we would expect the sphere intersections to be filtered out in the intersection allowed function but they won't be because: - the left hit flag will be false and - the in left flag will be true which will pass the difference operator's validation conditions.
I tried setting all the cylinders in my smooth cube to be closed, to make the shape enclose its volume and the issue seemed to fix itself
However, this is only a work around for an underlying issue, which is the intersection allowed function seems to have the false assumption that every ray that intersects an object will eventually have another intersection as it leaves the object, which, as we can see, is not true.
Question: How should the intersection allowed function be modified to correctly handle this edge case.
Thanks, Ben
|
|
|
Post by budgiep on Mar 5, 2024 8:41:42 GMT
Here are some unit tests that demonstrate what I think the difference operation should do with a sphere subtracted from an open cylinder.
I'm not sure how you could change the intersection filtering in the CSG shape to make these pass
|
|