浏览代码

GC fix (saves 360B/frame)

/main
Thomas 7 年前
当前提交
1a8f983d
共有 1 个文件被更改,包括 4 次插入4 次删除
  1. 8
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs

8
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


private const int kMaxCascades = 4;
private int m_ShadowCasterCascadesCount;
private int m_ShadowMapRTID;
private Matrix4x4[] m_ShadowMatrices = new Matrix4x4[kMaxCascades + 1];
private RenderTargetIdentifier m_CurrCameraColorRT;
private RenderTargetIdentifier m_ShadowMapRT;
private RenderTargetIdentifier m_ColorRT;

float shadowResolution = m_ShadowSlices[0].shadowResolution;
int cascadeCount = m_ShadowCasterCascadesCount;
Matrix4x4[] shadowMatrices = new Matrix4x4[kMaxCascades + 1];
shadowMatrices[i] = (cascadeCount >= i) ? m_ShadowSlices[i].shadowTransform : Matrix4x4.identity;
m_ShadowMatrices[i] = (cascadeCount >= i) ? m_ShadowSlices[i].shadowTransform : Matrix4x4.identity;
// We setup and additional a no-op WorldToShadow matrix in the last index
// because the ComputeCascadeIndex function in Shadows.hlsl can return an index

shadowMatrices[kMaxCascades] = noOpShadowMatrix;
m_ShadowMatrices[kMaxCascades] = noOpShadowMatrix;
cmd.SetGlobalMatrixArray("_WorldToShadow", shadowMatrices);
cmd.SetGlobalMatrixArray("_WorldToShadow", m_ShadowMatrices);
cmd.SetGlobalVector("_ShadowData", new Vector4(light.shadowStrength, 0.0f, 0.0f, 0.0f));
cmd.SetGlobalVectorArray("_DirShadowSplitSpheres", m_DirectionalShadowSplitDistances);
cmd.SetGlobalVector("_DirShadowSplitSphereRadii", m_DirectionalShadowSplitRadii);

正在加载...
取消
保存