Hello everyone!
The problem:
I’m currently making a path tracer, and I’m trying to get refractive materials to work. However, when I cast a ray from P1 (refracted ray), the issue in “Figure A” happens. And to get this properly working, I would need to somehow get the RaycastResult
which intersects the inward face at P2. I apologize in advance for my terrible drawing skills
My solution:
My idea is to cast the refracted ray with the magnitude of its direction equal to the magnitude of the part’s size, then cast another ray with the opposite direction of the refracted ray to intersect the outward face of the part at P2. The reason why it should be the magnitude of the part’s size is to not undershoot the part.
But this poses many drawbacks, such as being:
- inefficient and expensive
- more prone to floating point accuracy errors
- can intersect another intruding part on the opposite ray’s way back
- just really stupid.
Is there a way to avoid this issue? And is there any built-in methods on roblox which already do this? I would really appreciate if a graphics programmer who happened to make the raycasting functions come and magically fix all my problems