Shader Question

Started by
2 comments, last by mrbig 18 years, 3 months ago
The fragment shader runs once for every pixel, but what if I need a value generated at the previous time the shader ran for the next time it runs?
Advertisement
Then you're screwed.

[EDIT] I suppose an explanation is in order. The graphics card doesn't process pixels one at a time. It does them in blocks; i.e. if you have 12 pixel pipelines, 12 are computed at a time, in no particular order. So there is no concept of "previous" or "next" pixel.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
You can use multiple passes and let the first pass render into a different render target, which you then use as lookup texture in the next pass.
Quote:Original post by Promit
Then you're screwed.

[EDIT] I suppose an explanation is in order. The graphics card doesn't process pixels one at a time. It does them in blocks; i.e. if you have 12 pixel pipelines, 12 are computed at a time, in no particular order. So there is no concept of "previous" or "next" pixel.


That seriously sucks!
I wanted to optimize my box blur, so that instead of doing 2r texture reads per pixel, I would only have do 1 texture read and add it to the previous value (because neighbour pixels share almost the same neighbourhood of pixels, and it's a waste to read and add 2r pixels and than subtract 2r - 1 of them).
That would make the blur resolution independant and sOooOoO much faster...

This topic is closed to new replies.

Advertisement