浏览代码

Improve comments

/main
Evgenii Golubev 8 年前
当前提交
440e138a
共有 2 个文件被更改,包括 13 次插入9 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl
  2. 20
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl

2
Assets/ScriptableRenderLoop/HDRenderPipeline/Material/Lit/Lit.hlsl


// We need to take into account the modified normal for faking anisotropic here.
float3 iblR = reflect(-V, iblNormalWS);
preLightData.iblDirWS = GetSpecularDominantDir(bsdfData.normalWS, iblR, bsdfData.roughness);
preLightData.iblDirWS = GetSpecularDominantDir(bsdfData.normalWS, iblR, bsdfData.roughness, preLightData.NdotV);
// Area light specific
// UVs for sampling the LUTs

20
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


// Util image based lighting
//-----------------------------------------------------------------------------
// The *approximated* version of the non-linear remapping which improves
// the perceptual roughness distribution and adds reflection (contact) hardening.
// The *approximated* version of the non-linear remapping. It works by
// approximating the cone of the specular lobe, and then computing the MIP map level
// which (approximately) covers the footprint of the lobe with a single texel.
// Improves the perceptual roughness distribution.
float perceptualRoughnessToMipmapLevel(float perceptualRoughness)
{
perceptualRoughness = perceptualRoughness * (1.7 - 0.7 * perceptualRoughness);

// The *accurate* version of the non-linear remapping which improves
// the perceptual roughness distribution and adds reflection (contact) hardening.
// The *accurate* version of the non-linear remapping. It works by
// approximating the cone of the specular lobe, and then computing the MIP map level
// which (approximately) covers the footprint of the lobe with a single texel.
// Improves the perceptual roughness distribution and adds reflection (contact) hardening.
// TODO: optimize!
float perceptualRoughnessToMipmapLevel(float perceptualRoughness, float NdotR)
{

return perceptualRoughness * UNITY_SPECCUBE_LOD_STEPS;
}
// The *approximated* version of the non-linear remapping which improves
// the perceptual roughness distribution and adds reflection (contact) hardening.
// The inverse of perceptualRoughnessToMipmapLevel().
float mipmapLevelToPerceptualRoughness(float mipmapLevel)
{
float perceptualRoughness = saturate(mipmapLevel / UNITY_SPECCUBE_LOD_STEPS);

// Ref: See "Moving Frostbite to PBR" Listing 22
// This formulation is for GGX only (with smith joint visibility or regular)
float3 GetSpecularDominantDir(float3 N, float3 R, float roughness)
float3 GetSpecularDominantDir(float3 N, float3 R, float roughness, float NdotV)
// TODO: we could bias this further (and use 'NdotV') to better match the reference.
float lerpFactor = a * (sqrt(a) + roughness);
// The result is not normalized as we fetch in a cubemap
return lerp(N, R, lerpFactor);

float omegaS = rcp(sampleCount) * invPdf;
// invOmegaP is precomputed on CPU and provide as a parameter of the function
// float omegaP = FOUR_PI / (6.0f * cubemapWidth * cubemapWidth);
mipLevel = 0.5 * log2(omegaS * invOmegaP);
mipLevel = 0.5 * log2(omegaS * invOmegaP + 1.0);
// Bias the MIP map level to compensate for the importance sampling bias.
// This will blur the reflection.

正在加载...
取消
保存