Pixel/vertex-shading and clip planes

Hi

Does anybody have an idea on how to perform fast clipping (glClipPlane) using per-pixel or (rather) per-vertex shading techniques ???

any comments are welcome :slight_smile:
thanks !
M

for static geometry:

preprocessing. do it yourself, it’s not that complicated. just some line-plane intersection tests…

for dynamic geometry:

  1. method
    the NVIDIA openGL SDK provides some examples for hardware-based geometry clipping. they are using a fragmentshader with the fragment_cull functionality to perform some kind of per-pixel clipping… i’m not sure how it works and wich HW supports it (but i’m think this is gf3 and above - except some the crappy gf4… i allways forget the right number… ok it’s the smallest one)

2.method:
you need singlepass multitexturing for this method, and 1 TMU per clippingplane.
What you do is simply setup the 2nd tmu to use an alpha-texture and multiply this value with your final alphavalue. then use alphatesting to clipaway all areas which has the alphavalue of 0. If you setup your texgen to map the vertexposition into uvw coodinates, you can just move your texgen matrix to move your clippingplane around.
ok, this method isn’t perfect, but for many applications/effects it’s good enough (and it’s works fine without any vendor-specific extensions on every hardware that uses singlepassmultitexturing…)
and btw.: with this method you can also do some fake-csg effects (depending on your alphamap) and you can also do a smooth clipping-border which fades away instead of cutting an hard edge.

imho it’s the easiest and fastest way for clippingplanes in realtime(not the most flexible, but for FX its good enough)

Originally posted by AdrianD:
for static geometry:

Thanks a lot !!

methode-1 seems the most interesting to me (should yield better performance than texgen+texturing+alpha testing …).

I’ll try to find some fragment shader related sample code on NVidia’s page…

bye