Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: gl_ClipDistance[] in Tesselation Ev. Shader, NVIDI

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2011
    Posts
    1

    gl_ClipDistance[] in Tesselation Ev. Shader, NVIDI

    Hi!
    I'm using OpenGL 4.1 on a NVIDIA GeForce 460 for a demo, and I use tesselation which works fine. But now I tried to add a clipping plane to the shader program, so I wrote in the Tesselation Evaluation Shader:
    Code :
    #version 410 core
    (..)
    void main()
    {
    (...)
    gl_ClipDistance[0] = dot((Model_TransformMatrix * vec4(my_ObjPosition, 1.0)).xyz, vec3(0, -1, 0));
    (...)
    }

    With this command, the shader error throws an error "gl_ClipDistance is not available in this profile". Maybe I missunderstood the specification, so I tried another variant:
    Code :
    #version 410 core
    (..)
    void main()
    {
    (...)
    gl_PerVertex.gl_ClipDistance[0] = dot((Model_TransformMatrix * vec4(my_ObjPosition, 1.0)).xyz, vec3(0, -1, 0));
    (...)
    }
    Now the compiler throws syntax errors:
    Code :
    0(59) : error C0000: syntax error, unexpected '.', expecting ';' or '(' at token "."
    0(59) : error C0501: type name expected at token "."
    0(59) : error C1043: size of dimension cannot be less than 1
    0(59) : error C1060: incompatible types in initialization
    0(59) : error C1056: invalid initialization

    Is this my fault, is there an other way to define the clipping plane? Or is it a driver bug?

    Greetings,
    Christian M


    edit: I'm using driver version 260.19.36 under linux, but also tried the latest 266.58 under windows 7.


  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    529

    Re: gl_ClipDistance[] in Tesselation Ev. Shader, NVIDI

    Quote Originally Posted by GLSLang Spec 4.1, Section 7.1, page 86
    In the tessellation evaluation language, built-in variables are intrinsically declared as:

    Code :
    in gl_PerVertex {
      vec4 gl_Position;
      float gl_PointSize;
      float gl_ClipDistance[];
    } gl_in[gl_MaxPatchVertices];
     
    in int gl_PatchVerticesIn;
    in int gl_PrimitiveID;
    in vec3 gl_TessCoord;
    patch in float gl_TessLevelOuter[4];
    patch in float gl_TessLevelInner[2];
     
    out gl_PerVertex {
      vec4 gl_Position;
      float gl_PointSize;
      float gl_ClipDistance[];
    };
    So your first code quote:

    Code :
    gl_ClipDistance[0] = dot((Model_TransformMatrix * vec4(my_ObjPosition, 1.0)).xyz, vec3(0, -1, 0));
    should have worked. File a bug with NVIDIA. Quite some time ago, I had trouble with gl_ClipDistance in GL3.x (under GeForce8/9/100/200) and when I filed the bug report it was fixed very quickly.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •