Refraction for rays in transparent material

Yesterday we realized we havn't implemented refraction yet, so I decided to try it out.
Refraction is when waves hits a denser/lighter material and the wave changes direction ever so slightly.
Example is when you look through a glass ball and the object behind the glass ball gets distorted.

After some research of how refraction works i implemented it using snells law wich is the formula to calculate how waves refract when crossing another material.

The refraction is not perfect, and I probably don't have the time to fix it either. But for now it looks pretty close to the real world equivalent for glass.
 
Glass pawn in front of a KTH emblem.
 
Glass ball in front of a KTH emblem.

Comments

Popular posts from this blog

Specular reflection and Phong shading/lighting