PBRT_V2 总结记录 Microfacet::Sample_f

Spectrum Microfacet::Sample_f(const Vector &wo, Vector *wi,
                              float u1, float u2, float *pdf) const {
    distribution->Sample_f(wo, wi, u1, u2, pdf);
    if (!SameHemisphere(wo, *wi)) return Spectrum(0.f);
    return f(wo, *wi);
}


float Microfacet::Pdf(const Vector &wo, const Vector &wi) const {
    if (!SameHemisphere(wo, wi)) return 0.f;
    return distribution->Pdf(wo, wi);
}

作用:

(参考《PBRT_V2 总结记录 Microfacet 和 MicrofacetDistribution》可以看到Microfacet的作用,对于Microfacet.Sample_f  来说,其实简单化了,直接使用D项,那就是直接使用 MicrofacetDistribution 的Sample_f 来进行 ,所以 MicrofacetDistribution 一定要实现 Sample_f 和 Pdf)

BRDFs based on microfacet distribution functions are more difficult to sample. For these
models, the BRDF is a product of three terms, D, G, and F, which is then divided by two
cosine terms; recall Equation (8.8). It is impractical to find the probability distribution
that matches the complete model, so instead we will derive a method for drawing samples
from the distribution described by the microfacet distribution function D alone.
This
is an effective strategy for importance sampling the complete model, since the D term
accounts for most of its variation.
Therefore, all MicrofacetDistribution implementations must implement methods for
sampling from their distribution and computing the value of their PDF, each with the
same signature as the corresponding BxDF function, except that their Sample_f() methods
return void.

virtual void Sample_f(const Vector &wo, Vector *wi, float u1, float u2, float *pdf) const = 0;
virtual float Pdf(const Vector &wo, const Vector &wi) const = 0;

猜你喜欢

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