-
Notifications
You must be signed in to change notification settings - Fork 945
Description
Currently, we implement bubbles (or transparent spheres with non-zero thickness) by specifying an inner sphere of negative radius. It's a hack that works, but creates several geometric issues that then need to be special-cased. Here are some issues dealing with this:
- Determination of normal direction in geometry hit function #270
- Sphere Bounding Box: Artifact for negative radius. #532
bvh_node
is broken with negative-radius spheres #733- Book 2 Section 3.7 AABB surrounding box calculation incorrect for hollow glass sphere #899
- Sphere normal calculation confusion #977
- AABB and BVH can not process a sphere containing a smaller sphere inside correctly. #1130
- [Book1] A hollow glass sphere #1278
However, there's a much cleaner way to address this. Instead of having dielectric
take an index of refraction for the single construction parameter, it should take the ratio of the inner index of refraction over the outer index of refraction. Since air is considered to have an index of refraction of 1.00, the resulting value is the same most materials, where the index of refraction is greater then 1.00. However, this means that bubbles (say of air inside glass) can be specified with a ratio of 1.00 over the index of refraction of the object material (that is, modeling a bubble of air, instead of a bubble of negative glass).
Tests show that the results are identical. To model a hollow glass sphere of non-zero thickness (implicitly filled with air), current code defines an inside sphere as having a negative radius, with an index of refraction of glass. If we change this to have an inside sphere of positive (but smaller) radius, with an index of refraction of 0.67 (= 1 / IOR_glass), then we get identical results. If we follow this approach, then we can eliminate the need to handle or special-case spheres of negative radii.
Before, with negative-radius bubble, IOR of glass:
After, with positive-radius bubble, IOR of 1/glass:
(Note that Vassillen Chizhov (@vchizhov) has already made this suggestion parenthetically here: #270 (comment).)
If this work is done, I suggest we either take the absolute value of sphere radii in the constructor, or throw an exception for negative radii or something. Following that, remove the negative-radius hack from the text.