I’m having a hard time getting OpenGL Tessellation to work. I have been struggling with it for about a month now. I’ve looked at a lot of example code and what I am doing doesn’t seem that different to what they are doing in their code. I was wondering if anyone could be a second pair of eyes and maybe point out why it isn’t working.
My scene is only rendering a black screen.
My shaders are as follows:
Vertex Shader
#version 150
in vec3 vertexPosition;
in vec3 vertexNormal;
in vec2 textureCoords;
in float textureIndex;
out VertexData
{
vec4 VertexPositions;
vec3 VertexNormals;
vec2 TextureCoords;
float TextureIndexs;
} vertex;
void main()
{
vertex.VertexPositions = vec4(vertexPosition, 1.0);
vertex.VertexNormals = vertexNormal;
vertex.TextureCoords = textureCoords;
vertex.TextureIndexs = textureIndex;
}
Tessellation Control Shader
#version 400
layout(vertices = 3) out;
in vec4 iVertexPositions;
in vec3 iVertexNormals;
in vec2 iTextureCoords;
in float iTextureIndexs;
out vec4 oVertexPositions;
out vec3 oVertexNormals;
out vec2 oTextureCoords;
out float oTextureIndexs;
void main()
{
float inLevel = 2;
float outLevel = 2;
gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
oVertexPositions[gl_InvocationID] = iVertexPositions[gl_InvocationID];
oVertexNormals[gl_InvocationID] = iVertexNormals[gl_InvocationID];
oTextureCoords[gl_InvocationID] = iTextureCoords[gl_InvocationID];
oVertexPositions[gl_InvocationID] = iVertexPositions[gl_InvocationID];
if (gl_InvocationID == 0)
{
gl_TessLevelOuter[0] = outLevel;
gl_TessLevelOuter[1] = outLevel;
gl_TessLevelOuter[2] = outLevel;
gl_TessLevelOuter[3] = outLevel;
gl_TessLevelInner[0] = inLevel;
gl_TessLevelInner[1] = inLevel;
}
}
Tessellation Eval Shader
#version 400
layout(triangles, equal_spacing, ccw) in;
uniform mat4 uMVPMatrix;
in vec4 iVertexPositions;
in vec3 iVertexNormals;
in vec2 iTextureCoords;
in float iTextureIndexs;
out VertexData
{
vec4 VertexPositions;
vec3 VertexNormals;
vec2 TextureCoords;
float TextureIndexs;
} vOut;
void main()
{
vec4 p0 = gl_TessCoord.x * iVertexPositions[0];
vec4 p1 = gl_TessCoord.y * iVertexPositions[1];
vec4 p2 = gl_TessCoord.z * iVertexPositions[2];
vec4 newCoord = normalize(p0 + p1 + p2);
vec3 normal = cross(vec3(p0 - newCoord), vec3(p1 - newCoord));
vOut.VertexPositions = newCoord;
vOut.VertexNormals = normal;
vOut.TextureCoords = vec2(gl_TessCoord.xy);
vOut.TextureIndexs = iTextureIndexs[0];
gl_Position = newCoord;
}