OGRE  1.7
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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-2011 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 
75  bool isLayerNormalMappingEnabled() const { return mLayerNormalMappingEnabled; }
78  void setLayerNormalMappingEnabled(bool enabled);
81  bool isLayerParallaxMappingEnabled() const { return mLayerParallaxMappingEnabled; }
84  void setLayerParallaxMappingEnabled(bool enabled);
87  bool isLayerSpecularMappingEnabled() const { return mLayerSpecularMappingEnabled; }
90  void setLayerSpecularMappingEnabled(bool enabled);
94  bool isGlobalColourMapEnabled() const { return mGlobalColourMapEnabled; }
98  void setGlobalColourMapEnabled(bool enabled);
102  bool isLightmapEnabled() const { return mLightmapEnabled; }
106  void setLightmapEnabled(bool enabled);
110  bool isCompositeMapEnabled() const { return mCompositeMapEnabled; }
114  void setCompositeMapEnabled(bool enabled);
118  bool getReceiveDynamicShadowsEnabled() const { return mReceiveDynamicShadows; }
122  void setReceiveDynamicShadowsEnabled(bool enabled);
123 
127  void setReceiveDynamicShadowsPSSM(PSSMShadowCameraSetup* pssmSettings);
134  void setReceiveDynamicShadowsDepth(bool enabled);
137  bool getReceiveDynamicShadowsDepth() const { return mDepthShadows; }
140  void setReceiveDynamicShadowsLowLod(bool enabled);
143  bool getReceiveDynamicShadowsLowLod() const { return mLowLodShadows; }
144 
146  bool _isSM3Available() const { return mSM3Available; }
147 
148  protected:
149 
151  {
154  RENDER_COMPOSITE_MAP
155  };
156  void addTechnique(const MaterialPtr& mat, const Terrain* terrain, TechniqueType tt);
157 
160  {
161  public:
163  virtual ~ShaderHelper() {}
164  virtual HighLevelGpuProgramPtr generateVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
165  virtual HighLevelGpuProgramPtr generateFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
166  virtual void updateParams(const SM2Profile* prof, const MaterialPtr& mat, const Terrain* terrain, bool compositeMap);
167  protected:
168  virtual String getVertexProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
169  virtual String getFragmentProgramName(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
170  virtual HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
171  virtual HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt) = 0;
172  virtual void generateVertexProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
173  virtual void generateFragmentProgramSource(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
174  virtual void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
175  virtual void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
176  virtual void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
177  virtual void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) = 0;
178  virtual void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
179  virtual void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) = 0;
180  virtual void defaultVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
181  virtual void defaultFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const HighLevelGpuProgramPtr& prog);
182  virtual void updateVpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
183  virtual void updateFpParams(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, const GpuProgramParametersSharedPtr& params);
184  static String getChannel(uint idx);
185 
188 
189  };
190 
193  {
194  protected:
195  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
196  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
197  void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
198  void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
199  void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
200  void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream);
201  void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
202  void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
203  uint generateVpDynamicShadowsParams(uint texCoordStart, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
204  void generateVpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
205  void generateFpDynamicShadowsHelpers(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
206  void generateFpDynamicShadowsParams(uint* texCoord, uint* sampler, const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
207  void generateFpDynamicShadows(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream);
208  };
209 
211  {
212  protected:
213  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
214  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
215  };
216 
219  {
220  protected:
221  HighLevelGpuProgramPtr createVertexProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
222  HighLevelGpuProgramPtr createFragmentProgram(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt);
223  void generateVpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
224  void generateFpHeader(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
225  void generateVpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) {}
226  void generateFpLayer(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, uint layer, StringUtil::StrStreamType& outStream) {}
227  void generateVpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
228  void generateFpFooter(const SM2Profile* prof, const Terrain* terrain, TechniqueType tt, StringUtil::StrStreamType& outStream) {}
229  };
230 
243 
244  bool isShadowingEnabled(TechniqueType tt, const Terrain* terrain) const;
245 
246  };
247 
248 
249 
250 
251  };
252 
253 
254 
259 }
260 
261 #endif
262 
unsigned char uint8
Definition: OgrePlatform.h:248
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).
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:77
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.
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)...
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)
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).
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:677
bool isLightmapEnabled() const
Whether to support a light map over the terrain in the shader, if it's present (default true)...
unsigned int uint