Material Property Block support

I used Material Property Blocks to alter a shader, and this works in the Scene view, but not in the Game view, leading to the material not changing and ‘sticking’ to whatever value it was. I can manually change it however, either in the inspector or a script and this will update in the Game view.

Property Blocks are a good optimisation tool. Is there any reason why they might not be working?

I see there is an existing thread on this already, and the conclusion is that no Property blocks are not supported.

They do work, see MaterialPropertyBlock - #16 by kapolka

1 Like

They should work if you’re using an up-to-date version of Unity and PolySpatial: for example, PolySpatial 1.2 and Unity 2022.3.27f1. For Unity versions lower than that, there’s an issue where the MeshRenderer won’t be dirtied (and thus won’t be transferred via PolySpatial) when the MaterialPropertyBlock is set. You can work around this by manually dirtying the Renderer via Unity.PolySpatial.PolySpatialObjectUtils.MarkDirty(Renderer) every time you set the MaterialPropertyBlock.

I can tell you, though, that using MaterialPropertyBlocks for visionOS won’t result in any kind of optimization. We are limited by RealityKit’s API, which doesn’t have a MaterialPropertyBlock equivalent. We handle MaterialPropertyBlocks behind the scenes by simply creating a new material with the affected properties.

At any rate, if you still have issues with MaterialPropertyBlocks, please file a bug report and let us know the incident number (IN-#####), so that we can look into it.

1 Like