DX11 get darkest pixel from a given texture

hello everyone.

since no one can help me in this thread ( https://discourse.vvvv.org/t/11630 ) i want to split up the problem into subtasks and hopefully someone can help me with it.

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.

so what should i do?

darkestPixelTex.zip (3.2 kB)

i just went one step forward. by changing the topology to a pointlist it is possible to write all sampled pixels to a single pixel.

but the final texture still has not the darkest value. ideas?

darkestPixelTex2.zip (6.2 kB)

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.

hey antokhio!

i already tried that ( see https://discourse.vvvv.org/t/11630 ) but it doesnt work very well when using more than 1 thread.

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…

No one here who can solve the problem?

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).

darkestPixelTex.zip (8.4 kB)

this helped me a lot! thank you very much ;)