geometry shaders


i have some questions about geometry shaders:

  1. what is geometry shaders exactly?
  2. how can i use geometry shaders?
  3. which editor support geometry shaders? ( i try on rendermonky
    but i can declare an geometry shader)

sorry for bad english

I recommend reading the specification. In short, it is a programmable stage in the pipeline with entire primitives as input and output.

You can use geometry shaders for many things–you can destroy, create, and duplicate primitives, you can use them to render quads from points (for better point sprites), etc… :slight_smile:

  1. Geometry shaders function on triangles (or triangle strips) rather than vertices. You can use them to turn one primitive into many (or many into one)

  2. there’s a vendor-neutral extension for them. GL_EXT_geometry_shader_4. AMD/ATI don’t support it. It’s currently only working on nvidia GeForce 8, GeForce 9 and GTX 200 cards

  3. Rendermonkey won’t work because AMD doesn’t support the extension. I don’t know if any other editors support it.

i am confused!!!
the specification is too large and with-out example

can you help me with a simple shader?

where can i found more information about it? ( like as a book)

Sure. Here’s a simple geometry shader which passes through vertex positions:

#version 120
#extension EXT_gpu_shader4 : require
#extension EXT_geometry_shader4 : require

void main()
    for (int i = 0; i < gl_VerticesIn; i++)
        gl_Position = gl_PositionIn[i];


The gl_VerticesIn variable is actually a constant depending on how your geometry shader is set up. For example, if you set up the geometry shader to accept triangles as input, gl_VerticesIn will be 3. If you have it set to take in lines, it will be 2.

gl_PositionIn[] is an array containing all of the vertices of the incoming primitive, and gl_Position is an output varying.

A Quick google search found this. Looks like it goes over both the C code and the Shader code.

My shader IDE can do geometry shaders:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.