/Utilities/Graphics/ShaderFeatures/SpecularShaderFeature.cs
C# | 118 lines | 66 code | 9 blank | 43 comment | 0 complexity | 151eb0f329830e07e58c5d6b7d27b974 MD5 | raw file
Possible License(s): Apache-2.0
- using System.Collections.Generic;
- using System.IO;
- using Delta.Utilities.Datatypes;
-
- namespace Delta.Utilities.Graphics.ShaderFeatures
- {
- /// <summary>
- /// Specular shader feature
- /// </summary>
- public class SpecularShaderFeature : IShaderFeature
- {
- #region SpecularColor (Public)
- /// <summary>
- /// Specular color is the color of highlights on a shiny surface.
- /// The highlights are reflections of the lights that illuminate the
- /// surface. For a naturalistic effect, set the specular color to the
- /// same color as the key light source, or make it a high-value,
- /// low-saturation version of the diffuse color.
- /// </summary>
- public Color SpecularColor = ShaderConstants.DefaultSpecularColor;
- #endregion
-
- #region SpecularPower (Public)
- /// <summary>
- /// A specular power refers to how much light is reflected in a mirror
- /// like fashion, rather than scattered randomly in a diffuse manner.
- /// So a mirror would have high specular power, a glossy surface some
- /// specular power and a matt black surface none.
- /// </summary>
- public float SpecularPower = ShaderConstants.DefaultSpecularPower;
- #endregion
-
- #region ShaderFeature (Public)
- /// <summary>
- /// Which shader feature flag is this ShaderFeature class using?
- /// Important for loading this file via ShaderData.LoadShaderFeature.
- /// Each flag should obviously only have one class for it!
- /// </summary>
- public ShaderFeatureFlags ShaderFeature
- {
- get
- {
- return ShaderFeatureFlags.Specular;
- }
- }
- #endregion
-
- #region RequiredShaderFeatures (Public)
- /// <summary>
- /// Which shader feature flags are required for this ShaderFeature.
- /// Very important for creating of a new ShaderFeature.
- /// </summary>
- public ShaderFeatureFlags RequiredShaderFeatures
- {
- get
- {
- // NOTE: We don't need the AmbientDiffuse flag here.
- // The Lighting has it already.
- return ShaderFeatureFlags.DynamicDirectionalLighting;
- }
- }
- #endregion
-
- #region Parameters (Public)
- /// <summary>
- /// Parameters as a dictionary, will be generated on the fly when
- /// requested.
- /// </summary>
- public Dictionary<string, object> Parameters
- {
- get
- {
- Dictionary<string, object> ret = new Dictionary<string, object>();
- ret.Add("SpecularColor", SpecularColor);
- ret.Add("SpecularPower", SpecularPower);
- return ret;
- }
- }
- #endregion
-
- #region Constructors
- /// <summary>
- /// Create specular shader feature
- /// </summary>
- public SpecularShaderFeature()
- {
- }
-
- /// <summary>
- /// Create specular shader feature
- /// </summary>
- public SpecularShaderFeature(BinaryReader reader)
- {
- Load(reader);
- }
- #endregion
-
- #region ISaveLoadBinary Members
- /// <summary>
- /// Load this ShaderFeature from a binary data stream.
- /// </summary>
- public void Load(BinaryReader reader)
- {
- SpecularColor.Load(reader);
- SpecularPower = reader.ReadSingle();
- }
-
- /// <summary>
- /// Save this ShaderFeature to a binary data stream.
- /// </summary>
- public void Save(BinaryWriter writer)
- {
- SpecularColor.Save(writer);
- writer.Write(SpecularPower);
- }
- #endregion
- }
- }