About Path Tracer:
Path tracer is an
algorithm used to render realistic 3D scenes with global illumination.
In path tracer, huge number of rays are traced and random paths from the
point of intersection towards the light source are computed. Hence, it
requires computation of large number of rays, so computationally very
expensive. However, it is assumed that each ray path is independent,
hence, embarrassingly parallel. So, it makes sense to implement path
tracer in CUDA.
path tracer algorithm, any ray which does not intersect an object will
have zero contribution to the final image. Hence, does not require to be
traced again. Hence, I used stream compaction in order to reduce the
traversal of such rays with each iterations. Thus, reducing the
computation time considerably.
In this post, I am explaining the method used to implement refraction and reflection in the path tracer and some results.
Added the refraction.
calculated the refraction using the snell's law. Snell's law is the
formula that describes the relationship between angle of incidence and
refraction, when a ray of light passes from one material to another. The
actual science behind it is explained in below image:
Better image, without noise:
I also added Reflection today.
ray is reflected from the reflective surface at an angle equal to the
angle between the incident ray and the normal to the surface. The
reflected direction can be calculated using the formula:
Reflected direction = incident - 2.0 * dot(normal, incident) * normal ;
Fresnel equation is solved using the wikipedia link.