Add LEFT & RIGHT nodemask bits

Add LEFT_BIT and RIGHT_BIT node masks, which are only shown on the left
or right viewports. These will be used for eye specific visibility masks
with VR.
This commit is contained in:
James Hogan 2021-09-18 08:27:24 +01:00
parent d4496d3b2c
commit 1d0a99a077
No known key found for this signature in database
GPG Key ID: 35CEE4862B1023F2
3 changed files with 9 additions and 5 deletions

View File

@ -45,7 +45,10 @@ enum NodeMask {
// eventually for other models?
MODEL_BIT = (1 << 12),
MODELLIGHT_BIT = (1 << 13),
PERMANENTLIGHT_BIT = (1 << 14)
PERMANENTLIGHT_BIT = (1 << 14),
// Used for per-eye VR visibility masks
LEFT_BIT = (1 << 15),
RIGHT_BIT = (1 << 16)
};
// Theory of bin numbering:

View File

@ -374,8 +374,8 @@ Compositor::setCullMask(osg::Node::NodeMask cull_mask)
if (pass->inherit_cull_mask) {
osg::Camera *camera = pass->camera;
camera->setCullMask(pass->cull_mask & cull_mask);
camera->setCullMaskLeft(pass->cull_mask & cull_mask);
camera->setCullMaskRight(pass->cull_mask & cull_mask);
camera->setCullMaskLeft(pass->cull_mask & cull_mask & ~RIGHT_BIT);
camera->setCullMaskRight(pass->cull_mask & cull_mask & ~LEFT_BIT);
}
}
}

View File

@ -28,6 +28,7 @@
#include <simgear/scene/material/EffectCullVisitor.hxx>
#include <simgear/scene/material/EffectGeode.hxx>
#include <simgear/scene/util/OsgMath.hxx>
#include <simgear/scene/util/RenderConstants.hxx>
#include <simgear/scene/util/SGReaderWriterOptions.hxx>
#include <simgear/scene/util/SGUpdateVisitor.hxx>
#include <simgear/structure/exception.hxx>
@ -167,8 +168,8 @@ PassBuilder::build(Compositor *compositor, const SGPropertyNode *root,
std::stoul(root->getStringValue("cull-mask", "0xffffffff"), nullptr, 0);
pass->cull_mask = cull_mask;
camera->setCullMask(pass->cull_mask);
camera->setCullMaskLeft(pass->cull_mask);
camera->setCullMaskRight(pass->cull_mask);
camera->setCullMaskLeft(pass->cull_mask & ~RIGHT_BIT);
camera->setCullMaskRight(pass->cull_mask & ~LEFT_BIT);
osg::Vec4f clear_color(0.0f, 0.0f, 0.0f, 1.0f);
const SGPropertyNode *p_clear_color = root->getChild("clear-color");