Example #1
0
        /// <summary>
        /// Select which lights can actually cast shadows
        /// </summary>
        private void SelectShadowCasters()
        {
            _lightShadowCasters.Clear();

            for (int i = 0; i < _lightEntries.Count; i++)
            {
                LightEntry entry = _lightEntries[i];
                if (_lightEntries[i].light.CastShadows)
                {
                    //only spot and directional lights can cast shadows right now
                    if (entry.light.LightType == Light.Type.Spot)
                    {
                        entry.spotShadowMap = _shadowRenderer.GetFreeSpotShadowMap();
                        entry.castShadows   = entry.spotShadowMap != null;
                        //if we dont have that many shadow maps, it cannot cast shadows
                        if (entry.castShadows)
                        {
                            _lightShadowCasters.Add(entry);
                        }
                    }
                }
                //assign it back, since it's a struct
                _lightEntries[i] = entry;
            }
        }