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.
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.
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
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.
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.
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 :
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.
Try the following:
gl_ClipVertex = gl_ModelViewMatrix * gl_Vertex;
Already tried but no luck
This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.