PBRT_V2 总结记录 <38> Material 和 Intersection->GetBSDF

Material 类

class Material : public ReferenceCounted {
public:
    // Material Interface
    virtual BSDF *GetBSDF(const DifferentialGeometry &dgGeom,
                          const DifferentialGeometry &dgShading,
                          MemoryArena &arena) const = 0;
    virtual BSSRDF *GetBSSRDF(const DifferentialGeometry &dgGeom,
                              const DifferentialGeometry &dgShading,
                              MemoryArena &arena) const {
        return NULL;
    }
    virtual ~Material();
    static void Bump(const Reference<Texture<float> > &d, const DifferentialGeometry &dgGeom,
        const DifferentialGeometry &dgShading, DifferentialGeometry *dgBump);
};

类的作用:

(Material 是所有材质的基类,继承Material的类要实现 Material::GetBSDF() 和 Material::GetBSSRDF(),这两个方法主要负责确定 面上一个点 的反射属性,并且返回这个点的BSDF或者BSSRDF)

The abstract Material class defines two methods that material implementations must
provide, Material::GetBSDF() and Material::GetBSSRDF(). Implementations of these
methods are responsible for determining the reflective properties at the given point on
the surface and returning an instance of the BSDF class that describes them.

 

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

作用:

(dgGeom 表示的是 实际上 交点的几何信息,dgShading 表示的是,可能平滑过后的 交点的几何信息)

The Material::GetBSDF() method is given two differential geometry objects. The first,
dgGeom, represents the actual differential geometry at the ray intersection point, and the
second, dgShading, represents possibly perturbed(扰乱) shading geometry, such as that from
per-vertex normals in a triangle mesh. The material implementation may further perturb(扰乱)
the shading geometry with bump mapping in the GetBSDF() method; the returned BSDF
holds information about the final shading geometry at the point as well as the BRDF and
BTDF components for the point.

 

细节:

BSDF *GeometricPrimitive::GetBSDF(const DifferentialGeometry &dg,
                                  const Transform &ObjectToWorld,
                                  MemoryArena &arena) const {
    DifferentialGeometry dgs;
    shape->GetShadingGeometry(ObjectToWorld, dg, &dgs);
    return material->GetBSDF(dg, dgs, arena);
}

看 GeometricPrimitive 的GetBSDF方法,里面是调用material的GetBSDF方法,在调用material的GetBSDF方法之前,会先进行shape->GetShadingGeometry方法,这个GetShadingGeometry方法在之前的《PBRT_V2 总结记录 <7> Shape》中有提及,主要的作用就是:

通过DifferentialGeometry 可以得到更加平滑,更加准确的数据, 例如Triangle,在Intersect中计算得到的DifferentialGeometry的dpdu,dpdv, 其实就是自动计算的,但是,有时候Triangle 有可能自身提供了法线(dpdu)和切线(dpdv)的数据, 那么GetShadingGeometry 就是 抛弃了自动计算的dpdu,dpdv,利用重心坐标插值提供的法线和切线数据,重新生成 更加合适的 法线(dpdu),切线(dpdv)数据,参考 Triangle:GetShadingGeometry。

所以,material的GetBSDF方法中 dgShading 参数 就是 平滑过后的 dgGeom 。


 

2. virtual BSSRDF *GetBSSRDF(const DifferentialGeometry &dgGeom,
                              const DifferentialGeometry &dgShading,
                              MemoryArena &arena) const {
        return NULL;
    }

作用:

(BSSRDF 表示的是 透明材质,这个方法就是返回 一个BSSRDF,表示的就是物体 表面底下 散射属性 )

For materials that represent translucent materials that exhibit subsurface(表面下的) scattering, the
GetBSSRDF() method returns a BSSRDF object that represents the object’s subsurface scattering
properties.
The BSSRDF is defined later, in Section 11.6, after the foundations of
volumetric scattering have been introduced. Because most materials don’t have meaningful
amounts of subsurface scattering, this method has a default implementation that
just returns NULL.

 

3. BSDF *Intersection::GetBSDF(const RayDifferential &ray, MemoryArena &arena) const

BSDF *Intersection::GetBSDF(const RayDifferential &ray,
                            MemoryArena &arena) const {
    PBRT_STARTED_BSDF_SHADING(const_cast<RayDifferential *>(&ray));
    dg.ComputeDifferentials(ray);
    BSDF *bsdf = primitive->GetBSDF(dg, ObjectToWorld, arena);
    PBRT_FINISHED_BSDF_SHADING(const_cast<RayDifferential *>(&ray), bsdf);
    return bsdf;
}

BSSRDF *Intersection::GetBSSRDF(const RayDifferential &ray,
          MemoryArena &arena) const {
    PBRT_STARTED_BSSRDF_SHADING(const_cast<RayDifferential *>(&ray));
    dg.ComputeDifferentials(ray);
    BSSRDF *bssrdf = primitive->GetBSSRDF(dg, ObjectToWorld, arena);
    PBRT_FINISHED_BSSRDF_SHADING(const_cast<RayDifferential *>(&ray), bssrdf);
    return bssrdf;
}

作用:

(常用的用法 是直接调用 Intersection->GetBSDF,Intersection->GetBSDF 中调用 Primitive->GetBSDF,Primitive->GetBSDF 中再去调用 Material->GetBSDF,对于 GetBSSRDF 已经一样的道理,值得注意的是,在  Intersection->GetBSDF 调用了  Differentialgeometry::ComputeDifferentials() 方法,这个方法主要的作用就是: 计算 交点附近的面区域投影大小 信息)

Since the usual interface to the hit point used by Integrators is through an instance of
the Intersection class, we will add two convenience methods to Intersection, GetBSDF()
and GetBSSRDF(), that respectively return the BSDF or BSSRDF at the hit point.

These methods call the Differentialgeometry::ComputeDifferentials() method to compute information
about the projected size of the surface area around the intersection on the image
plane for use in texture antialiasing
and then forward the request to the Primitive, which
in turn will call the corresponding GetBSDF() or GetBSSRDF() method of its Material.

 

 

 

 

 

 

 

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值