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 ?