Page 1 of 1

[2.2] Easiest way to show overlays on selected windows

Posted: Tue Apr 16, 2019 10:34 pm
by xrgo
Hello!
In my apps I can have many windows (and many screens), and those windows uses the same workspace definition with mIncludeOverlays = true, later I create some overlays to show some cameras, textures, info, etc. but I want to show the overlays in just one of the screens... for now... later I would like to show specific overlays on specific windows.

this used to be simple on 1.X with viewport and rendertarget, but there's no more of that on 2.2. I can imagine a couple of solutions but are a bit overkill for something this simple, what would be the easiest solution?

thanks!!

Re: [2.2] Easiest way to show overlays on selected windows

Posted: Tue Apr 16, 2019 11:03 pm
by dark_sylinc
Use execution masks to prevent certain passes from executing when instantiating the workspace:

Code: Select all

//In script, overlay pass:
execution_mask 0x01

//Have overlays
mgr->addWorkspace( ..., executionMask = 0x01, ... );

//No overlays
mgr->addWorkspace( ..., executionMask = ~0x01, ... );

Re: [2.2] Easiest way to show overlays on selected windows

Posted: Wed Apr 17, 2019 12:03 am
by xrgo
mmm that means that I would need to put the overlays in a separated pass, and I have a problem with that: viewtopic.php?f=25&t=94960
I am going to try again, maybe I find a combination that don't causes the yflipping problem

thanks!

Re: [2.2] Easiest way to show overlays on selected windows

Posted: Wed Apr 17, 2019 7:57 pm
by xrgo
if I put the overlay pass before the quad pass I can avoid the flipping problem...
now I want to be hable to set which overlay to show on which window... for that I was planning to create some overlay passes (masked out by execution masks, so each pass only shows in 1 window) and every pass only renders a certain renderqueue, and if I want to show an overlay on a specific window I just need to set its renderqueue group

but!! it seems like overlay->setRenderQueueGroup its not working :S

I have this:

Code: Select all

mOverlay->setRenderQueueGroup( 250 );

Code: Select all

         //SCENE
            mPassSceneDef = static_cast<Ogre::CompositorPassSceneDef*>( targetDef->addPass( Ogre::PASS_SCENE ) );
		........
            mPassSceneDef->mLastRQ = 254;
and its not showing any overlay
but if I do

Code: Select all

mPassSceneDef->mLastRQ = 255;
it does show, its like the RenderQueueGroup is still 254

any ideas?

Re: [2.2] Easiest way to show overlays on selected windows

Posted: Mon Apr 22, 2019 5:51 pm
by xrgo
Its really easy to repro this behavior, just add:

Code: Select all

        mDebugOverlayPSSM->setRenderQueueGroup( 250 );
to the ShadowMapDebuggingSample
and

Code: Select all

			rq_first	0
			rq_last		254
to the compositor script and you'll see that the overlays don't show, and 250 is indeed between 0 and 254

is this an expected behavior? is a bug? do I need to enable something?

Re: [2.2] Easiest way to show overlays on selected windows

Posted: Mon Apr 22, 2019 6:37 pm
by dark_sylinc
The short version is that Overlays are a hack. A separate render path created just for them until a more modern v2 version can replace it. 4 years later that replacement hasn't arrived yet.

The long version is this snippet:

Code: Select all

void OverlaySystem::renderQueueStarted( RenderQueue *rq, uint8 queueGroupId,
                                        const String& invocation, bool& skipThisInvocation )
{
    if(queueGroupId == mOverlayManager->mDefaultRenderQueueId) //<-- This snippet HERE
    {
        Ogre::Viewport* vp = Ogre::Root::getSingletonPtr()->getRenderSystem()->_getViewport();
        if(vp != NULL)
        {
            if (vp->getOverlaysEnabled())
            {
                OverlayManager::getSingleton()._queueOverlaysForRendering( rq, vp );
            }
        }
    }
}
I can't remember exactly why that was there. I think it was because otherwise renderQueueStarted would be called too frequently causing performance issues or rendering artifacts.
Or maybe overlays didn't like to live in different RQ IDs (i.e. they all have to be in the same RQ to be glitch free?).
It is also possible the reason it was added no longer applies.

Re: [2.2] Easiest way to show overlays on selected windows

Posted: Mon Apr 22, 2019 7:38 pm
by xrgo
thank you I am going to test =)