Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

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

Discussion in 'Shaders' started by BitJunkie, Aug 15, 2019 at 1:37 AM.

  1. BitJunkie

    BitJunkie

    Joined:
    Jun 8, 2017
    Posts:
    2
    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.)