PDA

View Full Version : Trying to mask parts of 3D quads after projection on a 2D image



nicolasv
11-09-2002, 03:15 PM
Hi all, I'm new to this forum and I badly need some help http://www.opengl.org/discussion_boards/ubb/smile.gif
I'm actually working on a project where I have a scene composed of thousands of small quads. I want to texture them with a photo I took from the scene. I've created a mecanism of retroprojection, that is I put the 2D image between the scene and the camera and I apply textures to the quads that project on it. Now, when projected on the 2D image, some quads are masked by others totally and some are masked partially. After ordering the quads I'm projecting I've managed to create a 2D mask of the exact size of the JPG image to determine if a quad is going to be visible, partially masked or invisible. For the moment I'm only able to render the quads that are fully visible, because I don't seem to be able to render a portion of a quad that is partially masked http://www.opengl.org/discussion_boards/ubb/frown.gif. I would like to render the fragments from the quads that are partially visible( their projected pixel on my 2D mask corresponds to a state where they should not be drawn). I don't know how to do this testing for single pixels and I'd really rather not fragment my quads. I've thought about applying my mask to the JPG image to add transparency to the pixels that should be invisible but that will be hard given the implementation I've chosen so far.
I've started looking also if I could use a stencil buffer but I'm not sure I can test the 3D pixels projection on my 2D mask
Does anyone have an idea to help me out .. ?
Thanks http://www.opengl.org/discussion_boards/ubb/smile.gif