3
$\begingroup$

I am currently trying to understand IBL in Unreal Engine, and there are so much things that I don't understand about the formula. Unreal approximate the specular term of shading equation by doing split sum approximation.

enter image description here

This is how unreal pre-filter the environment map for specular-irradiance term.

float3 PrefilterEnvMap(float Roughness, float3 R )
{
    float3 N = R;
    float3 V = R;
    float3 PrefilteredColor = 0;
    const uint NumSamples = 1024;
    for(uint i = 0; i < NumSamples; i++ )
    {
        float2 Xi = Hammersley( i, NumSamples );
        float3 H = ImportanceSampleGGX( Xi, Roughness, N );
        float3 L = 2 * dot  ( V, H ) * H - V;
        float NoL =saturate( dot  ( N, L ) );
        if ( NoL > 0 )
        {
            PrefilteredColor += EnvMap.SampleLevel( EnvMapSampler, L, 0 ).rgb * NoL;
            TotalWeight += NoL;
        }
    }
    return PrefilteredColor / TotalWeight;
}

My question is why does the total weight is the sum of saturate(dot(N,L)). My understanding on importance sampling is that we should divide our sample with the pdf we use to sample. In this case, from what I read at here the pdf should be

$$p_i(wm, wo) = \frac{D(wm)(wm \cdot wg)}{4|wo \cdot wm|}$$

My reference on pbr in unreal engine is here and here.

$\endgroup$

1 Answer 1

3
$\begingroup$

I just read notes on moving frostbite to pbr and I found the derivation of the method above. So I will just show the derivation here and quote some of the explanation.

enter image description here

One can notice an extra〈n·l〉in the LD term as well as a different weighting 1/(∑Ni〈n·l〉). These empirical terms have been introduce by Karis to allows to improve the reconstructed lighting integral which suffers from coarse hypothesis of separability of this integral. There is no mathematical derivation for these terms, goal was to have an exact match with a constant L(l).

So it turns out the pdf is weighted on the DFG term. As for dot(N,l), the term is introduced to minimize the error that is caused by split sum approximation. But I am actually still wondering what is the intuition on that empirical term.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.