PBRT_V2 总结记录 <29> SpecularReflection

概述

(SpecularReflection 描述镜面反射效果, 它的BRDF使用 the delta distribution,除了自己的镜面反射方向,其他方向反射都是0)

We can now implement the SpecularReflection class, which describes physically plausible(貌似可信)
specular reflection
, using the Fresnel interface to compute the fraction of light that
is reflected.

Intuitively, we want the BRDF to be zero everywhere except at the perfect reflection
direction,
which suggests the use of the delta distribution.

the correct BRDF for perfect specular reflection:

where R(ωo, n) is the specular reflection vector for ωo reflected about the surface normal
n.

 

SpecularReflection  类

class SpecularReflection : public BxDF {
public:
    // SpecularReflection Public Methods
    SpecularReflection(const Spectrum &r, Fresnel *f)
        : BxDF(BxDFType(BSDF_REFLECTION | BSDF_SPECULAR)),
          R(r), fresnel(f) {
    }
    Spectrum f(const Vector &, const Vector &) const {
        return Spectrum(0.);
    }
    Spectrum Sample_f(const Vector &wo, Vector *wi,
                      float u1, float u2, float *pdf) const;
    float Pdf(const Vector &wo, const Vector &wi) const {
        return 0.;
    }
private:
    // SpecularReflection Private Data
    Spectrum R;
    Fresnel *fresnel;
};

1. 构造函数

(构造函数需要一个 Fresnel object 和 Spectrum object 作为参数,Spectrum object主要是用来缩放 反射的 颜色)

The SpecularReflection class takes a Fresnel object to describe dielectric or conductor
Fresnel properties and an additional Spectrum object, which is used to scale the reflected
color.

 

2. 

Spectrum f(const Vector &, const Vector &) const {
        return Spectrum(0.);
    }

作用:

(由于这个SpecularReflection 的BRDF使用了 delta function,那么f 没有作用,作用返回0)

The rest of the implementation is straightforward. No scattering is returned from
SpecularReflection::f(), since for an arbitrary pair of directions the delta function
returns no scattering

 

3. Spectrum Sample_f(const Vector &wo, Vector *wi,
                      float u1, float u2, float *pdf) const;

Spectrum SpecularReflection::Sample_f(const Vector &wo,
        Vector *wi, float u1, float u2, float *pdf) const {
    // Compute perfect specular reflection direction
    *wi = Vector(-wo.x, -wo.y, wo.z);
    *pdf = 1.f;
    return fresnel->Evaluate(CosTheta(wo)) * R / AbsCosTheta(*wi);
}

作用: 

(wi 是wo的反射向量,wi提供外部使用,因为 BSDF的所有计算都是在 shading coordinate system 进行,那么wo 直接绕 法线旋转 180 度就可以得到自己的 反射向量wi)

However, we do implement the Sample_f() method, which selects an appropriate direction
according to the delta function. It sets the output variable wi to be the reflection of
the supplied direction wo about the surface normal.
The *pdf value is set to be one, which
is the appropriate value for this case, where no Monte Carlo sampling is being done.

 

The desired direction is the reflection of ωo around the surface normal. Because all
computations take place in a shading coordinate system where the surface normal is
(0, 0, 1), we just rotate ωi by π radians about n

Recall the transformation
matrix from Chapter 2 for a rotation around the z axis; if the angle of rotation is π
radians, the matrix is

When a vector is multiplied by this matrix, the effect is just to negate the x and y
components.

*wi = Vector(-wo.x, -wo.y, wo.z);

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值