PBRT_V2 总结记录 DistantLight

DistantLight 类

class DistantLight : public Light {
public:
    // DistantLight Public Methods
    DistantLight(const Transform &light2world, const Spectrum &radiance, const Vector &dir);
    bool IsDeltaLight() const { return true; }
    Spectrum Sample_L(const Point &p, float pEpsilon, const LightSample &ls,
        float time, Vector *wi, float *pdf, VisibilityTester *) const;
    Spectrum Power(const Scene *) const;
    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;
private:
    // DistantLight Private Data
    Vector lightDir;
    Spectrum L;
};


Spectrum DistantLight::Sample_L(const Point &p, float pEpsilon,
        const LightSample &ls, float time, Vector *wi, float *pdf,
        VisibilityTester *visibility) const {
    *wi = lightDir;
    *pdf = 1.f;
    visibility->SetRay(p, pEpsilon, *wi, time);
    return L;
}

类的作用:

(方向光,这个光源 照射到的每一个点的方向都是一致的)

Another useful light source type is the distant light, also known as a directional light. It
describes an emitter that deposits illumination from the same direction at every point
in space.
Such a light is also called a point light “at infinity,” since, as a point light
becomes progressively farther away, it acts more and more like a directional light. For
example, the sun (as considered from Earth) can be thought of as a directional light
source. Although it is actually an area light source, the illumination effectively arrives
at Earth in parallel beams because it is so far away.

1. 

Spectrum DistantLight::Power(const Scene *scene) const {
    Point worldCenter;
    float worldRadius;
    scene->WorldBound().BoundingSphere(&worldCenter, &worldRadius);
    return L * M_PI * worldRadius * worldRadius;
}

作用:

The distant light is unusual in that the amount of power it emits is related to the spatial
extent of the scene. In fact, it is proportional to the area of the scene receiving light. To see
why this is so, consider a disk of area A being illuminated by a distant light with emitted
radiance L where the incident light arrives along the disk’s normal direction. The total
power reaching the disk is P = AL. As the size of the receiving surface varies, power
varies proportionally.

To find the emitted power for a DistantLight, it’s impractical to compute the total surface
area of the objects that are visible to the light. Instead, we will approximate this area with
a disk inside the scene’s bounding sphere oriented in the light’s direction
(Figure 12.10).
This will always overestimate the actual area, but is sufficient for the needs of code
elsewhere in the system.

Figure 12.10: An approximation of the power emitted by a distant light into a given scene can be
obtained by finding the sphere that bounds the scene, computing the area of an inscribed disk, and
computing the power that arrives on the surface of that disk.

猜你喜欢

转载自blog.csdn.net/aa20274270/article/details/84281875