PageRenderTime 72ms CodeModel.GetById 30ms app.highlight 3ms RepoModel.GetById 37ms app.codeStats 0ms

/Utilities/Graphics/ShaderFeatures/FresnelShaderFeature.cs

#
C# | 108 lines | 65 code | 9 blank | 34 comment | 0 complexity | 181469420a682f2015029414f8fa1fdb MD5 | raw file
  1using System.Collections.Generic;
  2using System.IO;
  3
  4namespace Delta.Utilities.Graphics.ShaderFeatures
  5{
  6	/// <summary>
  7	/// Fresnel shader feature
  8	/// </summary>
  9	public class FresnelShaderFeature : IShaderFeature
 10	{
 11		#region FresnelPower (Public)
 12		/// <summary>
 13		/// Fresnel power.
 14		/// </summary>
 15		public float FresnelPower = ShaderConstants.DefaultSpecularPower;
 16		#endregion
 17
 18		#region FresnelFactor (Public)
 19		/// <summary>
 20		/// Fresnel factor.
 21		/// </summary>
 22		public float FresnelFactor = ShaderConstants.DefaultFresnelFactor;
 23		#endregion
 24
 25		#region ShaderFeature (Public)
 26		/// <summary>
 27		/// Which shader feature flag is this ShaderFeature class using?
 28		/// Important for loading this file via ShaderData.LoadShaderFeature.
 29		/// Each flag should obviously only have one class for it!
 30		/// </summary>
 31		public ShaderFeatureFlags ShaderFeature
 32		{
 33			get
 34			{
 35				return ShaderFeatureFlags.Fresnel;
 36			}
 37		}
 38		#endregion
 39
 40		#region RequiredShaderFeatures (Public)
 41		/// <summary>
 42		/// Which shader feature flags are required for this ShaderFeature.
 43		/// Very important for creating of a new ShaderFeature.
 44		/// </summary>
 45		public ShaderFeatureFlags RequiredShaderFeatures
 46		{
 47			get
 48			{
 49				return ShaderFeatureFlags.Specular;
 50			}
 51		}
 52		#endregion
 53
 54		#region Parameters (Public)
 55		/// <summary>
 56		/// Parameters as a dictionary, will be generated on the fly when
 57		/// requested.
 58		/// </summary>
 59		public Dictionary<string, object> Parameters
 60		{
 61			get
 62			{
 63				Dictionary<string, object> ret = new Dictionary<string, object>();
 64				ret.Add("FresnelPower", FresnelPower);
 65				ret.Add("FresnelFactor", FresnelFactor);
 66				return ret;
 67			}
 68		}
 69		#endregion
 70
 71		#region Constructors
 72		/// <summary>
 73		/// Create fresnel shader feature
 74		/// </summary>
 75		public FresnelShaderFeature()
 76		{
 77		}
 78
 79		/// <summary>
 80		/// Create fresnel shader feature
 81		/// </summary>
 82		public FresnelShaderFeature(BinaryReader reader)
 83		{
 84			Load(reader);
 85		}
 86		#endregion
 87
 88		#region ISaveLoadBinary Members
 89		/// <summary>
 90		/// Load this ShaderFeature from a binary data stream.
 91		/// </summary>
 92		public void Load(BinaryReader reader)
 93		{
 94			FresnelPower = reader.ReadSingle();
 95			FresnelFactor = reader.ReadSingle();
 96		}
 97
 98		/// <summary>
 99		/// Save this ShaderFeature to a binary data stream.
100		/// </summary>
101		public void Save(BinaryWriter writer)
102		{
103			writer.Write(FresnelPower);
104			writer.Write(FresnelFactor);
105		}
106		#endregion
107	}
108}