Since Max doesn’t have a human readable mat format, I made a MEL script that spits out a MaxScript to use in Max for any selected material. It was originally a Unix shell script I wrote and you can see the results here:
The newer code writes out to a text file and, on OS X the results are sent to the clipboard automatically (this isn’t doable on Windows, from what I can tell). The script doesn’t do subtextures, since that’s the easy part, with all the other stuff like subdivs and Fresnel, trace depth, etc. being taken care of by the script. The script is part of my V-Ray Tuner 2 script but here’s the code if you’d rather have it on it’s own:
http://www.creativecrash.com/maya/downloads/scripts-plugins/rendering/c/v-ray-tuner-for-maya
This is for V-Ray 1.5 materials but I’ll be doing another for V-Ray 2 format soon:
global proc vray15MatConverter()
{
string $mySelection[] = `ls -sl`;
float $myDiffuse[] = `getAttr ($mySelection[0] + ".diffuseColor")`;
float $myDiffuseMax[] = {($myDiffuse[0] * 255), ($myDiffuse[1] * 255), ($myDiffuse[2] * 255)};
float $myRoughness = `getAttr ($mySelection[0] + ".roughnessAmount")`;
float $myreflectionColor[] = `getAttr ($mySelection[0] + ".reflectionColor")`;
float $myreflectionColorMax[] = {($myreflectionColor[0] * 255), ($myreflectionColor[1] * 255), ($myreflectionColor[2] * 255)};
float $myfresnelIOR = `getAttr ($mySelection[0] + ".fresnelIOR")`;
float $myrefractionIOR = `getAttr ($mySelection[0] + ".refractionIOR")`;
float $myreflectionGlossiness = `getAttr ($mySelection[0] + ".reflectionGlossiness")`;
int $myreflectionSubdivs = `getAttr ($mySelection[0] + ".reflectionSubdivs")`;
int $myuseFresnel = `getAttr ($mySelection[0] + ".useFresnel")`;
string $booluseFresnel = ($myuseFresnel == 0) ? "false" : "true";
int $myreflectionsMaxDepth = `getAttr ($mySelection[0] + ".reflectionsMaxDepth")`;
float $myreflectionExitColor[] = `getAttr ($mySelection[0] + ".reflectionExitColor")`;
float $myreflectionExitColorMax[] = {($myreflectionExitColor[0] * 255), ($myreflectionExitColor[1] * 255), ($myreflectionExitColor[2] * 255)};
int $myreflInterpolation = `getAttr ($mySelection[0] + ".reflInterpolation")`;
string $boolmyreflInterpolation = ($myreflInterpolation == 0) ? "false" : "true";
int $myrefrInterpolation = `getAttr ($mySelection[0] + ".refrInterpolation")`;
string $boolmyrefrInterpolation = ($myrefrInterpolation == 0) ? "false" : "true";
int $myhilightGlossinessLock = `getAttr ($mySelection[0] + ".hilightGlossinessLock")`;
string $boolhilightGlossinessLock = ($myhilightGlossinessLock == 0) ? "false" : "true";
int $mylockFresnelIORToRefractionIOR = `getAttr ($mySelection[0] + ".lockFresnelIORToRefractionIOR")`;
string $boolmylockFresnelIORToRefractionIOR = ($mylockFresnelIORToRefractionIOR == 0) ? "false" : "true";
float $myrefractionColor[] = `getAttr ($mySelection[0] + ".refractionColor")`;
float $myrefractionColorMax[] = {($myrefractionColor[0] * 255), ($myrefractionColor[1] * 255), ($myrefractionColor[2] * 255)};
float $myrefractionGlossiness = `getAttr ($mySelection[0] + ".refractionGlossiness")`;
int $myrefractionSubdivs = `getAttr ($mySelection[0] + ".refractionSubdivs")`;
float $myfogColor[] = `getAttr ($mySelection[0] + ".fogColor")`;
float $myfogColorMax[] = {($myfogColor[0] * 255), ($myfogColor[1] * 255), ($myfogColor[2] * 255)};
float $myfogMult = `getAttr ($mySelection[0] + ".fogMult")`;
float $myfogBias = `getAttr ($mySelection[0] + ".fogBias")`;
int $myaffectShadows = `getAttr ($mySelection[0] + ".affectShadows")`;
string $boolmyaffectShadows = ($myaffectShadows == 0) ? "false" : "true";
int $myaffectAlpha = `getAttr ($mySelection[0] + ".affectAlpha")`;
string $boolmyaffectAlpha = ($myaffectAlpha == 0) ? "false" : "true";
int $myrefractionsMaxDepth = `getAttr ($mySelection[0] + ".refractionsMaxDepth")`;
float $myrefractionExitColor[] = `getAttr ($mySelection[0] + ".refractionExitColor")`;
float $myrefractionExitColorMax[] = {($myrefractionExitColor[0] * 255), ($myrefractionExitColor[1] * 255), ($myrefractionExitColor[2] * 255)};
int $myrefractionExitColorOn = `getAttr ($mySelection[0] + ".refractionExitColorOn")`;
string $boolmyrefractionExitColorOn = ($myrefractionExitColorOn == 0) ? "false" : "true";
float $myscatterCoeff = `getAttr ($mySelection[0] + ".scatterCoeff")`;
float $myscatterDir = `getAttr ($mySelection[0] + ".scatterDir")`;
float $mytranslucencyColor[] = `getAttr ($mySelection[0] + ".translucencyColor")`;
float $mytranslucencyColorMax[] = {($mytranslucencyColor[0] * 255), ($mytranslucencyColor[1] * 255), ($mytranslucencyColor[2] * 255)};
int $mybrdfType = `getAttr ($mySelection[0] + ".brdfType")`;
float $myanisotropy = `getAttr ($mySelection[0] + ".anisotropy")`;
float $myanisotropyRotation = `getAttr ($mySelection[0] + ".anisotropyRotation")`;
float $mysoftenEdge = `getAttr ($mySelection[0] + ".softenEdge")`;
int $mytraceReflections = `getAttr ($mySelection[0] + ".traceReflections")`;
string $boolmytraceReflections = ($mytraceReflections == 0) ? "false" : "true";
int $mytraceRefractions = `getAttr ($mySelection[0] + ".traceRefractions")`;
string $boolmytraceRefractions = ($mytraceRefractions == 0) ? "false" : "true";
int $myreflectOnBackSide = `getAttr ($mySelection[0] + ".reflectOnBackSide")`;
string $boolmyreflectOnBackSide = ($myreflectOnBackSide == 0) ? "false" : "true";
int $myuseIrradianceMap = `getAttr ($mySelection[0] + ".useIrradianceMap")`;
string $boolmyuseIrradianceMap = ($myuseIrradianceMap == 0) ? "false" : "true";
float $mybumpMult = `getAttr ($mySelection[0] + ".bumpMult")`;
string $maxScriptTemplate = "objs = selectByName title:\"Select the objects you want to create a VRay material for\"\n\
for obj in objs do \(\n\
newMat = VRayMtl\(\)\n\
newMat.diffuse = [" + $myDiffuseMax[0] + "," + $myDiffuseMax[1] + "," + $myDiffuseMax[2] + "]\n\
newMat.diffuse_roughness = " + $myRoughness + "\n\
newMat.reflection = [" + $myreflectionColorMax[0] + "," + $myreflectionColorMax[1] + "," + $myreflectionColorMax[2] + "]\n\
newMat.reflection_glossiness = " + $myreflectionGlossiness + "\n\
newMat.reflection_subdivs = " + $myreflectionSubdivs + "\n\
newMat.reflection_fresnel = " + $booluseFresnel + " \n\
newMat.reflection_maxDepth = " + $myreflectionsMaxDepth + "\n\
newMat.reflection_exitColor = [" + $myreflectionExitColorMax[0] + "," + $myreflectionExitColorMax[1] + "," + $myreflectionExitColorMax[2] + "]\n\
newMat.reflection_useInterpolation = " + $boolmyreflInterpolation + "\n\
newMat.reflection_lockGlossiness = " + $boolhilightGlossinessLock + "\n\
newMat.hilight_glossiness = " + $myreflectionGlossiness + "\n\
newMat.reflection_ior = " + $myfresnelIOR + "\n\
newMat.reflection_lockIOR = " + $boolmylockFresnelIORToRefractionIOR + "\n\
newMat.refraction = [" + $myrefractionColorMax[0] + "," + $myrefractionColorMax[1] + "," + $myrefractionColorMax[2] + "]\n\
newMat.refraction_glossiness = " + $myrefractionGlossiness + "\n\
newMat.refraction_subdivs = " + $myrefractionSubdivs + "\n\
newMat.refraction_ior = " + $myrefractionIOR + "\n\
newMat.refraction_fogColor = [" + $myfogColorMax[0] + "," + $myfogColorMax[1] + "," + $myfogColorMax[2] + "]\n\
newMat.refraction_fogMult = " + $myfogMult + "\n\
newMat.refraction_fogBias = " + $myfogBias + "\n\
newMat.refraction_affectShadows = " + $boolmyaffectShadows + "\n\
newMat.refraction_affectAlpha = " + $myaffectAlpha + "\n\
newMat.refraction_maxDepth = " + $myrefractionsMaxDepth + "\n\
newMat.refraction_exitColor = [" + $myrefractionExitColorMax[0] + "," + $myrefractionExitColorMax[1] + "," + $myrefractionExitColorMax[2] + "]\n\
newMat.refraction_useExitColor = " + $boolmyrefractionExitColorOn + "\n\
newMat.refraction_useInterpolation = " + $boolmyrefrInterpolation + "\n\
newMat.translucency_scatterCoeff = " + $myscatterCoeff + "\n\
newMat.translucency_fbCoeff = " + $myscatterDir + "\n\
newMat.translucency_color = [" + $mytranslucencyColorMax[0] + "," + $mytranslucencyColorMax[1] + "," + $mytranslucencyColorMax[2] + "]\n\
newMat.brdf_type = " + $mybrdfType + "\n\
newMat.anisotropy = " + $myanisotropy + "\n\
newMat.anisotropy_rotation = " + $myanisotropyRotation + "\n\
newMat.soften = " + $mysoftenEdge + "\n\
newMat.option_traceReflection = " + $boolmytraceReflections + "\n\
newMat.option_traceRefraction = " + $boolmytraceRefractions + "\n\
newMat.option_reflectOnBack = " + $boolmyreflectOnBackSide + "\n\
newMat.option_useIrradMap = " + $boolmyuseIrradianceMap + "\n\
newMat.texmap_bump_multiplier = " + $mybumpMult + "\n\
obj.material = newMat \n\
\)\n";
string $singleFilter = "All Files (*.*)";
string $result[] = `fileDialog2 -fileFilter $singleFilter -dialogStyle 2`;
$exampleFileName = $result[0];
$fileId=`fopen $exampleFileName "w"`;
fprint $fileId $maxScriptTemplate;
fclose $fileId;
if( `about -win`)
{
system $result[0];
}
else if ( `about -mac`)
{
system ("open -a /Applications/TextEdit.app " + $result[0]);
//Dave's personal setting
system ("cat " + $result[0] + " | pbcopy");
}
}