http://http.developer.nvidia.com/GPUGem ... _ch21.html
Notice the glow render target must use current depth buffer, because part of glow object could be blocked by other object on show.
So let's look at _setRenderTarget@RenderSystem. This method set a render target, and it auto request a depth stencil that is compatible with the format when no depth buffer provided. I suggest add a parameter like: bool autoDepth to point the render target need to auto provided depth buffer or just use primary depth buffer.
After that, we assign these glow objects into glow render queue.
Code: Select all
#define GLOWRENDERQUEUEID Ogre::RENDER_QUEUE_9Code: Select all
void GlowEffect::renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation,
bool& skipThisInvocation)
{
if(m_pRenderTarget.isNull())
{
return ;
}
if(queueGroupId==GLOWRENDERQUEUEID/*&&m_pRenderTarget.isNull()==false*//*&&m_bRenderTexture==true*/)
{
m_pOldTarget=m_pCamera->getViewport()->getTarget();
Ogre::RenderSystem* pRenderSystem=Ogre::Root::getSingleton().getRenderSystem();
Ogre::RenderTarget* pTarget=m_pRenderTarget->getBuffer()->getRenderTarget();
pTarget->setAutoUpdated(false);
pTarget->setActive(true);
Ogre::Root::getSingleton().getRenderSystem()->_setRenderTarget(pTarget,false);
Ogre::Root::getSingleton().getRenderSystem()->clearFrameBuffer(Ogre::FBT_COLOUR/*|Ogre::FBT_DEPTH|Ogre::FBT_STENCIL*/,Ogre::ColourValue::Black);
skipThisInvocation=false;
}
}
void GlowEffect::renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation,
bool& repeatThisInvocation)
{
if(queueGroupId==GLOWRENDERQUEUEID)
{
if(m_pOldTarget!=NULL/*&&m_bRenderTexture*/)
{
Ogre::RenderSystem* pRenderSystem=Ogre::Root::getSingleton().getRenderSystem();
pRenderSystem->_setRenderTarget(m_pOldTarget,false);
m_pOldTarget=NULL;
}
repeatThisInvocation=false;
}
}


