ClipFragmentShaderTest

This is a custom standard material to help perform simple clipping of fragments with a SINGLE draw-call  WITHOUT having to use stencil buffer or a render-to-texture pre-pass. Before rendering, the necessary planes in local coordinate spaces are pre-calculated.

This allows stuffs like mirrors, alternate dimensions, portals, etc. to be drawn. For convex portals, you just need multiple versions of the shader program to test against multiple planes, depending on how many portal sides there are.

Drag the slider to see the 2 different sides of the cube.

A WebGL example of this can be found at: http://thecarpandtheseagull.thecreatorsproject.com , but I'm not sure if their approach is similar or different from mine.