Demo entry 6645350

Fresnel

   

Submitted by anonymous on Oct 10, 2017 at 07:57
Language: GLSL. Code size: 623 Bytes.

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;
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).