Getting your shaders to do clipping in such a way that both ATI and nVidia work is a hassle:
nVidia wants to use gl_ClipVertex (vec4) ala GL 2.x
ATI wants I think to use gl_ClipDistance (array of floats) ala GL 3.x
gl_ClipDistance gives the “signed distance” between the vertex and the clipping plane, the equations of the clip planes set from glClipPlane are stored in gl_ClipPlane, which is marked as deprecated in GLSL 1.3. The relation to think is:
gl_ClipDistance[i] = dot( gl_ClipVertex, gl_ClipPlane[i] )
the thing is that gl_ClipDistance gives more flexibility, AFAIK, gl_ClipDistance is not supported on nVidia cards (someone correct me if I am wrong), so you shaders will have this kind of beauty in it:
gl_ClipVertex = vertex.xyzw in same co-ordiante system as the planes were specified in glClipEquation;
gl_ClipDistance[i]= dot( vertex.xyzw, plane_equation[i].xyzw);
on the surface so far it looks like gl_ClipVertex is better, but actually it is not as flexible, with gl_ClipDistance you can have clipping determined by something else that just a plane equation, the sky is the limit (make sure you know it’s interpolation rules!). With gl_ClipDistance you can choose how clipping is done from the shader, i.e. the “clip planes” can be made to vary from vertex to vertex! (but be aware of the interpolation rules, better for it to vary just primitive to primitive).
Additionally, if you do not specify gl_ClipVertex, then GL does:
which most often you won’t like as gl_Position is in clip co-ordinates, not eye-coordinates, you can cheese muffin the entire issue by doing GL 2.x, not writing to gl_ClipVertex/Distance AND make sure you specify the clip planes in cough clip-coordinates which are given by:
Plane_ClipCoords.xyzw = Inverse Transpose ProjectionMatrix ( Plane_EyeCoords.xyzw)
ewww… a while back on nVidia hardware I tried to use gl_ClipDistance but the link stage always failed, I have not tried ATI hardware with gl_ClipDistance, anyone have experience?