Set VisibilityMask when using ShadowNodeHelper::createShadowNodeWithSettings

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Set VisibilityMask when using ShadowNodeHelper::createShadowNodeWithSettings

Post by xrgo »

Hello!
I can´t fin a way to set the VisibilityMask for a shadow node created with createShadowNodeWithSettings, I have some objects that have a special mask set to them and when I omit this mask in the VisibilityMask for the main render scene pass, the objects are hidden but I can see the shadows

thanks in advance!!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5505
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1372

Re: Set VisibilityMask when using ShadowNodeHelper::createShadowNodeWithSettings

Post by dark_sylinc »

Welcome back!

The visibility mask from shadow nodes is independent from that of its master.

I see several possible solutions:
  1. Modify createShadowNodeWithSettings to accept a default visibility mask
  2. Modify createShadowNodeWithSettings to accept an array of visibility masks (one per individual shadow map)
  3. Alter the shadow nodes created by createShadowNodeWithSettings after it returns
  4. Modify shadow nodes to inherit an 'and' mask from its master node (slightly tricky, because CompositorShadowNodeDef::_validateAndFinish needs to correctly determine, when using SHADOW_NODE_FIRST_ONLY, if the shadow node needs recalculation)
  5. Provide your visibility mask via SceneManager::setVisibilityMask (which affects all viewports/compositor workspaces) instead of doing at pass level
Cheers
Matias
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: Set VisibilityMask when using ShadowNodeHelper::createShadowNodeWithSettings

Post by xrgo »

Thanks!!
I tried 3. like this:

Code: Select all

    mCompositorManager->validateAllNodes();
    Ogre::CompositorNodeDef* shadowNode = mCompositorManager->getShadowNodeDefinitionNonConst( "MainEngineShadowNode" );

    for( size_t i=0; i<shadowNode->getNumTargetPasses(); ++i ){
        Ogre::CompositorTargetDef* targetDef = shadowNode->getTargetPass(i);
        Ogre::CompositorPassDefVec passesDef = targetDef->getCompositorPassesNonConst();
        for( size_t j=0; j<passesDef.size(); ++j ){
            Ogre::CompositorPassDef* passDef = passesDef.at(j);
            if( passDef->getType() == Ogre::PASS_SCENE ){
                static_cast<Ogre::CompositorPassSceneDef*>( passDef )->mVisibilityMask = MySuperMegaDuperMask;
            }
        }
    }
but its not working =(, pretty sure the mask I am setting is correct since its the same I am setting to my main workspace render scene pass

I am going to try 1 or 2 if I find it fast to implement, and I'll make a PR

edit: implementing 1 was a piece of cake, I´ll make a PR hopefully soon
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 169

Re: Set VisibilityMask when using ShadowNodeHelper::createShadowNodeWithSettings

Post by xrgo »

https://github.com/OGRECave/ogre-next/pull/52 (made with my company's account =D)