rXpSwiss

12-08-2014, 10:51 AM

Hello,

I am trying to set a pass-through tessellation shader and then build on top of that while learning.

From what I found/read I need to do in the TE shader everything that was done in the vertex shader and the TC shader just has to send the data forward. The vertex shader just sends the vertices coordinate, normal, tangent to the TC shader.

So for now, I pass the data do the computing in the TE shader that was done in the vertex shader and the fragment will just color everything in red. No texture is applied, I really just want to see something, which is not the case. I only have a black screen.

I did change the draw command from triangles to patches and set the GL_PATCHES_VERTICES to 3. I also want to say that the vertex/fragment shader works fine with or without texture.

In that spirit :

Vertex Shader :

#version 430 core

in vec4 vertCoord;

in vec3 vertNormal;

in vec3 texCoord;

in vec4 tangent;

out vec2 f_texcoord;

out vec4 vPosition;

void main()

{

vPosition = vertCoord;

f_texcoord = vec2(texCoord);

}

TC shader :

#version 430 core

layout (vertices=3) out;

in vec4 vPosition[];

in vec3 normal[];

in vec4 tangent[];

out vec4 tcPosition[];

out vec3 tcNormal[];

out vec4 tcTangent[];

void main(void) {

tcPosition[gl_InvocationID]=vPosition[gl_InvocationID];

tcNormal[gl_InvocationID]=normal[gl_InvocationID];

tcTangent[gl_InvocationID]=tangent[gl_InvocationID];

if(gl_InvocationID==0){

gl_TessLevelOuter[0] = 1.0;

gl_TessLevelOuter[1] = 1.0;

gl_TessLevelOuter[2] = 1.0;

gl_TessLevelInner[0] = 1.0;

gl_TessLevelInner[1] = 1.0;

}

}

TE shader :

#version 430 core

layout(triangles,equal_spacing,ccw) in;

in vec4 tcPosition[];

in vec3 tcNormal[];

in vec4 tcTangent[];

uniform mat4 invTransp;

uniform mat4 mvp;//MVP

uniform mat4 m;

uniform mat4 mv;

uniform mat4 invView;

out mat3 tangenteSpace;

out vec4 position;// position of the vertex in world space

out vec3 varyingNormalDirection;

void main(void) {

vec3 p = gl_TessCoord.xyz;

vec4 vertCoord = vec4(normalize(tcPosition[0]*p.x + tcPosition[1]*p.y + tcPosition[2]*p.z).xyz,1.0);

vec3 vertNormal = normalize(tcNormal[0]*p.x + tcNormal[1]*p.y + tcNormal[2]*p.z);

vec4 tangent = vec4(normalize(tcTangent[0]*p.x + tcTangent[1]*p.y + tcTangent[2]*p.z).xyzw);

//comnpute tangent space

tangenteSpace[0] = normalize(tangent.xyz);

tangenteSpace[2] = normalize(vertNormal);

tangenteSpace[1] = normalize(cross(tangenteSpace[0],tangenteSpace[2])*tangent.w);

tangenteSpace = transpose(tangenteSpace);

//for no bump map

varyingNormalDirection = normalize(mat3(invTransp)*vertNormal);

//position in world space

position = m * vertCoord;

//f_texcoord = vec2(texCoord);

gl_Position = mvp*vertCoord;

}

What could be so wrong that nothing is displayed but no error either ?

rXp :)

I am trying to set a pass-through tessellation shader and then build on top of that while learning.

From what I found/read I need to do in the TE shader everything that was done in the vertex shader and the TC shader just has to send the data forward. The vertex shader just sends the vertices coordinate, normal, tangent to the TC shader.

So for now, I pass the data do the computing in the TE shader that was done in the vertex shader and the fragment will just color everything in red. No texture is applied, I really just want to see something, which is not the case. I only have a black screen.

I did change the draw command from triangles to patches and set the GL_PATCHES_VERTICES to 3. I also want to say that the vertex/fragment shader works fine with or without texture.

In that spirit :

Vertex Shader :

#version 430 core

in vec4 vertCoord;

in vec3 vertNormal;

in vec3 texCoord;

in vec4 tangent;

out vec2 f_texcoord;

out vec4 vPosition;

void main()

{

vPosition = vertCoord;

f_texcoord = vec2(texCoord);

}

TC shader :

#version 430 core

layout (vertices=3) out;

in vec4 vPosition[];

in vec3 normal[];

in vec4 tangent[];

out vec4 tcPosition[];

out vec3 tcNormal[];

out vec4 tcTangent[];

void main(void) {

tcPosition[gl_InvocationID]=vPosition[gl_InvocationID];

tcNormal[gl_InvocationID]=normal[gl_InvocationID];

tcTangent[gl_InvocationID]=tangent[gl_InvocationID];

if(gl_InvocationID==0){

gl_TessLevelOuter[0] = 1.0;

gl_TessLevelOuter[1] = 1.0;

gl_TessLevelOuter[2] = 1.0;

gl_TessLevelInner[0] = 1.0;

gl_TessLevelInner[1] = 1.0;

}

}

TE shader :

#version 430 core

layout(triangles,equal_spacing,ccw) in;

in vec4 tcPosition[];

in vec3 tcNormal[];

in vec4 tcTangent[];

uniform mat4 invTransp;

uniform mat4 mvp;//MVP

uniform mat4 m;

uniform mat4 mv;

uniform mat4 invView;

out mat3 tangenteSpace;

out vec4 position;// position of the vertex in world space

out vec3 varyingNormalDirection;

void main(void) {

vec3 p = gl_TessCoord.xyz;

vec4 vertCoord = vec4(normalize(tcPosition[0]*p.x + tcPosition[1]*p.y + tcPosition[2]*p.z).xyz,1.0);

vec3 vertNormal = normalize(tcNormal[0]*p.x + tcNormal[1]*p.y + tcNormal[2]*p.z);

vec4 tangent = vec4(normalize(tcTangent[0]*p.x + tcTangent[1]*p.y + tcTangent[2]*p.z).xyzw);

//comnpute tangent space

tangenteSpace[0] = normalize(tangent.xyz);

tangenteSpace[2] = normalize(vertNormal);

tangenteSpace[1] = normalize(cross(tangenteSpace[0],tangenteSpace[2])*tangent.w);

tangenteSpace = transpose(tangenteSpace);

//for no bump map

varyingNormalDirection = normalize(mat3(invTransp)*vertNormal);

//position in world space

position = m * vertCoord;

//f_texcoord = vec2(texCoord);

gl_Position = mvp*vertCoord;

}

What could be so wrong that nothing is displayed but no error either ?

rXp :)