OGRE  1.8
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-2013 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:
58 
62  {
63  public:
64  SM2Profile(TerrainMaterialGenerator* parent, const String& name, const String& desc);
65  ~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 
150  protected:
151 
153  {
156  RENDER_COMPOSITE_MAP
157  };
158  void addTechnique(const MaterialPtr& mat, const Terrain* terrain, TechniqueType tt);
159 
162  {
163  public:
165  virtual ~ShaderHelper() {}
166  virtual HighLevelGpuProgramPtr generateVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
167  virtual HighLevelGpuProgramPtr generateFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
168  virtual void updateParams(const SM2Profile* prof, const MaterialPtr& mat, const Terrain* terrain, bool compositeMap);
169  protected:
170  virtual String getVertexProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
171  virtual String getFragmentProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
172  virtual HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
173  virtual HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
174  virtual void generateVertexProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
175  virtual void generateFragmentProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
176  virtual void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
177  virtual void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
178  virtual void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
179  virtual void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
180  virtual void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
181  virtual void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
182  virtual void defaultVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
183  virtual void defaultFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
184  virtual void updateVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
185  virtual void updateFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
186  static String getChannel(uint idx);
187 
190 
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  };
232 
235  {
236  protected:
237  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
238  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
239  void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
240  void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
241  void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) {}
242  void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) {}
243  void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
244  void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
245  };
246 
260 
261  bool isShadowingEnabled(TechniqueType tt, const Terrain* terrain) const;
262 
263  };
264 
265 
266 
267 
268  };
269 
270 
271 
276 }
277 
278 #endif
279 
unsigned char uint8
Definition: OgrePlatform.h:272
void generateVpLayer(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType &outStream)
bool isCompositeMapEnabled() const
Whether to use the composite map to provide a lower LOD technique in the distance (default true)...
void generateVpHeader(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
Class that provides functionality to generate materials for use with a terrain.
The main containing class for a chunk of terrain.
Definition: OgreTerrain.h:261
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)...
void generateVpFooter(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
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
Specialisation of SharedPtr to allow SharedPtr to be assigned to HighLevelGpuProgramPtr.
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.
void generateFpHeader(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
void generateVpFooter(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
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
void generateVpLayer(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType &outStream)
void generateFpFooter(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
void generateFpFooter(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
Parallel Split Shadow Map (PSSM) shadow camera setup.
void generateFpHeader(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
bool isLayerSpecularMappingEnabled() const
Whether to support specular mapping per layer in the shader (default true).
void generateVpHeader(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, StringUtil::StrStreamType &outStream)
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.
void generateFpLayer(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType &outStream)
_StringBase String
Inner class which should also be subclassed to provide profile-specific material generation.
Specialisation of SharedPtr to allow SharedPtr to be assigned to MaterialPtr.
Definition: OgreMaterial.h:688
bool isLightmapEnabled() const
Whether to support a light map over the terrain in the shader, if it's present (default true)...
void generateFpLayer(const SM2Profile *prof, const Terrain *terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType &outStream)
unsigned int uint