Lambertian 类:
class Lambertian : public BxDF {
public:
// Lambertian Public Methods
Lambertian(const Spectrum &reflectance)
: BxDF(BxDFType(BSDF_REFLECTION | BSDF_DIFFUSE)), R(reflectance) { }
Spectrum f(const Vector &wo, const Vector &wi) const;
Spectrum rho(const Vector &, int, const float *) const { return R; }
Spectrum rho(int, const float *, const float *) const { return R; }
private:
// Lambertian Private Data
Spectrum R;
};
类的作用:
(模拟无光泽的材质)
One of the simplest BRDFs is the Lambertian model. It models a perfect diffuse surface
that scatters incident illumination equally in all directions. Although this reflection
model is not physically plausible, it is a good approximation to many real-world surfaces
such as matte paint.
1. 代码
Spectrum Lambertian::f(const Vector &wo, const Vector &wi) const {
return R * INV_PI;
}
Spectrum rho(const Vector &, int, const float *) const { return R; }
Spectrum rho(int, const float *, const float *) const { return R; }
作用:
(这里的 R 直接表示了 the fraction of incident light that is scattered,也就是 有百分之多少的 入射光 是散射的,注意的是
f 返回的值 是R/π,这个是可以证明)
The Lambertian constructor takes a reflectance spectrum R, which gives the fraction of
incident light that is scattered.
The reflection distribution function for Lambertian is quite straightforward, since its
value is constant. However, the value R/π must be returned, rather than R: the constructor
takes the BRDF’s reflectance; equating this to the earlier ρhd integral and solving
for the BRDF’s value demonstrates why this is the correct value to return for the BRDF.
The directional-hemispherical and hemispherical-hemispherical reflectance values for a
Lambertian BRDF are trivial to compute analytically, so the derivations are omitted here.