Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
ShadowMap.cs
Go to the documentation of this file.
1 using System;
2 using SiliconStudio.Paradox.Effects.Modules;
3 using SiliconStudio.Paradox.Graphics;
4 using SiliconStudio.Core.Mathematics;
5 
6 namespace SiliconStudio.Paradox.Effects
7 {
8  /// <summary>
9  /// Represents a ShadowMap.
10  /// </summary>
11  public class ShadowMap
12  {
13  internal ParameterCollection Parameters { get; set; }
14 
16  {
17  Light = light;
18 
19  Parameters = new ParameterCollection("ShadowMap parameters");
20 
21  // Inherits light parameters (to have its color and direction or viewproj matrix).
22  Parameters.AddSources(light.Parameters);
23 
24  CasterParameters = new ParameterCollection("ShadowMap Caster Parameters");
25  CasterParameters.AddSources(Parameters);
26  ShadowDistance = 1000.0f;
27  ShadowMapSize = 512;
28  }
29 
30  /// <summary>
31  /// Gets or sets the size of the shadow map (default: 1024)
32  /// </summary>
33  /// <value>
34  /// The size of the shadow map.
35  /// </value>
36  public int ShadowMapSize { get; set; }
37 
38  public Texture Texture
39  {
40  get { return Parameters.TryGet(ShadowMapKeys.Texture); }
41  set { Parameters.Set(ShadowMapKeys.Texture, value); }
42  }
43 
44  /// <summary>
45  /// Gets or sets the shadow distance.
46  /// </summary>
47  /// <value>
48  /// The shadow distance.
49  /// </value>
50  /// <remarks>
51  /// Maximum distance in camera space to render the shadow
52  /// </remarks>
53  public float ShadowDistance
54  {
55  get { return Parameters.TryGet(ShadowMapKeys.DistanceMax); }
56  set { Parameters.Set(ShadowMapKeys.DistanceMax, value); }
57  }
58 
59  /// <summary>
60  /// Gets the associated light.
61  /// </summary>
62  public Light Light { get; protected set; }
63 
64  /// <summary>
65  /// Gets the associated light, as a DirectionalLight.
66  /// </summary>
68 
69  /// <summary>
70  /// Gets or sets the level of shadow maps (default: <see cref="CascadeShadowMapLevel.X4"/>)
71  /// </summary>
72  /// <value>
73  /// The level.
74  /// </value>
75  public CascadeShadowMapLevel Level { get; set; }
76 
77  public Vector4[] TextureCoordsBorder { get; set; }
78 
79  public ShadowMapFilter Filter { get; internal set; }
80 
81  /// <summary>
82  /// Gets the level count.
83  /// </summary>
84  internal int LevelCount
85  {
86  get
87  {
88  return (int)Level;
89  }
90  }
91 
92  internal RenderPass[] Passes { get; set; }
93 
94  internal RenderTargetsPlugin[] Plugins { get; set; }
95 
96  internal ParameterCollection CasterParameters { get; set; }
97 
98  public ShadowMap SetFilter(Func<ShadowMap, ShadowMapFilter> initializeFilter)
99  {
100  Filter = initializeFilter(this);
101  return this;
102  }
103  }
104 }
Represents a ShadowMap.
Definition: ShadowMap.cs:11
Represents a four dimensional mathematical vector.
Definition: Vector4.cs:42
CascadeShadowMapLevel
Level defined for a cascade shadow map.
ShadowMap SetFilter(Func< ShadowMap, ShadowMapFilter > initializeFilter)
Definition: ShadowMap.cs:98
ShadowMap(DirectionalLight light)
Definition: ShadowMap.cs:15
A container to handle a hierarchical collection of effect variables.
Base class for texture resources.
Definition: Texture.cs:38