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.
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.
Enable depth buffer writing (is enabled by default)
glDepthMask(GL_TRUE);
Disable the color writing
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
3)Draw the wall
Enable the color writing
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
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.