Use names to identify deferred buffers
Change effect syntax for buffers
This commit is contained in:
@@ -82,19 +82,6 @@ public:
|
||||
const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
osg::StateSet* getDefaultStateSet();
|
||||
|
||||
enum Buffer
|
||||
{
|
||||
DEPTH_BUFFER,
|
||||
NORMAL_BUFFER,
|
||||
DIFFUSE_BUFFER,
|
||||
SPEC_EMIS_BUFFER,
|
||||
LIGHTING_BUFFER,
|
||||
MIDDLE_BLOOM_BUFFER,
|
||||
BLOOM_BUFFER,
|
||||
AO_BUFFER,
|
||||
SHADOW_BUFFER
|
||||
};
|
||||
|
||||
// Define what needs to be generated for this effect
|
||||
enum Generator
|
||||
{
|
||||
|
||||
@@ -98,14 +98,14 @@ void EffectCullVisitor::clearBufferList()
|
||||
_bufferList.clear();
|
||||
}
|
||||
|
||||
void EffectCullVisitor::addBuffer(int i, osg::Texture2D* tex)
|
||||
void EffectCullVisitor::addBuffer(std::string b, osg::Texture2D* tex)
|
||||
{
|
||||
_bufferList.insert(std::make_pair(i,tex));
|
||||
_bufferList.insert(std::make_pair(b,tex));
|
||||
}
|
||||
|
||||
osg::Texture2D* EffectCullVisitor::getBuffer(int i)
|
||||
osg::Texture2D* EffectCullVisitor::getBuffer(std::string b)
|
||||
{
|
||||
return _bufferList[i];
|
||||
return _bufferList[b];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ public:
|
||||
virtual void reset();
|
||||
|
||||
void clearBufferList();
|
||||
void addBuffer(int i, osg::Texture2D* tex);
|
||||
osg::Texture2D* getBuffer(int i);
|
||||
void addBuffer(std::string b, osg::Texture2D* tex);
|
||||
osg::Texture2D* getBuffer(std::string b);
|
||||
|
||||
private:
|
||||
std::map<int,osg::ref_ptr<osg::Texture2D> > _bufferList;
|
||||
std::map<std::string,osg::ref_ptr<osg::Texture2D> > _bufferList;
|
||||
std::vector<osg::ref_ptr<EffectGeode> > _lightList;
|
||||
bool _collectLights;
|
||||
};
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace simgear
|
||||
class Pass : public osg::StateSet
|
||||
{
|
||||
public:
|
||||
typedef std::list<std::pair<int,int> > BufferUnitList;
|
||||
typedef std::list<std::pair<int,std::string> > BufferUnitList;
|
||||
typedef std::map<std::string,osg::Vec4> PositionedUniformMap;
|
||||
|
||||
META_Object(simgear,Pass);
|
||||
@@ -34,7 +34,7 @@ public:
|
||||
Pass(const Pass& rhs,
|
||||
const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
|
||||
|
||||
void setBufferUnit( int unit, int buffer ) { _bufferUnitList.push_back( std::make_pair(unit,buffer) ); }
|
||||
void setBufferUnit( int unit, std::string buffer ) { _bufferUnitList.push_back( std::make_pair(unit,buffer) ); }
|
||||
const BufferUnitList& getBufferUnitList() const { return _bufferUnitList; }
|
||||
|
||||
void addPositionedUniform( const std::string& name, const osg::Vec4& offset ) { _positionedUniforms[name] = offset; }
|
||||
|
||||
@@ -832,11 +832,11 @@ bool makeTextureParameters(SGPropertyNode* paramRoot, const StateSet* ss)
|
||||
class GBufferBuilder : public TextureBuilder
|
||||
{
|
||||
public:
|
||||
GBufferBuilder(int b) : buffer(b) {}
|
||||
GBufferBuilder() {}
|
||||
Texture* build(Effect* effect, Pass* pass, const SGPropertyNode*,
|
||||
const SGReaderWriterOptions* options);
|
||||
private:
|
||||
int buffer;
|
||||
string buffer;
|
||||
};
|
||||
|
||||
Texture* GBufferBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode* prop,
|
||||
@@ -847,15 +847,10 @@ Texture* GBufferBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode*
|
||||
if (pUnit) {
|
||||
unit = pUnit->getValue<int>();
|
||||
} else {
|
||||
const SGPropertyNode* pName = prop->getChild("name");
|
||||
if (pName)
|
||||
try {
|
||||
unit = boost::lexical_cast<int>(pName->getStringValue());
|
||||
} catch (boost::bad_lexical_cast& lex) {
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "can't decode name as texture unit "
|
||||
<< lex.what());
|
||||
}
|
||||
SG_LOG(SG_INPUT, SG_ALERT, "no texture unit");
|
||||
}
|
||||
buffer = prop->getStringValue("name");
|
||||
|
||||
pass->setBufferUnit( unit, buffer );
|
||||
|
||||
// Return white for now. Would be overridden in Technique::ProcessDrawable
|
||||
@@ -864,15 +859,7 @@ Texture* GBufferBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode*
|
||||
|
||||
namespace
|
||||
{
|
||||
TextureBuilder::Registrar installDepthBuffer("depth-buffer", new GBufferBuilder(Effect::DEPTH_BUFFER));
|
||||
TextureBuilder::Registrar installNormalBuffer("normal-buffer", new GBufferBuilder(Effect::NORMAL_BUFFER));
|
||||
TextureBuilder::Registrar installDiffuseBuffer("diffuse-buffer", new GBufferBuilder(Effect::DIFFUSE_BUFFER));
|
||||
TextureBuilder::Registrar installSpecularBuffer("spec-emis-buffer", new GBufferBuilder(Effect::SPEC_EMIS_BUFFER));
|
||||
TextureBuilder::Registrar installLightingBuffer("lighting-buffer", new GBufferBuilder(Effect::LIGHTING_BUFFER));
|
||||
TextureBuilder::Registrar installMiddleBloomBuffer("middle-bloom-buffer", new GBufferBuilder(Effect::MIDDLE_BLOOM_BUFFER));
|
||||
TextureBuilder::Registrar installBloomBuffer("bloom-buffer", new GBufferBuilder(Effect::BLOOM_BUFFER));
|
||||
TextureBuilder::Registrar installAoBuffer("ao-buffer", new GBufferBuilder(Effect::AO_BUFFER));
|
||||
TextureBuilder::Registrar installShadowBuffer("shadow-buffer", new GBufferBuilder(Effect::SHADOW_BUFFER));
|
||||
TextureBuilder::Registrar installBuffer("buffer", new GBufferBuilder);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user