Stencil Glow Demo
- Falagard
- OGRE Retired Moderator
- Posts: 2060
- Joined: Thu Feb 26, 2004 12:11 am
- Location: Toronto, Canada
- x 3
- Contact:
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Open the ps_glow.cg file in a text editor.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.
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;
}
The x,y,z are r,g,b. The w is the alpha.
Post a replay if you need more help.
Watch out for my OGRE related tweets here.
-
- Kobold
- Posts: 28
- Joined: Tue Nov 15, 2005 3:11 pm
- Location: Greece
- Contact:
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
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?
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?
Watch out for my OGRE related tweets here.
-
- Kobold
- Posts: 28
- Joined: Tue Nov 15, 2005 3:11 pm
- Location: Greece
- Contact:
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
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
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
You also need to clear the stencil buffer - like I do in the sample.sdragou wrote:is there something else needed to tell the system to overwrite the pixels with stencil value 0?
Watch out for my OGRE related tweets here.
-
- Kobold
- Posts: 28
- Joined: Tue Nov 15, 2005 3:11 pm
- Location: Greece
- Contact:
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
2) The attachment to the rendersystem
3) The screenshot
the material "red" is just a red material.
I get the same result as this screenshot even if i delete the lines below
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();
}
}
};
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.
I get the same result as this screenshot even if i delete the lines below
Code: Select all
mStencilOpFrameListener = new StencilOpQueueListener();
mSceneMgr->addRenderQueueListener(mStencilOpFrameListener);
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
Sorry I didn't replay until now; it is hard for me to tell what your problem is.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
...
Can you post a small sample or change my demo so I will be able to see the problem?
Can anyone else help?
I haven’t heard about a port yet. (Surprise me guys… ).RichTufty wrote:This looks great!! Has anyone ported this to C#? With Mogre?
Last edited by Assaf Raman on Mon Mar 10, 2008 1:46 am, edited 1 time in total.
Watch out for my OGRE related tweets here.
-
- Kobold
- Posts: 26
- Joined: Tue May 09, 2006 7:43 pm
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]
[img=http://img259.imageshack.us/img259/9784/ogresz2.th.jpg]
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
I am thinking of converting also this demo:
http://www.mvps.org/directx/articles/wipe/index.htm
to ogre.
Does anyone needs a shaderless dynamic wipe?
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.
Does anyone needs a shaderless dynamic wipe?
Watch out for my OGRE related tweets here.
- saladin
- Halfling
- Posts: 43
- Joined: Sat Nov 05, 2005 12:49 pm
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.
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.
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:
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.
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
}
}
}
}
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()
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
- nullsquared
- Old One
- Posts: 3245
- Joined: Tue Apr 24, 2007 8:23 pm
- Location: NY, NY, USA
- x 11
- OgreZenist
- Gnoblar
- Posts: 18
- Joined: Wed Jun 20, 2007 11:20 pm
Hi,Assaf Raman wrote:post a small demo + code and I will fix it for you.
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.
Once a direction is chosen, all you need to do is keep walking.
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
I see.OgreZenist wrote:Hi,Assaf Raman wrote:post a small demo + code and I will fix it for you.
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.
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.
Watch out for my OGRE related tweets here.
-
- Halfling
- Posts: 50
- Joined: Mon Mar 10, 2008 12:08 am
- Location: Stuttgart|Germany
- x 1
- Contact:
Hi,
Thanks for your good work. I want to use it in my project but I have a problem.
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
Thanks for your good work. I want to use it in my project but I have a problem.
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
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
@Zero: Just to make things clear - you want the text glowing?
Sort of like this?:
Sort of like this?:
Watch out for my OGRE related tweets here.
- Assaf Raman
- OGRE Team Member
- Posts: 3092
- Joined: Tue Apr 11, 2006 3:58 pm
- Location: TLV, Israel
- x 76
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.
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.
Watch out for my OGRE related tweets here.