forked from teamnwah/openmw-tes3coop
Terrain: make the blendmapSize and layerTileSize in FixedFunctionTechnique configurable
This commit is contained in:
parent
e081eb2c34
commit
95cf13e3f2
3 changed files with 15 additions and 9 deletions
|
@ -11,7 +11,7 @@ namespace Terrain
|
|||
{
|
||||
|
||||
FixedFunctionTechnique::FixedFunctionTechnique(const std::vector<osg::ref_ptr<osg::Texture2D> >& layers,
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps)
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapSize, float layerTileSize)
|
||||
{
|
||||
bool firstLayer = true;
|
||||
int i=0;
|
||||
|
@ -36,7 +36,7 @@ namespace Terrain
|
|||
|
||||
// This is to map corner vertices directly to the center of a blendmap texel.
|
||||
osg::Matrixf texMat;
|
||||
float scale = (16/(16.f+1.f));
|
||||
float scale = (blendmapSize/(static_cast<float>(blendmapSize)+1.f));
|
||||
texMat.preMultTranslate(osg::Vec3f(0.5f, 0.5f, 0.f));
|
||||
texMat.preMultScale(osg::Vec3f(scale, scale, 1.f));
|
||||
texMat.preMultTranslate(osg::Vec3f(-0.5f, -0.5f, 0.f));
|
||||
|
@ -57,8 +57,7 @@ namespace Terrain
|
|||
stateset->setTextureAttributeAndModes(texunit, tex.get());
|
||||
|
||||
osg::ref_ptr<osg::TexMat> texMat (new osg::TexMat);
|
||||
float scale = 16.f;
|
||||
texMat->setMatrix(osg::Matrix::scale(osg::Vec3f(scale,scale,1.f)));
|
||||
texMat->setMatrix(osg::Matrix::scale(osg::Vec3f(layerTileSize,layerTileSize,1.f)));
|
||||
stateset->setTextureAttributeAndModes(texunit, texMat, osg::StateAttribute::ON);
|
||||
|
||||
firstLayer = false;
|
||||
|
@ -67,9 +66,12 @@ namespace Terrain
|
|||
}
|
||||
}
|
||||
|
||||
Effect::Effect(const std::vector<osg::ref_ptr<osg::Texture2D> > &layers, const std::vector<osg::ref_ptr<osg::Texture2D> > &blendmaps)
|
||||
Effect::Effect(const std::vector<osg::ref_ptr<osg::Texture2D> > &layers, const std::vector<osg::ref_ptr<osg::Texture2D> > &blendmaps,
|
||||
int blendmapSize, float layerTileSize)
|
||||
: mLayers(layers)
|
||||
, mBlendmaps(blendmaps)
|
||||
, mBlendmapSize(blendmapSize)
|
||||
, mLayerTileSize(layerTileSize)
|
||||
{
|
||||
osg::ref_ptr<osg::Material> material (new osg::Material);
|
||||
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
|
||||
|
@ -80,7 +82,7 @@ namespace Terrain
|
|||
|
||||
bool Effect::define_techniques()
|
||||
{
|
||||
addTechnique(new FixedFunctionTechnique(mLayers, mBlendmaps));
|
||||
addTechnique(new FixedFunctionTechnique(mLayers, mBlendmaps, mBlendmapSize, mLayerTileSize));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Terrain
|
|||
public:
|
||||
FixedFunctionTechnique(
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& layers,
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps);
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapSize, float layerTileSize);
|
||||
|
||||
protected:
|
||||
virtual void define_passes() {}
|
||||
|
@ -30,7 +30,7 @@ namespace Terrain
|
|||
public:
|
||||
Effect(
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& layers,
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps);
|
||||
const std::vector<osg::ref_ptr<osg::Texture2D> >& blendmaps, int blendmapSize, float layerTileSize);
|
||||
|
||||
virtual bool define_techniques();
|
||||
|
||||
|
@ -50,6 +50,8 @@ namespace Terrain
|
|||
private:
|
||||
std::vector<osg::ref_ptr<osg::Texture2D> > mLayers;
|
||||
std::vector<osg::ref_ptr<osg::Texture2D> > mBlendmaps;
|
||||
int mBlendmapSize;
|
||||
float mLayerTileSize;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
#include <components/sceneutil/lightmanager.hpp>
|
||||
|
||||
#include <components/esm/loadland.hpp>
|
||||
|
||||
#include <osg/PositionAttitudeTransform>
|
||||
#include <osg/Geometry>
|
||||
#include <osg/Geode>
|
||||
|
@ -150,7 +152,7 @@ void TerrainGrid::loadCell(int x, int y)
|
|||
for (unsigned int i=0; i<2; ++i)
|
||||
geometry->setTexCoordArray(i, mCache.getUVBuffer());
|
||||
|
||||
osg::ref_ptr<osgFX::Effect> effect (new Terrain::Effect(layerTextures, blendmapTextures));
|
||||
osg::ref_ptr<osgFX::Effect> effect (new Terrain::Effect(layerTextures, blendmapTextures, ESM::Land::LAND_TEXTURE_SIZE, ESM::Land::LAND_TEXTURE_SIZE));
|
||||
|
||||
effect->addCullCallback(new SceneUtil::LightListCallback);
|
||||
|
||||
|
|
Loading…
Reference in a new issue