PBRT_V2 总结记录 <87> PointLight 补充(Sample_L) 和 SpotLight 补充(Sample_L)

1. 

Spectrum PointLight::Sample_L(const Scene *scene, const LightSample &ls,
        float u1, float u2, float time, Ray *ray, Normal *Ns,
        float *pdf) const {
    *ray = Ray(lightPos, UniformSampleSphere(ls.uPos[0], ls.uPos[1]),
               0.f, INFINITY, time);
    *Ns = (Normal)ray->d;
    *pdf = UniformSpherePdf();
    return Intensity;
}

Spectrum Sample_L(const Scene *scene, const LightSample &ls, float u1,
                      float u2, float time, Ray *ray, Normal *Ns, float *pdf) const;

作用:

(点光源的 Sample_L 根据采样点发出一条射线,采样分布是 UniformSampleSphere,均匀的球分布,pdf 是 均匀球分布 pdf )

The sampling method for generating rays leaving point lights is also straightforward.
The origin of the ray must be the light’s position; this part of the density is described
with a delta distribution. Directions are uniformly sampled over the sphere, and the
overall sampling density is the product of these two densities. As usual, we’ll ignore
the delta distribution that is in the actual PDF because it is canceled out by a (missing)
corresponding delta term in the radiance value in the Spectrum returned by the sampling
routine.

 

2. 

Spectrum SpotLight::Sample_L(const Scene *scene, const LightSample &ls,
        float u1, float u2, float time, Ray *ray, Normal *Ns,
        float *pdf) const {
    Vector v = UniformSampleCone(ls.uPos[0], ls.uPos[1], cosTotalWidth);
    *ray = Ray(lightPos, LightToWorld(v), 0.f, INFINITY, time);
    *Ns = (Normal)ray->d;
    *pdf = UniformConePdf(cosTotalWidth);
    return Intensity * Falloff(ray->d);
}

Vector UniformSampleCone(float u1, float u2, float costhetamax) {
    float costheta = (1.f - u1) + u1 * costhetamax;
    float sintheta = sqrtf(1.f - costheta*costheta);
    float phi = u2 * 2.f * M_PI;
    return Vector(cosf(phi) * sintheta, sinf(phi) * sintheta, costheta);
}

float UniformConePdf(float cosThetaMax) {
    return 1.f / (2.f * M_PI * (1.f - cosThetaMax));
}

Spectrum Sample_L(const Scene *scene, const LightSample &ls,
        float u1, float u2, float time, Ray *ray, Normal *Ns, float *pdf) const;

作用:

(SpotLight 发出的射线是 处于某一个圆锥体 (cosTotalWidth) 内部的, 采样分布也是 在这个圆锥体内进行采样分布,具体的数学原理可以参考 PBRT P712)

we will sample from a uniform distribution over the cone of directions in which the light casts
illumination. Although the sampling distribution does not try to account for the falloff
toward the edges of the beam, this is only a minor shortcoming in practice.

 

 

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值