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\$
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.

| improve this answer | |
\$\endgroup\$
  • \$\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\$ – dsilva.vinicius Feb 6 '14 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\$ – Pacha Feb 6 '14 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\$ – OriginalDaemon Feb 6 '14 at 15:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.