PBRT_V2 總結記錄 SubsurfaceMaterial 和 KdSubsurfaceMaterial
SubsurfaceMaterial 和 KdSubsurfaceMaterial
There are two Materials for translucent objects: SubsurfaceMaterial,KdSubsurfaceMaterial,The only difference
between these two materials is how the scattering properties of the medium are
specified.
SubsurfaceMaterial 類
class SubsurfaceMaterial : public Material { public: // SubsurfaceMaterial Public Methods SubsurfaceMaterial(float sc, Reference<Texture<Spectrum> > kr, Reference<Texture<Spectrum> > sa, Reference<Texture<Spectrum> > sps, Reference<Texture<float> > e, Reference<Texture<float> > bump) { scale = sc; Kr = kr; sigma_a = sa; sigma_prime_s = sps; eta = e; bumpMap = bump; } BSDF *GetBSDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading, MemoryArena &arena) const; BSSRDF *GetBSSRDF(const DifferentialGeometry &dgGeom, const DifferentialGeometry &dgShading, MemoryArena &arena) const; private: // SubsurfaceMaterial Private Data float scale; Reference<Texture<Spectrum> > Kr, sigma_a, sigma_prime_s; Reference<Texture<float> > eta, bumpMap; };
類的作用:
(利用Texture來儲存 volumetric 散射屬性,而且有 高光反射 Kr ,在incident ray 不進入 medium 的時候,使用 Kr)
SubsurfaceMaterial stores textures that allow the scattering properties to vary as a function
of the position on the surface. Note that this isn’t the same as scattering properties
that vary as a function of 3D inside the scattering medium, but it can give a reasonable
approximation to heterogeneous media in some cases.
In addition to the volumetric scattering properties, a specular reflection term Kr accounts
for specular reflection from incident rays that don’t enter the medium due to the different
indices of refraction at the boundary. The SubsurfaceMaterial::GetBSDF() method adds
a SpecularReflection component to the BSDF if Kr isn’t black.
1. BSDF *GetBSDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading,
MemoryArena &arena) const;
BSDF *SubsurfaceMaterial::GetBSDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading, MemoryArena &arena) const {
// Allocate _BSDF_, possibly doing bump mapping with _bumpMap_
DifferentialGeometry dgs;
if (bumpMap)
Bump(bumpMap, dgGeom, dgShading, &dgs);
else
dgs = dgShading;
BSDF *bsdf = BSDF_ALLOC(arena, BSDF)(dgs, dgGeom.nn);
Spectrum R = Kr->Evaluate(dgs).Clamp();
float e = eta->Evaluate(dgs);
if (!R.IsBlack())
bsdf->Add(BSDF_ALLOC(arena, SpecularReflection)(R,
BSDF_ALLOC(arena, FresnelDielectric)(1., e)));
return bsdf;
}
作用:
The SubsurfaceMaterial::GetBSDF() method adds a SpecularReflection component to the BSDF if Kr isn’t black.
2. BSSRDF *GetBSSRDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading,
MemoryArena &arena) const;
BSSRDF *SubsurfaceMaterial::GetBSSRDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading, MemoryArena &arena) const {
float e = eta->Evaluate(dgShading);
return BSDF_ALLOC(arena, BSSRDF)(scale * sigma_a->Evaluate(dgShading),
scale * sigma_prime_s->Evaluate(dgShading), e);
}
作用:
(計算一個點的 在Texture的 散射屬性)
The SubsurfaceMaterial::GetBSSRDF() method uses the textures to compute the values
of the scattering properties at the point. The absorption and reduced scattering coefficients
are then scaled by the scale member variable, which provides an easy way to
change the units of the scattering properties. (Recall that they’re expected to be specified
in terms of reciprocal distance measured in meters, m−1. If the scene isn’t modeled in
meters, the scattering properties can be adjusted accordingly.)
KdSubsurfaceMaterial 類
class KdSubsurfaceMaterial : public Material {
public:
// KdSubsurfaceMaterial Public Methods
KdSubsurfaceMaterial(Reference<Texture<Spectrum> > kd,
Reference<Texture<Spectrum> > kr,
Reference<Texture<float> > mfp,
Reference<Texture<float> > e,
Reference<Texture<float> > bump) {
Kd = kd;
Kr = kr;
meanfreepath = mfp;
eta = e;
bumpMap = bump;
}
BSDF *GetBSDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading,
MemoryArena &arena) const;
BSSRDF *GetBSSRDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading,
MemoryArena &arena) const;
private:
// KdSubsurfaceMaterial Private Data
Reference<Texture<Spectrum> > Kd, Kr;
Reference<Texture<float> > meanfreepath, eta, bumpMap;
};
BSSRDF *KdSubsurfaceMaterial::GetBSSRDF(const DifferentialGeometry &dgGeom,
const DifferentialGeometry &dgShading,
MemoryArena &arena) const {
float e = eta->Evaluate(dgShading);
float mfp = meanfreepath->Evaluate(dgShading);
Spectrum kd = Kd->Evaluate(dgShading).Clamp();
Spectrum sigma_a, sigma_prime_s;
SubsurfaceFromDiffuse(kd, mfp, e, &sigma_a, &sigma_prime_s);
return BSDF_ALLOC(arena, BSSRDF)(sigma_a, sigma_prime_s, e);
}
作用:
(SubsurfaceMaterial 如果使用 absorption 和 reduced scattering coefficients 來實現一個 自己想要的效果的話,有點困難,也不直觀,所以就引入了 KdSubsurfaceMaterial ,KdSubsurfaceMaterial 允許 使用者 根據 the diffuse reflectance of the surface 和 the mean free path 指定 表面下的散射屬性,它使用 SubsurfaceFromDiffuse() 來計算對應的 intrinsic(內在) scattering properties)
Directly setting the absorption and reduced scattering coefficients to achieve a desired
visual look is difficult. The parameters have a nonlinear and unintuitive(不直觀) effect on the
result.
The KdSubsurfaceMaterial allows the user to specify the subsurface(表面下的) scattering
properties in terms of(根據) the diffuse reflectance of the surface and the mean free path—
the average distance light travels in the medium before scattering.
It then uses the SubsurfaceFromDiffuse() utility function, defined in Section 16.5, to compute the corresponding
intrinsic(內在) scattering properties.
Being able to specify translucent materials
in this manner is particularly useful in that it makes it possible to use standard texture
maps that might otherwise be used for diffuse reflection to define scattering properties
(again with the caveat that varying properties on the surface don’t properly correspond
to varying properties in the medium).
Finally, GetVolumeScatteringProperties() is a utility function that has a small library of
measured scattering data for translucent materials; it returns the corresponding scattering
properties if it has an entry for the given name. (For a list of the valid names, see the
implementation in core/volume.cpp.) The data provided by this function is from papers
by Jensen et al. (2001b) and Narasimhan et al. (2006).
(GetVolumeScatteringProperties 在 CreateSubsurfaceMaterial 呼叫)
1. SubsurfaceFromDiffuse 解釋待續以後16章