View Full Version : Invisible wall that covers other 3D geometry
02-10-2010, 12:50 PM
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:
02-10-2010, 03:09 PM
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.
02-10-2010, 03:10 PM
1) Enable depth buffer writing (is enabled by default)
2) Disable the color writing
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
3)Draw the wall
4) Enable the color writing
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
5) 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.
02-11-2010, 04:59 AM
Thank You! I will try this out soon.
Since, I'm a noob in OpenGL...
What is depth pass?
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.