Invisible wall that covers other 3D geometry

Hi, I want to make sort of a wall in my game, that is invisible, but other objects start to appear behind the wall like it was a real visible wall. So if an enemy would lean behind that wall, I would see his upper body, but not lower body because its behind the “invisible” wall and the wall is not seen either. How can I do this? Is there some wicked GL stuff or do I have to figure this out mathematicall by drawing a line to the enemy and then see if the wall is in the path.

I have 2 pictures to illustrate this:

http://betwixt.kirves.pri.ee/Stuff/InvisibleWall.png
http://betwixt.kirves.pri.ee/Stuff/InvisibelWallMonster.png

Probably the easiest way to do this is to use a clipping plane. Start by looking at the documentation for glClipPlane(). Enable the clipping plane just before rendering the character(s) you want obscured, then disable it afterward.

You can also do this rendering geometry for the wall and writing to the depth buffer only but you can’t “turn it off” as easily as disabling a clipping plane.

Regards,
Patrick

  1. Enable depth buffer writing (is enabled by default)
    glDepthMask(GL_TRUE);

  2. Disable the color writing
    glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);

3)Draw the wall

  1. Enable the color writing
    glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
  2. Draw the monster

Sometime people make a depth pass only to remove expensive fragment shader drawing. If you are using this tecnique you can draw the invisible wall only in the depth pass.

Thank You! I will try this out soon.

Since, I’m a noob in OpenGL…

What is depth pass?