Make sure we render the CameraGroup cameras one after another

This commit is contained in:
Fernando García Liñán 2020-11-18 14:30:06 +01:00
parent 1852e3c7fc
commit da53e8fb1b
3 changed files with 8 additions and 1 deletions

View File

@ -45,6 +45,8 @@ public:
namespace simgear {
namespace compositor {
int Compositor::_order_offset = 0;
Compositor *
Compositor::create(osg::View *view,
osg::GraphicsContext *gc,
@ -85,6 +87,8 @@ Compositor::create(osg::View *view,
compositor->addPass(pass);
}
++_order_offset;
return compositor.release();
}

View File

@ -127,6 +127,7 @@ public:
Pass * getPass(size_t index) const { return _passes[index]; }
Pass * getPass(const std::string &name) const;
int getOrderOffset() const { return _order_offset; }
protected:
osg::View *_view;
osg::GraphicsContext *_gc;
@ -135,6 +136,7 @@ protected:
BufferMap _buffers;
PassList _passes;
BuiltinUniforms _uniforms;
static int _order_offset;
};
} // namespace compositor

View File

@ -85,7 +85,8 @@ PassBuilder::build(Compositor *compositor, const SGPropertyNode *root,
// that doesn't involve the rendering pipeline itself. NESTED_RENDER is also
// not a possibility since we don't want to share RenderStage with the View
// master camera.
camera->setRenderOrder(osg::Camera::POST_RENDER, pass->render_order * 10);
camera->setRenderOrder(osg::Camera::POST_RENDER,
pass->render_order + compositor->getOrderOffset() * 100);
camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);
// XXX: Should we make this configurable?