浏览代码

Reduce the importance sampling bias

/main
Evgenii Golubev 8 年前
当前提交
360609df
共有 3 个文件被更改,包括 6 次插入4 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/Resources/GGXConvolve.shader
  2. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs
  3. 7
      Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl

2
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/Resources/GGXConvolve.shader


#endif
float _Level;
float _MaxLevel;
float _InvOmegaP;
half4 Frag(Varyings input) : SV_Target

float4 val = IntegrateLD(TEXTURECUBE_PARAM(_MainTex, sampler_MainTex),
V, N,
roughness,
_MaxLevel,
_InvOmegaP,
sampleCount, // Must be a Fibonacci number
true);

1
Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyManager.cs


float invOmegaP = (6.0f * input.width * input.width) / (4.0f * Mathf.PI); // Solid angle associated to a pixel of the cubemap;
m_GGXConvolveMaterial.SetTexture("_MainTex", input);
m_GGXConvolveMaterial.SetFloat("_MaxLevel", mipCount - 1);
m_GGXConvolveMaterial.SetFloat("_InvOmegaP", invOmegaP);
for (int mip = 1; mip < ((int)EnvConstants.SpecCubeLodStep + 1); ++mip)

7
Assets/ScriptableRenderLoop/ShaderLibrary/ImageBasedLighting.hlsl


float3 V,
float3 N,
float roughness,
float maxMipLevel,
float invOmegaP,
uint sampleCount, // Must be a Fibonacci number
bool prefilter)

// Bias samples towards the mirror direction to reduce variance.
// This will have a side effect of making the reflection sharper.
// Ref: Stochastic Screen-Space Reflections, p. 67.
const float bias = 0.5;
const float bias = 0.2;
u.x = lerp(u.x, 0.0, bias);
float3 L;

// Bias the MIP map level to compensate for the importance sampling bias.
// This will blur the reflection.
// TODO: bias more accurately once the 'UNITY_SPECCUBE_LOD_STEPS' limit has been lifted.
mipLevel = lerp(mipLevel, UNITY_SPECCUBE_LOD_STEPS, sqrt(bias));
mipLevel = min(mipLevel, UNITY_SPECCUBE_LOD_STEPS);
mipLevel = lerp(mipLevel, maxMipLevel, bias);
}
if (NdotL > 0.0)

正在加载...
取消
保存