Page 2 of 5

Posted: Wed Jan 03, 2007 5:42 pm
by Falagard
It's better in the shader. A simple vertex program like this is no problem on the GPU, and if you use setScale you can't scale from the bounding box center and instead it will scale from the origin.

Posted: Sat Mar 31, 2007 11:18 pm
by Slicky
How do you change the color of the shader?

I am getting a pale yellow. I haven't messed with shaders before. I was trying param_name color and a value with no effect.

Posted: Sat Mar 31, 2007 11:53 pm
by Assaf Raman
Slicky wrote:How do you change the color of the shader?

I am getting a pale yellow. I haven't messed with shaders before. I was trying param_name color and a value with no effect.
Open the ps_glow.cg file in a text editor.

This is what you will see:

Code: Select all

float4 main(uniform float alpha_value, uniform float time) : COLOR
{
   float4 color;
   color.x = 1.0;
   color.y = 1.0;
   color.z = 0.0;
   color.w =  alpha_value * ((sin(time * 5.0) / 3.14 + 1.0) / 2.0 );
   return color;
}
Play with the x,y,z to change the color. the values are in the range of 0 to 1.
The x,y,z are r,g,b. The w is the alpha.

Post a replay if you need more help.

Posted: Sun Apr 01, 2007 12:26 am
by Slicky
Thanks that was it. I hadn't noticed the reference to ps_glow.cg and I was messing with values in the material file.

Posted: Sun Apr 01, 2007 6:40 am
by Virion
this could be pretty useful.

Posted: Tue Apr 03, 2007 3:25 pm
by sdragou
I use the code posted and don't get the outline glow. Just the full glow.

It looks like the StencilOpQueueListener doesn't exsist.
Actually even when i don;t attach the StencilOpQueueListener i get the same result.

Posted: Tue Apr 03, 2007 7:51 pm
by Assaf Raman
I downloaded the latest OGRE (1.4.0) source. Then I downloaded my sample. Fixed it so it will compile and link with OSI - and - it worked fine.

I will try to help you.

Did the EXE demo worked for you?
What kind of GPU do you use?
Does it act the same both in openGL and in DX?
Can you try it on a different computer with a new GPU?
Does anybody else see the problem?

Posted: Tue Apr 03, 2007 11:08 pm
by sdragou
The glow demo worked fine. I have an ati radeon 9700 GPU.

Maybe i don;t understand the use of stencil buffer correctly.

I create the renderqueuelistener where entites of group 90 make their stencil value 1 and of group 91 0.

and i attach this listener to rendersystem (like the code u gave).

is there something else needed to tell the system to overwrite the pixels with stencil value 0?

I'll post pictures when i find access to some server where i can place them.

Thnx in advance

Posted: Wed Apr 04, 2007 3:15 am
by Assaf Raman
sdragou wrote:is there something else needed to tell the system to overwrite the pixels with stencil value 0?
You also need to clear the stencil buffer - like I do in the sample.

Posted: Wed Apr 04, 2007 8:21 am
by sdragou
I do clear the stencil buffer.

I post the code and a screenshot to help u help me :)
(Even though it's a copy of your code)

1) The renderqueuelistener

Code: Select all

// stencil values
#define STENCIL_VALUE_FOR_OUTLINE_GLOW 1
#define STENCIL_FULL_MASK 0xFFFFFFFF


class StencilOpQueueListener : public Ogre::RenderQueueListener 
{ 
public: 
	void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& skipThisInvocation) 
	{ 
		if (queueGroupId == 90) // outline glow object 
		{ 
			Ogre::RenderSystem * rendersys = Ogre::Root::getSingleton().getRenderSystem(); 

			rendersys->clearFrameBuffer(Ogre::FBT_STENCIL); 
			rendersys->setStencilCheckEnabled(true); 
			rendersys->setStencilBufferParams(Ogre::CMPF_ALWAYS_PASS,
				STENCIL_VALUE_FOR_OUTLINE_GLOW, STENCIL_FULL_MASK, 
				Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_REPLACE,false);       
		} 
		if (queueGroupId == 91)  // outline glow
		{ 
			Ogre::RenderSystem * rendersys = Ogre::Root::getSingleton().getRenderSystem(); 
			rendersys->setStencilCheckEnabled(true); 
			rendersys->setStencilBufferParams(Ogre::CMPF_NOT_EQUAL,
				STENCIL_VALUE_FOR_OUTLINE_GLOW, STENCIL_FULL_MASK, 
				Ogre::SOP_KEEP,Ogre::SOP_KEEP,Ogre::SOP_ZERO,false);       
		} 
		

	} 

	void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String& invocation, bool& repeatThisInvocation) 
	{ 
		if (( queueGroupId == 91 )

			) 
		{ 
			Ogre::RenderSystem * rendersys = Ogre::Root::getSingleton().getRenderSystem(); 
			rendersys->setStencilCheckEnabled(false); 
			rendersys->setStencilBufferParams(); 
		} 
	} 

}; 
2) The attachment to the rendersystem

Code: Select all

mStencilOpFrameListener = new StencilOpQueueListener();
		mSceneMgr->addRenderQueueListener(mStencilOpFrameListener);

		mFrameListener= new StateFrameListener(mWindow,mGUIRenderer,mCamera,m_World,0,ex,data);
		mRoot->addFrameListener(mFrameListener);


3) The screenshot

the material "red" is just a red material.

Image

I get the same result as this screenshot even if i delete the lines below

Code: Select all

mStencilOpFrameListener = new StencilOpQueueListener();
		mSceneMgr->addRenderQueueListener(mStencilOpFrameListener);

Posted: Thu Apr 05, 2007 1:46 pm
by RichTufty
This looks great!! Has anyone ported this to C#? With Mogre?

Posted: Thu Apr 05, 2007 9:09 pm
by Assaf Raman
sdragou wrote:I do clear the stencil buffer.

I post the code and a screenshot to help u help me
(Even though it's a copy of your code)

1) The renderqueuelistener
...
Sorry I didn't replay until now; it is hard for me to tell what your problem is.
Can you post a small sample or change my demo so I will be able to see the problem?
Can anyone else help?
RichTufty wrote:This looks great!! Has anyone ported this to C#? With Mogre?
I haven’t heard about a port yet. (Surprise me guys… :D ).

Posted: Sun Apr 15, 2007 4:13 pm
by alhobarata
In your demo, if i comment the lines of creation of the full glow entities, the outline glow don't work properly. Why?
[img=http://img259.imageshack.us/img259/9784/ogresz2.th.jpg]

Posted: Wed Apr 18, 2007 4:53 pm
by RichTufty
I have now converted this to Mogre and C# ... !! I shall upload the code very soon if anyone is interested?... prob at the weekend!

Posted: Wed Apr 18, 2007 5:00 pm
by Assaf Raman
I am thinking of converting also this demo:
http://www.mvps.org/directx/articles/wipe/index.htm
to ogre.
This sample illustrates how to transfer an image mask to the stencil buffer, and utilizes this technique to perform a dynamic wipe between two 3D scenes.
Image Image

Does anyone needs a shaderless dynamic wipe?

Posted: Tue Nov 20, 2007 7:08 am
by saladin
Hi,
Thanks for the great work. I've been using this stencil glow technique in my project.

Now I'm having a bit of a problem.
Image

As seen in the screen shot.

The snowy terrain is in the farthest background, then the bus, then the tree.

The terrain is in the render queue group RENDER_QUEUE_MAIN, and so is the tree.

The bus, since it's highlighted, is in the render queue group RENDER_QUEUE_MAIN + 1. Its outline glow is in render queue group RENDER_QUEUE_MAIN + 2.

The tree's leaves are using the following material with an alpha texture.

Code: Select all

material tree4
{
	receive_shadows on
	technique
	{
		pass
		{
			ambient 0.500000 0.500000 0.500000 1.000000
			diffuse 0.086275 0.403922 0.062745 1.000000
			specular 0.100000 0.100000 0.100000 1.000000 0.250000
			emissive 0.000000 0.000000 0.000000 1.000000
			scene_blend alpha_blend
			depth_write off
			texture_unit
			{
				texture tree4_leaves.png
				tex_address_mode wrap
				filtering trilinear
			}
		}
	}
}
The bus shows through the tree leaves because the tree is being rendered ealier than the bus. If I set the tree's render queue to the same as the bus, the tree itself will be displayed properly. But the paradox is if I do that, the tree will occlude the glow of the bus. And if I do that for every unhighlighted object including the snow terrain, I'll never be able to see the outline glow of the bus.

If there any technique that can let me see the glow of the bus through the leaves and at the same time has the bus covered by the non-transparent part of the tree?

Following is my render queue listener code in python:

Code: Select all

class CGStencilOpQueueListener(ogre.RenderQueueListener):
    def renderQueueStarted(self, queueGroupId, invocation, skipThisInvocation):
        if (queueGroupId == RENDER_QUEUE_OUTLINE_GLOW_OBJECTS):
            renderSys = ogre.Root.getSingleton().getRenderSystem()
            renderSys.clearFrameBuffer(ogre.FBT_STENCIL)
            renderSys.setStencilCheckEnabled(True)
            renderSys.setStencilBufferParams(ogre.CMPF_ALWAYS_PASS, STENCIL_VALUE_FOR_OUTLINE_GLOW, STENCIL_FULL_MASK, ogre.SOP_KEEP,
                   ogre.SOP_KEEP, ogre.SOP_REPLACE, False)

        if (queueGroupId == RENDER_QUEUE_OUTLINE_GLOW_GLOW):
            renderSys = ogre.Root.getSingleton().getRenderSystem()
            renderSys.setStencilCheckEnabled(True)
            renderSys.setStencilBufferParams(ogre.CMPF_NOT_EQUAL, STENCIL_VALUE_FOR_OUTLINE_GLOW, STENCIL_FULL_MASK, ogre.SOP_KEEP,
                   ogre.SOP_KEEP, ogre.SOP_KEEP, False)

    def renderQueueEnded(self, queueGroupId, invocation, repeatThis):
      if queueGroupId == RENDER_QUEUE_OUTLINE_GLOW_OBJECTS or queueGroupId == RENDER_QUEUE_OUTLINE_GLOW_GLOW:
          renderSys = ogre.Root.getSingleton().getRenderSystem()
          renderSys.setStencilCheckEnabled(False)
          renderSys.setStencilBufferParams()

Posted: Fri Nov 23, 2007 1:53 am
by Assaf Raman
post a small demo + code and I will fix it for you.

Posted: Fri Nov 23, 2007 2:46 am
by nullsquared
Interesting, great job!

I love using the stencil buffer... so many awesome uses... (I use it for my portals) The best part, Ogre wraps it all up in two amazing functions. No low-level direct D3D or GL needed :D

Posted: Sat Nov 24, 2007 12:44 pm
by OgreZenist
Assaf Raman wrote:post a small demo + code and I will fix it for you.
Hi,
Thanks for the quick reply.

I'm using python-ogre. So you'll need python2.5 installed to run the code. However there's really no need to change any code from the demo you provided. Just replace the outline glow object (ogre head) with any entity with an alpha texture and with 'depthWrite off' to skip writing to the depth buffer. Then this object will stop occluding the glowing object behind it.

This is a detailed introduction of my problem:
http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=

If you can run python-ogre code please tell me I'll quickly make a demo.

Cheers.

Posted: Sat Nov 24, 2007 3:47 pm
by Assaf Raman
OgreZenist wrote:
Assaf Raman wrote:post a small demo + code and I will fix it for you.
Hi,
Thanks for the quick reply.

I'm using python-ogre. So you'll need python2.5 installed to run the code. However there's really no need to change any code from the demo you provided. Just replace the outline glow object (ogre head) with any entity with an alpha texture and with 'depthWrite off' to skip writing to the depth buffer. Then this object will stop occluding the glowing object behind it.

This is a detailed introduction of my problem:
http://www.ogre3d.org/phpBB2/viewtopic. ... highlight=

If you can run python-ogre code please tell me I'll quickly make a demo.

Cheers.
I see.

A possible solution for you will be to draw the object twice – once with depth write, stencil write, and no color write, and once without a depth write, a color write and a stencil check.

Posted: Tue Nov 27, 2007 1:21 am
by saladin
A possible solution for you will be to draw the object twice – once with depth write, stencil write, and no color write, and once without a depth write, a color write and a stencil check.
Thanks I'll try that.

Posted: Mon Mar 10, 2008 12:27 am
by Zero
Hi,
Thanks for your good work. I want to use it in my project but I have a problem.

Image

As you can see here I want to use it with CEGUI. But you can see it don`t want to work correctly with CEGUI.
In the boxes and at the buttons is normaly text but as you can see it won`t be shown with stencil.
I don`t know why it won`t work.
I use the same code like you in your example.
I hope you can help me.

Zero

Posted: Mon Mar 10, 2008 1:41 am
by Assaf Raman
@Zero: Just to make things clear - you want the text glowing?
Sort of like this?:
Image

Posted: Mon Mar 10, 2008 7:46 am
by Shion
I work on the same project.

We don't want the text glowing.
We want the ogrehead glowing and this works.
The problem is, if we let glow the ogrehead all text from the buttons and other widgets are not shown.

Posted: Mon Mar 10, 2008 8:24 am
by Assaf Raman
I see.
Can you add a gui sample to my sample in this thread and post the code - I will be able to look at the problem and solve it for you.