- January 24, 2011 at 12:20 pm #30430
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.January 25, 2011 at 10:47 am #34718
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.
Xmas 2011-01-25 10:48:01January 25, 2011 at 11:04 am #34719
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.January 25, 2011 at 11:14 am #34720
XmasMemberOpenGLES 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).