Ejemplo n.º 1
0
 public override void Serialize(ref ParameterCollection parameterCollection, ArchiveMode mode, SerializationStream stream)
 {
     if (mode == ArchiveMode.Serialize)
     {
         var parameters = new ParameterCollectionData();
         foreach (var parameter in parameterCollection.InternalValues)
         {
             if (parameterCollection.IsValueOwner(parameter.Value))
             {
                 parameters.Add(parameter.Key, parameter.Value.Object);
             }
         }
         stream.Write(parameters);
     }
     else if (mode == ArchiveMode.Deserialize)
     {
         var parameters = stream.Read <ParameterCollectionData>();
         foreach (var parameter in parameters)
         {
             var parameterValue = parameter.Value;
             if (parameterValue is ContentReference)
             {
                 parameterValue = ((ContentReference)parameterValue).ObjectValue;
             }
             parameterCollection.SetObject(parameter.Key, parameterValue);
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the collection of parameters from the data.
        /// </summary>
        /// <returns>The parameter collection.</returns>
        public ParameterCollectionData GetCollection()
        {
            var parameters = new ParameterCollectionData();

            parameters.Set(LightingKeys.MaxDirectionalLights, MaxNumDirectionalLight);
            parameters.Set(LightingKeys.MaxPointLights, MaxNumPointLight);
            parameters.Set(LightingKeys.MaxSpotLights, MaxNumSpotLight);
            parameters.Set(LightingKeys.UnrollDirectionalLightLoop, UnrollDirectionalLightLoop);
            parameters.Set(LightingKeys.UnrollPointLightLoop, UnrollPointLightLoop);
            parameters.Set(LightingKeys.UnrollSpotLightLoop, UnrollSpotLightLoop);

            if (ShadowConfigurations != null && ShadowConfigurations.Groups != null && ShadowConfigurations.Groups.Count > 0)
            {
                var shadow = new List <ShadowMapParameters>();
                foreach (var shadowConfig in ShadowConfigurations.Groups)
                {
                    var shadowParams = new ShadowMapParameters();
                    shadowParams.Set(ShadowMapParameters.LightType, shadowConfig.LightType);
                    shadowParams.Set(ShadowMapParameters.ShadowMapCount, shadowConfig.ShadowCount);
                    shadowParams.Set(ShadowMapParameters.ShadowMapCascadeCount, shadowConfig.LightType == LightType.Directional ? shadowConfig.CascadeCount : 1);
                    shadowParams.Set(ShadowMapParameters.FilterType, shadowConfig.FilterType);
                    shadow.Add(shadowParams);
                }
                parameters.Set(ShadowMapParameters.ShadowMaps, shadow.ToArray());
            }
            return(parameters);
        }