|
|
|
|
|
|
|
|
|
|
if (NdotL > 0.0) |
|
|
|
{ |
|
|
|
// Integral is |
|
|
|
// 1 / NumSample * \int[ L * fr * (N.L) / pdf ] with pdf = D(H) * (N.H) / (4 * (L.H)) and fr = F(H) * G(V, L) * D(H) / (4 * (N.L) * (N.V)) |
|
|
|
// This is split in two part: |
|
|
|
// A) \int[ L * (N.L) ] |
|
|
|
// B) \int[ F(H) * 4 * (N.L) * V(V, L) * (L.H) / (N.H) ] with V(V, L) = G(V, L) / (4 * (N.L) * (N.V)) |
|
|
|
// = \int[ F(H) * weightOverPdf ] |
|
|
|
// Integral{BSDF * <N,L> dw} = |
|
|
|
// Integral{(F0 + (1 - F0) * (1 - <V,H>)^5) * (BSDF / F) * <N,L> dw} = |
|
|
|
// F0 * Integral{(BSDF / F) * <N,L> dw} + |
|
|
|
// (1 - F0) * Integral{(1 - <V,H>)^5 * (BSDF / F) * <N,L> dw} = |
|
|
|
// F0 * y + (1 - F0) * x = lerp(x, y, F0) |
|
|
|
// Recombine at runtime with: ( f0 * weightOverPdf * (1 - Fc) + f90 * weightOverPdf * Fc ) with Fc =(1 - V.H)^5 |
|
|
|
float Fc = pow(1.0 - VdotH, 5.0); |
|
|
|
acc.x += (1.0 - Fc) * weightOverPdf; |
|
|
|
acc.y += Fc * weightOverPdf; |
|
|
|
acc.x += weightOverPdf; |
|
|
|
acc.y += weightOverPdf * pow(1 - VdotH, 5); |
|
|
|
} |
|
|
|
|
|
|
|
// for Disney we still use a Cosine importance sampling, true Disney importance sampling imply a look up table |
|
|
|