浏览代码

Fixed cascade selection when there are less than max cascades.

/main
uygar 7 年前
当前提交
3251dfad
共有 2 个文件被更改,包括 5 次插入3 次删除
  1. 2
      ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
  2. 6
      ScriptableRenderPipeline/Core/CoreRP/Shadow/Shadow.cs

2
ScriptableRenderPipeline/Core/CoreRP/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl


wposDir = -sphere.xyz + positionWS;
float distSq = dot( wposDir, wposDir );
relDistance = distSq / sphere.w;
if( relDistance <= 1.0 )
if( relDistance > 0.0 && relDistance <= 1.0 )
{
splitSphere = sphere.xyz;
wposDir /= sqrt( distSq );

6
ScriptableRenderPipeline/Core/CoreRP/Shadow/Shadow.cs


if( sr.shadowType == GPUShadowType.Directional )
{
asd.GetShadowCascades( out cascadeCnt, out cascadeRatios, out cascadeBorders );
for( int i = 0; i < m_TmpSplits.Length; i++ )
m_TmpSplits[i].w = -1.0f;
}

uint first = k_MaxCascadesInShader, second = k_MaxCascadesInShader;
for( uint i = 0; i < k_MaxCascadesInShader; i++, payloadOffset++ )
{
first = (first == k_MaxCascadesInShader && m_TmpSplits[i].w > 0.0f) ? i : first;
second = (second == k_MaxCascadesInShader && m_TmpSplits[i].w > 0.0f) ? i : second;
first = ( first == k_MaxCascadesInShader && m_TmpSplits[i].w > 0.0f) ? i : first;
second = ((second == k_MaxCascadesInShader || second == first) && m_TmpSplits[i].w > 0.0f) ? i : second;
sp.Set( m_TmpSplits[i] );
payload[payloadOffset] = sp;
}

正在加载...
取消
保存