OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreTerrainMaterialGeneratorA.h
Go to the documentation of this file.
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 
34 #include "OgreGpuProgramParams.h"
35 
36 namespace Ogre
37 {
38  class PSSMShadowCameraSetup;
39 
54  {
55  public:
57  virtual ~TerrainMaterialGeneratorA();
58 
62  {
63  public:
64  SM2Profile(TerrainMaterialGenerator* parent, const String& name, const String& desc);
65  virtual ~SM2Profile();
66  MaterialPtr generate(const Terrain* terrain);
67  MaterialPtr generateForCompositeMap(const Terrain* terrain);
68  uint8 getMaxLayers(const Terrain* terrain) const;
69  void updateParams(const MaterialPtr& mat, const Terrain* terrain);
70  void updateParamsForCompositeMap(const MaterialPtr& mat, const Terrain* terrain);
71  void requestOptions(Terrain* terrain);
72  bool isVertexCompressionSupported() const;
73 
76  bool isLayerNormalMappingEnabled() const { return mLayerNormalMappingEnabled; }
79  void setLayerNormalMappingEnabled(bool enabled);
82  bool isLayerParallaxMappingEnabled() const { return mLayerParallaxMappingEnabled; }
85  void setLayerParallaxMappingEnabled(bool enabled);
88  bool isLayerSpecularMappingEnabled() const { return mLayerSpecularMappingEnabled; }
91  void setLayerSpecularMappingEnabled(bool enabled);
95  bool isGlobalColourMapEnabled() const { return mGlobalColourMapEnabled; }
99  void setGlobalColourMapEnabled(bool enabled);
103  bool isLightmapEnabled() const { return mLightmapEnabled; }
107  void setLightmapEnabled(bool enabled);
111  bool isCompositeMapEnabled() const { return mCompositeMapEnabled; }
115  void setCompositeMapEnabled(bool enabled);
119  bool getReceiveDynamicShadowsEnabled() const { return mReceiveDynamicShadows; }
123  void setReceiveDynamicShadowsEnabled(bool enabled);
124 
128  void setReceiveDynamicShadowsPSSM(PSSMShadowCameraSetup* pssmSettings);
135  void setReceiveDynamicShadowsDepth(bool enabled);
138  bool getReceiveDynamicShadowsDepth() const { return mDepthShadows; }
141  void setReceiveDynamicShadowsLowLod(bool enabled);
144  bool getReceiveDynamicShadowsLowLod() const { return mLowLodShadows; }
145 
147  bool _isSM3Available() const { return mSM3Available; }
148  bool _isSM4Available() const { return mSM4Available; }
149  String _getShaderLanguage() const { return mShaderLanguage; }
150 
151  protected:
152 
154  {
157  RENDER_COMPOSITE_MAP
158  };
159  void addTechnique(const MaterialPtr& mat, const Terrain* terrain, TechniqueType tt);
160 
163  {
164  public:
165  ShaderHelper() : mShadowSamplerStartHi(0), mShadowSamplerStartLo(0) {}
166  virtual ~ShaderHelper() {}
167  virtual HighLevelGpuProgramPtr generateVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
168  virtual HighLevelGpuProgramPtr generateFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
169  virtual void updateParams(const SM2Profile* prof, const MaterialPtr& mat, const Terrain* terrain, bool compositeMap);
170  protected:
171  virtual String getVertexProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
172  virtual String getFragmentProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
173  virtual HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
174  virtual HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
175  virtual void generateVertexProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
176  virtual void generateFragmentProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
177  virtual void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
178  virtual void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
179  virtual void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
180  virtual void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
181  virtual void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
182  virtual void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
183  virtual void defaultVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
184  virtual void defaultFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
185  virtual void updateVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
186  virtual void updateFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
187  static String getChannel(uint idx);
188 
191  };
192 
195  {
196  protected:
197  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
198  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
199  void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
200  void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
201  void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
202  void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
203  void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
204  void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
205  uint generateVpDynamicShadowsParams(uint texCoordStart, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
206  void generateVpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
207  void generateFpDynamicShadowsHelpers(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
208  void generateFpDynamicShadowsParams(uint* texCoord, uint* sampler, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
209  void generateFpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
210  };
211 
213  {
214  protected:
215  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
216  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
217  };
218 
221  {
222  protected:
223  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
224  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
225  void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
226  void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
227  void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
228  void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
229  void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
230  void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
231  uint generateVpDynamicShadowsParams(uint texCoordStart, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
232  void generateVpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
233  void generateFpDynamicShadowsHelpers(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
234  void generateFpDynamicShadowsParams(uint* texCoord, uint* sampler, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
235  void generateFpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
236  };
237 
240  {
241  protected:
242  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
243  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
244  void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
245  void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
246  void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
247  void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
248  void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
249  void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
250  uint generateVpDynamicShadowsParams(uint texCoordStart, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
251  void generateVpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
252  void generateFpDynamicShadowsHelpers(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
253  void generateFpDynamicShadowsParams(uint* texCoord, uint* sampler, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
254  void generateFpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
255  };
256 
271 
272  bool isShadowingEnabled(TechniqueType tt, const Terrain* terrain) const;
273  };
274  };
277 }
278 
279 #endif
280 
unsigned char uint8
Definition: OgrePlatform.h:346
bool isCompositeMapEnabled() const
Whether to use the composite map to provide a lower LOD technique in the distance (default true)...
Class that provides functionality to generate materials for use with a terrain.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:262
bool isLayerParallaxMappingEnabled() const
Whether to support parallax mapping per layer in the shader (default true).
Utility class to help with generating shaders for GLSL ES.
PSSMShadowCameraSetup * getReceiveDynamicShadowsPSSM() const
Whether to use PSSM support dynamic texture shadows, and if so the settings to use (default 0)...
Interface definition for helper class to generate shaders.
bool getReceiveDynamicShadowsEnabled() const
Whether to support dynamic texture shadows received from other objects, on the terrain (default true)...
StringStream StrStreamType
Definition: OgreString.h:78
bool getReceiveDynamicShadowsDepth() const
Whether to use depth shadows (default false).
bool isLayerNormalMappingEnabled() const
Whether to support normal mapping per layer in the shader (default true).
Utility class to help with generating shaders for GLSL.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
A TerrainMaterialGenerator which can cope with normal mapped, specular mapped terrain.
bool getReceiveDynamicShadowsLowLod() const
Whether to use shadows on low LOD material rendering (when using composite map) (default false)...
#define _OgreTerrainExport
Parallel Split Shadow Map (PSSM) shadow camera setup.
bool isLayerSpecularMappingEnabled() const
Whether to support specular mapping per layer in the shader (default true).
bool isGlobalColourMapEnabled() const
Whether to support a global colour map over the terrain in the shader, if it's present (default true)...
Utility class to help with generating shaders for Cg / HLSL.
_StringBase String
Inner class which should also be subclassed to provide profile-specific material generation.
bool isLightmapEnabled() const
Whether to support a light map over the terrain in the shader, if it's present (default true)...
unsigned int uint