PBRT_V2 总结记录 <40> PlasticMaterial

PlasticMaterial 类

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

作用:

(塑料材质,是混合 diffuse 和 glossy 来 模拟塑料的,Kd 和 Ks主要是控制 diffuse 和 glossy的反射率,而roughness控制的是高光的大小)

Plastic(塑料) can be modeled as a mixture of a diffuse and glossy scattering function with
parameters controlling the particular colors and specular highlight size
. The parameters
to PlasticMaterial are two reflectivities, Kd and Ks, which respectively control the
amounts of diffuse reflection and glossy specular reflection. Next is a roughness parameter
(which ranges from zero to one) that determines the size of the specular highlight;
the
higher the roughness value, the larger the highlight.

 

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

BSDF *PlasticMaterial::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 kd = Kd->Evaluate(dgs).Clamp();
    if (!kd.IsBlack()) {
        BxDF *diff = BSDF_ALLOC(arena, Lambertian)(kd);
        bsdf->Add(diff);
    }
    Spectrum ks = Ks->Evaluate(dgs).Clamp();
    if (!ks.IsBlack()) {
        Fresnel *fresnel = BSDF_ALLOC(arena, FresnelDielectric)(1.5f, 1.f);
        float rough = roughness->Evaluate(dgs);
        BxDF *spec = BSDF_ALLOC(arena, Microfacet)
                       (ks, fresnel, BSDF_ALLOC(arena, Blinn)(1.f / rough));
        bsdf->Add(spec);
    }
    return bsdf;
}

作用:

(先判断是否使用 Bump,再判断相交点是否有Diffuse,有的话就直接添加 Lambertion,之后再判断是否有Glossy,有的话就直接添加 Microfacet,用Blinn作为 D函数,FresnelDielectric 作为F函数)

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值