what i want to achieve:
the shader should sample all pixels of the given depth texture and write its values to a 1x1 texture. by setting the blendstate operation to minimum the final texture should show the darkest pixel.
as you can see it doesn’t work. i think the cause is that by setting the coords of SV_POSITION to only one point the triangle is deemed as “degenerate” and nothing shows up.
two ways to acess readwrite buffer is compute or pixel shader.
but the concept is easy(dunno if u need buffer for that): store pixel to temporary value, check if color darker then stored one, rewrite.
vux proposed a better solution that i try to implement now.
so i still want to get the darkest pixel by writing all pixels from the input texture to a 1x1 texture and setting blendmode to minimum (see attached patch darkestPixelTex2.zip). something is still missing or wrong…
Ok I added two ways to do it, issue using Rasterizer is you need to send enough data, a quad is not sufficient, so you need to feed enough pixels to it (hence null drawer as pointlist).
Also added how to do it in compute shader, which is much much faster compared to rasterizer version (but really it’s not optimized, two pass scan would be better since it would avoid a lot of Interlocked operations).