3 using System.Collections.Generic;
5 using SiliconStudio.Paradox.DataModel;
6 using SiliconStudio.Paradox.Shaders;
8 namespace SiliconStudio.
Paradox.Effects.Data
10 public partial class LightingConfigurationData
12 public int TotalLightCount
16 var shadowLightCount = 0;
17 if (ShadowConfigurations != null && ShadowConfigurations.Groups.Count > 0)
19 foreach (var group
in ShadowConfigurations.Groups)
20 shadowLightCount += group.ShadowCount;
22 return MaxNumDirectionalLight + MaxNumPointLight + MaxNumSpotLight + shadowLightCount;
28 MaxNumDirectionalLight = 0;
32 UnrollDirectionalLightLoop =
false;
33 UnrollPointLightLoop =
false;
34 UnrollSpotLightLoop =
false;
43 MaxNumDirectionalLight = collection.Get(LightingKeys.MaxDirectionalLights);
44 MaxNumPointLight = collection.Get(LightingKeys.MaxPointLights);
45 MaxNumSpotLight = collection.Get(LightingKeys.MaxSpotLights);
47 UnrollDirectionalLightLoop =
false;
48 UnrollPointLightLoop =
false;
49 UnrollSpotLightLoop =
false;
51 var configs = collection.Get(ShadowMapParameters.ShadowConfigurations);
55 if (configs.Groups.Count > 0)
57 ShadowConfigurations.Groups =
new List<ShadowConfigurationData>();
58 for (var i = 0; i < configs.Groups.Count; ++i)
60 if (configs.Groups[i].ShadowCount > 0)
63 configData.LightType = configs.Groups[i]
.LightType;
64 configData.ShadowCount = configs.Groups[i].ShadowCount;
65 configData.CascadeCount = configData.LightType == LightType.Directional ? configs.Groups[i].CascadeCount : 1;
66 configData.FilterType = configs.Groups[i].FilterType;
67 ShadowConfigurations.Groups.Add(configData);
81 parameters.Set(LightingKeys.MaxDirectionalLights, MaxNumDirectionalLight);
82 parameters.Set(LightingKeys.MaxPointLights, MaxNumPointLight);
83 parameters.Set(LightingKeys.MaxSpotLights, MaxNumSpotLight);
84 parameters.Set(LightingKeys.UnrollDirectionalLightLoop, UnrollDirectionalLightLoop);
85 parameters.Set(LightingKeys.UnrollPointLightLoop, UnrollPointLightLoop);
86 parameters.Set(LightingKeys.UnrollSpotLightLoop, UnrollSpotLightLoop);
88 if (ShadowConfigurations != null && ShadowConfigurations.Groups != null && ShadowConfigurations.Groups.Count > 0)
90 var shadow =
new List<ShadowMapParameters>();
91 foreach (var shadowConfig
in ShadowConfigurations.Groups)
95 shadowParams.Set(ShadowMapParameters.ShadowMapCount, shadowConfig.ShadowCount);
96 shadowParams.Set(ShadowMapParameters.ShadowMapCascadeCount, shadowConfig.LightType == LightType.Directional ? shadowConfig.CascadeCount : 1);
97 shadowParams.Set(ShadowMapParameters.FilterType, shadowConfig.FilterType);
98 shadow.Add(shadowParams);
100 parameters.Set(ShadowMapParameters.ShadowMaps, shadow.ToArray());
108 for (var i = 0; i < sortedConfigs.Length; ++i)
110 var currentConfig = sortedConfigs[i];
111 var lightCount = currentConfig.MaxNumDirectionalLight + currentConfig.MaxNumPointLight + currentConfig.MaxNumSpotLight;
112 for (var j = 0; j < sortedConfigs.Length; ++j)
114 var localConfig = sortedConfigs[j];
115 var localCount = localConfig.MaxNumDirectionalLight + localConfig.MaxNumPointLight + localConfig.MaxNumSpotLight;
116 if (localCount == lightCount)
118 if (localCount + 1 == lightCount)
120 if (localConfig.MaxNumDirectionalLight + 1 == currentConfig.MaxNumDirectionalLight)
121 currentConfig.UnrollDirectionalLightLoop =
true;
122 if (localConfig.MaxNumPointLight + 1 == currentConfig.MaxNumPointLight)
123 currentConfig.UnrollPointLightLoop =
true;
124 if (localConfig.MaxNumSpotLight + 1 == currentConfig.MaxNumSpotLight)
125 currentConfig.UnrollSpotLightLoop =
true;
Data type for SiliconStudio.Paradox.Effects.LightingConfiguration.
LightingConfigurationData(ParameterCollection collection)
Creates a new LightingConfigurationData from a collection of parameters.
Data type for SiliconStudio.Paradox.Effects.ShadowConfigurationArray.
Data type for SiliconStudio.Paradox.Effects.ParameterCollection.
ParameterCollectionData GetCollection()
Gets the collection of parameters from the data.
static void CheckUnrolls(LightingConfigurationData[] sortedConfigs)
Data type for SiliconStudio.Paradox.Effects.ShadowConfiguration.
LightingConfigurationData()
A container to handle a hierarchical collection of effect variables.