Our cull visitor no longer collects light sources by default

This commit is contained in:
Fernando García Liñán 2021-01-01 10:34:01 +01:00
parent b62808bb4c
commit 5a2c348b12
4 changed files with 13 additions and 6 deletions

View File

@ -54,11 +54,14 @@ CullVisitor* EffectCullVisitor::clone() const
void EffectCullVisitor::apply(osg::Node &node) void EffectCullVisitor::apply(osg::Node &node)
{ {
// TODO: Properly cull lights outside the viewport (override computeBounds())
CullVisitor::apply(node); CullVisitor::apply(node);
SGLight *light = dynamic_cast<SGLight *>(&node); if (_collectLights) {
if (light) // TODO: Properly cull lights outside the viewport
_lightList.push_back(light); // (override computeBounds() in SGLight)
SGLight *light = dynamic_cast<SGLight *>(&node);
if (light)
_lightList.push_back(light);
}
} }
void EffectCullVisitor::apply(osg::Geode& node) void EffectCullVisitor::apply(osg::Geode& node)

View File

@ -284,7 +284,7 @@ Compositor::addPass(Pass *pass)
identifier = sceneView->getCullVisitor()->getIdentifier(); identifier = sceneView->getCullVisitor()->getIdentifier();
sceneView->setCullVisitor( sceneView->setCullVisitor(
new EffectCullVisitor(false, pass->effect_scheme)); new EffectCullVisitor(pass->collect_lights, pass->effect_scheme));
sceneView->getCullVisitor()->setIdentifier(identifier.get()); sceneView->getCullVisitor()->setIdentifier(identifier.get());
identifier = sceneView->getCullVisitorLeft()->getIdentifier(); identifier = sceneView->getCullVisitorLeft()->getIdentifier();

View File

@ -682,8 +682,10 @@ public:
const SGPropertyNode *p_clustered = root->getNode("clustered-shading"); const SGPropertyNode *p_clustered = root->getNode("clustered-shading");
ClusteredShading *clustered = nullptr; ClusteredShading *clustered = nullptr;
if (p_clustered) { if (p_clustered) {
if (checkConditional(p_clustered)) if (checkConditional(p_clustered)) {
clustered = new ClusteredShading(camera, p_clustered); clustered = new ClusteredShading(camera, p_clustered);
pass->collect_lights = true;
}
} }
camera->setCullCallback(new SceneCullCallback(clustered)); camera->setCullCallback(new SceneCullCallback(clustered));

View File

@ -48,6 +48,7 @@ class Compositor;
*/ */
struct Pass : public osg::Referenced { struct Pass : public osg::Referenced {
Pass() : Pass() :
collect_lights(false),
useMastersSceneData(true), useMastersSceneData(true),
cull_mask(0xffffff), cull_mask(0xffffff),
inherit_cull_mask(false), inherit_cull_mask(false),
@ -57,6 +58,7 @@ struct Pass : public osg::Referenced {
int render_order; int render_order;
std::string name; std::string name;
std::string type; std::string type;
bool collect_lights;
std::string effect_scheme; std::string effect_scheme;
osg::ref_ptr<osg::Camera> camera; osg::ref_ptr<osg::Camera> camera;
bool useMastersSceneData; bool useMastersSceneData;