Accessing an entire column or row of a frame.

This topic contains 3 replies, has 2 voices, and was last updated by  Xmas 6 years, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #30430

    OpenGLES
    Member

    Is there a way to access all the elements of a particular column (and row) of a frame (sized MxN) in the fragment shader? My application requires processing a column (say adding all pixels of a column).

     

    I prefer not to use glReadPixels() as it degrades the performance considerably.

     

    Thanks.
    #34718

    Xmas
    Member

    You can render to a texture, then sample from that texture using texture2D in the fragment shader. Note that – depending on what operation you want – splitting the process into multiple steps may be more efficient.Xmas2011-01-25 10:48:01

    #34719

    OpenGLES
    Member

    Did you mean rendering the whole frame (of size MxN,  with M=640 and N=480)? Can you please elaborate more on that?

    Now each fragment operation should be about adding/processing the 480 pixel elements in each column.
    #34720

    Xmas
    Member
    OpenGLES wrote:
    Did you mean rendering the whole frame (of size MxN,  with M=640 and N=480)? Can you please elaborate more on that?

    Yes, you would render the whole scene to a texture (used as a colour attachment to a framebuffer object) so it can later be accessed in a fragment shader.

    There is example code in our SDK which demonstrates rendering to a texture.

    Quote:
    Now each fragment operation should be about adding/processing the 480 pixel elements in each column.

    It may be more efficient to reduce the texture in multiple steps, e.g. adding groups of eight elements from each column at a time. That way you’d reduce the frame from 640×480 to 640×60 to 640×8.

    What’s best depends on the exact operation you want to perform (including the precision requirements).

Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic.