I am working with imported assets that have multiple materials per mesh (eg: a single MeshFilter and MeshRenderer, with the MeshRenderer’s materials array containing 2 or more entries). Each Material has a unique albedo texture but shares other parameters with every other material. For Meshes that contain only a single material, I’ve been using MaterialPropertyBlocks to quickly change properties across every material. (I’m ingesting models from photogrammetry software, and adding overlays, different shading strategies, etc – this is data viz in a game engine, not really a ‘game’).
This breaks when Models have two or more Materials, though – I can only set a single MaterialPropertyBlock for the MeshRenderer, so Material[0] gets the correct albedo, but Material[1] through whatever end up sharing that albedo, which of course looks horrible since the UVs are all wrong.
To work around the issue I could create several shaders with texture samplers named eg _MainTex0, _MainTex1, etc, and make sure the variant with _MainTex1 is always assigned to materials[1], etc, but this seems like a silly hack.
Is there a “right” way to get this done?