1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-29 21:45:32 +00:00

move renderbin

Signed-off-by: Bret Curtis <psi29a@gmail.com>
This commit is contained in:
bzzt lost a hitlab login 2020-05-07 13:37:00 +00:00 committed by Bret Curtis
parent 4dccabeb83
commit da92ad329b
5 changed files with 29 additions and 20 deletions

View file

@ -4,6 +4,7 @@
#include <osg/Texture2D>
#include <osg/ClusterCullingCallback>
#include <osg/Material>
#include <osgUtil/IncrementalCompileOperation>
@ -31,7 +32,11 @@ ChunkManager::ChunkManager(Storage *storage, Resource::SceneManager *sceneMgr, T
, mCompositeMapLevel(1.f)
, mMaxCompGeometrySize(1.f)
{
mMultiPassRoot = new osg::StateSet;
mMultiPassRoot->setRenderingHint(osg::StateSet::OPAQUE_BIN);
osg::ref_ptr<osg::Material> material (new osg::Material);
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
mMultiPassRoot->setAttributeAndModes(material, osg::StateAttribute::ON);
}
osg::ref_ptr<osg::Node> ChunkManager::getChunk(float size, const osg::Vec2f &center, unsigned char lod, unsigned int lodFlags, bool far, const osg::Vec3f& viewPoint, bool compile)
@ -196,6 +201,8 @@ osg::ref_ptr<osg::Node> ChunkManager::createChunk(float chunkSize, const osg::Ve
geometry->createClusterCullingCallback();
geometry->setStateSet(mMultiPassRoot);
if (useCompositeMap)
{
osg::ref_ptr<CompositeMap> compositeMap = new CompositeMap;

View file

@ -65,6 +65,8 @@ namespace Terrain
CompositeMapRenderer* mCompositeMapRenderer;
BufferCache mBufferCache;
osg::ref_ptr<osg::StateSet> mMultiPassRoot;
unsigned int mNodeMask;
unsigned int mCompositeMapSize;

View file

@ -183,17 +183,20 @@ namespace Terrain
osg::ref_ptr<osg::StateSet> stateset (new osg::StateSet);
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
if (!firstLayer)
if (!blendmaps.empty())
{
stateset->setAttributeAndModes(BlendFunc::value(), osg::StateAttribute::ON);
stateset->setAttributeAndModes(EqualDepth::value(), osg::StateAttribute::ON);
}
else
{
stateset->setAttributeAndModes(BlendFuncFirst::value(), osg::StateAttribute::ON);
stateset->setAttributeAndModes(LequalDepth::value(), osg::StateAttribute::ON);
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
stateset->setRenderBinDetails(passIndex++, "RenderBin");
if (!firstLayer)
{
stateset->setAttributeAndModes(BlendFunc::value(), osg::StateAttribute::ON);
stateset->setAttributeAndModes(EqualDepth::value(), osg::StateAttribute::ON);
}
else
{
stateset->setAttributeAndModes(BlendFuncFirst::value(), osg::StateAttribute::ON);
stateset->setAttributeAndModes(LequalDepth::value(), osg::StateAttribute::ON);
}
}
int texunit = 0;
@ -268,8 +271,6 @@ namespace Terrain
}
stateset->setRenderBinDetails(passIndex++, "RenderBin");
passes.push_back(stateset);
}
return passes;

View file

@ -102,6 +102,10 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
bool pushedLight = mLightListCallback && mLightListCallback->pushLightState(this, cv);
osg::StateSet* stateset = getStateSet();
if (stateset)
cv->pushStateSet(stateset);
for (PassVector::const_iterator it = mPasses.begin(); it != mPasses.end(); ++it)
{
cv->pushStateSet(*it);
@ -109,6 +113,8 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
cv->popStateSet();
}
if (stateset)
cv->popStateSet();
if (pushedLight)
cv->popStateSet();
}

View file

@ -1,7 +1,6 @@
#include "world.hpp"
#include <osg/Group>
#include <osg/Material>
#include <osg/Camera>
#include <components/resource/resourcesystem.hpp>
@ -23,12 +22,6 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
{
mTerrainRoot = new osg::Group;
mTerrainRoot->setNodeMask(nodeMask);
mTerrainRoot->getOrCreateStateSet()->setRenderingHint(osg::StateSet::OPAQUE_BIN);
osg::ref_ptr<osg::Material> material (new osg::Material);
material->setColorMode(osg::Material::AMBIENT_AND_DIFFUSE);
mTerrainRoot->getOrCreateStateSet()->setAttributeAndModes(material, osg::StateAttribute::ON);
mTerrainRoot->setName("Terrain Root");
osg::ref_ptr<osg::Camera> compositeCam = new osg::Camera;