Howto render MyGUI after OGRE's compositor?

djpcradock

19-04-2010 11:01:34

If I have MyGUI rendering it's thing with OGRE's example bloom compositor enabled, the compositor is rendered after/above MyGUI making it all blurry and horrible looking.
Is there a way to make it so MyGUI's rendering is unaffected by OGRE's compositor? Perhaps by being rendered after the compositor?

I do not know enough about OGRE or MyGUI to get the required rendering order and any help would be greatly appreciated.
Even if someone could point my in the right direction, I'll then go away and if/when I get it working, I'll post the solution here with code.

akilar

08-10-2014 07:01:55

see the mygui reference render code:

void OgreRenderManager::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
{
Gui* gui = Gui::getInstancePtr();
if (gui == nullptr)
return;

if (Ogre::RENDER_QUEUE_OVERLAY != queueGroupId)
return;

Ogre::Viewport* viewport = mSceneManager->getCurrentViewport();
if (nullptr == viewport
|| !viewport->getOverlaysEnabled())
return;

if (mWindow->getNumViewports() <= mActiveViewport
|| viewport != mWindow->getViewport(mActiveViewport))
return;

mCountBatch = 0;

static Timer timer;
static unsigned long last_time = timer.getMilliseconds();
unsigned long now_time = timer.getMilliseconds();
unsigned long time = now_time - last_time;

onFrameEvent((float)((double)(time) / (double)1000));

last_time = now_time;

//begin();
setManualRender(true);
onRenderToTarget(this, mUpdate);
//end();

// сбрасываем флаг
mUpdate = false;
}

So it is always only render in main window viewport(always filter other viewport).
two solution:
1.Reference mygui rtt example to render gui to the ogre compositor's rtt.(maybe cause render twice, rtt and main window viewport)
2.Filter viewport by custom interface:
the example code:

...
if(m_pInterface)
{
if(m_pInterface->IsSkipRender(queueGroupId, invocation, skipThisInvocation))
return;
}
else
{
Ogre::Viewport* viewport = mSceneManager->getCurrentViewport();
if (nullptr == viewport
|| !viewport->getOverlaysEnabled())
return;
if (mWindow->getNumViewports() <= mActiveViewport
|| viewport != mWindow->getViewport(mActiveViewport))
return;
}
mCountBatch = 0;
static Timer timer;
static unsigned long last_time = timer.getMilliseconds();
unsigned long now_time = timer.getMilliseconds();
unsigned long time = now_time - last_time;

onFrameEvent((float)((double)(time) / (double)1000));

last_time = now_time;

//begin();
setManualRender(true);
onRenderToTarget(this, mUpdate);
//end();

// сбрасываем флаг
mUpdate = false;


//the IsSkipRender Implement

bool CPostEffectManager::IsSkipRender(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation)
{
Ogre::SceneManager* pSceneManager = Ogre::Root::getSingleton()._getCurrentSceneManager();
if(!pSceneManager)
return true;
Ogre::Viewport* viewport = pSceneManager->getCurrentViewport();
if(!viewport)
return true;
Ogre::RenderTarget* pRenderTarget = viewport->getTarget();
if(!pRenderTarget)
return true;
const std::string& strTargetName = pRenderTarget->getName();

if(strTargetName.find("ScreenShock") != std::string::npos)
{
int akilar = 10;
}

//check is other custom rtt
if(strTargetName.find("MainWindow") == std::string::npos)
return true;

//is main window viewport
if(strTargetName == "MainWindow")
return m_bEnableAnyState;

//post effet rtt block
return false;
}


The demo video is here:
[flash=700,490]http://www.youtube.com/v/p6hS7UpjB9A[/flash]

welcome to my blogger, thanks. :D
http://makedreamvsogre.blogspot.com/