Click to See Complete Forum and Search --> : Pixel shaders for image processing


Koiby25
January 8th, 2009, 01:49 AM
What I'm trying to do is use Direct3D shaders to do per-pixel processing on a texture/surface. I don't want to render any geometry to a texture... just input one image, perform some operation on each pixel with the shader, then output to another image.

I'm not sure if it even makes sense to use shaders for this. If it does make sense, can anybody give me an idea of how to start, or give me some resources on how to do it?

Lindley
January 8th, 2009, 11:45 AM
These are written for OpenGL, but the principals should apply equally:

http://www.mathematik.uni-dortmund.de/~goeddeke/gpgpu/index.html

Also, you might want to consider some of the emerging GPGPU-specific tools like CUDA or OpenCL instead of D3D.

The key is to create a 1-to-1 mapping between shaders and pixels by ensuring that you're rendering to the same number of output pixels as you have inputs.

Koiby25
January 9th, 2009, 02:06 AM
Thanks for the reply! I'll look into some of that stuff.

Esperient
January 28th, 2009, 01:38 PM
Set your image/surface as the output render target. You will then need to render a "full screen quad", which is basically an untransformed rectangle that encompases the screen. Depending on how you go about doing this, you may need to tweak a simple vertex shader to calculate the appropriate texture coordinates. With the above setup, you can perform whatever per-pixel calculations you want into your render target through a pixel shader.

I hope i wasn't too vague here to be helpful.