4 Replies Latest reply on Aug 1, 2014 4:31 AM by ionutcava

    why the gl_ClipDistance[] doesn't work?

    yan_qingsong

      I just can't understand why the gl_ClipDistance doesn't work. The result is the same as I didn't set the gl_ClipDistance.

       

      I had set "glEnable(GL_CLIP_DISTANCE0) ;glEnable(GL_CLIP_DISTANCE1) ;"by application.

       

      the vertex shader is like this:

       

      #version 410
      
      uniform mat4    mvpMatrix;
      //.......some other uniforms here
      in vec2 vVertex;
      uniform vec4 clip_plane=vec4(1.0,1.0,0.0,0.85);
      uniform vec4 clip_sphere=vec4(0.0,0.0,0.0,10.0);
      
      void main(void) 
          { 
          //........some other code,include vec2 worldPos
          vec4 worldPosition=vec4(worldPos.x,height,worldPos.y,1.0);
          gl_ClipDistance[0]=dot(worldPosition,clip_plane);
          gl_ClipDistance[1]=length(worldPosition.xyz/worldPosition.w-clip_sphere.xyz)-clip_sphere.w;
          gl_Position = mvpMatrix * position;
          }
      
      

       

       

      I tried to only set "glEnable(GL_CLIP_DISTANCE0)"and"gl_ClipDistance[0]=-1.0" ,but what make me confused is that my model just still stay there,didn't disappear.

       

      Anybody know how this happen?