Jump to content
  • Advertisement
Sign in to follow this  
Sal0hcine

OpenGL Unkown Layout Identifier

This topic is 2747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi,

I have been trying to implement a tessellation shader to have a play and I have seen the various exampls using layout(vertices = 4) outl; which all seems understandable after reading the OpenGL 4.1 spec.

My problem is every time I compile my code I get the error message "error C3008: unknown layout specifier 'vertices'" however I am certain it is valid.

I am using a GTX470 and the latest release drivers 266.58.

Has anyone else experienced this problem, or do you have any ideas what might be causing it?

Here is my control shader code, it is the example from codeflow:

#version 400 core

layout(vertices = 3) out;

uniform vec2 screen_size;
uniform mat4 mvpControl;
uniform float lod_factor;

bool offscreen(vec4 vertex)
{
if(vertex.z < -0.5)
{
return true;
}
return any(lessThan(vertex.xt, vec2(1.7)) || greaterThan(vertex.xy, vec2(1.7)));
}

vec4 project(vec4 vertex)
{
vec4 result = mvpControl * vertex;
result /= result.w;
return result;
}

vec2 screen_space(vec4 vertex)
{
return (clamp(vertex.xy, -1.3, 1.3)+1) * (screen_size*0.5);
}

float level(vec2 v0, vec2 v1)
{
float lod_fac = 4.0;
return clamp(distance(v0, v1)/lod_fac, 1, 64);
}

void main()
{
if(gl_InvocationID == 0)
{
vec4 v0 = project(gl_in[0].gl_Position);
vec4 v1 = project(gl_in[1].gl_Position);
vec4 v2 = project(gl_in[2].gl_Position);
vec4 v3 = project(gl_in[3].gl_Position);

//If the polygon is off the screen do not tessellation
if(all(bvec4(offscreen(v0), offscreen(v1), offscreen(v2), offscreen(v3))))
{
gl_TessLevelInner[0] = 0;
gl_TessLevelInner[1] = 0;
gl_TessLevelOuter[0] = 0;
gl_TessLevelOuter[1] = 0;
gl_TessLevelOuter[2] = 0;
gl_TessLevelOuter[3] = 0;
}
else
{
vec2 ss0 = screen_space(v0);
vec2 ss1 = screen_space(v1);
vec2 ss2 = screen_space(v2);
vec2 ss3 = screen_space(v3);

float e0 = level(ss1, ss2);
float e1 = level(ss0, ss1);
float e2 = level(ss3, ss0);
float e3 = level(ss2, ss3);

gl_TessLevelInner[0] = mix(e1, e2, 0.5);
gl_TessLevelInner[1] = mix(e0, e3, 0.5);
gl_TessLevelOuter[0] = e0;
gl_TessLevelOuter[1] = e1;
gl_TessLevelOuter[2] = e2;
gl_TessLevelOuter[3] = e3;
}
}

gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
}

Share this post


Link to post
Share on other sites
Advertisement

Hi,

I have been trying to implement a tessellation shader to have a play and I have seen the various exampls using layout(vertices = 4) outl; which all seems understandable after reading the OpenGL 4.1 spec.

My problem is every time I compile my code I get the error message "error C3008: unknown layout specifier 'vertices'" however I am certain it is valid.

I am using a GTX470 and the latest release drivers 266.58.

Has anyone else experienced this problem, or do you have any ideas what might be causing it?

Here is my control shader code, it is the example from codeflow:

#version 400 core

layout(vertices = 3) out;

uniform vec2 screen_size;
uniform mat4 mvpControl;
uniform float lod_factor;

bool offscreen(vec4 vertex)
{
if(vertex.z < -0.5)
{
return true;
}
return any(lessThan(vertex.xt, vec2(1.7)) || greaterThan(vertex.xy, vec2(1.7)));
}

vec4 project(vec4 vertex)
{
vec4 result = mvpControl * vertex;
result /= result.w;
return result;
}

vec2 screen_space(vec4 vertex)
{
return (clamp(vertex.xy, -1.3, 1.3)+1) * (screen_size*0.5);
}

float level(vec2 v0, vec2 v1)
{
float lod_fac = 4.0;
return clamp(distance(v0, v1)/lod_fac, 1, 64);
}

void main()
{
if(gl_InvocationID == 0)
{
vec4 v0 = project(gl_in[0].gl_Position);
vec4 v1 = project(gl_in[1].gl_Position);
vec4 v2 = project(gl_in[2].gl_Position);
vec4 v3 = project(gl_in[3].gl_Position);

//If the polygon is off the screen do not tessellation
if(all(bvec4(offscreen(v0), offscreen(v1), offscreen(v2), offscreen(v3))))
{
gl_TessLevelInner[0] = 0;
gl_TessLevelInner[1] = 0;
gl_TessLevelOuter[0] = 0;
gl_TessLevelOuter[1] = 0;
gl_TessLevelOuter[2] = 0;
gl_TessLevelOuter[3] = 0;
}
else
{
vec2 ss0 = screen_space(v0);
vec2 ss1 = screen_space(v1);
vec2 ss2 = screen_space(v2);
vec2 ss3 = screen_space(v3);

float e0 = level(ss1, ss2);
float e1 = level(ss0, ss1);
float e2 = level(ss3, ss0);
float e3 = level(ss2, ss3);

gl_TessLevelInner[0] = mix(e1, e2, 0.5);
gl_TessLevelInner[1] = mix(e0, e3, 0.5);
gl_TessLevelOuter[0] = e0;
gl_TessLevelOuter[1] = e1;
gl_TessLevelOuter[2] = e2;
gl_TessLevelOuter[3] = e3;
}
}

gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
}



layout(vertices = 3) out; >> layout(vertices = 4) out;

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!