Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

2019.2 latest LWRP doens't sort opaque draw calls

Discussion in 'Universal Render Pipeline' started by sebas77, Nov 7, 2019.

  1. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    For testing purposes I have disabled the SRP batched and the GPU instancing. I tested changing the
    Camera.main.opaqueSortMode to OpaqueSortMode.FrontToBack, but whatever value I use, the sorting doesn't change.

    I also wonder why I shouldn't use the FrontToBack sorting an any time.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    976
    What platform are you targeting?
     
    sebas77 likes this.
  3. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    Windows standalone. I forgot to mention that I test it using the frame debugger, so I am relying on what I see there.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    976
  5. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    Ok thank you. I am not sure why without any batching enabled it shouldn't work, seems very suspicious, but probably relying on sorting is not a great idea so another question if you don't mind: how can I enable a depth prepass to prime the z buffer using the depth pass before the actual rendering?
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    976
    Looking at the comments in the code:

    Code (CSharp):
    1. // Depth prepass is generated in the following cases:
    2.             // - We resolve shadows in screen space
    3.             // - Scene view camera always requires a depth texture. We do a depth pre-pass to simplify it and it shouldn't matter much for editor.
    4.             // - If game or offscreen camera requires it we check if we can copy the depth from the rendering opaques pass and use that instead.
     
    sebas77 likes this.
  7. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    thank you, it's still not clear how I can enable it explicitly. I will try to figure it out.
     
  8. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    I am back from holiday and tested this immediately. If I hack the code and force the requiresDepthPrepass to be true it works fine, but I am not sure how to force it otherwise. I wish to not support a custom LWRP just to force this.

    edit: setting the requiredDepthPrepass to true alone is not enough as the standard pipeline doesn't use the default render target for it, while instead obviously I need the depth pre pass to work on the default render target.
     
    Last edited: Nov 18, 2019 at 5:31 PM
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    976
    Well, I don't think there's another option for this at the moment.
     
  10. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    Your suggestion is to have custom LWRP pipeline just to prime the depth buffer then? If it helps my case, I could do it, but how can I do it without modifying your package?
     
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    976
    I'm saying that you can't do it without modifying the pipeline at the moment.
     
  12. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    which I don't know what it actually means. If you mean that the only way is to modify ForwardRender.cs, then this is what I am doing:

    Code (CSharp):
    1. if (true /*requiresDepthPrepass*/)
    2. {
    3.     m_DepthPrepass.Setup(cameraTargetDescriptor, m_ActiveCameraDepthAttachment/*
    4. m_DepthTexture*/
    5. );
    6.     EnqueuePass(m_DepthPrepass);
    7. }
    8.  
     
    Last edited: Nov 19, 2019 at 2:29 PM
  13. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    976
    I don't think this is a correct way to do this. If something relies on depth prepass populating m_DepthTexture, it will not have the data there.
    I suppose you need to add another pass to populate the backbuffer contents and enqueue it separately.
     
    sebas77 likes this.
  14. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    906
    yes I ended up doing it, but I still have so many questions, hence I opened a new thread