PBRT_V2 总结记录 <98> PathIntegrator

本文详细介绍了PBRT_V2中PathIntegrator类的作用和工作原理,包括其如何利用采样点进行路径追踪,以及如何在路径的不同阶段应用随机数和多次重要性采样。通过逐步解析每次循环中光线与场景交互的过程,阐述了从光源到像素的辐射亮度计算方法,涉及到光的反射、透射和Russian roulette路径终止策略。
摘要由CSDN通过智能技术生成

 

PathIntegrator


// PathIntegrator Declarations
class PathIntegrator : public SurfaceIntegrator {
public:
    // PathIntegrator Public Methods
    Spectrum Li(const Scene *scene, const Renderer *renderer,
        const RayDifferential &ray, const Intersection &isect,
        const Sample *sample, RNG &rng, MemoryArena &arena) const;
    void RequestSamples(Sampler *sampler, Sample *sample, const Scene *scene);
    PathIntegrator(int md) { maxDepth = md; }
private:
    // PathIntegrator Private Data
    int maxDepth;
#define SAMPLE_DEPTH 3
    LightSampleOffsets lightSampleOffsets[SAMPLE_DEPTH];
    int lightNumOffset[SAMPLE_DEPTH];
    BSDFSampleOffsets bsdfSampleOffsets[SAMPLE_DEPTH];
    BSDFSampleOffsets pathSampleOffsets[SAMPLE_DEPTH];
};

类的作用:

(路径追踪) 

 

1. 

void PathIntegrator::RequestSamples(Sampler *sampler, Sample *sample,
                                    const Scene *scene) {
    for (int i = 0; i < SAMPLE_DEPTH; ++i) {
        lightSampleOffsets[i] = LightSampleOffsets(1, sample);
        lightNumOffset[i] = sample->Add1D(1);
        bsdfSampleOffsets[i] = BSDFSampleOffsets(1, sample);
        pathSampleOffsets[i] = BSDFSampleOffsets(1, sample);
    }
}

作用:

(这里申请  SAMPLE_DEPTH 个采样数据,之后 超过 SAMPLE_DEPTH 就直接使用 随机数)

The integrator uses samples from the Sampler for sampling at the first SAMPLE_DEPTH
vertices of the path. After the first few bounces, the advantages of well-distributed sample
points are greatly reduced, and it switches to using uniform random numbers.
The
integrator needs light and BSDF samples formultiple importance sampling for the direct
lighting calculation at each vertex of the path as well as a second set of BSDF samples for
sampling directions when generating the outgoing direction for finding the next vertex
of the path.

 

2. 

Spectrum PathIntegrator::Li(const Scene *scene, const Renderer *renderer,
        const RayDifferential &r, const Intersection &isect,
        const Sample *sample, RNG &rng, MemoryArena &arena) const {
    // Declare common path integration variables
    Spectrum pathThroughput = 1., L = 0.;
    RayDifferential ray(r);
    bool specularBounce = false;
    Intersection localIsect;
    const Intersection *isectp = &isect;
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值