Jump to content
  • Advertisement
Sign in to follow this  
baykalsa

Manipulating a specific pixel

This topic is 4162 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

Hi guys! Let's say we have 1024x768 (or whatever) textured screen quad. How can I change a specific pixel of the texture? Or are there any real time post proceesing trick to change a specific pixel of the rendered scene? Thanks in advance :)

Share this post


Link to post
Share on other sites
Advertisement
It depends on what you want to do because there is dozens of methods to manipulate either individual pixels or all of them in both the frame buffer or in a texture.

Share this post


Link to post
Share on other sites
overlord, I want to implement some post processing operations,but I should be able to change correct pixels.well, i.e. changing the pixel on the (x=120,y=320) point of the screen. I hope it clarifies.

Share this post


Link to post
Share on other sites
What kind of post-processing do you want to do?

GL has functions to simply read and write a pixel values, but they're slow because of the transfer from gfx to system RAM, and therefore aren't exactly used very much in games...

A hardware accelerated post-processing system will usually do something along the lines of:
1)render the scene
2)copy the frame-buffer to a texture
3)bind a pixel shader containing your post-process algorithm
4)set an appropriate blending mode
5)render a full-screen quad using that texture
6)unbind PS and reset blending mode

Share this post


Link to post
Share on other sites
And in a lot of cases you don't even need to use pixel shaders, regular blending works really fine for things like blurring and so on.

One thing you should really take a look at is FBO, since it allows you to render directly to a texture and then use that texture for post processing directly to the framebuffer.
I have written a short tutorial on the subject of FBOs on my site, just go to flashbang.se(see link below) and look up the line FBO on the right.

Share this post


Link to post
Share on other sites
Also, if you dont want to get into FBO's and want to stick to "older methods" then take a look at glReadPixels and glDrawPixels. These two functions get and draw an array of pixels to the frame buffer. You need to note that these functions are awfully slow but with them you can easily get your array of pixels, loop through them and change what pixels need to be modified. Then, you just take the array you modified and redraw it. Hope that helps as an alternative.

Jon

Share this post


Link to post
Share on other sites
Thanks for the great replies guys.But I want to do that in real time. I've looked at it and I think I should use FBO. How can I change a pixel of the screen quad's texture by using FBO? Do you know where I can find an example code? ( no post processing just changing the texture pixels.) Is it logical to do it for a 1024x768+ quad in real time? Thanks again :)

Share this post


Link to post
Share on other sites
If you care to answer: why do you WANT to change a single pixel?
At a resolution of 1024x768 you have 786,432 pixels. Do you think changing a single pixel will make a significant addition to the graphical quality of your scene?

Share this post


Link to post
Share on other sites
Quote:
Original post by Kalasjniekof
If you care to answer: why do you WANT to change a single pixel?
At a resolution of 1024x768 you have 786,432 pixels. Do you think changing a single pixel will make a significant addition to the graphical quality of your scene?


My guess is he wants to do more than edit a single pixel. But in order to do that you need to know how to edit one.

Share this post


Link to post
Share on other sites
Well, I don't why it is sooooo important for you, but I will make a pattern recognition program(neural nets). I need to know how to change a pixel.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!