I'm using a metal shader to draw many particles onto the screen. Each particle has its own position (which can change) and often two particles have the same position. How can I check if the texture2d
I write into does not have a pixel at a certain position yet? (I want to make sure that I only draw a particle at a certain position if there hasn't been drawn a particle yet, because I get an ugly flickering if many particles are drawn at the same positon)
I've tried outTexture.read(particlePosition)
, but this obviously doesn't work, because of the texture access qualifier, which is access::write
.
Is there a way I can have read and write access to a texture2d
at the same time? (If there isn't, how could I still solve my problem?)