terrMaterial.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _TERRMATERIAL_H_
  23. #define _TERRMATERIAL_H_
  24. #ifndef _SIMBASE_H_
  25. #include "console/simBase.h"
  26. #endif
  27. #include "T3D/assets/ImageAsset.h"
  28. /// The TerrainMaterial class orginizes the material settings
  29. /// for a single terrain material layer.
  30. class TerrainMaterial : public SimObject
  31. {
  32. typedef SimObject Parent;
  33. protected:
  34. ///
  35. //FileName mDiffuseMap;
  36. //AssetPtr<ImageAsset> mDiffuseAsset;
  37. DECLARE_IMAGEASSET(TerrainMaterial, DiffuseMap, onDiffuseMapChanged, GFXStaticTextureSRGBProfile);
  38. DECLARE_ASSET_SETGET(TerrainMaterial, DiffuseMap);
  39. /// The size of the diffuse base map in meters
  40. /// used to generate its texture coordinates.
  41. F32 mDiffuseSize;
  42. ///
  43. DECLARE_IMAGEASSET(TerrainMaterial, NormalMap, onNormalMapChanged, GFXNormalMapProfile);
  44. DECLARE_ASSET_SETGET(TerrainMaterial, NormalMap);
  45. ///
  46. DECLARE_IMAGEASSET(TerrainMaterial, DetailMap, onDetailMapChanged, GFXStaticTextureProfile);
  47. DECLARE_ASSET_SETGET(TerrainMaterial, DetailMap);
  48. /// The size of the detail map in meters used
  49. /// to generate the texture coordinates for the
  50. /// detail and normal maps.
  51. F32 mDetailSize;
  52. ///
  53. F32 mDetailStrength;
  54. ///
  55. F32 mDetailDistance;
  56. ///
  57. DECLARE_IMAGEASSET(TerrainMaterial, ORMConfigMap, onORMConfigMapChanged, GFXStaticTextureProfile);
  58. DECLARE_ASSET_SETGET(TerrainMaterial, ORMConfigMap);
  59. bool mIsSRGB;
  60. bool mInvertRoughness;
  61. /// Normally the detail is projected on to the xy
  62. /// coordinates of the terrain. If this flag is true
  63. /// then this detail is projected along the xz and yz
  64. /// planes.
  65. bool mSideProjection;
  66. DECLARE_IMAGEASSET(TerrainMaterial, MacroMap, onMacroMapChanged, GFXStaticTextureProfile);
  67. DECLARE_ASSET_SETGET(TerrainMaterial, MacroMap);
  68. F32 mMacroSize;
  69. F32 mMacroStrength;
  70. F32 mMacroDistance;
  71. ///
  72. F32 mParallaxScale;
  73. /// Depth for blending the textures using the new
  74. /// blending method. Higher numbers = larger blend
  75. /// radius.
  76. F32 mBlendDepth;
  77. F32 mBlendContrast;
  78. public:
  79. TerrainMaterial();
  80. virtual ~TerrainMaterial();
  81. bool onAdd();
  82. static void initPersistFields();
  83. DECLARE_CONOBJECT( TerrainMaterial );
  84. /// This method locates the TerrainMaterial if it exists, tries
  85. /// to create a new one if a valid texture path was passed, or
  86. /// returns a debug material if all else fails.
  87. static TerrainMaterial* findOrCreate( const char *nameOrPath );
  88. /// Returns the default warning terrain material used when
  89. /// a material is not found or defined.
  90. static TerrainMaterial* getWarningMaterial();
  91. F32 getDiffuseSize() const { return mDiffuseSize; }
  92. F32 getDetailSize() const { return mDetailSize; }
  93. F32 getDetailStrength() const { return mDetailStrength; }
  94. F32 getDetailDistance() const { return mDetailDistance; }
  95. F32 getMacroSize() const { return mMacroSize; }
  96. F32 getMacroDistance() const { return mMacroDistance; }
  97. F32 getMacroStrength() const { return mMacroStrength; }
  98. bool useSideProjection() const { return mSideProjection; }
  99. F32 getParallaxScale() const { return mParallaxScale; }
  100. F32 getBlendDepth() const { return mBlendDepth; }
  101. F32 getBlendContrast() const { return mBlendContrast; }
  102. bool getIsSRGB() const { return mIsSRGB; }
  103. bool getInvertRoughness() const { return mInvertRoughness; }
  104. void onDiffuseMapChanged() {}
  105. void onNormalMapChanged() {}
  106. void onDetailMapChanged() {}
  107. void onORMConfigMapChanged() {}
  108. void onMacroMapChanged() {}
  109. };
  110. #endif // _TERRMATERIAL_H_