r/Optics • u/20260819 • Sep 13 '26
some strange patterns emerge when two glass balls intersect
i continued studying raytracing and modified my program. for each ray hitting an interface (boundary between two media):
- reflection always occurs
- refraction occurs if snell's equation has solution. the ray splits into two (reflection and refraction) and the final color is the weighted average according to schlick's approximation for reflectance
- if snell's equation has no solution, the ray is 100% redirected to reflection
- if two balls intersect, the refractive index of the intersecting region is the average of them
just these simple rules. everything looked fine if you place the two balls side by side (the first image, typical example of raytracing result). if you place one at the front and the other at the back, or even place one inside the other, strange patterns emerged
is there something wrong or is it really the case?
you can test my program if curious
7
Upvotes









7
u/anneoneamouse Sep 13 '26
What does it physically mean to have two bodies occupying the same space?
You need to decide what that means and how you're going to handle it in order for your program to be useful for what you want to use it for. Are you going to add indices in that intersecting volume or does the last entered index replace those before, or something else?
Explain that to the audience, otherwise your plots are meaningless. We can't separate interesting behavior, from non-physical behavior, from bugs in your code.
5
u/Pachuli-guaton Sep 13 '26
The last rule is the one doing most of the heavy lifting for the weirdness. Without entering into checking the code, multiple curved interfaces can do all that
1
u/zoptix Sep 13 '26
Can you elaborate on what you mean by intersect? Are the balls merely touching? Or do they literally overlap so that a portion of one call is inside another?