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

What it says on the tin: a place to discuss proposed new features.
Post Reply
oiram
Halfling
Posts: 87
Joined: Sun Dec 13, 2009 5:06 am

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

Post by oiram » Wed Jan 12, 2011 6:16 am

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?
0 x

oiram
Halfling
Posts: 87
Joined: Sun Dec 13, 2009 5:06 am

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

Post by oiram » Mon Feb 21, 2011 6:22 am

any advice? :(
0 x

User avatar
koirat
Orc
Posts: 446
Joined: Mon Feb 25, 2008 7:56 pm

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

Post by koirat » Mon Feb 21, 2011 10:12 am

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.
0 x
This is a block of text that can be added to posts you make. There is a 255 character limit.

Rambus
Greenskin
Posts: 100
Joined: Tue Aug 01, 2006 6:50 am
Location: Canada
Contact:

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

Post by Rambus » Fri Mar 11, 2011 6:13 am

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).
0 x

User avatar
Jabberwocky
OGRE Moderator
OGRE Moderator
Posts: 2819
Joined: Mon Mar 05, 2007 11:17 pm
Location: Canada
Contact:

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

Post by Jabberwocky » Sat Mar 19, 2011 4:05 am

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.
0 x
Image

mail2ameen
Gnoblar
Posts: 12
Joined: Fri Jun 03, 2011 8:32 pm

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

Post by mail2ameen » Fri Jun 24, 2011 4:42 pm

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
0 x

User avatar
syedhs
Silver Sponsor
Silver Sponsor
Posts: 2702
Joined: Mon Aug 29, 2005 3:24 pm
Location: Kuala Lumpur, Malaysia
x 3

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

Post by syedhs » Tue Jun 28, 2011 5:26 pm

Google for 'custom parameter' - you can basically feed different value to shader parameter even though they are of the same material.
0 x
A willow deeply scarred, somebody's broken heart
And a washed-out dream
They follow the pattern of the wind, ya' see
Cause they got no place to be
That's why I'm starting with me

mail2ameen
Gnoblar
Posts: 12
Joined: Fri Jun 03, 2011 8:32 pm

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

Post by mail2ameen » Wed Jun 29, 2011 3:01 pm

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.
0 x

Post Reply