Maxscript check if a material has anything plugged into a node or not


I’m trying o figure out what’s the most reliable way to check if a certain material feature is used or not.

For example I want to know if a material is using Displacement. I tried mat.texmap_displacement_on but sometimes that seems to return true when the material doesn’t have anything plugged into displacement. Maybe the materials I have to work with are weird idk.

How can I just check in script if there is anything plugged into the Displacement node?
Thanks :blush:

PS: I don’t want to know if there is a -texture- plugged into Displacement, I want to know if -anything at all- is plugged into a material’s input node (in this case if anything is plugged into the displacement node).


if the slot value is undefined then there’s nothing plugged in
but you’ll have to figure out which material property corresponds which slot


but I am new to max & maxscript, and I don’t know how to find the slot via script, to check if it’s there or not. I googled for hours :blush:

I tried to just print out all properties of the material and the only thing that comes up is texmap_displacement_on (and I’m not even sure what that is referring to, is it the Displacement slot in my screenshot?):

local props = (for propName in getPropNames mat where matchPattern propName pattern:“disp” collect propName)
for prop in props do (
print ("mat prop with disp: "+prop)

Is there something I’m missing like a “getSlotNames”?


afaik, there’s no robust and easy way to map properties to slot names automatically
you can flush showProperties output to stringstream and try parse the needed data from there


Ok. But I’m just trying to find out a very very basic, simple thing. I just want to know if a material is using Displacement in any shape or form. (Or if a material is using Bump map in any shape or form, etc etc)

It would be ridiculous if maxscript didn’t have a way to check such a basic thing on a material, right?


sure, but you have to know the prop name first before the check
then you simply use GetProperty mtl prop_name == undefined to know if there’s anything there


Ah ok I see! But shouldn’t this be extremely well documented by now? I mean it’s the main standard material slots we’re talking about here.

Surely people should know, what the maxscript equivalent name for “Diffuse map” or “Bump map” or “Displacement” is, right? Is there docs on this anywhere?


maxscript has a pretty good docs in general, but I never stumbled on anything like that
I guess it is no big deal to map these props manually if we are talking about just one standardmaterial
just look into the listener (macro recoreder) output to know which prop corresponds the slot you need

oh, it seems I was wrong. You can iterate over all the submaps and check the slot value

-- getNumSubTexmaps meditMaterials[1] -- 24
getSubTexmapSlotName meditMaterials[1] 12 -- Displacement
getSubTexmap meditMaterials[1] 12 == undefined


I think this will do it! Thanks I would not have found the getSubTexmap commands. One thing I noticed is that for you it seems displacement is on index 12, for me it was on index 7. So I just did this for loop to first find displacement (or whatever I am looking for) and then proceed:

for i=1 to getNumSubTexmaps mat do (
local slotName = getSubTexmapSlotName mat i
if findString slotName “isplace” != undefined then(
if getSubTexmap mat i != undefined then(
print(“uses displacement”)