Jump to content
  • Advertisement
Sign in to follow this  
Rmendil

OpenGL Pixel shader question

This topic is 4109 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
What information do you want to gather? You can
a) 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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!