   Pixel shader question
  This may be a stupid question but i want to first gather information about each framebuffer image before altering the image using a pixel shader. I need to step through the whole image before I am ready to change the image. Is there anyway to implement the first pass in a seperate or indeed the same pixel shader to give the necessary information to my second pass? Or does it have to be done using standard opengl? btw im using cg.Thanks for any help you can give me   
  What information do you want to gather? You cana) directly access the framebuffer using glReadPixels but that would stall the pipeline and hurts performance. It also involves two bus crossings. One to read the pixels from video memory into main memory and the other to write the processed data back into the framebuffer using glDrawPixels.b) Pixel Buffer Objects (PBO for short) not only allow buffer objects to be allocated in high performance video/AGP memory but they also allow for asynchronous DMA-assisted data transfers, which when used properly can boost the performance. If you choose to allocate a PBO inside AGP memory you can directly update it using the CPU. You need to keep this PBO synchronized with the contents of the framebuffer though.c) You may also render your scene into a texture in the first pass and process that inside a shader in the second pass.   ;  Basically what Im doing is first using a unique colour render of each frame to be able to pick out each object. I then want to calculate the average distance for all the pixels belonging to each object to some predefined point. Finally I want to use that average distance calculation as input to a pixel shader to use when rendering each object in a particular way.Passing the whole image to the pixle shader wouldnt help because then id have to do all the calculations for every pixel surely.Thanks for your help   ;  Given that those objects are distributed randomly, how else are you going to tell to which object each pixel belongs if you are not going to iterate over all those pixels?   