Search Unity

Dynamic Batching Issue

Discussion in 'General Graphics' started by Alan-Liu, Aug 10, 2016.

  1. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    393
    In our project, we copy the content of depth buffer generated by depth pass, to the depth buffer used by rendering opaque objects, trying to utilize Early Z to avoid some cost of executing pixel shader. Everything is OK except some meshes which using dynamic batching are not rendered correctly. Using RenderDoc, I found the depth value generated by two passes (depth pass and drawing pass) of these objects are not the same completely. (Object maybe rendered as a single mesh in depth pass, and rendered using dynamic batching in drawing pass)



    I test in 5.4.0f3.
    The project can be downloaded in this link.
    To reproduce:
    1. Play the scene "test.unity"
    2. Use WASD to move camera, you can see the most left tree is not rendered correctly. (On my machine, I move camera right a little, then move camera up)
    I have two questions:
    1. Is this an expected behaviour or a bug?
    2. Why are some objects rendered as a single mesh in depth pass while it can use dynamic batching obviously? (I think if all objects are consistent with dynamic batching in depth pass and drawing pass, this issue can be solved)
     
  2. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    393
    I posted a thread in beta forum, which needs HTC Vive to reproduce. But the above project can reproduce this issue without VR devices.
     
  3. richardkettlewell

    richardkettlewell

    Unity Technologies

    Joined:
    Sep 9, 2015
    Posts:
    2,285
    This sounds like the expected behavior. An object must use the same rendering choice in both passes (dynamic batching or single draw call) in order to work correctly. Otherwise, small mathematical differences will appear due to floating point precision.
     
  4. zeroyao

    zeroyao

    Unity Technologies

    Joined:
    Mar 28, 2013
    Posts:
    169
    Hey @Alan-Liu,

    Regarding your second question, it's not always the same batching criteria in depth pass and shading pass, as the material states and shaders (pass) used are different.