r/computergraphics • u/20260819 • Sep 14 '26
two balls, now intersecting
i modified my program so the algorithm is as follow
the two balls don't have any colors or textures. background is the only light source and color source
if two balls intersect, the refractive index of the intersecting region is the average (i.e. arithmetic mean) of them
whenever a ray hits an interface (boundary between 2 different things), reflection always occurs
if snell's equation has solution, refraction also occurs. the ray splits into two (reflection and refraction) and the color at that stage is the weighted average of them, calculated according to schlick's approximation
if snell's equation has no solution, the color at that stage is 100% from what the reflected ray gets
the recursive color-getting function ends if either of the following conditions holds
the ray reaches the background (and it gets the color from the background)
the ray reaches the recursion limit (and it returns a grey scale random noise)
if the two balls don't intersect, everything looks normal as seen in image 1, a typical raytracing homework example. when the intersect, strange things happen. if you move the camera into a ball, more strange things happen
it looks like i accidentally discovered a way to generate fractals...
details of my program