Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
LightComponent.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 using System.ComponentModel;
5 
6 using SiliconStudio.Core.Serialization.Converters;
7 using SiliconStudio.Paradox.DataModel;
8 using SiliconStudio.Paradox.Effects;
9 using SiliconStudio.Paradox.EntityModel;
10 using SiliconStudio.Core;
11 using SiliconStudio.Core.Mathematics;
12 
13 namespace SiliconStudio.Paradox.Engine
14 {
15  [DataContract("ShadowMapFilterType")]
16  public enum ShadowMapFilterType
17  {
18  Nearest = 0,
20  Variance = 2,
21  }
22 
23  /// <summary>
24  /// Add a light to an <see cref="Entity"/>, that will be used during rendering.
25  /// </summary>
26  [DataConverter(AutoGenerate = true)]
27  [DataContract("LightComponent")]
28  public sealed class LightComponent : EntityComponent
29  {
31 
32  public LightComponent()
33  {
34  Intensity = 1.0f;
35  ShadowMapFilterType = ShadowMapFilterType.Nearest;
36  Enabled = true;
37  Deferred = false;
38  Layers = RenderLayers.RenderLayerAll;
39  SpotBeamAngle = 0;
40  SpotFieldAngle = 0;
41  ShadowMap = false;
42  ShadowMapMaxSize = 512;
43  ShadowMapMinSize = 512;
44  ShadowMapCascadeCount = 1;
45  ShadowNearDistance = 1.0f;
46  ShadowFarDistance = 100000.0f;
47  BleedingFactor = 0.0f;
48  MinVariance = 0.0f;
49  }
50 
51  /// <summary>
52  /// Gets or sets a value indicating whether the light is enabled.
53  /// </summary>
54  [DataMemberConvert]
55  [DefaultValue(true)]
56  public bool Enabled { get; set; }
57 
58  /// <summary>Gets or sets a value indicating whether the light is deferred (if available).</summary>
59  /// <value>true if light is deferred, false if not.</value>
60  [DataMemberConvert]
61  public bool Deferred { get; set; }
62 
63  /// <summary>
64  /// Gets or sets the light type.
65  /// </summary>
66  /// <value>
67  /// The type.
68  /// </value>
69  [DataMemberConvert]
70  public LightType Type { get; set; }
71 
72  /// <summary>
73  /// Gets or sets the light color.
74  /// </summary>
75  /// <value>
76  /// The color.
77  /// </value>
78  [DataMemberConvert]
79  public Color3 Color { get; set; }
80 
81  /// <summary>
82  /// Gets or sets the light intensity.
83  /// </summary>
84  /// <value>
85  /// The light intensity.
86  /// </value>
87  [DataMemberConvert]
88  [DefaultValue(1.0f)]
89  public float Intensity { get; set; }
90 
91  /// <summary>
92  /// Gets or sets the decay start.
93  /// </summary>
94  /// <value>
95  /// The decay start.
96  /// </value>
97  [DataMemberConvert]
98  public float DecayStart { get; set; }
99 
100  /// <summary>Gets or sets the light direction.</summary>
101  /// <value>The light direction.</value>
102  [DataMemberConvert]
103  public Vector3 LightDirection { get; set; }
104 
105  /// <summary>Gets or sets the beam angle of the spot light.</summary>
106  /// <value>The beam angle of the spot (in degrees between 0 and 90).</value>
107  [DataMemberConvert]
108  [DefaultValue(0)]
109  public float SpotBeamAngle { get; set; }
110 
111  /// <summary>Gets or sets the spot field angle of the spot light.</summary>
112  /// <value>The spot field angle of the spot (in degrees between 0 and 90).</value>
113  [DataMemberConvert]
114  [DefaultValue(0)]
115  public float SpotFieldAngle { get; set; }
116 
117  /// <summary>Gets or Sets a value indicating if the light cast shadows.</summary>
118  /// <value>True if the ligh generates a shadowmap, false otherwise.</value>
119  [DataMemberConvert]
120  [DefaultValue(false)]
121  public bool ShadowMap { get; set; }
122 
123  /// <summary>Gets or Sets the maximium size (in pixel) of one cascade of the shadow map.</summary>
124  /// <value>The maximum size of the shadow map.</value>
125  [DataMemberConvert]
126  [DefaultValue(512)]
127  public int ShadowMapMaxSize { get; set; }
128 
129  /// <summary>Gets or Sets the minimum size (in pixel) of one cascade of the shadow map.</summary>
130  /// <value>The minimum size of the shadow map.</value>
131  [DataMemberConvert]
132  [DefaultValue(512)]
133  public int ShadowMapMinSize { get; set; }
134 
135  /// <summary>Gets or Sets the number of cascades for this shadow.</summary>
136  /// <value>The number of cascades for this shadow.</value>
137  [DataMemberConvert]
138  [DefaultValue(1)]
139  public int ShadowMapCascadeCount { get; set; }
140 
141  /// <summary>Gets or Sets the near plane distance of the shadow.</summary>
142  /// <value>The near plane distance of the shadow.</value>
143  [DataMemberConvert]
144  [DefaultValue(1.0f)]
145  public float ShadowNearDistance { get; set; }
146 
147  /// <summary>Gets or Sets the far plane distance of the shadow.</summary>
148  /// <value>The far plane distance of the shadow.</value>
149  [DataMemberConvert]
150  [DefaultValue(100000.0f)]
151  public float ShadowFarDistance { get; set; }
152 
153  /// <summary>
154  /// Gets or sets the shadow map filtering.
155  /// </summary>
156  /// <value>The filter type.</value>
157  [DataMemberConvert]
158  [DefaultValue(ShadowMapFilterType.Nearest)]
160 
161  /// <summary>
162  /// Gets or sets the bleeding factor of the variance shadow map.
163  /// </summary>
164  /// <value>The bleeding factor.</value>
165  [DataMemberConvert]
166  [DefaultValue(0.0f)]
167  public float BleedingFactor { get; set; }
168 
169  /// <summary>
170  /// Gets or sets the minimal value of the variance of the variance shadow map.
171  /// </summary>
172  /// <value>The minimal variance.</value>
173  [DataMemberConvert]
174  [DefaultValue(0.0f)]
175  public float MinVariance { get; set; }
176 
177  /// <summary>
178  /// Get or sets the layers that the light influences
179  /// </summary>
180  /// <value>
181  /// The layer mask.
182  /// </value>
183  [DataMemberConvert]
184  [DefaultValue(RenderLayers.RenderLayerAll)]
185  public RenderLayers Layers { get; set; }
186 
187  public override PropertyKey DefaultKey
188  {
189  get { return Key; }
190  }
191  }
192 }
Add a light to an Entity, that will be used during rendering.
Represents a color in the form of rgb.
Definition: Color3.cs:41
Base class for converters to/from a data type.
Represents a three dimensional mathematical vector.
Definition: Vector3.cs:42
Represents a ShadowMap.
Definition: ShadowMap.cs:11
Represents a 32-bit color (4 bytes) in the form of RGBA (in byte order: R, G, B, A).
Definition: Color.cs:16
A class that represents a tag propety.
Definition: PropertyKey.cs:17