您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
23 行
1.1 KiB
23 行
1.1 KiB
TEXTURE2D(_PreIntegratedFGD);
|
|
|
|
// For image based lighting, a part of the BSDF is pre-integrated.
|
|
// This is done both for specular GGX height-correlated and DisneyDiffuse
|
|
// reflectivity is Integral{(BSDF_GGX / F) - use for multiscattering
|
|
void GetPreIntegratedFGDGGXAndDisneyDiffuse(float NdotV, float perceptualRoughness, float3 fresnel0, out float3 GGXSpecularFGD, out float disneyDiffuseFGD, out float reflectivity)
|
|
{
|
|
float3 preFGD = SAMPLE_TEXTURE2D_LOD(_PreIntegratedFGD, s_linear_clamp_sampler, float2(NdotV, perceptualRoughness), 0).xyz;
|
|
|
|
// Pre-integrate GGX FGD
|
|
// Integral{BSDF * <N,L> dw} =
|
|
// Integral{(F0 + (1 - F0) * (1 - <V,H>)^5) * (BSDF / F) * <N,L> dw} =
|
|
// (1 - F0) * Integral{(1 - <V,H>)^5 * (BSDF / F) * <N,L> dw} + F0 * Integral{(BSDF / F) * <N,L> dw}=
|
|
// (1 - F0) * x + F0 * y = lerp(x, y, F0)
|
|
GGXSpecularFGD = lerp(preFGD.xxx, preFGD.yyy, fresnel0);
|
|
|
|
// Pre integrate DisneyDiffuse FGD:
|
|
// z = DisneyDiffuse
|
|
// Remap from the [0, 1] to the [0.5, 1.5] range.
|
|
disneyDiffuseFGD = preFGD.z + 0.5;
|
|
|
|
reflectivity = preFGD.y;
|
|
}
|