Search Unity

  1. We are looking for feedback on our SRP Rendering APIs through this Survey.
    Dismiss Notice
  2. Unity 2020.2 has been released.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Fragment shader writing 3x per pixel (to compute buffer)

Discussion in 'Shaders' started by BitJunkie, Aug 15, 2019.

  1. BitJunkie


    Jun 8, 2017
    If I count the number of writes per pixel using InterlockedAdd on a RWStructuredBuffer, I can plainly see that the fragment shader is running 3x for every pixel of the mesh, per frame. 6x and more if backface culling is turned off or there are overlaps. Is this intended behavior? How does it avoid drawing translucent pixels too dense if it's drawing multiple times?

    It's important to me to save info once per pixel per polygon layer. I need to record all the depth values of the mesh for building a 3D volume, even if the mesh overlaps a few times.

    (The mesh is procedurally made and rendered with with DrawProcedural to one camera. The scene is VR enabled, but this camera's set to 'target eye: None' so it only runs once.)