Unity Introduces Material Variants
Like Prefabs, now you can create variants of Materials with local custom settings in Unity 2021.1.
Prefabs have been a great life saver and a performance booster for all the Unity developers. It is well known for the scalability and efficient workflow that helps the developers immensely during the development process. Just like the Prefabs workflow, now Unity finally introduced Material Variants with a similar concept possessing a great potential to speed up iterations, reuse, enhance asset library and help collaborate with artists more uniformly. This works with all the render pipelines available and it can be integrated into any project on the Unity version 2022.1 or greater.
Back then, Unity used the concept of shared materials where developers were not allowed to keep custom local changes for different materials even though there was the need for just minor changes in value. Developers need to create a duplicate or else a completely new material for having a minor parametric change which was undoubtedly inefficient. This was not only increasing the material count but also it was hard to manage such a huge library of redundant material. There are higher chances, especially for beginners to mess up the material linking, as many assets in the game might have been linked with a single material, and developers might be changing the local values of the material by going through each asset, which ultimately changing the main material itself for all other assets as well. Now to cut the way short, Unity finally brings on the ability to create the variants of the materials with a similar concept to prefabs for better efficient workflow.
The new Material variants feature allows the developers to create several templates that can be reused and overridden wherever required with local changes. The base template holds the common parameters/settings which can be overridden locally and reused as per the need. Additionally, developers can also lock and protect some of the specific properties that they do not want to be overridden. This workflow works best for anyone creating materials from a shader graph having several properties that are required to be changed for specific assets and purposes. For example, we made a water shader, now this water shader is dynamically created inside the shader graph in such a way that we can change the type of water using an Enum. So, we will populate our scene with water material wherever required, and now depending on the situation, we will use running water in the drains and still water for ponds. And all these settings are just a click away, we just need to go to individual materials and change the type of water which will technically override the base settings of the water. Super simple and fast to achieve such specific instances.
Now how to get started?
Working with Material Variant is pretty simple. First, to use this feature the project should be running on the Unity version 2022.1 or greater. Second, to create a material variant, simply head to Project Window, right-click on the Material Asset, and choose Material Variant inside Create. However, developers can also convert and attach existing duplicated material to a common parent material with this new feature. As stated previously, several properties on the parent material can be locked themselves so that no overridden can be done on variants. This makes the workflow safer and protects from any mishappening or errors.
Check the full documentation for the in-depth use case.
This has been a highly requested feature along with many other crucial feature requests, though it was very late for Unity to introduce this, still it would be a great performance booster for the game developers for faster and more efficient collaboration. If you want to request or vote for new features, head your way to Public Roadmap and make yourselves heard.
Check Unity Public Roadmap.
Get to know more about Material Variants on Unity Official Blog.
With Love From VOiD1 Gaming
**VOiD1 Gaming is not sponsored by the above company. All trademarks appearing above are registered trademarks of the respective company.**