POV-Ray : Newsgroups : povray.off-topic : Pixel shader question : Re: Pixel shader question Server Time
4 Sep 2024 09:20:36 EDT (-0400)
  Re: Pixel shader question  
From: Kevin Wampler
Date: 2 Mar 2010 13:04:38
Message: <4b8d5336$1@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.