PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Utilities/Graphics/ShaderFeatures/NormalMappingShaderFeature.cs

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