|
![](/i/fill.gif) |
Darren New wrote:
> Check me on this one...
>
> I have a motion detector written in terms of a handful of pixel shaders.
> (Make it greyscale, compare this frame against two previous frames for
> differences, threshold, erode, etc.)
>
> Now all I'm really interested in is how much motion there is.
>
> Is there any way in a pixel shader to do something like count the number
> of white pixels,
I haven't really done any shader coding myself, but IIRC the way to
implement this would be with a summation tree. If you're coding in a
standard shader language instead of CUDA or OpenCL I suppose you'd do
this in about the same way that you'd manually generate mipmaps from a
base texture, only with a downsampling operation which sums the counts
of the non-white pixels instead of averaging their colors. You'll need
to either create a surface with float precision or manually pack the
sub-counts into the color components though.
Post a reply to this message
|
![](/i/fill.gif) |