|
![](/i/fill.gif) |
> Is there any way in a pixel shader to do something like count the number
> of white pixels,
You might be able to use occlusion queries, the GPU counts all pixels that
pass the depth test and are actually rendered. In DirectX you can get this
information with CreateQuery() and related functions. You could clear your
render buffer to 50% depth, and make the pixel shader output a depth value
depending on whether you want it counted or not. At the end of the pass use
your API functions to read back the number of pixels rendered.
> There's no way to have the calculations of one pixel or vertex dependent
> on the calculations of a different pixel in the same pass?
No because they run in parallel, and in an undefined order I expect.
> Or any way to return an actual numeric value other than making a color?
Well you can create a surface texture that is full of floats or doubles
rather than RGBA bytes. On later cards and APIs a pixel shader can also
output multiple values to multiple render targets (but still limited to 4 or
something I think, IDK the details).
> I don't think a pass of a pixel shader can "see" the output of the
> previous pixel shader, right?
The usual method is to set the rendertarget as texture A (with input texture
B) and run your pixel shader, then the rendertarget as texture B and use
texture A as an input texture. That way you get to use the previous output,
and it isn't as slow as it sounds.
Post a reply to this message
|
![](/i/fill.gif) |