2

I have a little program that render terrain from some SRTM data.

i'm playing a bit with glsl new featutes. I've successfully create a vs, tcs, tes, gs and fs where gs was only a pass through shader with:

#version 430
layout(triangles_adjacency) in;
layout(triangle_strip, max_vertices = 3) out;

void main(void) {
    for (int i = 0; i < gl_in.length(); ++i) {
        gl_Position = gl_in[i].gl_Position;
        EmitVertex();
    }
    EndPrimitive();
}

Now, in tcs and tes i add more triangles and i need to compute new normals, so i think i have to compute then in gs with triangles_adjacency option, so i can access to six vertices of 4 triangles. But when i change the code so:

#version 430
layout(triangles_adjacency) in;
layout(triangle_strip, max_vertices = 3) out;

void main(void) {

    gl_Position = gl_in[0].gl_Position;
    EmitVertex();

    gl_Position = gl_in[2].gl_Position;
    EmitVertex();

    gl_Position = gl_in[4].gl_Position;
    EmitVertex();

    EndPrimitive();

}

nothing is draw. I know, if i have tessellation active i have to use GL_PATCHES in draw arrays (and i made in this way) but i cant understand what can i do in order to see work this gs.

However my goal is to compute new normals after tessellation; can anyone eventually help me where compute them?

genpfault
  • 51,148
  • 11
  • 85
  • 139

0 Answers0