• Advertisement
Sign in to follow this  

Tessellation makes point

This topic is 2041 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

[color=#000000][font=Arial,]A little problem with my tessellation shader. I try to implement a simple tessellation shader but it only makes points.[/font][/color]
[color=#000000][font=Arial,]Here's my vertex shader :[/font][/color]

[source lang="cpp"]out vec4 ecPosition;
out vec3 ecNormal;
void main( void )
vec4 position = gl_Vertex;

gl_Position = gl_ModelViewProjectionMatrix * position;
ecPosition = gl_ModelViewMatrix * position;
ecNormal = normalize(gl_NormalMatrix * gl_Normal);

[color=#000000][font=Arial,]My tessellation control shader :[/font][/color]

[source lang="cpp"]layout(vertices = 3) out;
out vec4 ecPosition3[];
in vec3 ecNormal[];
in vec4 ecPosition[];
out vec3 myNormal[];
void main()
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
myNormal[gl_InvocationID] = ecNormal[gl_InvocationID];
ecPosition3[gl_InvocationID] = ecPosition[gl_InvocationID];
gl_TessLevelOuter[0] = float(4.0);
gl_TessLevelOuter[1] = float(4.0);
gl_TessLevelOuter[2] = float(4.0);
gl_TessLevelInner[0] = float(4.0);

[color=#000000][font=Arial,]And my Tessellation Evaluation shader:[/font][/color]

[source lang="cpp"]layout(triangles, equal_spacing, ccw) in;
in vec3 myNormal[];
in vec4 ecPosition3[];
out vec3 ecNormal;
out vec4 ecPosition;

void main()
float u = gl_TessCoord.x;
float v = gl_TessCoord.y;
float w = gl_TessCoord.z;
vec3 position = vec4(gl_in[0].gl_Position.xyz * u +
gl_in[1].gl_Position.xyz * v +
gl_in[2].gl_Position.xyz * w );
vec3 position2 = vec4(ecPosition3[0].xyz * u +
ecPosition3[1].xyz * v +
ecPosition3[2].xyz * w );
vec3 normal = myNormal[0] * u +
myNormal[1] * v +
myNormal[2] * w );
ecNormal = normal;
gl_Position = vec4(position, 1.0);
ecPosition = vec4(position2, 1.0);

[color=#000000][font=Arial,]Here's a screenshot : [url="http://img4.imageshack.us/img4/9712/sanstitrektht.png"]http://img4.imagesha...nstitrektht.png[/url][/font][/color]
[color=#000000]Thanks all![/color]

Share this post

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

  • Advertisement