2019.2 latest LWRP doens't sort opaque draw calls

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.

What platform are you targeting?

1 Like

Windows standalone. I forgot to mention that I test it using the frame debugger, so I am relying on what I see there.

OK :slight_smile:

This mode does a rough front-to-back sorting. This meas that depending on some other conditions the order might not change at all.

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?

Looking at the comments in the code:

// Depth prepass is generated in the following cases:
            // - We resolve shadows in screen space
            // - 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.
            // - If game or offscreen camera requires it we check if we can copy the depth from the rendering opaques pass and use that instead.
1 Like

thank you, it’s still not clear how I can enable it explicitly. I will try to figure it out.

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.

Well, I don’t think there’s another option for this at the moment.

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?

I’m saying that you can’t do it without modifying the pipeline at the moment.

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:

if (true /*requiresDepthPrepass*/)
{
    m_DepthPrepass.Setup(cameraTargetDescriptor, m_ActiveCameraDepthAttachment/*
m_DepthTexture*/
);
    EnqueuePass(m_DepthPrepass);
}

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.

1 Like

yes I ended up doing it, but I still have so many questions, hence I opened a new thread