\$\begingroup\$

I am looking to achieve the following: I have a compute shader that receives a Texture2D as input, where a small percentage of the pixels in the texture are white. The location of the white pixels are unpredictable for any given frame. I want to read the depth value at these white pixels and store them in memory. I cant put them in a RWStructuredBuffer because there is no way to prevent each thread from overriding another thread when storing values to the buffer. Of course I could assign each thread its own position in the buffer, BUT THEN THIS WOULD INCLUDE ALL non-white pixels. I only want to store the values from white pixels, so the buffer would be much smaller in size than the texture. I can achieve this with an append buffer, simply by having only the white pixels append to the appendbuffer. But I don’t know how I can then subsequently READ from that appendbuffer in the same compute shader. Is that possible?

Daniel Cardin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

\$\endgroup\$

1

You must log in to answer this question.