- Set up your clip plane normally using glClipPlane and glEnable(GL_CLIP_PLANEx).
- Make sure to write the eye-space transformed vertex position to gl_ClipVertex in your vertex shader.
And this should make sense - the shape of a clipped triangle may not be a triangle - it could be a quadrilateral which must then be decomposed into two triangles for the setup-engine. So clipping needs to be done by dedicated hardware - your shader just has to give it access to eye-space coordinates.
(Clip planes are similar to eye-space tex-gen and lights in that you specify your input in object space, but the clip plane is then transformed to eye space at input time. This means that the clip plane is stored "camera relative" and will not move as you move the model view matrix. This is a good thing - clip planes are typically global in nature, so we don't want them to move each time we move the original to draw a car or some other moving mesh.)
EDIT: of course, you'll get software render if you touch gl_ClipVertex on most hardware. Your options:
- Use fixed function pipeline.
- Use pre-writing the Z buffer if you can.
- Case this out by card.
No comments:
Post a Comment