Vexator

07-17-2007, 11:20 AM

using clip planes in fixed functionality has never caused any trouble, but now that i'm using shaders all the time, i can't get them working correctly. i set them up as usual and call gl_ClipVertex in my vs - geometry is clipped as expected, but moving/rotating the camera causes serious flickering. i'm using a gf7800gt. any ideas what's wrong?

EDIT: i tried oblique depth projection desribed here: www.terathon.com/code/oblique.php (http://www.terathon.com/code/oblique.php) as a work-around, but it totally messes up my geometry; i tried to do it in in software and in the vs. u_ProjectionMatrix is the input matrix:

vec4 q;

mat4 ProjectionMatrix = u_ProjectionMatrix;

vec4 clipPlane = vec4( 0.0, -1.0, 0.0, 0.0 );

q.x = (sign(clipPlane.x)+ProjectionMatrix[2][0])/ProjectionMatrix[0][0];

q.y = (sign(clipPlane.y)+ProjectionMatrix[2][1])/ProjectionMatrix[1][1];

q.z = -1.0;

q.w = (1.0+ProjectionMatrix[2][2])/ProjectionMatrix[3][2];

vec4 c = clipPlane * (2.0/dot(clipPlane, q));

ProjectionMatrix[0][2] = c.x;

ProjectionMatrix[1][2] = c.y;

ProjectionMatrix[2][2] = c.z+1.0;

ProjectionMatrix[3][2] = c.w;

EDIT: i tried oblique depth projection desribed here: www.terathon.com/code/oblique.php (http://www.terathon.com/code/oblique.php) as a work-around, but it totally messes up my geometry; i tried to do it in in software and in the vs. u_ProjectionMatrix is the input matrix:

vec4 q;

mat4 ProjectionMatrix = u_ProjectionMatrix;

vec4 clipPlane = vec4( 0.0, -1.0, 0.0, 0.0 );

q.x = (sign(clipPlane.x)+ProjectionMatrix[2][0])/ProjectionMatrix[0][0];

q.y = (sign(clipPlane.y)+ProjectionMatrix[2][1])/ProjectionMatrix[1][1];

q.z = -1.0;

q.w = (1.0+ProjectionMatrix[2][2])/ProjectionMatrix[3][2];

vec4 c = clipPlane * (2.0/dot(clipPlane, q));

ProjectionMatrix[0][2] = c.x;

ProjectionMatrix[1][2] = c.y;

ProjectionMatrix[2][2] = c.z+1.0;

ProjectionMatrix[3][2] = c.w;