URP - Transparency mask

Hello everyone,

We would like to use MaterialPropertyBlock to increase performance but we got some problems with a ForwardRenderer feature (Transparency mask).

Here is the expected result, which works without MaterialPropertyBlock.
The transparent elements (sphere, cylinder and cube) masks the other transparent objects and you can still see through them (strictly speaking, they aren’t opaque objects) :

But when we use MaterialPropertyBlock, the ForwardRenderer feature seems to be ignored :

The forward render feature we use :

The transparency mask material :

public class MaterialPB : MonoBehaviour {
    public Renderer[] transparentObjects;
    public Color targetColor;
    public bool useMaterialPropertyBlock = true;

    private MaterialPropertyBlock _materialPropertyBlock;

    void Start () {
        _materialPropertyBlock = new MaterialPropertyBlock ();

        foreach (Renderer renderer in transparentObjects) {
            if (useMaterialPropertyBlock) {
                renderer.GetPropertyBlock (_materialPropertyBlock);
                _materialPropertyBlock.SetColor ("_BaseColor", targetColor);
                renderer.SetPropertyBlock (_materialPropertyBlock);
            } else {
                renderer.material.color = targetColor;
            }
        }
    }
}

We use unity 2019.4.13f1 with URP 7.3.1.

Does anyone have any ideas on how to fix the problem ?

We got a response from QA Team, we forgot to set the ‘Pass Index’ to 2.
In this way only the depth pass is rendered and we dont pay the cost of rendering the LitForward pass and it gives us the desired effect with MPB.

If you use URP > 7.6, ou need to set the ‘Pass Index’ to 3.

Because in 8.0.1:
“Drawing order of SRPDefaultUnlit is now the same as the Built-in Render Pipline”