How to pass variables through vertex shader, geometry shader and fragment shader?

Hi there,

I recently introduced geometry shader, but it didn’t work out well. I have trouble passing variables through vertex shader to geometry shader and vertex shader to fragment shader.

If I want to pass a variable through pipeline, do I have to pass it from vertex shader to geometry shader and then down to fragment shader? can I pass it from vertex shader directly to fragment shader?

What if I want to create a variable in geometry shader and pass it to fragment shader?

Can anyone explain this to me? Thank you very much!

can I pass it from vertex shader directly to fragment shader

No - think of the geometry shader as a consumer of the vertex or tesselation data and an exporter of data to the fragment shader. It does not have to export any of the date from the vertex shader if you don’t want to and it can create its own data to send to the fragment shader

Yes.

No.

All of a geometry shader’s output variables are created in the geometry shader.

Often, the values of the output variables are copied directly from elements of the input variables (which are always arrays whose size depends upon the input primitive type, e.g. 2 for lines, 3 for triangles, etc), but there’s nothing special about this case.

thank you guys. Do you have any suggestions on books or websites to learn these basic stuff of glsl?

I like this

It is getting a bit old now but will take you a long way

[QUOTE=tonyo_au;1252025]I like this

It is getting a bit old now but will take you a long way[/QUOTE]
thank you, i’ll check out that book.

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