Probably this has already been asked a thousand of times, but I can't find the answer anywhere.
I have a mesh representing my character, and I want to draw its outline in greyish with an alpha channel, when other objects are closer to the camera (and therefore, making it not visible).
Anyone knows? Thanks.
Draw character outline when not visible
-
- Halfling
- Posts: 63
- Joined: Tue Dec 04, 2012 12:59 am
-
- Halfling
- Posts: 63
- Joined: Tue Dec 04, 2012 12:59 am
Re: Draw character outline when not visible
So I asked in gamedev.stackexchange.com, and they gave me a solution that I think it is supposed to work:
I have no idea how to achieve this. Maybe a little help, please?Draw everything apart from your character. Switch to front face culling, turn depth testing off, and render your character in a transparent grey colour. Then return to back face culling, turn depth testing back on, and render your character normally
- tod
- Troll
- Posts: 1394
- Joined: Wed Aug 02, 2006 9:41 am
- Location: Bucharest
- x 94
- Contact:
Re: Draw character outline when not visible
Maybe you could do this with two with two passes in your material. The first part suggests that your character should be on a later render queue group also.
-
- Halfling
- Posts: 63
- Joined: Tue Dec 04, 2012 12:59 am
Re: Draw character outline when not visible
I want my character (with the proper texture) to be rendered correctly with the proper depth, like every object. But I also want to render a transparent grey silhouette when there is something blocking my character. I hope I am clear, I don't think your answer fixes my problem.tod wrote:Maybe you could do this with two with two passes in your material. The first part suggests that your character should be on a later render queue group also.
-
- Google Summer of Code Student
- Posts: 91
- Joined: Mon May 01, 2006 11:36 am
- x 21
Re: Draw character outline when not visible
Put two passes in the material.
For the second pass, which you want to draw obscured parts, set the depth comparison backwards and disable depth writes.
Done.
For the second pass, which you want to draw obscured parts, set the depth comparison backwards and disable depth writes.
Done.
-
- Halfling
- Posts: 63
- Joined: Tue Dec 04, 2012 12:59 am
Re: Draw character outline when not visible
Oh god your post is brilliant. How do you do that, by the way?Owen wrote:set the depth comparison backwards
Here is my material:
Code: Select all
material Character/Default
{
receive_shadows off
technique
{
pass
{
vertex_program_ref PlayerVertex
{
}
fragment_program_ref PlayerFragment
{
param_named diffuseMap int 0
param_named_auto deathState custom 0
}
cull_hardware none
cull_software none
texture_unit
{
filtering none
texture main-character.png 0
}
}
pass
{
cull_hardware none
cull_software none
depth_check off
depth_write off
ambient 0.8 0.0 0.0 0.5
diffuse 0.8 0.0 0.0 0.5
}
}
}
-
- Google Summer of Code Student
- Posts: 91
- Joined: Mon May 01, 2006 11:36 am
- x 21
Re: Draw character outline when not visible
See the manual: http://www.ogre3d.org/docs/manual/manua ... h_005ffunc
You'll need to put your character in a higher render queue than everything else, otherwise other stuff will still overdraw it.
You'll need to put your character in a higher render queue than everything else, otherwise other stuff will still overdraw it.