Notifications
Clear all

[Closed] How to get the diffuse value from Standard material using Maxplus?

 bpl

Hi guys!

Let’s say I’ve created a Box, created a Standard material, modified the diffuse rgb value and assigned that material to the box, ie:

Now, I’m trying to retrieve all the parameters from this material using maxplus with something like this:

n = MaxPlus.SelectionManager.GetNodes()[0]
mat = n.GetMaterial()
for p in mat.ParameterBlock:
    print(p.Name, p.Value)

which gives me (sorted by name):

(u'adTextureLock', True)
(u'ambientMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F780> >)
(u'ambientMapAmount', 100.0)
(u'ambientMapEnable', False)
(u'applyReflectionDimming', False)
(u'bumpMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049FC60> >)
(u'bumpMapAmount', 30.000001907348633)
(u'bumpMapEnable', False)
(u'diffuseMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F660> >)
(u'diffuseMapAmount', 100.0)
(u'diffuseMapEnable', False)
(u'dimLevel', 0.0)
(u'displacementMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F570> >)
(u'displacementMapAmount', 100.0)
(u'displacementMapEnable', False)
(u'faceMap', False)
(u'faceted', False)
(u'filterColor', <MaxPlus.Color; proxy of <Swig Object of type 'Autodesk::Max::Color *' at 0x000000005049F780> >)
(u'filterMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F660> >)
(u'filterMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049FC60> >)
(u'filterMapAmount', 100.0)
(u'filterMapEnable', False)
(u'glossinessMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F780> >)
(u'glossinessMapAmount', 100.0)
(u'glossinessMapEnable', False)
(u'ior', 1.5)
(u'mapAmounts', <MaxPlus.FloatList; proxy of <Swig Object of type 'Autodesk::Max::FloatList *' at 0x000000005049F660> >)
(u'mapEnables', <MaxPlus.BoolList; proxy of <Swig Object of type 'Autodesk::Max::PrimitiveList< bool > *' at 0x000000005049FC60> >)
(u'maps', <MaxPlus.TexmapList; proxy of <Swig Object of type 'Autodesk::Max::PointerList< Autodesk::Max::Texmap,::Texmap > *' at 0x000000005049F570> >)
(u'opacity', 100.0)
(u'opacityFallOff', 0.0)
(u'opacityFallOffType', 0)
(u'opacityMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F570> >)
(u'opacityMapAmount', 100.0)
(u'opacityMapEnable', False)
(u'opacityType', 0)
(u'reflectionLevel', 3.0)
(u'reflectionMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F660> >)
(u'reflectionMapAmount', 100.0)
(u'reflectionMapEnable', False)
(u'refractionMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F780> >)
(u'refractionMapAmount', 100.0)
(u'refractionMapEnable', False)
(u'sampler', 3)
(u'samplerAdaptOn', True)
(u'samplerAdaptThreshold', 0.10000000149011612)
(u'samplerAdvancedOptions', True)
(u'samplerByName', u'Max 2.5 Star')
(u'samplerEnable', False)
(u'samplerQuality', 0.5)
(u'samplerUseGlobal', True)
(u'selfIllumMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F570> >)
(u'selfIllumMapAmount', 100.0)
(u'selfIllumMapEnable', False)
(u'shaderByName', u'Blinn')
(u'shaderType', 1)
(u'specularLevelMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F660> >)
(u'specularLevelMapAmount', 100.0)
(u'specularLevelMapEnable', False)
(u'specularMap', <MaxPlus.Texmap; proxy of <Swig Object of type 'Autodesk::Max::Texmap *' at 0x000000005049F780> >)
(u'specularMapAmount', 100.0)
(u'specularMapEnable', False)
(u'subSampleTextureOn', True)
(u'twoSided', False)
(u'UserParam0', 0.0)
(u'UserParam1', 0.0)
(u'wire', False)
(u'wireSize', 1.0)
(u'wireUnits', 0)

My question is, why are not the RGB values listed there (ie: ambient, diffuse, specular, …)? For instance, how would I retrieve the diffuse value I’ve set to red using maxplus?

Thanks in advance

10 Replies
 bpl

I’ll self answer my own question here.

These material attributes don’t live in the ParameterBlock attribute, they were living in the Mtl class itself. For more info you can check the docs about Mtl.

 bpl

While I see there are methods such as:

GetAmbient
GetDiffuse
GetSelfIllum
GetSelfIllumColor
GetSelfIllumColorOn
GetShininess
GetShinyStrength
GetSoften
GetSpecular
GetSpecular

I don’t see the corresponding ones for the Specular Highlights group, ie:

Specular Level
Glossiness
Soften

any idea?

Standard Material and any Material has ReferenceTarget – BaseShader
#Ambient, #Diffuse, #Specular, and etc. are properties of BaseShader. So you have to get its ReferenceTarget and after that get its parameters

c# SDK has to have a method for material as GetShader()

and of course you can use methods those you showed above. I just tell where these properties are, and why you can’t find them in material’s param blocks

1 Reply
 bpl
(@bpl)
Joined: 1 year ago

Posts: 0

@denisT Thanks for your additional comments, I wasn’t aware about the BaseShader class, good to know.

I see your answer refers to c# SDK while I’m trying to retrieve the material information using python & MaxPlus module. I didn’t find any direct way to get attributes that are not listed in the ParameterBlock or Mtl instances so I guess I’ll have to resort to evaluate some maxscript code directly from python… although i always try to avoid maxscript evaluation from python side if it’s not strictly necessary

… are in the BaseShader as well

with MaxPlus you can get Reference by index I guess (GetReference()).
BaseShader is one of the references of Material

I can post a c++ code if it helps

1 Reply
(@denist)
Joined: 1 year ago

Posts: 0

I should be able to cast material to ReferenceMaker which has GetReference method. Afetr getting the right reference you can get its param blocks

(c++ code probably will confuse you. it’s very different what MaxPlus does do)

 bpl

Awesome, first time I hear about this concept of Reference … it seems Mtl is a ReferenceMaker subclass so you can indeed query their references like you suggested, ie:

for i in range(mat.GetNumRefs()):
    print(mat.GetReference(i).ParameterBlock)

The parameters coming from these material references can be added to the material ParameterBlock. That said, I’ve compared all properties (parameter from references + parameters from material) against the showproperties $.material and I still see there are some missing ones, for instance:

exposureControlInvertReflection
exposureControlInvertRefraction
exposureControlInvertSelfIllum
noExposureControl
subSampleTextureOn

Any idea about these last ones?

PS. About c++ code… i’ve coded in c++ for almost 20 years but as much as I love that language I don’t use it at all when it comes to code max plugins

the BaseShader has ExposureMaterialControl interface. these are properties of this interface

here is its id:

#define EXPOSURE_MATERIAL_CONTROL Interface_ID(0x153b0cbc, 0x5d6b0879)
 bpl

Thanks for the clarification! everything clear here already… By the way, it seems the framework used to make this forum is the same than Sublime Text. Although there is a subtle difference between Sublime’s forum and this one, in Sublime’s you can accept answers while here I don’t see such an option

Guess makes sense though so you keep conversations/topics open so new interesting content may emerge… Anyway, I see there are the like button, so let’s give some hearts then…