mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-07 02:15:32 +00:00
move renderbin
Signed-off-by: Bret Curtis <psi29a@gmail.com>
This commit is contained in:
parent
4dccabeb83
commit
da92ad329b
5 changed files with 29 additions and 20 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <osg/Texture2D>
|
#include <osg/Texture2D>
|
||||||
#include <osg/ClusterCullingCallback>
|
#include <osg/ClusterCullingCallback>
|
||||||
|
#include <osg/Material>
|
||||||
|
|
||||||
#include <osgUtil/IncrementalCompileOperation>
|
#include <osgUtil/IncrementalCompileOperation>
|
||||||
|
|
||||||
|
@ -31,7 +32,11 @@ ChunkManager::ChunkManager(Storage *storage, Resource::SceneManager *sceneMgr, T
|
||||||
, mCompositeMapLevel(1.f)
|
, mCompositeMapLevel(1.f)
|
||||||
, mMaxCompGeometrySize(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 ¢er, unsigned char lod, unsigned int lodFlags, bool far, const osg::Vec3f& viewPoint, bool compile)
|
osg::ref_ptr<osg::Node> ChunkManager::getChunk(float size, const osg::Vec2f ¢er, 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->createClusterCullingCallback();
|
||||||
|
|
||||||
|
geometry->setStateSet(mMultiPassRoot);
|
||||||
|
|
||||||
if (useCompositeMap)
|
if (useCompositeMap)
|
||||||
{
|
{
|
||||||
osg::ref_ptr<CompositeMap> compositeMap = new CompositeMap;
|
osg::ref_ptr<CompositeMap> compositeMap = new CompositeMap;
|
||||||
|
|
|
@ -65,6 +65,8 @@ namespace Terrain
|
||||||
CompositeMapRenderer* mCompositeMapRenderer;
|
CompositeMapRenderer* mCompositeMapRenderer;
|
||||||
BufferCache mBufferCache;
|
BufferCache mBufferCache;
|
||||||
|
|
||||||
|
osg::ref_ptr<osg::StateSet> mMultiPassRoot;
|
||||||
|
|
||||||
unsigned int mNodeMask;
|
unsigned int mNodeMask;
|
||||||
|
|
||||||
unsigned int mCompositeMapSize;
|
unsigned int mCompositeMapSize;
|
||||||
|
|
|
@ -183,17 +183,20 @@ namespace Terrain
|
||||||
|
|
||||||
osg::ref_ptr<osg::StateSet> stateset (new osg::StateSet);
|
osg::ref_ptr<osg::StateSet> stateset (new osg::StateSet);
|
||||||
|
|
||||||
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
|
if (!blendmaps.empty())
|
||||||
|
|
||||||
if (!firstLayer)
|
|
||||||
{
|
{
|
||||||
stateset->setAttributeAndModes(BlendFunc::value(), osg::StateAttribute::ON);
|
stateset->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||||
stateset->setAttributeAndModes(EqualDepth::value(), osg::StateAttribute::ON);
|
stateset->setRenderBinDetails(passIndex++, "RenderBin");
|
||||||
}
|
if (!firstLayer)
|
||||||
else
|
{
|
||||||
{
|
stateset->setAttributeAndModes(BlendFunc::value(), osg::StateAttribute::ON);
|
||||||
stateset->setAttributeAndModes(BlendFuncFirst::value(), osg::StateAttribute::ON);
|
stateset->setAttributeAndModes(EqualDepth::value(), osg::StateAttribute::ON);
|
||||||
stateset->setAttributeAndModes(LequalDepth::value(), osg::StateAttribute::ON);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stateset->setAttributeAndModes(BlendFuncFirst::value(), osg::StateAttribute::ON);
|
||||||
|
stateset->setAttributeAndModes(LequalDepth::value(), osg::StateAttribute::ON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int texunit = 0;
|
int texunit = 0;
|
||||||
|
@ -268,8 +271,6 @@ namespace Terrain
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stateset->setRenderBinDetails(passIndex++, "RenderBin");
|
|
||||||
|
|
||||||
passes.push_back(stateset);
|
passes.push_back(stateset);
|
||||||
}
|
}
|
||||||
return passes;
|
return passes;
|
||||||
|
|
|
@ -102,6 +102,10 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
|
||||||
|
|
||||||
bool pushedLight = mLightListCallback && mLightListCallback->pushLightState(this, 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)
|
for (PassVector::const_iterator it = mPasses.begin(); it != mPasses.end(); ++it)
|
||||||
{
|
{
|
||||||
cv->pushStateSet(*it);
|
cv->pushStateSet(*it);
|
||||||
|
@ -109,6 +113,8 @@ void TerrainDrawable::cull(osgUtil::CullVisitor *cv)
|
||||||
cv->popStateSet();
|
cv->popStateSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateset)
|
||||||
|
cv->popStateSet();
|
||||||
if (pushedLight)
|
if (pushedLight)
|
||||||
cv->popStateSet();
|
cv->popStateSet();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "world.hpp"
|
#include "world.hpp"
|
||||||
|
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/Material>
|
|
||||||
#include <osg/Camera>
|
#include <osg/Camera>
|
||||||
|
|
||||||
#include <components/resource/resourcesystem.hpp>
|
#include <components/resource/resourcesystem.hpp>
|
||||||
|
@ -23,12 +22,6 @@ World::World(osg::Group* parent, osg::Group* compileRoot, Resource::ResourceSyst
|
||||||
{
|
{
|
||||||
mTerrainRoot = new osg::Group;
|
mTerrainRoot = new osg::Group;
|
||||||
mTerrainRoot->setNodeMask(nodeMask);
|
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");
|
mTerrainRoot->setName("Terrain Root");
|
||||||
|
|
||||||
osg::ref_ptr<osg::Camera> compositeCam = new osg::Camera;
|
osg::ref_ptr<osg::Camera> compositeCam = new osg::Camera;
|
||||||
|
|
Loading…
Reference in a new issue