/src/ogre/Components/Terrain/include/OgreTerrainMaterialGeneratorA.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | ----------------------------------------------------------------------------- |
3 | | This source file is part of OGRE |
4 | | (Object-oriented Graphics Rendering Engine) |
5 | | For the latest info, see http://www.ogre3d.org/ |
6 | | |
7 | | Copyright (c) 2000-2014 Torus Knot Software Ltd |
8 | | |
9 | | Permission is hereby granted, free of charge, to any person obtaining a copy |
10 | | of this software and associated documentation files (the "Software"), to deal |
11 | | in the Software without restriction, including without limitation the rights |
12 | | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
13 | | copies of the Software, and to permit persons to whom the Software is |
14 | | furnished to do so, subject to the following conditions: |
15 | | |
16 | | The above copyright notice and this permission notice shall be included in |
17 | | all copies or substantial portions of the Software. |
18 | | |
19 | | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
20 | | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
21 | | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
22 | | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
23 | | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
24 | | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
25 | | THE SOFTWARE. |
26 | | ----------------------------------------------------------------------------- |
27 | | */ |
28 | | |
29 | | #ifndef __Ogre_TerrainMaterialGeneratorA_H__ |
30 | | #define __Ogre_TerrainMaterialGeneratorA_H__ |
31 | | |
32 | | #include "OgreTerrainPrerequisites.h" |
33 | | #include "OgreTerrainMaterialGenerator.h" |
34 | | |
35 | | namespace Ogre |
36 | | { |
37 | | class PSSMShadowCameraSetup; |
38 | | |
39 | | namespace RTShader |
40 | | { |
41 | | class RenderState; |
42 | | } |
43 | | |
44 | | /** \addtogroup Optional |
45 | | * @{ |
46 | | */ |
47 | | /** \addtogroup Terrain |
48 | | * @{ |
49 | | */ |
50 | | |
51 | | /** A TerrainMaterialGenerator which can cope with normal mapped, specular mapped |
52 | | terrain. |
53 | | */ |
54 | | class _OgreTerrainExport TerrainMaterialGeneratorA : public TerrainMaterialGenerator |
55 | | { |
56 | | public: |
57 | | class SM2Profile; |
58 | | private: |
59 | | std::unique_ptr<RTShader::RenderState> mMainRenderState; |
60 | | std::unique_ptr<SM2Profile> mActiveProfile; |
61 | | bool mLightmapEnabled; |
62 | | bool mCompositeMapEnabled; |
63 | | bool mReceiveDynamicShadows; |
64 | | bool mLowLodShadows; |
65 | | public: |
66 | | TerrainMaterialGeneratorA(); |
67 | | virtual ~TerrainMaterialGeneratorA(); |
68 | | |
69 | 0 | RTShader::RenderState* getMainRenderState() const { return mMainRenderState.get(); } |
70 | | |
71 | | /** Shader model 2 profile target. |
72 | | */ |
73 | | class _OgreTerrainExport SM2Profile : public Profile |
74 | | { |
75 | | public: |
76 | | SM2Profile(TerrainMaterialGeneratorA* parent); |
77 | | virtual ~SM2Profile(); |
78 | | /// Generate / reuse a material for the terrain |
79 | | MaterialPtr generate(const Terrain* terrain); |
80 | | /// Get the number of layers supported |
81 | | uint8 getMaxLayers(const Terrain* terrain) const; |
82 | | /** Whether to support normal mapping per layer in the shader (default true). |
83 | | */ |
84 | 0 | bool isLayerNormalMappingEnabled() const { return mLayerNormalMappingEnabled; } |
85 | | /** Whether to support normal mapping per layer in the shader (default true). |
86 | | */ |
87 | | void setLayerNormalMappingEnabled(bool enabled); |
88 | | /** Whether to support parallax mapping per layer in the shader (default true). |
89 | | */ |
90 | 0 | bool isLayerParallaxMappingEnabled() const { return mLayerParallaxMappingEnabled; } |
91 | | /** Whether to support parallax mapping per layer in the shader (default true). |
92 | | */ |
93 | | void setLayerParallaxMappingEnabled(bool enabled); |
94 | | /** Whether to support steep parallax mapping per layer in the shader (default true). |
95 | | */ |
96 | | void setLayerParallaxOcclusionMappingEnabled(bool enabled); |
97 | | /** Whether to support steep parallax mapping per layer in the shader (default true). |
98 | | */ |
99 | 0 | bool isLayerOcclusionMappingEnabled() const { return mLayerParallaxOcclusionMappingEnabled; } |
100 | | /** Whether to support specular mapping per layer in the shader (default true). |
101 | | */ |
102 | 0 | bool isLayerSpecularMappingEnabled() const { return mLayerSpecularMappingEnabled; } |
103 | | /** Whether to support specular mapping per layer in the shader (default true). |
104 | | */ |
105 | | void setLayerSpecularMappingEnabled(bool enabled); |
106 | | |
107 | | |
108 | | /** Whether to use PSSM support dynamic texture shadows, and if so the |
109 | | settings to use (default 0). |
110 | | */ |
111 | | void setReceiveDynamicShadowsPSSM(PSSMShadowCameraSetup* pssmSettings); |
112 | | /** Whether to use PSSM support dynamic texture shadows, and if so the |
113 | | settings to use (default 0). |
114 | | */ |
115 | 0 | PSSMShadowCameraSetup* getReceiveDynamicShadowsPSSM() const { return mPSSM; } |
116 | | |
117 | 0 | void setLightmapEnabled(bool enabled) { mParent->setLightmapEnabled(enabled); } |
118 | 0 | void setCompositeMapEnabled(bool enabled) { mParent->setCompositeMapEnabled(enabled); } |
119 | 0 | void setReceiveDynamicShadowsEnabled(bool enabled) { mParent->setReceiveDynamicShadowsEnabled(enabled); } |
120 | 0 | void setReceiveDynamicShadowsLowLod(bool enabled) { mParent->setReceiveDynamicShadowsLowLod(enabled); } |
121 | | private: |
122 | | enum TechniqueType |
123 | | { |
124 | | HIGH_LOD, |
125 | | LOW_LOD, |
126 | | RENDER_COMPOSITE_MAP |
127 | | }; |
128 | | bool isShadowingEnabled(TechniqueType tt, const Terrain* terrain) const; |
129 | | TerrainMaterialGeneratorA* mParent; |
130 | | bool mLayerNormalMappingEnabled; |
131 | | bool mLayerParallaxMappingEnabled; |
132 | | bool mLayerParallaxOcclusionMappingEnabled; |
133 | | bool mLayerSpecularMappingEnabled; |
134 | | PSSMShadowCameraSetup* mPSSM; |
135 | | }; |
136 | | |
137 | | /** Whether to support normal mapping per layer in the shader (default true). |
138 | | */ |
139 | 0 | void setLayerNormalMappingEnabled(bool enabled) { mActiveProfile->setLayerNormalMappingEnabled(enabled); } |
140 | | |
141 | | /** Whether to support specular mapping per layer in the shader (default true). |
142 | | */ |
143 | 0 | void setLayerSpecularMappingEnabled(bool enabled) { mActiveProfile->setLayerSpecularMappingEnabled(enabled); } |
144 | | |
145 | | /** Whether to support dynamic texture shadows received from other |
146 | | objects, on the terrain (default true). |
147 | | */ |
148 | 0 | bool getReceiveDynamicShadowsEnabled() const { return mReceiveDynamicShadows; } |
149 | | /** Whether to support dynamic texture shadows received from other |
150 | | objects, on the terrain (default true). |
151 | | */ |
152 | | void setReceiveDynamicShadowsEnabled(bool enabled); |
153 | | |
154 | | /** Whether to use shadows on low LOD material rendering (when using composite map) (default false). |
155 | | */ |
156 | | void setReceiveDynamicShadowsLowLod(bool enabled); |
157 | | |
158 | | /** Whether to use shadows on low LOD material rendering (when using composite map) (default false). |
159 | | */ |
160 | 0 | bool getReceiveDynamicShadowsLowLod() const { return mLowLodShadows; } |
161 | | |
162 | 0 | bool isLightmapEnabled() const { return mLightmapEnabled; } |
163 | | /** Whether to use the composite map to provide a lower LOD technique |
164 | | in the distance (default true). |
165 | | */ |
166 | | void setCompositeMapEnabled(bool enabled); |
167 | 0 | bool isCompositeMapEnabled() const { return mCompositeMapEnabled; } |
168 | | |
169 | | /// Get the active profile |
170 | 0 | Profile* getActiveProfile() const override { return mActiveProfile.get(); } |
171 | | |
172 | 0 | bool isVertexCompressionSupported() const override { return true; } |
173 | | void requestOptions(Terrain* terrain) override; |
174 | 0 | MaterialPtr generate(const Terrain* terrain) override { return mActiveProfile->generate(terrain); } |
175 | | MaterialPtr generateForCompositeMap(const Terrain* terrain) override; |
176 | | void setLightmapEnabled(bool enabled) override; |
177 | 0 | uint8 getMaxLayers(const Terrain* terrain) const override { return mActiveProfile->getMaxLayers(terrain); } |
178 | | void updateParams(const MaterialPtr& mat, const Terrain* terrain) override; |
179 | | void updateParamsForCompositeMap(const MaterialPtr& mat, const Terrain* terrain) override; |
180 | | }; |
181 | | /** @} */ |
182 | | /** @} */ |
183 | | } |
184 | | |
185 | | #endif |
186 | | |