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 7 of 7

Thread: How to read variables in fragment shader?

  1. #1
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    3

    How to read variables in fragment shader?

    For example, depending on the variable A, an program will continue or stop by the end of every pass.

    float4 main(......)
    {
    ......

    IF Condition
    Change A

    ......
    }

  2. #2
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,119

    Re: How to read variables in fragment shader?

    Sorry, but your question is unclear. Are you asking how to pass variables from application to shader?

  3. #3
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    3

    Re: How to read variables in fragment shader?

    Sorry, it was my fault.

    I am writing a seed filling algorithm on GPU, and need passing some variables from shader to application. These variables will be used to change the application running: to continue to filling, to generate new seed and start new round seed filling or to stop the application.

  4. #4
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,119

    Re: How to read variables in fragment shader?

    Ok, actually you can't pass variables from shader to application.
    The only output of your shader are pixels (color, depth and indirectly stencil). So, your shader should draw a pixel, and application should read it using glReadPixels.
    You could also use occlusion query to count pixels that were drawn if you need such information.

  5. #5
    Senior Member OpenGL Pro k_szczech's Avatar
    Join Date
    Feb 2006
    Location
    Poland
    Posts
    1,119

    Re: How to read variables in fragment shader?

    And one more thing - I don't think that using GPU for seed fill is a good idea. The nature of this algorithm is too far away from the way GPU's work. Seed fill is recursive/scatter and GPU's are parallel/gather.

  6. #6
    Junior Member Newbie
    Join Date
    Sep 2006
    Posts
    3

    Re: How to read variables in fragment shader?

    many thanks

  7. #7
    Intern Contributor
    Join Date
    Jun 2004
    Location
    Shanghai, China
    Posts
    79

    Re: How to read variables in fragment shader?

    maybe you should use pbuffer or fbo to process the texture data

Posting Permissions

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