public static ShadowUpdateInfo CreateShadowUpdateInfo(int index, int level)
        {
            var info = new ShadowUpdateInfo { CascadeCount = level };

            // Prepare keys for this shadow map type
            // TODO: use StringBuilder instead
            var shadowSubKey = string.Format("shadows[{0}]", index);
            info.ShadowMapReceiverInfoKey = ShadowMapRenderer.Receivers.ComposeWith(shadowSubKey);
            info.ShadowMapReceiverVsmInfoKey = ShadowMapRenderer.ReceiversVsm.ComposeWith(shadowSubKey);
            info.ShadowMapLevelReceiverInfoKey = ShadowMapRenderer.LevelReceivers.ComposeWith(shadowSubKey);
            info.ShadowMapLightCountKey = ShadowMapRenderer.ShadowMapLightCount.ComposeWith(shadowSubKey);
            info.ShadowMapTextureKey = ShadowMapKeys.Texture.ComposeWith(shadowSubKey);

            return info;
        }
Exemple #2
0
        public static ShadowUpdateInfo CreateShadowUpdateInfo(int index, int level)
        {
            var info = new ShadowUpdateInfo {
                CascadeCount = level
            };

            // Prepare keys for this shadow map type
            var shadowSubKey = string.Format(".shadows[{0}]", index);

            info.ShadowMapReceiverInfoKey      = ParameterKeys.AppendKey(ShadowMapRenderer.Receivers, shadowSubKey);
            info.ShadowMapReceiverVsmInfoKey   = ParameterKeys.AppendKey(ShadowMapRenderer.ReceiversVsm, shadowSubKey);
            info.ShadowMapLevelReceiverInfoKey = ParameterKeys.AppendKey(ShadowMapRenderer.LevelReceivers, shadowSubKey);
            info.ShadowMapLightCountKey        = ParameterKeys.AppendKey(ShadowMapRenderer.ShadowMapLightCount, shadowSubKey);
            info.ShadowMapTextureKey           = ParameterKeys.AppendKey(ShadowMapKeys.Texture, shadowSubKey);

            return(info);
        }
Exemple #3
0
        public static ShadowUpdateInfo CreateShadowUpdateInfo(int index, int level)
        {
            var info = new ShadowUpdateInfo {
                CascadeCount = level
            };

            // Prepare keys for this shadow map type
            // TODO: use StringBuilder instead
            var shadowSubKey = string.Format("shadows[{0}]", index);

            info.ShadowMapReceiverInfoKey      = ShadowMapRenderer.Receivers.ComposeWith(shadowSubKey);
            info.ShadowMapReceiverVsmInfoKey   = ShadowMapRenderer.ReceiversVsm.ComposeWith(shadowSubKey);
            info.ShadowMapLevelReceiverInfoKey = ShadowMapRenderer.LevelReceivers.ComposeWith(shadowSubKey);
            info.ShadowMapLightCountKey        = ShadowMapRenderer.ShadowMapLightCount.ComposeWith(shadowSubKey);
            info.ShadowMapTextureKey           = ShadowMapKeys.Texture.ComposeWith(shadowSubKey);

            return(info);
        }
        private void UpdateShadowParameters(ParameterCollection parameters, ShadowUpdateInfo shadowUpdateInfo, List <ShadowMap> shadows)
        {
            if (shadows != null && shadows.Count > 0)
            {
                var count        = 0;
                var cascadeCount = 0;
                foreach (var shadow in shadows)
                {
                    receiverInfos[count]    = shadow.ReceiverInfo;
                    receiverVsmInfos[count] = shadow.ReceiverVsmInfo;
                    for (var i = 0; i < shadowUpdateInfo.CascadeCount; ++i)
                    {
                        cascadeInfos[cascadeCount + i] = shadow.Cascades[i].ReceiverInfo;
                    }
                    ++count;
                    cascadeCount += shadowUpdateInfo.CascadeCount;
                }

                parameters.Set((ParameterKey <ShadowMapReceiverInfo[]>)shadowUpdateInfo.ShadowMapReceiverInfoKey, receiverInfos, 0, count);
                parameters.Set((ParameterKey <ShadowMapCascadeReceiverInfo[]>)shadowUpdateInfo.ShadowMapLevelReceiverInfoKey, cascadeInfos, 0, cascadeCount);
                if (shadows[0].Filter == ShadowMapFilterType.Variance)
                {
                    parameters.Set((ParameterKey <ShadowMapReceiverVsmInfo[]>)shadowUpdateInfo.ShadowMapReceiverVsmInfoKey, receiverVsmInfos, 0, count);
                    parameters.Set(shadowUpdateInfo.ShadowMapTextureKey, shadows[0].Texture.ShadowMapTargetTexture);
                }
                else
                {
                    parameters.Set(shadowUpdateInfo.ShadowMapTextureKey, shadows[0].Texture.ShadowMapDepthTexture);
                }
                parameters.Set(shadowUpdateInfo.ShadowMapLightCountKey, count);
            }
            else
            {
                parameters.Set(shadowUpdateInfo.ShadowMapLightCountKey, 0);
            }
        }