浏览代码

fix exception when not all active lights have shadows enabled

/main
vlad-andreev 8 年前
当前提交
0bfdd8a7
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 7
      Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs

7
Assets/ScriptableRenderLoop/RenderPasses/ShadowRenderPass.cs


//---------------------------------------------------------------------------------------------------------------------------------------------------
bool AutoPackLightsIntoShadowTexture(List<InputShadowLightData> shadowLights, ActiveLight[] lights, out ShadowOutput packedShadows)
{
Dictionary<int, InputShadowLightData> activeShadowLights = new Dictionary<int, InputShadowLightData>();
List<int> shadowIndices = new List<int>();
//@TODO: Disallow multiple directional lights

shadowIndices.Add (shadowLights[i].lightIndex);
activeShadowLights[shadowLights[i].lightIndex] = shadowLights[i];
}
// World's stupidest sheet packer:

{
int nCompare = 0;
// Sort shadow-casting lights by shadow resolution
nCompare = shadowLights[l1].shadowResolution.CompareTo(shadowLights[l2].shadowResolution); // Sort by shadow size
nCompare = activeShadowLights[l1].shadowResolution.CompareTo(activeShadowLights[l2].shadowResolution); // Sort by shadow size
if ( nCompare == 0 ) // Same, so sort by range to stabilize sort results
nCompare = lights[l1].range.CompareTo( lights[l2].range ); // Sort by shadow size

foreach (AtlasEntry entry in requestedPages)
{
int shadowResolution = shadowLights[entry.lightIndex].shadowResolution;
int shadowResolution = activeShadowLights[entry.lightIndex].shadowResolution;
// Check if first texture is too wide
if ( nCurrentY == -1 )

{
var setRenderTargetCommandBuffer = new CommandBuffer ();
setRenderTargetCommandBuffer.name = "Render packed shadows";
setRenderTargetCommandBuffer.GetTemporaryRT (m_ShadowTexName, m_Settings.shadowAtlasWidth, m_Settings.shadowAtlasHeight, kDepthBuffer, FilterMode.Bilinear, RenderTextureFormat.Shadowmap, RenderTextureReadWrite.Linear);
setRenderTargetCommandBuffer.SetRenderTarget (new RenderTargetIdentifier (m_ShadowTexName));

正在加载...
取消
保存