Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: how to pass variables through vertex shader, geometry shader and fragment shader?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    22

    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!
    Last edited by Sobeit; 06-20-2013 at 10:49 PM.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    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

  3. #3
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    490
    Quote Originally Posted by Sobeit View Post
    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?
    Yes.
    Quote Originally Posted by Sobeit View Post
    can I pass it from vertex shader directly to fragment shader?
    No.
    Quote Originally Posted by Sobeit View Post
    What if I want to create a variable in geometry shader and pass it to fragment shader?
    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.

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    22
    thank you guys. Do you have any suggestions on books or websites to learn these basic stuff of glsl?
    Last edited by Sobeit; 06-21-2013 at 01:20 PM.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    1,117
    I like this
    http://www.packtpub.com/opengl-4-0-s...-cookbook/book

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

  6. #6
    Junior Member Newbie
    Join Date
    Aug 2011
    Posts
    22
    Quote Originally Posted by tonyo_au View Post
    I like this
    http://www.packtpub.com/opengl-4-0-s...-cookbook/book

    It is getting a bit old now but will take you a long way
    thank you, i'll check out that book.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •