Using "core" Geometry shader in 3.2

Sorry if this post repeats something already asked, but I can’t find anything.

I’ve used vertex and fragment shaders in my application, and now that I have a machine which supports OpenGL 3.2 I want to have a go with geometry shaders since I think they could give me a real speed-up.

I have the ARB_GEOMETRY_SHADER4 extension, but reading that carefully suggests that it will only deal with points, lines and triangles and because I am dealing with (engineering) Finite Element meshes I want to be able to import and export quads as well as triangles.

As I understand it the “core” implementation in OpenGL 3.2 may be able to do this, but I simply can’t find any documentation on it anywhere.

Can anyone point me to some documentation and/or an example using the 3.2 core capability? (Oh, and an up to date glext.h file with the necessary #define statements would be good too!)

Thanks in advance.

Express quads as adjacency-lines at GS input (gives 4 vertices as input: 2 main vertices, 2 adjacent ones). Compose triangles out of it.

Sorry, I’m too stupid to understand what you mean.

I get a mesh of (mostly) quads and trias defined by the user, and I don’t want to split it up in any way.

My motive for using a geometry shader is to perform flat (per quad or per tria) shading without having to supply normals, instead computing the normal for the primitive from a cross-product in the geometry shader, then passing the unmodified primitive with its revised colour off to the fragment shader.

I can already do flat shading in the fragment shader (using dz/dX and dz/dY) but that has two problems:

(1) Quads have been split into trias by the time they arrive as fragments, so my quads get “faceted” into two triangles with distinctly different normals if they are at all warped (ie not flat) which is often the case. This doesn’t look very nice and is confusing for the user (an engineer interested in knowing the shape of his finite elements).

(2) Calculating lighting in the fragment shader is fine for a remote light source when using orthographic projection, gets less satisfactory if you use perspective projection (because the Z buffer is non-linear, ie dz/dZ is not constant), and falls apart completely if you use local lights.

Because the geometry shader is (I believe) still working in model space I should be able to get round these problems and give more satisfactory lighting.

Surely someone, somewhere has documented what is in OpenGL 3.2???

View it like this:
A Geom-shader doesn’t effectively/actually get triangles as inputs. It gets 1,2,3,4 or 6 vertices as inputs.

points: 1
lines: 2
lines_adjacency: 4
triangles: 3
triangles_adjacency: 6

(look at glsl 1.50 spec, page 37)

Example GS input declaration:

layout(lines_adjacency) in;
layout(triangle_strip, max_vertices = 4) out;

You may need 2 shaders/programs, one to handle the triangles, and another to handle the quads (with lines-adjacency input).