PDA

View Full Version : gl_ClipDistance[] in Tesselation Ev. Shader, NVIDI



the_easterbunny
01-24-2011, 01:43 AM
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:


#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:


#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:


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.

kRogue
01-25-2011, 03:38 AM
In the tessellation evaluation language, built-in variables are intrinsically declared as:



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:





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.