OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
material.hpp
Go to the documentation of this file.
1 #ifndef COMPONENTS_TERRAIN_MATERIAL_H
2 #define COMPONENTS_TERRAIN_MATERIAL_H
3 
4 #include <osgFX/Technique>
5 #include <osgFX/Effect>
6 
7 #include "defs.hpp"
8 
9 namespace osg
10 {
11  class Texture2D;
12 }
13 
14 namespace Shader
15 {
16  class ShaderManager;
17 }
18 
19 namespace Terrain
20 {
21 
22  struct TextureLayer
23  {
24  osg::ref_ptr<osg::Texture2D> mDiffuseMap;
25  osg::ref_ptr<osg::Texture2D> mNormalMap; // optional
26  bool mParallax;
27  bool mSpecular;
28  };
29 
30  class FixedFunctionTechnique : public osgFX::Technique
31  {
32  public:
34  const std::vector<TextureLayer>& layers,
35  const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize);
36 
37  protected:
38  virtual void define_passes() {}
39  };
40 
41  class ShaderTechnique : public osgFX::Technique
42  {
43  public:
44  ShaderTechnique(Shader::ShaderManager& shaderManager, bool forcePerPixelLighting, bool clampLighting,
45  const std::vector<TextureLayer>& layers,
46  const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize);
47 
48  protected:
49  virtual void define_passes() {}
50  };
51 
52  class Effect : public osgFX::Effect
53  {
54  public:
55  Effect(bool useShaders, bool forcePerPixelLighting, bool clampLighting, Shader::ShaderManager* shaderManager,
56  const std::vector<TextureLayer>& layers,
57  const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize);
58 
59  virtual bool define_techniques();
60 
61  virtual const char *effectName() const
62  {
63  return NULL;
64  }
65  virtual const char *effectDescription() const
66  {
67  return NULL;
68  }
69  virtual const char *effectAuthor() const
70  {
71  return NULL;
72  }
73 
74  private:
79  std::vector<TextureLayer> mLayers;
80  std::vector<osg::ref_ptr<osg::Texture2D> > mBlendmaps;
83  };
84 
85 }
86 
87 #endif
bool mUseShaders
Definition: material.hpp:76
bool mParallax
Definition: material.hpp:26
Definition: material.hpp:52
bool mSpecular
Definition: material.hpp:27
osg::ref_ptr< osg::Texture2D > mDiffuseMap
Definition: material.hpp:24
Effect(bool useShaders, bool forcePerPixelLighting, bool clampLighting, Shader::ShaderManager *shaderManager, const std::vector< TextureLayer > &layers, const std::vector< osg::ref_ptr< osg::Texture2D > > &blendmaps, int blendmapScale, float layerTileSize)
Definition: material.cpp:175
virtual bool define_techniques()
Definition: material.cpp:189
virtual const char * effectAuthor() const
Definition: material.hpp:69
virtual void define_passes()
Definition: material.hpp:38
bool mClampLighting
Definition: material.hpp:78
virtual const char * effectDescription() const
Definition: material.hpp:65
FixedFunctionTechnique(const std::vector< TextureLayer > &layers, const std::vector< osg::ref_ptr< osg::Texture2D > > &blendmaps, int blendmapScale, float layerTileSize)
Definition: material.cpp:61
Shader::ShaderManager * mShaderManager
Definition: material.hpp:75
float mLayerTileSize
Definition: material.hpp:82
virtual const char * effectName() const
Definition: material.hpp:61
bool mForcePerPixelLighting
Definition: material.hpp:77
Definition: material.hpp:22
Reads shader template files and turns them into a concrete shader, based on a list of define's...
Definition: shadermanager.hpp:18
osg::ref_ptr< osg::Texture2D > mNormalMap
Definition: material.hpp:25
Definition: material.hpp:30
ShaderTechnique(Shader::ShaderManager &shaderManager, bool forcePerPixelLighting, bool clampLighting, const std::vector< TextureLayer > &layers, const std::vector< osg::ref_ptr< osg::Texture2D > > &blendmaps, int blendmapScale, float layerTileSize)
Definition: material.cpp:112
std::vector< osg::ref_ptr< osg::Texture2D > > mBlendmaps
Definition: material.hpp:80
int mBlendmapScale
Definition: material.hpp:81
virtual void define_passes()
Definition: material.hpp:49
std::vector< TextureLayer > mLayers
Definition: material.hpp:79
Definition: material.hpp:41