View Full Version : clipping planes
07-19-2004, 09:37 AM
I just transformed my mirror reflections to glsl, but my clipping planes are not working any more. How do you clip planes in glsl?
I have :
What should I write to my vertex part to clip my scene by plane?
Thx for answers.
07-19-2004, 07:24 PM
Clip planes should still work the same. I don't see why GLSL should change anything. Unless of course you no longer use the modelview and projection matrix. Don't forget that clipping is done in post-perspective space, and that these matrixes matter at plane specification time.
07-20-2004, 03:08 AM
Finally I got it work.
I think that problem is in nvidia drivers (i've got FX5200)for linux. If I turn shader off it works.
Anyway I implemented checking side of plane in vertex/fragment program :
gl_FragColor = texture2D(textura1, texture_coordinate)*texture3D(textura3d,lc).x ;
So here is the screenshot of my reflection :)
07-20-2004, 07:30 PM
So you're using alpha test as I understand it now to kill fragments instead of using clip planes? I wouldn't recommend that from a performance point of view, unless you can't get it to work with real clip planes or get an updated driver.
07-20-2004, 10:03 PM
I know that this solution is very slow (it takes 30% performance of my little scene) but this is I think the simplest way to do this without modyfing anything and waiting for new drivers :) I will have to make simple application and test it with Windows to make sure I am right about the drivers. Anyway thank you for your interests.
07-21-2004, 01:36 AM
I have exactly the same result in both systems - there is no clipping. It would be nice if someone could test it. I modified 26th NeHe lesson to work with simple shader. A small ball should be clipped after reaching the surface.
Here are the links :
07-21-2004, 02:26 AM
Hope this quote from the official glSlang-Specs clears things up :
The variable gl_ClipVertex is available only in the vertex language and provides a place for vertex shaders
to write the coordinate to be used with the user clipping planes. The user must ensure the clip vertex and
user clipping planes are defined in the same coordinate space. User clip planes work properly only under
linear transform. It is undefined what happens under non-linear transform. So for the vertices to be clipped against your clipping planes, you'll need to write their coordinates to (if I'm not mistaken...I've never done anything with clipping planes AND shaders) gl_ClipVertex.
07-21-2004, 07:49 AM
Try the following:
gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
07-21-2004, 09:03 AM
Already tried but no luck :(
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.