2013-08-16 11:01:52 +00:00
|
|
|
#ifndef COMPONENTS_TERRAIN_MATERIAL_H
|
|
|
|
#define COMPONENTS_TERRAIN_MATERIAL_H
|
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
#include <osgFX/Technique>
|
|
|
|
#include <osgFX/Effect>
|
2013-08-16 11:01:52 +00:00
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
#include "defs.hpp"
|
|
|
|
|
|
|
|
namespace osg
|
|
|
|
{
|
|
|
|
class Texture2D;
|
|
|
|
}
|
2013-12-04 20:43:10 +00:00
|
|
|
|
2016-02-19 00:30:15 +00:00
|
|
|
namespace Shader
|
|
|
|
{
|
|
|
|
class ShaderManager;
|
|
|
|
}
|
|
|
|
|
2013-08-16 11:01:52 +00:00
|
|
|
namespace Terrain
|
|
|
|
{
|
|
|
|
|
2016-02-19 00:30:15 +00:00
|
|
|
struct TextureLayer
|
|
|
|
{
|
|
|
|
osg::ref_ptr<osg::Texture2D> mDiffuseMap;
|
|
|
|
osg::ref_ptr<osg::Texture2D> mNormalMap; // optional
|
2016-02-20 18:54:47 +00:00
|
|
|
bool mSpecular;
|
2016-02-19 00:30:15 +00:00
|
|
|
};
|
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
class FixedFunctionTechnique : public osgFX::Technique
|
2013-08-16 11:01:52 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-06-02 23:18:36 +00:00
|
|
|
FixedFunctionTechnique(
|
2016-02-19 00:30:15 +00:00
|
|
|
const std::vector<TextureLayer>& layers,
|
|
|
|
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void define_passes() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class ShaderTechnique : public osgFX::Technique
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ShaderTechnique(Shader::ShaderManager& shaderManager, bool forcePerPixelLighting, bool clampLighting,
|
|
|
|
const std::vector<TextureLayer>& layers,
|
2015-11-06 19:14:57 +00:00
|
|
|
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize);
|
2013-08-16 11:01:52 +00:00
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
protected:
|
|
|
|
virtual void define_passes() {}
|
|
|
|
};
|
2013-08-20 07:52:27 +00:00
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
class Effect : public osgFX::Effect
|
|
|
|
{
|
|
|
|
public:
|
2016-02-19 14:00:50 +00:00
|
|
|
Effect(bool useShaders, bool forcePerPixelLighting, bool clampLighting, Shader::ShaderManager* shaderManager,
|
2016-02-19 00:30:15 +00:00
|
|
|
const std::vector<TextureLayer>& layers,
|
2015-11-06 19:14:57 +00:00
|
|
|
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapScale, float layerTileSize);
|
2013-08-16 11:01:52 +00:00
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
virtual bool define_techniques();
|
2013-08-16 11:01:52 +00:00
|
|
|
|
2015-06-02 23:18:36 +00:00
|
|
|
virtual const char *effectName() const
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
virtual const char *effectDescription() const
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
virtual const char *effectAuthor() const
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-08-16 11:01:52 +00:00
|
|
|
|
|
|
|
private:
|
2016-02-19 14:00:50 +00:00
|
|
|
Shader::ShaderManager* mShaderManager;
|
2016-02-19 00:30:15 +00:00
|
|
|
bool mUseShaders;
|
|
|
|
bool mForcePerPixelLighting;
|
|
|
|
bool mClampLighting;
|
|
|
|
std::vector<TextureLayer> mLayers;
|
2015-06-02 23:18:36 +00:00
|
|
|
std::vector<osg::ref_ptr<osg::Texture2D> > mBlendmaps;
|
2015-11-06 19:14:57 +00:00
|
|
|
int mBlendmapScale;
|
2015-11-06 14:23:37 +00:00
|
|
|
float mLayerTileSize;
|
2013-08-16 11:01:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|