PDA

View Full Version : Problem with clip planes on ATI



Ehsan Kamrani
05-09-2012, 11:28 PM
I have a problem with clipping on my ATI card. but my NVidia graphics card clips the geometries with the same code. Note that I have updated the latest driver of my ATI graphics card from HP website ( it's a laptop). Here are the information of my ATI graphics card:
OpenGL Renderer: Radeon HD 6490M
OpenGL Version: 4.1.10664 compatibility profile context
GLSL version: 4.10

in my source code I specify the clip plane:

// Translate the world, then flip it upside down
glTranslatef(0.0f, m_fWaterCPos[1]*2.0f, 0.0f);
glScalef(1.0, -1.0, 1.0);

// Since the world is updside down we need to change the culling to FRONT
glCullFace(GL_FRONT);

// Set our plane equation and turn clipping on
CDouble plane[4] = {0.0, 1.0, 0.0, -m_fWaterCPos[1]};
//glEnable(GL_CLIP_PLANE0);
glClipPlane(GL_CLIP_PLANE0, plane);
glUniform4fv(glGetUniformLocation( g_shaderType , "plane_equation"), 1, (GLfloat*)plane );
glEnable( GL_CLIP_DISTANCE0 );
//Render the scene
glDisable( GL_CLIP_DISTANCE0 );


Then in my vertex shader:

gl_ClipDistance[0]= dot( gl_ModelViewMatrix * gl_Vertex, gl_ModelViewMatrix * plane_equation.xyzw);

Does my code have problem?

Ehsan Kamrani
05-10-2012, 12:57 AM
My problem solved. I was sending the uniform information before using the shader :D But it seems that NVidia manages the clipping internally. It means that it reads the fixed functions such as glClipPlane() and ignores the clipping in shader( I disabled the gl_ClipDistance in my shader and my NVidia card clipped the scene correctly).