Physical Material as Default
3ds Max 2021 defaults to using physical materials everywhere, even in places where standard materials were the norm before. The type of material used by default is in fact governed by the Market Default settings (accessible through the main menu Customize > Custom Defaults Switcher). All options that ship with 3ds Max 2021 in the Custom Default Switcher use the Physical Material, except the MAX.Legacy option, which when selected switches 3ds Max 2021 back to the same material and rendering settings as 3ds Max 2020 used. Please note that a 3rd party developer could install their own Market Default, as does VRay for example, and so a plugin should be prepared to handle any type of materials.
Important: Plugin developers and scripters should test that their code works as expected in 3ds Max 2021, both with Physical Material as default, and when using the MAX.Legacy option.
The following new APIs have been added to 3ds Max 2021 to support 3rd party plugin developers when they need to create material:
CoreExport Mtl* NewDefaultMaterial(const MCHAR *configkey = nullptr);
The NewDefaultMaterial()
API creates a new material instance based on the current Market Defaults. By default, 3ds Max uses physical material in all its market defaults, except when using the MAX.Legacy market default, or when a 3rd party has installed a custom market default and that is currently used.
Important: If you call this function, be prepared to handle any material being returned.
A plugin developer can ask that this API creates a standard material (type StdMat2
) by calling it with a configkey value equal to the name of a key set in 3dsmax.ini under the [LegacyMaterial]
section, and by setting that key to a value of 1. For example, if a 3rd party material plugin called "FooBar" would like to always populate its instance with StdMat2
sub-materials, it would set the key named "FooBar" under the [LegacyMaterial] section of 3dsmax.ini to 1, and then call NewDefaultMaterial(_M("FooBar"))
.
CoreExport Mtl* NewPhysicalMaterial(const MCHAR *configkey = nullptr, bool *legacy = nullptr);
The NewPhysicalMaterial()
API creates a new instance of the Physical Material, or a standard material (type StdMat2
) if called with a configkey that is the name of a key set in 3dsmax.ini under the [LegacyMaterial] section, and that key is set to 1. When you call this API, be prepared to handle either a physical material, or a standard material being returned. You can check the classid of the returned material, or attempt to dynamic_cast it to StdMat2
to verify its type.
CoreExport int GetPrimaryMapSlot(Mtl * mtl);
The GetPrimaryMapSlot()
API allows you to set the color texture of a material without having to know about the exact material type. It returns the main color map slot of the material passed as parameter, which in most cases (but not necessarily) is the "diffuse" slot.
Since the NewDefaultMaterial()
function can return any material, code that tries to set the color texture by calling mtl->SetSubTexmap(ID_DI, …. )
will be most likely wrong. The ID_DI macro applies for a standard material (type StdMat2
), but it is no longer guaranteed to be a relevant texture slot for another kind of material.
If the material derives from StdMat2
this function is equivalent to calling StdMat2::StdIDtoChannel(ID_DI)
. If not, a heuristic is used.