Friday, August 14, 2009

Refractions and more

Added a few basic objects to the raytracer. Now I can create point models of planes, spheres and cylinders with one function call.


Diffuse Sphere


But more importantly, Refraction finally works (I am guessing reflection will work too... but not tested yet). There is considerable aliasing right now.

Here are a few images of the refraction system at work:

9 spheres (1.5 seconds)



Intersecting spheres (2 seconds)



High resolution version (2000x2000, 12.38 seconds)


There are a few issues right now. One is that there seem to be a few rays 'leaking out through walls', due to which you can see black dots. The other is regarding rays that move parallel to the octree leaves. Such rays cannot move forward, because we cannot find their point of intersection with the octree. Adding a check for such rays only slows down the entire process, because such rays are very rare (in the images shown, they turn up as bright white spots). I am still looking for a solution to this issue.

In general, it seems that raytracing is quite hackish too... ie: a lot of messy tweaks are needed to get things working. For example, total internal reflection inside a sphere never terminates. I have a hack which prevents TIR completely, and instead allows the ray to pass through as though nothing ever happened. Then there is the issue of rays hitting overlapping splats which are nearby. Another hack which checks for a minimum distance between collisions, now allows me to avoid the 50 odd collisions that a ray would undergo, while moving through a sphere.

No comments:

Post a Comment