PBRT_V2 总结记录 DensityRegion

DensityRegion 类

class DensityRegion : public VolumeRegion {
public:
    // DensityRegion Public Methods
    DensityRegion(const Spectrum &sa, const Spectrum &ss, float gg,
                  const Spectrum &emit, const Transform &VolumeToWorld)
        : sig_a(sa), sig_s(ss), le(emit), g(gg),
          WorldToVolume(Inverse(VolumeToWorld)) { }
    virtual float Density(const Point &Pobj) const = 0;
    Spectrum sigma_a(const Point &p, const Vector &, float) const {
        return Density(WorldToVolume(p)) * sig_a;
    }
    Spectrum sigma_s(const Point &p, const Vector &, float) const {
        return Density(WorldToVolume(p)) * sig_s;
    }
    Spectrum sigma_t(const Point &p, const Vector &, float) const {
        return Density(WorldToVolume(p)) * (sig_a + sig_s);
    }
    Spectrum Lve(const Point &p, const Vector &, float) const {
        return Density(WorldToVolume(p)) * le;
    }
    float p(const Point &p, const Vector &w, const Vector &wp, float) const {
        return PhaseHG(w, wp, g);
    }
    Spectrum tau(const Ray &r, float stepSize, float offset) const;
protected:
    // DensityRegion Protected Data
    Spectrum sig_a, sig_s, le;
    float g;
    Transform WorldToVolume;
};

类的作用:

(这个类就是 考虑到 密度 到  volume 中)

The rest of the volume representations in this chapter are based on the assumption
that the underlying particles throughout the medium all have the same basic scattering
properties, but their density is spatially varying in the medium
.

One consequence(结论) of this
assumption is that it is possible to describe the volume scattering properties at a point as
the product of the density at that point and some baseline value. For example, we might
set the attenuation coefficient σt to have a base value of 0.2. In regions where the particle
density was 1, a σt value of 0.2 would be returned. If the particle density were 3, however,
a σt value of 0.6 would be the result.

1. 构造函数

    DensityRegion(const Spectrum &sa, const Spectrum &ss, float gg,
                  const Spectrum &emit, const Transform &VolumeToWorld)
        : sig_a(sa), sig_s(ss), le(emit), g(gg),
          WorldToVolume(Inverse(VolumeToWorld)) { }

作用:

(直接传入 sig_a, sig_s, le, g,g就时候phase function的g)

The DensityRegion constructor takes the basic values of the scattering properties and
stores them in corresponding member variables. Note that the interface specifies the
volume-to-world transformation, but the class instead stores the world-to-volume transformation.

2. virtual float Density(const Point &Pobj) const = 0;

作用:

(DensityRegion 的子类,必须要实现 DensityRegion::Density() 函数,这个其实就是密度函数,给一个 点,就会返回 这个点在 在 object space 对应的体积密度)

All DensityRegion implementations must implement the DensityRegion::Density()
method, which returns the volume’s density at the given point in object space. The density
is used to scale the basic scattering parameters, so it must be nonnegative everywhere.

3. Spectrum sigma_a(const Point &p, const Vector &, float) const

    Spectrum sigma_a(const Point &p, const Vector &, float) const {
        return Density(WorldToVolume(p)) * sig_a;
    }

作用:

(这里是  sig_a 是乘上 这个点的 体积密度的,需要注意下)

The DensityRegion::sigma_a() method is illustrative of how a DensityRegion works; it
scales DensityRegion::sig_a by the local density at the point. The other VolumeRegion
methods are similar and not shown here.

4.  float p(const Point &p, const Vector &w, const Vector &wp, float) const

    float p(const Point &p, const Vector &w, const Vector &wp, float) const {
        return PhaseHG(w, wp, g);
    }

作用:

(这里需要注意的是,p() 不需要 乘上 local destiry)

One exception is the DensityRegion::p() method, which does not scale the phase function’s
value by the local density. Variations in the amount of scattering from point to
point are already accounted for by the scaled σs values.

5. Spectrum tau(const Ray &r, float stepSize, float offset) const;

作用:

待续...

猜你喜欢

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