protected override void AllocateShadows(FrameId frameId, VisibleLight[] lights, uint totalGranted, ref ShadowRequestVector grantedRequests, ref ShadowIndicesVector shadowIndices, ref ShadowDataVector shadowDatas, ref ShadowPayloadVector shadowmapPayload) { ShadowData sd = new ShadowData(); shadowDatas.Reserve(totalGranted); shadowIndices.Reserve(grantedRequests.Count()); for (uint i = 0, cnt = grantedRequests.Count(); i < cnt; ++i) { VisibleLight vl = lights[grantedRequests[i].index]; Light l = vl.light; AdditionalLightData ald = l.GetComponent <AdditionalLightData>(); // set light specific values that are not related to the shadowmap GPUShadowType shadowtype; ShadowUtils.MapLightType(ald.archetype, vl.lightType, out sd.lightType, out shadowtype); sd.bias = l.shadowBias; sd.quality = 0; shadowIndices.AddUnchecked((int)shadowDatas.Count()); int smidx = 0; while (smidx < k_MaxShadowmapPerType) { if (m_ShadowmapsPerType[(int)shadowtype, smidx].Reserve(frameId, ref sd, grantedRequests[i], (uint)ald.shadowResolution, (uint)ald.shadowResolution, ref shadowDatas, ref shadowmapPayload, lights)) { break; } smidx++; } if (smidx == k_MaxShadowmapPerType) { throw new ArgumentException("The requested shadows do not fit into any shadowmap."); } } // final step for shadowmaps that only gather data during the previous loop and do the actual allocation once they have all the data. foreach (var sm in m_Shadowmaps) { if (!sm.ReserveFinalize(frameId, ref shadowDatas, ref shadowmapPayload)) { throw new ArgumentException("Shadow allocation failed in the ReserveFinalize step."); } } }