Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any easy way to put kind of a "mask" in front of the camera in an Ogre 3d application, so that parts of the scene are always covered by that mask? The idea is that I want to have an effect as if you would look through a keyhole, or as if you would look through a tube. There should be a black border around the center of the screen, so that the user only sees that center.

Ideally, I would be able to dynamically change the diameter of this circle through which the user looks on the scene. Thus that black border on the sides of the scene would become wider or narrower.

Any ideas how to implement that in Ogre?

share|improve this question
Ogre forums posting: – Matthias May 17 '13 at 14:22
You should not cross post on the Ogre3D forums at the same time; it essentially wastes people's time. I've seen many of your posts both here and there. – unixunited May 18 '13 at 17:53
@Hydrocity: I thought it's ok if I post the link to the other thread here? – Matthias May 18 '13 at 21:38
up vote 1 down vote accepted

You could either use a post processing effect to draw a 2D overlay to the screen, or modify the stencil buffer to achieve the results you want. Ogre may facilitate the overlay effect easier than it would modifying the stencil buffer.

share|improve this answer
Using an Ogre Overlay did the trick for me, thanks. – Matthias May 22 '13 at 21:49

Another option is to create an actual 3D object that represents the keyhole or tube, and position it appropriately.

That has the advantage that it gives you more freedom to play with the camera position. You can either scale the model or move the camera to get different sized holes. It should also make it fairly easy to transition smoothly from another camera view to the looking through a keyhole one.

The only obvious awkwardness is that you may need to adjust the clip planes while it's there because the camera will be very close to it, so it might get clipped away if you don't.

share|improve this answer
That is an interesting thought :) – Matthias May 18 '13 at 11:21

Couldn't you just place a sprite with a texture that has the correct opacity pattern in front of the camera?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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