Hi, as it is my first time here, I would like to introduce myself as an ivy league educated programmer without a degree; while I do not pretend to be at Bill Gate’s level I had a chance to sit with him at MTV Studios for ‘the Notorious B.G’ filming. I asked him one question off of film, “What do you think of linux?” “It’s an annoyance,” was his reply.
My question is, do I need to call glDrawElementsInstanced in order to get an gl_InvocationID in the shader? I am at a stopping point with my project and would like some help. I have code available if needed.
I am, or was, confused about the language of the rendering pipeline. In GLES 2, the shaders are simple, tessellation (location) and fragment (color) processing. With the addition of the geometry shader in GL 33 my programming technique is to use it to modify the 3D camera projections of the properly termed tessellation (vertex) stage. I looked directly here:
[QUOTE=abb2104;398122]I am, or was, confused about the language of the rendering pipeline.
…geometry shader gl_InvocationID … and the verbiage confused me …
My current understanding is that the gl_InvocationID allows for multiple instances of the same tessellation output for repeated renderings.[/QUOTE]
I think I see where the disconnect is. You might have crossed the meaning of the word “instance” used in two different contexts.
[li]gl_InvocationID for tessellation evaluation shaders just tells you which input patch vertex (control point) this shader run should handle. [/li][li]gl_InvocationID for geometry shaders (when used with geometry shader instancing) tells you which “copy” of the primitive this shader run should handle. [/li][li]Whereas, glDrawElementsInstanced is one of the calls used to launch what’s called an instanced draw call. [/li][/ol]
Though the latter two can both be used to render multiple copies of geometry, the “instancing” technique referred to in each of these is different. In the instanced draw call case, the geometry replication happens up at the draw call dispatch stage (ahead of the whole shader pipeline, including the vertex shader). Whereas in the geometry shader instancing case, the geometry replication occurs after the vertex shader before the geometry shader.
If you’re using an instanced draw call and you want to know which draw call instance you’re currently rendering, use gl_InstanceID (in the vertex shader). OTOH, if you’re using geometry shader instancing and want to know which geom shader instance you’re currently rendering, use gl_InvocationID (in the geometry shader).
I think that I am looking in the wrong place in my code. My overall goal is just to map a multisampled framebuffer object to a lwjgl window. I wrote the shaders, as I was accustomed to doing with GLES 2; however, it seems that there is a glBlitFramebuffer call that I could use. OpenGL Frame Buffer Object (FBO) . I took out the shader functions and here is my rendering call:
It seems clear from your geometry shader that you don’t quite understand how a GS works. It’s not a vertex shader. The VS takes a single vertex as input and writes a single vertex as output.
A geometry shader takes a primitive as input. That’s why its input values are arrayed; if a GS takes triangles as input, then its input arrays contain 3 vertices worth of data. Your shader only ever reads index 0 from the array, so indices 1 and 2 never do anything.
A geometry shader writes primitives as output. That’s why it has the EmitVertex and EmitPrimitive functions; so that you can call them multiple times within the same GS invocation. You don’t build up primitives from multiple GS invocations; each invocations writes zero or more distinct primitives. Your shader only ever emits a single vertex. And since a triangle cannot be composed of a single vertex, nothing happens.
I would like to know more about the array output values, I got some sort of error along the lines of ‘output values must not be looped when arrayed’ when I put the tex_coord variable into an output array. There are multiple instances of the output, are they modified, overwritten? I would like to implement a geometry shader, could you explain more, Alfouse Reinheart?
There are no “array output values”, so it’s not clear what you’re talking about. You output different values for different vertices by using the same output variable, with EmitVertex calls between them. That is, each call to EmitVertex takes the current values of the output values as a single vertex. And then renders their contents undefined.