PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/Utilities/Graphics/ShaderFeatures/NormalMappingShaderFeature.cs

#
C# | 101 lines | 59 code | 8 blank | 34 comment | 0 complexity | 2c361a680cb3da185a047ecd1a048585 MD5 | raw file
  1using System.Collections.Generic;
  2using System.IO;
  3
  4namespace Delta.Utilities.Graphics.ShaderFeatures
  5{
  6	/// <summary>
  7	/// Normal mapping shader feature
  8	/// Note: Make sure that the normal map required also the PointLight.
  9	/// </summary>
 10	public class NormalMapShaderFeature : IShaderFeature
 11	{
 12		#region NormalMap (Public)
 13		/// <summary>
 14		/// NormalMap, is always set except when ShaderFeatureFlags.NoTexturing is
 15		/// set (then we don't want a diffuse map and this setting is ignored).
 16		/// </summary>
 17		public string NormalMap = "";
 18		#endregion
 19
 20		#region ShaderFeature (Public)
 21		/// <summary>
 22		/// Which shader feature flag is this ShaderFeature class using?
 23		/// Important for loading this file via ShaderData.LoadShaderFeature.
 24		/// Each flag should obviously only have one class for it!
 25		/// </summary>
 26		public ShaderFeatureFlags ShaderFeature
 27		{
 28			get
 29			{
 30				return ShaderFeatureFlags.NormalMap;
 31			}
 32		}
 33		#endregion
 34
 35		#region RequiredShaderFeatures (Public)
 36		/// <summary>
 37		/// Which shader feature flags are required for this ShaderFeature.
 38		/// Very important for creating of a new ShaderFeature.
 39		/// </summary>
 40		public ShaderFeatureFlags RequiredShaderFeatures
 41		{
 42			get
 43			{
 44				return ShaderFeatureFlags.DynamicDirectionalLighting;
 45			}
 46		}
 47		#endregion
 48
 49		#region Parameters (Public)
 50		/// <summary>
 51		/// Parameters as a dictionary, willl be generated on the fly when
 52		/// requested.
 53		/// </summary>
 54		public Dictionary<string, object> Parameters
 55		{
 56			get
 57			{
 58				Dictionary<string, object> ret = new Dictionary<string, object>();
 59				ret.Add("NormalMap", NormalMap);
 60				return ret;
 61			}
 62		}
 63		#endregion
 64
 65		#region Constructors
 66		/// <summary>
 67		/// Create normal mapping shader feature
 68		/// </summary>
 69		public NormalMapShaderFeature()
 70		{
 71		}
 72
 73		/// <summary>
 74		/// Create normal mapping shader feature and load automatically
 75		/// the ShaderFeatures from a binary data stream.
 76		/// </summary>
 77		public NormalMapShaderFeature(BinaryReader reader)
 78		{
 79			Load(reader);
 80		}
 81		#endregion
 82
 83		#region ISaveLoadBinary Members
 84		/// <summary>
 85		/// Load this ShaderFeature from a binary data stream.
 86		/// </summary>
 87		public void Load(BinaryReader reader)
 88		{
 89			NormalMap = reader.ReadString();
 90		}
 91
 92		/// <summary>
 93		/// Save this ShaderFeature to a binary data stream.
 94		/// </summary>
 95		public void Save(BinaryWriter writer)
 96		{
 97			writer.Write(NormalMap);
 98		}
 99		#endregion
100	}
101}