visibility masks permanently set?

Problems building or running the engine, queries about how to use features etc.
Post Reply
Rak'kar
Gremlin
Posts: 152
Joined: Sun May 30, 2004 5:51 pm

visibility masks permanently set?

Post by Rak'kar » Sun Jun 03, 2007 8:10 pm

I'm having a problem where I cannot change visibility masks while using a compositor.

I have visibility masks as follows:

Code: Select all

VISIBILITY_MASK_DEFAULT=1<<0,
	VISIBILITY_MASK_RADAR=1<<1,
	VISIBILITY_MASK_ROOFS=1<<2,
	VISIBILITY_MASK_TRIGGER_VOLUME=1<<3,
What I've been doing, which works fine without a compositor, is I set the visibility mask depending on if I want to show the roof or not. This changes as the player moves around.

Code: Select all

int visibilityMask = GetApp()->GetSceneManager()->getVisibilityMask();
GetApp()->GetSceneManager()->setVisibilityMask(visibilityMask | VISIBILITY_MASK_ROOFS);
However, if I add a compositor, roofs no longer show up. At first I thought this was a bug with roofs. However, I found the scene manager visibility flags become fixed forever at the first setting that I ever call the compositor with, and it just so happens that with the first setting roofs were never visible. If I force the first time I call it to show roofs, roofs are always visible.

Code: Select all

unsigned int oldVisibilityMask = sceneManager->getVisibilityMask();

// BUG - Proves that the visibility masks are fixed at whatever I set it to be the first time I ever render it
// Changing visibility masks during runtime has no effect!
static bool firstCall=true;
if (firstCall)
	oldVisibilityMask=(1<<2) | (1<<0);

Ogre::ShadowTechnique oldShadowTechnique = sceneManager->getShadowTechnique();
if (oldShadowTechnique!=Ogre::SHADOWTYPE_NONE)
	sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_NONE);

unsigned i;

for (i=0; i < ti->getNumTargetPasses(); i++)
	ti->getTargetPass(i)->setVisibilityMask(oldVisibilityMask);

shieldGroup->update(curTimeMS);
distortionRenderTarget->update();
shieldGroup->hideGroup();
Ogre::MaterialManager::getSingleton().setActiveScheme(currentScheme);
if (oldShadowTechnique!=Ogre::SHADOWTYPE_NONE)
	sceneManager->setShadowTechnique(oldShadowTechnique);
sceneManager->setVisibilityMask(oldVisibilityMask);
The scene manager visibility masks input to the function is correct and changes as the player moves around, it's something in Ogre that becomes fixed like a pitbull that won't let go.

Is there some function I need to call, or maybe I am calling these things out of order?
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Post by sinbad » Mon Jun 04, 2007 12:04 pm

I presume you have a render_scene pass in your compositor? If so, it is the visibility mask that the compositor pass has which applies, not any other mask you may have set.

You might want to consider removing the render_scene pass from the compositor and using 'input previous' instead. Either that or alter the visiblity mask on your compositor.
0 x

Rak'kar
Gremlin
Posts: 152
Joined: Sun May 30, 2004 5:51 pm

Post by Rak'kar » Mon Jun 04, 2007 7:43 pm

We are using input_previous

Code: Select all

compositor ShieldDistort
{
	technique
	{
		//original scene
		texture rtScene target_width target_height PF_R8G8B8
		
		//render the original scene (full)
		target rtScene
		{
			input previous
		}
		
		//combine the original scene with the distortion texture (pre generated)
		target_output
        	{
            		input none
           		pass render_quad
           		{
				input 0 rtScene
              			material Render/DistortionCombine
            		}
       		}
	
	}
}
The compositor itself doesn't have any visibility masks.

Will input previous use the global visibility masks?
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Post by sinbad » Tue Jun 05, 2007 4:43 pm

Ah ok, it's because during the compilation stage the visibility mask is copied and the implied render_scene still does that. You can force it to recompile when you change the setting by calling CompositorChain::_markDirty.
0 x

Rak'kar
Gremlin
Posts: 152
Joined: Sun May 30, 2004 5:51 pm

Post by Rak'kar » Tue Jun 05, 2007 6:56 pm

Works now, thanks a lot! Maybe it would be a good feature to automatically check the visibility masks to see if they were different from last time.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19261
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
Contact:

Post by sinbad » Wed Jun 06, 2007 12:32 pm

Yeah, working on it :)
0 x

User avatar
fractile
Gremlin
Posts: 197
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
Contact:

Re: visibility masks permanently set?

Post by fractile » Sun Sep 07, 2014 9:13 am

I know this is an old thread, but I'm facing the exact same problem and I just can't use either of the proposed solutions. I have a split-screen setup, with two viewports and I need to hide some objects from the other viewport. I have visibility flags set on the objects, but I just can't get the mask set properly.

Only way I have found to have anti-aliasing work with compositors requires using render_scene, which makes using setVisibilityMask() in viewports impossible. More on this in my posts here: http://www.ogre3d.org/forums/viewtopic.php?f=2&t=77938

The other proposed way of setting visibility mask on compositor doesn't work well either. It seems that both viewports share the same compositor pass instances, so if I set the visibility mask on render_scene pass for the other viewport, it affects the other one too.

Any ideas on how to resolve this?
0 x

User avatar
fractile
Gremlin
Posts: 197
Joined: Thu Jan 13, 2005 2:35 pm
Location: Tampere, Finland
Contact:

Re: visibility masks permanently set?

Post by fractile » Tue Sep 09, 2014 9:11 pm

I tried registering a RenderTargetListener to the window and setting visibility mask for compositors in preViewportUpdate() for every viewport. It seemed to work for a while, but it broke down when enabling/disabling any compositors. Presumable due to compositor chain getting "recompiled".

Only remaining option I can think of is duplicating compositor scripts for every viewport. That should result in separate compositor pass instances and let me set different visibility masks for different viewports. Far from ideal, but it should work.
0 x

Post Reply