In OpenGL/JOGL, when using more than one clipping plane, the union of all clipping planes appears to be applied. What I want is instead the intersection of all clipping planes to be applied. Is this possible? See the below simplified 2-D example.
Edit: An example of clipping by vertex shader (see comments below).
Multi-pass:
Using
glClipPlane
, no. Vertices are clipped if they are outside the positive halfspace of at least one plane. Once that happens, it doesn't matter what any other plane may be.However, you can get this effect (or almost any other effect) by writing appropriate values to
gl_ClipDistance
in a vertex shader.Any portion where the interpolated value that you write out is less than 0.0 ("negative halfspace") will be clipped, and you can write any value you like, e.g. the squared distance to a point, or the sum of distances to two planes, or anything else you calculate.