In this assignment we had to model glass and metal.
A realistic and inexpensive model for reflection is given by Fernet
equation:-
R(lambda) = R0(lambda) + (1-R(lambda))*(1-cos(theta))^5
where:-
R(lambda) is the fraction of incident light reflected
lambda = wavelength of incident light
R0(lambda) is a function characteristic of the reflecting surface andis
define as the fraction of light reflected when the incident ray is normal
to the surface.
theta is the angle of incidence.
The model for refraction for a ray entering material o from a material
i is:-
n_o/n_i = sin(theta_i)/sin(theta_o)
where n is the refractive index of a material.
When a ray hits a metallic surface, we shoot a reflected ray which returns a spectrum say S. Multiplying the spectrum with R(lambda) of the metal give the resultant color at that point.
When a ray hits a glass surface, we need to shoot 2 rays - the reflected
and the refracted ray and add their contribution
Care should be taken to take total internal reflection into account.
In the images generated below, n for glass is fixed as 1.5
The rays are attenuated towards the green spectrum when they pas through
glass, hence the greenish tinge.
The metal is copper. Since there is no lighting model used(only ambient
light), the metal looks very unrealistic.
Below is an image of 3 glass balls, 1 copper slab and 2 glass sheets
Pinhole Camera
Position: (0 , 0 , 2.1)
Lookat : (1.5 , 1.5 , 0)
Field of View: 90 degrees
16 samples per pixel