PBRT_V2 总结记录 PointLight

PointLight 类

class PointLight : public Light {
public:
    // PointLight Public Methods
    PointLight(const Transform &light2world, const Spectrum &intensity);
    Spectrum Sample_L(const Point &p, float pEpsilon, const LightSample &ls,
        float time, Vector *wi, float *pdf, VisibilityTester *vis) const;
    Spectrum Power(const Scene *) const;
    bool IsDeltaLight() const { return true; }
    Spectrum Sample_L(const Scene *scene, const LightSample &ls, float u1,
                      float u2, float time, Ray *ray, Normal *Ns, float *pdf) const;
    float Pdf(const Point &, const Vector &) const;
    void SHProject(const Point &p, float pEpsilon, int lmax, const Scene *scene,
        bool computeLightVisibility, float time, RNG &rng, Spectrum *coeffs) const;
private:
    // PointLight Private Data
    Point lightPos;
    Spectrum Intensity;
};

类的作用:

(点光源,每一个方向发出的所有的光线都是相同的)

A number of interesting lights can be described in terms of emission from a single
point in space with some possibly angularly varying distribution of outgoing light. This
section describes the implementation of a number of them, starting with PointLight,
which represents an isotropic point light source that emits the same amount of light in
all directions.

1. 构造函数

PointLight::PointLight(const Transform &light2world,
                       const Spectrum &intensity)
    : Light(light2world) {
    lightPos = LightToWorld(Point(0,0,0));
    Intensity = intensity;
}

作用:

(lightto2world 负责把点光源从 光源空间变换到世界空间,Intensity 表示的是  the amount of power per unit solid angle

PointLights are positioned at the origin in light space. To place them elsewhere, the lightto-
world transformation should be modified as appropriate
. Using this transformation,
the world space position of the light is precomputed and cached in the constructor by
transforming (0, 0, 0) from light space to world space. The constructor also stores the
intensity for the light source, which is the amount of power per unit solid angle. Because
the light source is isotropic, this is a constant.

2. 

Spectrum PointLight::Sample_L(const Point &p, float pEpsilon,
         const LightSample &ls, float time, Vector *wi, float *pdf,
         VisibilityTester *visibility) const {
    *wi = Normalize(lightPos - p);
    *pdf = 1.f;
    visibility->SetSegment(p, pEpsilon, lightPos, 0., time);
    return Intensity / DistanceSquared(lightPos, p);
}

作用:

(在之前《PBRT_V2 总结记录 <11> Light and Color && Measuring Light》有提及过,Intensity 只用来描述点光源,我个人疑惑的就是,很多 光源 Sample_L 都是返回 radiance 单位,但是 Point Light 的 Sample_L 返回的是 Intensity,下面的解释就是,他们滥用术语,在 点光源的 Sample_L 方法中,直接把 intensity 当成 radiance 用了。

为什么要除以 r的平方,

Strictly speaking, it is incorrect to describe the light arriving at a point due to a point
light source using units of radiance. Radiant intensity is instead the proper unit for
describing emission from a point light source,
as explained in Section 5.4.

In the light
source interfaces here, however, we will abuse(滥用) terminology(术语) and use Sample_L() methods
to report the illumination arriving at a point for all types of light sources, dividing radiant
intensity by the squared distance to the point p to convert units.
Section 14.6 revisits the
details of this issue in its discussion of how delta distributions affect evaluation of the
integral in the scattering equation. In the end, the correctness of the computation does
not suffer from this fudge, and it makes the implementation of light transport algorithms
more straightforward by not requiring them to use different interfaces for different types
of light.

3. 

Spectrum PointLight::Power(const Scene *) const {
    return 4.f * M_PI * Intensity;
}

bool IsDeltaLight() const { return true; }

猜你喜欢

转载自blog.csdn.net/aa20274270/article/details/84228094
今日推荐