1
\$\begingroup\$

I have a mesh representing my character. I want to give it a partially transparent greyish silhouette when other objects are blocking it from view of the camera.

I'm using Ogre3D, and GLSL as a shading language, but this is a pretty technology/language agnostic question.

\$\endgroup\$
2
  • \$\begingroup\$ You could render it without any texture (in white) and use a pixel shader to get the outline by checking if a pixel's neighbors are of two different colors. The greater the range you'll check, the thicker the outline you'll get. \$\endgroup\$ Commented Feb 6, 2014 at 14:04
  • \$\begingroup\$ Related: gamedev.stackexchange.com/questions/16391/… and gamedev.stackexchange.com/questions/68401/… \$\endgroup\$ Commented Feb 6, 2014 at 15:15

1 Answer 1

1
\$\begingroup\$

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.

The grey outline always gets drawn, but if the character is visible/not blocked, it'll get drawn on top of the grey outline, hiding it.

\$\endgroup\$
3
  • \$\begingroup\$ I think this approach will not actually render an outline. It will render the occluded part of the character in the transparent grey colour. \$\endgroup\$ Commented Feb 6, 2014 at 14:52
  • \$\begingroup\$ @dsilva.vinicius I actually wanted to do that. I probably didn't explain it well enough. Still trying to figure out how to do that with my Rendering engine. \$\endgroup\$ Commented Feb 6, 2014 at 14:55
  • \$\begingroup\$ Before rendering the grey bit, render the model to a stencil buffer, but scaled down a little. That should cut a hole in the grey image so it's more of an outline. \$\endgroup\$ Commented Feb 6, 2014 at 15:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.