Material Variants now available in Unity 2022.1

Welcome to the Material Variants discussion thread. You can use this thread to ask for help, share feedback, and have discussions about this new feature available in Unity 2022.1.

We are super excited to introduce this new system (which has been requested for a long time and quite highly voted on our public roadmap!) to manage variants of materials at scale!

It allows for reuse and improve management of materials that share most surface properties and differ only through others (think “Prefabs for Materials”).

You can read more about it in our documentation and blog post.

Once you have tinkered with the system, please take 5 minutes to fill our poll that will help us validate the quality of our initial design.

Best,
The Unity Graphics Team

7 Likes

Really nice new feature!

I’m going to make full use of it, thanks!

( About the survey, sorry not doing those, as there is too much data mining questions that have nothing todo with the material variants, like the first questions about organisation etc. I may be wrong but I feel like if I don’t put there an organisation with millions of revenue my answers will not be valued the same )

3 Likes

Material variant increases the number of draw calls.
Property block has more efficiency?

Material variants are for workflow, not optimization.
Every variant is like separate material.

The system of material variants exists only in the editor for better workflow/QoL.
I believe in the background, for a built game, each “variant” is a new material.

It’s mentioned in the blog if you want more information.

a bit strange, so the script with c # and property block changing values gives me 1 material on many objects and the system written by unity gives only utility in the editor :frowning:

Is there any way I can batch-convert a series of existing materials to be children of another material that uses the same shader? I’d really like to use material variants on the project I’m working on right now but I have 200+ materials that I’d like to all be child materials of one master material. Would take quite some time to convert by hand :roll_eyes: Maybe there’s something I can add to the YAML to do this?

If serialization of material variants is as “brilliant” as serialization of prefab variants than I would not stick my fingers into it.

Material variants are great. Can we have ScriptableObject variants?

2 Likes

+1 for this. It would be incredibly useful.

Also +1 for replying my previous question about converting materials to variants, please?

This is fantastic! Anything that reduces data copying is a huge + for me. Scriptable Objects being next would definitely be great :wink:

@Matjio I started updating the Measured Materials Library (We have you covered with the Measured Materials Library | Unity Blog) a month ago for Unity 2019, 2020, 2021, 2022 and 2023. Since I am still working on the 2019 URP version I am glad I found this forum before I started on the other versions, which I will probably cancel now, as the variants solution is way better. Looking at the image you used at the start of the thread I am wondering if you are also updating (extending) the Measured Materials Library using material variants (which should make it a lot easier as you can just create the master materials and base variant of those)?

If not, do you mind if I would update it to a variants version and is there a way I can get the model that you are using in the example at the start of this thread? I am currently using the older Unity ball model for previews.

This feature seems to have broken the copying of Material properties from and to TextMeshPro materials and broken the Create Preset Material feature of TextMeshPro, too.

@ddreams_anne Sorry for the delay! I don’t know of any work planned on upgrading the measured materials to the variant system, which indeed would make sense.
The material ball is available on HDRP sample scene from the Hub.

Hey, can you explain how we can manage shader keywords with material variants?

I would like all children of a parent material to inherit the keywords of the parent.
Using ValidateMaterial works when the child is first loaded. However, after that point, changing keywords on the parent doesn’t change the children. ValidateMaterial is not called.

Here’s a simple script I’m using for my materials:

public class MyShaderGUI : ShaderGUI {

    public override void ValidateMaterial(Material material) {

        if (material.parent != null) {

            material.shaderKeywords = material.parent.shaderKeywords;
        }
    }
}

Is there some API to access the children of a material?
So that when ValidateMaterial is called on the parent, I can iterate over the children and apply the keywords there?