The material of a particular object determines the following:
- How/Whether the ray hitting an object is scattered.
- The level of attenuation in the scattered ray.
We already have a generic material class. Define a virtual function scatter in the material class.
Also, derive a class Metal from Material and implement the scatter function.
The scatter function can take in the following:
- A
HitInfo object. This is implemented in this PR. This should provide all the necessary information needed.
- The initial ray.
- References to the attenuation color and the scattered ray.
In the case of metals, the scatter function is quite straightforward. Just obtain the reflected ray according to the laws of reflections. That will be the scattered ray.
Thus, update the scattered ray. The attenuation color in the case of metal can be any color.
The material of a particular object determines the following:
We already have a generic material class. Define a virtual function
scatterin the material class.Also, derive a class Metal from Material and implement the
scatterfunction.The scatter function can take in the following:
HitInfoobject. This is implemented in this PR. This should provide all the necessary information needed.In the case of metals, the
scatterfunction is quite straightforward. Just obtain the reflected ray according to the laws of reflections. That will be the scattered ray.Thus, update the scattered ray. The attenuation color in the case of metal can be any color.