-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlambertian.h
36 lines (34 loc) · 932 Bytes
/
lambertian.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#ifndef LAMBERTIAN_H
#define LAMBERTIAN_H
#include "material.h"
/*! Lambertian diffuse (matte) type Material. */
class Lambertian : public Material {
public:
/** Create Lambertian Material for object with specified Vector3D color.
*
* Example:
*
* Lambertian(Vector3D(1, 0, 0));
*/
Lambertian(const Vector3D& a) : m_vAlbedo(a) {}
virtual bool Scatter(const Ray &r_in, const HitRecord &rec, Vector3D &attenuation, Ray &scattered) const {
Vector3D vTarget = rec.m_vP + rec.m_vNormal + RandomInUnitSphere();
scattered = Ray(rec.m_vP, vTarget - rec.m_vP);
attenuation = m_vAlbedo;
return true;
}
virtual int MatType() const {
return 0;
}
virtual Vector3D MatColor() const {
return m_vAlbedo;
}
virtual double MatFuzz() const {
return 0;
}
virtual double MatRef() const {
return 0;
}
Vector3D m_vAlbedo; //!< Vector3D attenuation of light absorbed or reflected from Object.
};
#endif // LAMBERTIAN_H