4
\$\begingroup\$

I want a 3D Mesh to come out of a flat portal. Only the part of the mesh that's coming out of the portal should be rendered, so the mesh should be cut off or sliced until it's fully outside the portal.

I thought about using discards in a fragment shader, but since I work on iOS OpenGL ES 2.0 I'd like to avoid that for performance reasons. Is there a performant way to do this?

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

You can implement the clipping plane functionality using vertex and fragment shaders and using discard fragment.

The other option is described in this paper, where it introduces a technique that modifies the projection matrix so the near and far planes are re-positioned to become a general purpose clipping plane. This way you can implement that without developing extra shaders. Also quoting from the paper's introduction:

The plane chosen to represent the image is simply the plane that naturally separates the image from the rest of the environment, such as the plane of a mirror, portal,or water surface.

\$\endgroup\$
1
  • \$\begingroup\$ That projection matrix trick looks useful. As I said I want to avoid discards, hope I can get the math down for the projection stuff! Thanks for the answer, any other suggestions would be appreciated. \$\endgroup\$
    – cboe
    Dec 24, 2013 at 12:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .