Material property block for Path tracer

I need to change some properties of a material for an object. When using the rasterization pipeline this works fine with the setPropertyBlock function of the renderer of that object. But these changes are ignored when I switch from the rasterization pipeline to the path tracer. Is there a similar feature to set material properties for the path tracer or is the only solution to make a copy of my material and directly changing this?

Renderer renderer = GameObject.Find("myObject").GetComponent<Renderer>();
MaterialPropertyBlock newProperties = new MaterialPropertyBlock();
renderer.GetPropertyBlock(newProperties);
newProperties.SetColor("_Color", new Color(0.3f, 0.4f, 0.6f));
renderer.SetPropertyBlock(newProperties); // works for the rasterization pipeline but not for path tracer

This should work fine starting with 2020.2.
The support for SetPropertyBlock in ray tracing was added in 2020.2.

1 Like

I tested your code in 2020.2.0f1 and works as expected.

1 Like

This indeed got fixed in version 2020.2.0f1 but I noticed this behavior has reappeared as of version 2022.2.0b1 (it might have happened sooner version 2021.2.0b1 is the last version I tested where it still worked.) I also tested on version 2023.3.0b7 and here its still broken.

So to reiterate: when using the property block to override the BaseColor of the lit shader (see script below) the new value is ignored when enabling the Path Tracing volume override but it is used when disabling this.

Renderer renderer = this.gameObject.GetComponent<Renderer>();
MaterialPropertyBlock newProperties = new MaterialPropertyBlock();
renderer.GetPropertyBlock(newProperties);
newProperties.SetColor("_BaseColor", new Color(1.0f, 0.0f, 0.0f));
renderer.SetPropertyBlock(newProperties);

Hi! Thanks for reporting the issue. It will be fixed ASAP and backported.

1 Like

I just tested version 2023.3.0b10 and it works again!
Thanks for the support.