Page 1 of 1

For implement glow effect like "Real-Time Glow" of GPU Gems

Posted: Wed Jan 12, 2011 6:16 am
by oiram
For implement glow effect like "Real-Time Glow" of GPU Gems - Chapter 21. I need render only glow objects to a render target and mix it into primary render target after blur it.
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_9
For your reference these codes below:

Code: 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;
	}
}
So what's your advice?

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Mon Feb 21, 2011 6:22 am
by oiram
any advice? :(

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Mon Feb 21, 2011 10:12 am
by koirat
There is already a glow shader implemented somewhere on the wiki.

http://www.ogre3d.org/tikiwiki/Glow&structure=Cookbook

What you basically do is to use compositor.

You render your scene normally.
After this you render your scene to texture, you use material "scheme" to render every non glowing object as solid black and every glowing object with some non black. Now you blur this new texture and add it to the scene.

And yes you got some glowing leaks, but it's not disturbing overall result.

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Fri Mar 11, 2011 6:13 am
by Rambus
The shader / compositor from the wiki can be set up in no time at all (I can attest that it works with out modification in the most recent versions of Ogre).

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Sat Mar 19, 2011 4:05 am
by Jabberwocky
The only problem with the glow effect in the wiki is that very distant glowing objects have the exact same glow radius as very near glowing objects. Depending on your project, this may or may not be a big deal, but it didn't work out for me.

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Fri Jun 24, 2011 4:42 pm
by mail2ameen
Hi,

Any idea on how to control glow size for each entity? I have a variable glowSize in the shader and setting it from "notifyMaterialRender" function of
Compositor listener. Since it is full-sceen effect, it is affecting for all the entities.
But I could control the "amount of glow" by changing ambient/diffuse in the material of each entity.
Is it possible to run the compositor for each entity and combine the output into the Scene?
I want to set each entity's glow size to different.

Thanks in advance.
Ameen

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Tue Jun 28, 2011 5:26 pm
by syedhs
Google for 'custom parameter' - you can basically feed different value to shader parameter even though they are of the same material.

Re: For implement glow effect like "Real-Time Glow" of GPU G

Posted: Wed Jun 29, 2011 3:01 pm
by mail2ameen
syedhs wrote:Google for 'custom parameter' - you can basically feed different value to shader parameter even though they are of the same material.
Hi, Thanks for the reply. Let me try this.
I am kind of new to Ogre. I am also trying to glow using RTT.
Can you give me some suggestion which way I can go about? Compositor or RTT method?
which way is more suitable for individual object glow than full screen?
- Thanks.