Use a shader if required to display the composite map

Fixes composited terrain not respecting the 'clamp lighting' setting.
pull/1225/head
scrawl 8 years ago
parent 7f5beb3172
commit 088d5604bf

@ -201,12 +201,14 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
mCompositeMapRenderer->addCompositeMap(compositeMap.get(), false);
std::vector<osg::ref_ptr<osg::StateSet> > passes2;
passes2.push_back(new osg::StateSet);
passes2[0]->setTextureAttributeAndModes(0, compositeMap->mTexture, osg::StateAttribute::ON);
geometry->setPasses(passes2);
transform->getOrCreateUserDataContainer()->setUserData(compositeMap);
TextureLayer layer;
layer.mDiffuseMap = compositeMap->mTexture;
layer.mParallax = false;
layer.mSpecular = false;
geometry->setPasses(::Terrain::createPasses(mSceneManager->getForceShaders() || !mSceneManager->getClampLighting(), mSceneManager->getForcePerPixelLighting(),
mSceneManager->getClampLighting(), &mSceneManager->getShaderManager(), std::vector<TextureLayer>(1, layer), std::vector<osg::ref_ptr<osg::Texture2D> >(), 1.f, 1.f));
}
else
{

@ -81,7 +81,8 @@ namespace Terrain
{
stateset->setTextureAttributeAndModes(texunit, it->mDiffuseMap);
stateset->setTextureAttributeAndModes(texunit, getLayerTexMat(layerTileSize), osg::StateAttribute::ON);
if (layerTileSize != 1.f)
stateset->setTextureAttributeAndModes(texunit, getLayerTexMat(layerTileSize), osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("diffuseMap", texunit));
@ -147,7 +148,8 @@ namespace Terrain
osg::ref_ptr<osg::Texture2D> tex = it->mDiffuseMap;
stateset->setTextureAttributeAndModes(texunit, tex.get());
stateset->setTextureAttributeAndModes(texunit, getLayerTexMat(layerTileSize), osg::StateAttribute::ON);
if (layerTileSize != 1.f)
stateset->setTextureAttributeAndModes(texunit, getLayerTexMat(layerTileSize), osg::StateAttribute::ON);
}
firstLayer = false;

Loading…
Cancel
Save