hello guys,
i have a simple problem, i just converted a simple textured 3d cube code into tessellation and i am getting only cube, texture doesn’t show,
texture binding is good and loaded the texture into shaders,
here are the shaders,
thanks in advance
vertex
#version 420
in vec3 position;
in vec2 texturecoord;
out vec2 texCoord;
out vec4 vposition;
uniform mat4 ftm;
void main()
{
vposition = ftm*vec4(position, 1.0f);
texCoord=texturecoord;
}
tescontrol
#version 420
layout (vertices = 4) out;
in vec2 texCoord[];
in vec4 vposition[];
out vec2 tcCoords[];
out vec4 tcposition[];
void main()
{
if(gl_InvocationID==0)
{
gl_TessLevelOuter[0] = 3.0;
gl_TessLevelOuter[1] = 3.0;
gl_TessLevelOuter[2] = 3.0;
gl_TessLevelOuter[3] = 3.0;
gl_TessLevelInner[0] = 3.0;
gl_TessLevelInner[1] = 3.0;
// and then set tessellation levels
}
tcposition[gl_InvocationID] = vposition[gl_InvocationID];
tcCoords[gl_InvocationID]=texCoord[gl_InvocationID];
}
tesseval
#version 420
layout (quads, equal_spacing, ccw) in;
in vec2 tcCoords[];
in vec4 tcposition[];
out vec2 texCoord0;
void main()
{
vec4 a0 = mix(tcposition[0], tcposition[3],gl_TessCoord.x);
vec4 a1 = mix(tcposition[1], tcposition[2],gl_TessCoord.x);
gl_Position = mix(a0,a1,gl_TessCoord.y);
vec2 t0 = mix(tcCoords[0], tcCoords[3],gl_TessCoord.x);
vec2 t1 = mix(tcCoords[1], tcCoords[2],gl_TessCoord.x);
vec2 texCoord0 = mix(t0,t1,gl_TessCoord.y);
}
fragment shader
#version 420
in vec2 texCoord0;
out vec4 color;
uniform sampler2D sampler;
void main()
{
color = texture(sampler, texCoord0);
}