How to show a glow around characters?

Problems building or running the engine, queries about how to use features etc.
User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Here are some screenshots of my current work.

Image
Image
Image
Image



Here is the exe (download and run): http://assaframan.googlepages.com/outline.zip

I did something similar to this article: http://www.codeproject.com/opengl/Outline_Mode.asp

This is only good for an outline and not for a glow effect.

Also – it only works in openGL and I had to add _setLineWidth function to the render system – and the Line Width only works with openGL. You can’t set the wireframe line thickness in DirectX.

If anyone wants the code – post a replay.

I will create a glow using a similer technique to the one in nebukadnezzar code.

The nice thing about the outlines technique in the screenshots is that the outlines stay with the same thickness no matter if you are far or near.
Watch out for my OGRE related tweets here.

User avatar
JohnJ
OGRE Expert User
OGRE Expert User
Posts: 975
Joined: Thu Aug 04, 2005 4:14 am
Location: Santa Clara, California
x 4

Post by JohnJ »

but how can i show an voluminous glow around an object?
There is actually a very simple way to do this with no pixel shaders, no vertex shaders, no stencils, etc., etc.

What you do is create a texture of a colored circular halo (whatever color you want the outline to be) on a black background. Then you apply this texture (in additive blending mode) as a spherical texture map to a copy of your object which has been slightly up-scaled. If the halo in the texture was close enough to the edge of the image, the result should be a smooth glowing outline around your entire object. This effect is very useful for planet atmosphere glow effects, glowing outline effects, and many others.

One of the drawbacks of this method is that for irregular objects like player characters there may be more than just an outline - the player's arms, legs, head, etc. may also be outlined even when within the player's silhouette. However, this may be a good or bad thing, depending on the effect you're trying to achieve.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

JohnJ: You might be right.

I didn't get nice results with the stencil+shaders.

Here is the best I have got until now:
Image
Image
Image

Here is the exe (download and run):
http://assaframan.googlepages.com/glow.zip

Here is the source:
http://assaframan.googlepages.com/glow_code.zip

Not a nice glow - but a nice code sample of how to use the stencil with OGRE. :D
Watch out for my OGRE related tweets here.

psquare
Hobgoblin
Posts: 554
Joined: Tue Nov 14, 2006 3:26 pm
x 6

Post by psquare »

I did something like this before:

1. Programmatically add a pass at the end of all passes of the technique you are using.

2. Render to texture the object(s)

3. Use this rendered texture as a projective texture in the pass that you added. In the pass you can have a shader which scales the original color.

You can use something like a toon shader as your last pass shader.

If dot(normal, viewVector) > treshold
color = glow color
else
color = original color

This will accurately do the edge detection for you.



Note that I add a pass, so that I do this non-invasively (do not modify the existing passes).


To do a glow around the edges, you can add a bloom shader as Falagard mentions.You can accomplish this using compositor framework of Ogre.

There is a sample for bloom in the OgreSDK. There are also various scene shaders (compositor effects (.fx) ) in the Direct X SDK.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

jimmiemalone: Render to texture cost too much. What if you want to add glow to 10 man standing in a group of 20 man? Will what you wrote work?

I have an idea of how to improve my sample to get better results.
I will post my results soon.
Watch out for my OGRE related tweets here.

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Quite looking forward to it, Assaf Raman! :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

psquare
Hobgoblin
Posts: 554
Joined: Tue Nov 14, 2006 3:26 pm
x 6

Post by psquare »

Assaf Raman wrote:jimmiemalone: Render to texture cost too much. What if you want to add glow to 10 man standing in a group of 20 man? Will what you wrote work?
Yes, you can render to texture all 10 men in the same pass using the last pass toon shader as their material.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

Have a look here: HLSL Glow Shader
http://www.steelskies.com/article/4/
Image
shader source: http://www.steelskies.com/HLSL2.htm

Have a look here:
Image
Download: http://download.developer.nvidia.com/de ... ona.fxproj

I need to see what they did there... might be better then my way... :D
I will look into it and replay a post soon.
Watch out for my OGRE related tweets here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

jimmiemalone: You might be right.
Watch out for my OGRE related tweets here.

User avatar
Assaf Raman
OGRE Team Member
OGRE Team Member
Posts: 3092
Joined: Tue Apr 11, 2006 3:58 pm
Location: TLV, Israel
x 76

Post by Assaf Raman »

nebukadnezzar: I did as much as I can with your stencil outline idea.
I have posted the exe and code here in this showcase thread:
http://www.ogre3d.org/phpBB2/viewtopic.php?p=194816

Image
Watch out for my OGRE related tweets here.

zander76
Halfling
Posts: 89
Joined: Sun Oct 06, 2002 11:19 pm

Post by zander76 »

Has anybody tried to duplicate this in a shader instead..

Ben
Dating a women is like driving in a foreign country. You don't know what side of the road your on, you can't understand the signs and you certainly don't want to ask for directions but it usually worth the ride. :)

Post Reply