PBRT_V2 总结记录 <39> MatteMaterial

MatteMaterial 类

// MatteMaterial Declarations
class MatteMaterial : public Material {
public:
    // MatteMaterial Public Methods
    MatteMaterial(Reference<Texture<Spectrum> > kd,
                  Reference<Texture<float> > sig,
                  Reference<Texture<float> > bump)
        : Kd(kd), sigma(sig), bumpMap(bump) {
    }
    BSDF *GetBSDF(const DifferentialGeometry &dgGeom,
                  const DifferentialGeometry &dgShading,
                  MemoryArena &arena) const;
private:
    // MatteMaterial Private Data
    Reference<Texture<Spectrum> > Kd;
    Reference<Texture<float> > sigma, bumpMap;
};

类的作用:

(Kd表示的 漫反射值,sigma 表示的是粗糙值(如果是0的话,使用 Lambertion BRDF,不是的话,使用 OrenNayar BRDF),还有一个可选的参数bumpMap,偏移法线用的,这些参数都是一张 Texture)

The MatteMaterial material is the simplest material in pbrt and describes a purely diffuse surface. It is parameterized
by a spectral diffuse reflection value, Kd, and a scalar roughness value, sigma. If sigma
has the value zero at the point on a surface, MatteMaterial returns a Lambertian BRDF;
otherwise, the OrenNayar model is used.
Like all of the other Material implementations in
this chapter, it also takes an optional scalar texture that defines an offset function over the
surface. If non-NULL, this texture is used to compute a shading normal at each point based
on the function it defines.

 

1. 

BSDF *GetBSDF(const DifferentialGeometry &dgGeom,
                  const DifferentialGeometry &dgShading,
                  MemoryArena &arena) const;

BSDF *MatteMaterial::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);

    // Evaluate textures for _MatteMaterial_ material and allocate BRDF
    Spectrum r = Kd->Evaluate(dgs).Clamp();
    float sig = Clamp(sigma->Evaluate(dgs), 0.f, 90.f);
    if (!r.IsBlack()) {
        if (sig == 0.)
            bsdf->Add(BSDF_ALLOC(arena, Lambertian)(r));
        else
            bsdf->Add(BSDF_ALLOC(arena, OrenNayar)(r, sig));
    }
    return bsdf;
}

作用:

(如果有 bump map 的话,就利用 bump 来计算 交点的新的法线出来,之后 传入 dgs 到 Kd 和 sigma Texture 中 ,计算出 交点在图片中的值,得到值之后,就可以判断使用 Lambertion  还是 OrenNayar )

If a bump map was provided to the MatteMaterial constructor, the Material::Bump()
method is called to calculate the shading normal at the point.
This method will be defined
in the next section.

Next, the Textures that give the values of the diffuse reflection coefficient and the roughness
are evaluated; these may return constant values, look up values from image maps, or
do complex procedural shading calculations to compute these values (the texture evaluation
process is the subject of Chapter 10). Given these values, all that needs to be done is
to allocate a BSDF and the appropriate BRDF component using the BSDF memory allocation
macros and return the result. Because Textures may return negative values or values
otherwise outside of the expected range,
these values are clamped before they are passed
to the BRDF constructor.

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值