Refractive and Reflective Transparency

When light rays hit a transparent surface like glass or water, a fraction of the ray is reflected and the rest passes through the material. The transmitted ray is refracted according to the material's properties (refraction index).

In action

The case that a ray is refracted rather slightly is visible on the glass on the table, where the rays enter the material at quite straight angle.
On the water surface, the little waves reflect and refract in all directions because of the rough structure.


An earlier version of the glass. The effect of the fresnel term is clearly visible the outer areas.

Implementation idea

Every material has a transparency coefficient (the alpha value). If this value is < 1, the object is transparent and the transparent shader is used. When a ray hits a transparent material, two new rays are calculated: The reflected and the refracted ray.
The refracted ray either enters the material at the new refraction angle, given by solving the Snell's Law Equation, or if it leaves a dense material (ex. from water to air), it is reflected totally in the material. The reflected ray is just mirrored at the face normal.
The contribution of each of the two rays to the resulting color value is calculated by the Fresnel Term

Changes made