4 using System.Collections.Generic;
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.Diagnostics;
8 using SiliconStudio.Core.Mathematics;
9 using SiliconStudio.Paradox.DataModel;
10 using SiliconStudio.Paradox.Engine;
11 using SiliconStudio.Paradox.EntityModel;
12 using SiliconStudio.Paradox.Graphics;
14 namespace SiliconStudio.
Paradox.Effects.Modules.Processors
18 public static readonly
Logger Logger = GlobalLogger.GetLogger(
"LightShadowProcessor");
20 #region Protected members
36 #region Public properties
41 public Dictionary<Entity, EntityLightShadow> Lights
43 get {
return enabledEntities; }
49 public virtual HashSet<ShadowMapTexture> ShadowMapTextures
51 get {
return InternalShadowMapTextures; }
57 public virtual HashSet<ShadowMapTexture> ActiveShadowMapTextures
59 get {
return InternalActiveShadowMapTextures; }
65 public virtual HashSet<ShadowMap> ActiveShadowMaps
67 get {
return InternalActiveShadowMaps; }
72 #region Protected methods
76 foreach (var shadowMap
in InternalShadowMaps)
77 shadowMap.Texture = null;
78 InternalShadowMaps.Clear();
80 foreach (var texture
in InternalShadowMapTextures)
82 InternalShadowMapTextures.Remove(texture);
83 Utilities.Dispose(ref texture.ShadowMapDepthBuffer);
84 Utilities.Dispose(ref texture.ShadowMapDepthTexture);
85 Utilities.Dispose(ref texture.ShadowMapRenderTarget);
86 Utilities.Dispose(ref texture.ShadowMapTargetTexture);
87 Utilities.Dispose(ref texture.IntermediateBlurRenderTarget);
88 Utilities.Dispose(ref texture.IntermediateBlurTexture);
90 InternalShadowMapTextures.Clear();
92 base.OnSystemRemove();
99 ManageShadows = manageShadows;
100 InternalShadowMapTextures =
new HashSet<ShadowMapTexture>();
101 InternalActiveShadowMapTextures =
new HashSet<ShadowMapTexture>();
102 InternalShadowMaps =
new HashSet<ShadowMap>();
103 InternalActiveShadowMaps =
new HashSet<ShadowMap>();
114 base.OnEntityAdding(entity, data);
116 CreateShadowMap(data);
123 #region Protected static methods
128 light.ShadowMap.LightDirection =
new Vector3(worldDir.X, worldDir.Y, worldDir.Z);
129 light.ShadowMap.LightPosition = light.Entity.Transformation.Translation;
130 light.ShadowMap.Fov = light.Light.SpotFieldAngle;
131 light.ShadowMap.ReceiverInfo.ShadowLightDirection = light.ShadowMap.LightDirectionNormalized;
132 light.ShadowMap.ShadowFarDistance = light.Light.ShadowFarDistance;
133 light.ShadowMap.ReceiverInfo.ShadowMapDistance = light.Light.Type == LightType.Directional ? light.ShadowMap.ShadowFarDistance : light.ShadowMap.ShadowFarDistance - light.ShadowMap.ShadowNearDistance;
134 light.ShadowMap.ReceiverVsmInfo.BleedingFactor = light.Light.BleedingFactor;
135 light.ShadowMap.ReceiverVsmInfo.MinVariance = light.Light.MinVariance;
readonly HashSet< ShadowMapTexture > InternalShadowMapTextures
Game entity. It usually aggregates multiple EntityComponent
readonly GraphicsDevice GraphicsDevice
readonly bool ManageShadows
override void OnSystemRemove()
Represents a shadow map for the ShadowMapRenderer.
readonly HashSet< ShadowMap > InternalActiveShadowMaps
Entity processor, triggered on various EntitySystem events such as Entity and Component additions and...
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
Base implementation for ILogger.
override void OnEntityAdding(Entity entity, EntityLightShadow data)
Represents a four dimensional mathematical vector.
LightShadowProcessor(GraphicsDevice device, bool manageShadows)
LightType Type
Gets or sets the light type.
static void UpdateEntityLightShadow(EntityLightShadow light)
SiliconStudio.Core.Mathematics.Vector3 Vector3
readonly HashSet< ShadowMapTexture > InternalActiveShadowMapTextures
readonly HashSet< ShadowMap > InternalShadowMaps
override EntityLightShadow GenerateAssociatedData(Entity entity)
A class that represents a tag propety.
Vector3 LightDirection
Gets or sets the light direction.