PDA

View Full Version : Howto get pixel values of the surface?



Linuxhippy
09-06-2005, 12:55 AM
Hi there,

I would like to use shaders (both vertex and fragment) for hw-accalerated sub-ipxel intialiasing of text.

I have a glyph-texture (a texture with just a single rendered letter in it) which I need to "blit" to a surface (PBuffer, Screen, FBO). The resulting pixel color depends on the color of the pixel I am overwriting on screen - however I do not have an idea how I could get access to the screen's pixels.

What I would like to do:
1.) get position of actual rendering (done in vertex shader with shared variable) - ok
2.) get pixel-value of the glyph-texture for current pixel - ok
3.) get pixel-value of the surface where the texture should be painted to for current pixel - ????
4.) Compute pixel value

The only idea I had was to render into a pbuffer first, bind it to a texture (so I can access it from the shader), create a second (to just render the glyph + shader in it) and last render the second pbuffer into the first.
However thats not only complicated but also quite slow :-(

Any better ideas?

Thank you in advance, lg Clemens

al_bob
09-06-2005, 09:57 AM
3.) get pixel-value of the surface where the texture should be painted to for current pixel - ????This step isn't (yet) hardware accelerated on any commercial GPUs.

You will need to either use the blending functionality, or render to texture (with copy) to get the effect you want.

Peter_dup1
09-06-2005, 04:04 PM
Sounds to me like you need to use blending. What algorithm do you use to compute the pixel value in step 4? - you have a wide range of blend functions to choose from, so I'm sure one of them will do what you need.

Going one step further, unless you are doing something really fancy, it should be possible to do the whole thing with the fixed functionality pipeline - just set up an ortho projection and render an appropriately aligned, textured quad.

Peter