portal cutoff effect

| | August 5, 2015

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?

One Response to “portal cutoff effect”

  1. 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.

Leave a Reply