Нету большинства материалов Vray

Автор
Сообщение
На сайте c 05.05.2017
Сообщений: 3

Здраствуйте, есть проблема : при выборе в списке доступных материалов во вкладке Vray доступны только три материала, как видно на скриншоте. А где  vrayblendmtl и другие? Крякнут врей нормально, выбран рендерером. Вот зацепка: сразу после установки vray в 3ds max начинает постоянно выскакивать ошибка при запуске(второй скриншот) код ошибки выкладываю вконце

06ec77d36efbb2368bcbd144d4d15ce6.jpg

b4d63753bee276c2de7e05cbb46a18dc.jpg

include "$startupScripts\\vrayutils.ms"

-- You can call this on any built-in value that will properly convert to a string

-- without any extra work...like floats ints bools strings...

fn value_to_xml value container out = (

if container != undefined then(

format "<%><%></%>\n" container value container to:out

)else(

format "%" value to:out

)

)

fn value_to_xml_string value container  =(

    s = stringstream ""

    value_to_xml value container s

    return s as string

)

-- Generic parameter - all inputs are expected to be strings

--Makes parameter element of <parameters>..</parameters> section of xml

--paramType:- bool, integer, float, string, vector, acolor texture, float texture, color, list, componentTransform, transform, output vector texture, output float texture, output acolor texture, plugin

--paramValue:- if there is parameter value it's nested in <value>..</value> element

--out:- output stream(file)

--gammaCorrect:- true if exists such parameter attribute.  It is boolean flag tells us whether a given parameter needs gamma correction before being sent to V-Ray. 

--handler:- ComboBoxHandler, FileBrowserHandler, TextureTransformHandler, CheckBoxHandler, DoubleSpinBoxHandler, ColorTexFrameHandler, FloatTexFrameHandler, TextureHandler, LockButtonHandler, UVWHandler

--isUserData:-  true if exists such parameter attribute. This is helper param for the UI and will not be sent to V-Ray.

fn make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined=(

userDataString=""

gammaCorrectString=""

handlerName = handler

if gammaCorrect != undefined then(

gammaCorrectString = " gammaCorrect=\"1\""

)

if isUserData != undefined then(

userDataString=" isUserData=\"1\""

)

format "\t\t\t\t\t<parameter%% handler=\"%\" name=\"%\" type=\"%\">\n\t\t\t\t\t\t<value>%</value>\n\t\t\t\t\t</parameter>\n" userDataString gammaCorrectString handlerName paramName paramType paramValue  to:out

)

--Makes list parameter element of <parameters>..</parameters> section of xml

--listType:- it is the type of parameter stored in the list

--paramType:- bool, integer, float, string, vector, acolor texture, float texture, color, list, componentTransform, transform, output vector texture, output float texture, output acolor texture, plugin

--listOfValues:- container of values. Each value nested in <entry>..</entry> element compaund <list>..</list> element 

--out:- output stream(file)

--gammaCorrect:- true if exists such parameter attribute.  It is boolean flag tells us whether a given parameter needs gamma correction before being sent to V-Ray. 

--handler:- ComboBoxHandler, FileBrowserHandler, TextureTransformHandler, CheckBoxHandler, DoubleSpinBoxHandler, ColorTexFrameHandler, FloatTexFrameHandler, TextureHandler, LockButtonHandler, UVWHandler

--isUserData:-  true if exists such parameter attribute. This is helper param for the UI and will not be sent to V-Ray.

fn make_list_parameter_xml paramName listType paramType listOfValues out gammaCorrect:undefined handler:"default" isUserData:undefined=(

userDataString=""

gammaCorrectString=""

handlerName = handler

if gammaCorrect != undefined then(

gammaCorrectString = " gammaCorrect=\"1\""

)

if isUserData != undefined then(

userDataString=" isUserData=\"1\""

)

formatedentry = stringstream ""

entry = "\t\t\t\t\t\t\t\t<entry>%</entry>\n"

numOfValues = listOfValues.count

for i=1 to numOfValues - 1 do (

format entry listOfValues[i] to:formatedentry

)

entry = "\t\t\t\t\t\t\t\t<entry>%</entry>"

if numOfValues > 0 then (

format entry listOfValues[numOfValues] to:formatedentry

) else (

format entry "" to:formatedentry

)

paramValue = formatedentry as string

format "\t\t\t\t\t<parameter%% handler=\"%\" name=\"%\" listType=\"%\" type=\"%\">\n\t\t\t\t\t\t<value>\n\t\t\t\t\t\t\t<list>\n%\n\t\t\t\t\t\t\t</list>\n\t\t\t\t\t\t</value>\n\t\t\t\t\t</parameter>\n" userDataString gammaCorrectString handlerName paramName listType paramType paramValue  to:out

)

--The next four functions surve bool/color type parameter creation which need of additional work around convertion to string

fn boolToInteger paramVal = (

val = 0

    if paramVal != false then(

        val = 1

)

return val

)

fn make_bool_parameter_xml paramName paramVal out isUserData:undefined handler:"default"=(    

val = boolToInteger( paramVal )

return make_parameter_xml paramName "bool" (value_to_xml_string val undefined )  out isUserData:isUserData handler:handler

)

fn vraymax_color_to_xml_string val =(

s = stringstream ""

format "<r>%</r><g>%</g><b>%</b>" (val.r as float/255.0f) (val.g as float/255.0f) (val.b as float/255.0f) to:s

return s as string

)

fn vraymax_colorwithalpha_to_xml_string val =(

s = stringstream ""

format "<r>%</r><g>%</g><b>%</b><a>%</a>" (val.r as float/255.0f) (val.g as float/255.0f) (val.b as float/255.0f) (val.a as float/255.0f) to:s

return s as string

)

fn make_color_parameter_xml paramName val out gammaCorrect:undefined isUserData:undefined handler:"default" bAlpha:false=(

if bAlpha == true then (

make_parameter_xml paramName "color" (vraymax_colorwithalpha_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

) else (

make_parameter_xml paramName "color" (vraymax_color_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

fn make_acolortexture_parameter_xml paramName val out gammaCorrect:undefined isUserData:undefined handler:"default" bAlpha:false=(

if bAlpha == true then (

make_parameter_xml paramName "acolor texture" (vraymax_colorwithalpha_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler 

) else (

make_parameter_xml paramName "acolor texture" (vraymax_color_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

--Generally open_tag and close_tag methods are used for creating root nodes

fn open_tag tag out tabs:""=(

format "%<%>\n" tabs tag to:out

)

fn close_tag tag out tabs:""=(

format "%</%>\n" tabs tag  to:out

)

--begin_asset and end_asset are responsible for Asset element creation

--Assets mach  V-Ray plugins

--url: - a scene-unique string identifier for the asset

--pluginType: - generally the same as the underlying V-Ray Plugin's type. 

--pluginFamily: - usually it is the same as pluginType

--layout: -  this lets us know what user interface layout knows how to deal with this kind of asset

--out: - output file

fn begin_asset url pluginType pluginFamily layout out =(

format "\t<Asset url=\"%\" type=\"%\" layout=\"%\" renderer=\"vray\">\n\t\t<plugin>\n\t\t\t<vrayplugin name=\"%\" type=\"%\">\n\t\t\t\t<parameters>\n" url pluginFamily layout pluginType pluginFamily to:out

)

fn end_asset out =(

close_tag "parameters" out tabs:"\t\t\t\t"

close_tag "vrayplugin" out tabs:"\t\t\t"

close_tag "plugin" out tabs:"\t\t"

close_tag "Asset" out tabs:"\t"

)

--

listOfMAPCoordsStyles = #("Point3", "UV")

fn dumpComponentTransformParameterForMapCoords paramName map out=(

s= stringstream ""

local uvMap

if ((classof map) == VRayHDRI ) then uvMap = map.UVGen

else uvMap = map.coords

-- We don't fully support all the rotation, etc, in our material editor at this point. So I can set these values but they will not be editable.

-- At this time I am just bringing over values that will show up and be editable in our material editor.

format "\n" to:s

tabs ="\t\t\t\t\t\t\t\t"

format "\t\t\t\t\t\t\t<componentTransform>\n" to:s

format "%<x_rotation>%</x_rotation>\n"  tabs uvMap.u_angle to:s

format "%<y_rotation>%</y_rotation>\n"  tabs uvMap.v_angle to:s

local wRot = uvMap.w_angle

local sign = 1

if wRot < 0 then sign = -1

if abs(wRot) > 360 then (

wRot = abs(wRot) - 360

wRot = sign * wRot

)

if wRot > 0 then (

wRot = 360 - wRot

) else if wRot < 0 then (

wRot = -1 * wRot

)

format "%<z_rotation>%</z_rotation>\n"  tabs wRot to:s

format "%<x_offset>%</x_offset>\n" tabs uvMap.UVTransform[4][1] to:s

format "%<y_offset>%</y_offset>\n" tabs uvMap.UVTransform[4][2] to:s

format "%<z_offset>%</z_offset>\n"  tabs uvMap.UVTransform[4][3] to:s

--width = map.coords.realWorldWidth

--height = map.coords.realWorldHeight

--if not map.coords.realWorldScale then(

--width = 1.0 / width

--height = 1.0 / height

--)

format "%<x_scale>%</x_scale>\n" tabs uvMap.U_Tiling to:s

format "%<y_scale>%</y_scale>\n" tabs uvMap.V_Tiling to:s

format "%<z_scale>1</z_scale>\n"  tabs to:s

format "%<x_mirror>%</x_mirror>\n" tabs (boolToInteger uvMap.u_mirror ) to:s

format "%<y_mirror>%</y_mirror>\n" tabs (boolToInteger uvMap.v_mirror ) to:s

format "%<z_mirror>0</z_mirror>\n"  tabs to:s

format "\t\t\t\t\t\t\t</componentTransform>\n" to:s

format "\t\t\t\t\t\t" to:s

make_parameter_xml paramName "componentTransform" (s as string) out handler:"TextureTransformHandler"

)

fn dumpComponentTransformParameterForPoint3MapCoords paramName map out=(

s= stringstream ""

local uvMap

if ((classof map) == VRayHDRI ) then uvMap = map.UVGen

else uvMap = map.coords

-- We don't fully support all the rotation, etc, in our material editor at this point. So I can set these values but they will not be editable.

-- At this time I am just bringing over values that will show up and be editable in our material editor.

format "\n" to:s

tabs ="\t\t\t\t\t\t\t\t"

format "\t\t\t\t\t\t\t<componentTransform>\n" to:s

format "%<x_rotation>%</x_rotation>\n"  tabs uvMap.angle.x to:s

format "%<y_rotation>%</y_rotation>\n"  tabs uvMap.angle.y to:s

format "%<z_rotation>%</z_rotation>\n"  tabs uvMap.angle.z to:s

format "%<x_offset>%</x_offset>\n" tabs uvMap.offset.x to:s

format "%<y_offset>%</y_offset>\n" tabs uvMap.offset.y to:s

format "%<z_offset>%</z_offset>\n"  tabs uvMap.offset.z to:s

format "%<x_scale>%</x_scale>\n" tabs uvMap.tiling.x to:s

format "%<y_scale>%</y_scale>\n" tabs uvMap.tiling.y to:s

format "%<z_scale>%</z_scale>\n"  tabs uvMap.tiling.z to:s

format "%<x_mirror>0</x_mirror>\n" tabs to:s

format "%<y_mirror>0</y_mirror>\n" tabs to:s

format "%<z_mirror>0</z_mirror>\n"  tabs to:s

format "\t\t\t\t\t\t\t</componentTransform>\n" to:s

format "\t\t\t\t\t\t" to:s

make_parameter_xml paramName "componentTransform" (s as string) out handler:"TextureTransformHandler"

)

-- If you want to manually specify the url you can but be careful that it is unique for the vismat you are exporting.

fn dumpUVWGenChannelForMap parentURL map style out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenChannel"

)

local uvMap

if ((classof map) == VRayHDRI ) then uvMap = map.UVGen

else uvMap = map.coords

begin_asset uvwURL "UVWGenChannel" "UVW" "" out 

make_parameter_xml "uvw_channel" "integer" (uvMap.mapChannel as string) out 

if style == listOfMAPCoordsStyles[1] then(

dumpComponentTransformParameterForPoint3MapCoords "uvw_transform" map out

)

else(

if (uvMap.U_Tile) then (

make_parameter_xml "wrap_u" "integer" (1 as string) out

make_parameter_xml "crop_u" "integer" (0 as string) out

) else (

make_parameter_xml "wrap_u" "integer" (0 as string) out

make_parameter_xml "crop_u" "integer" (1 as string) out

)

if (uvMap.V_Tile) then (

make_parameter_xml "wrap_v" "integer" (1 as string) out

make_parameter_xml "crop_v" "integer" (0 as string) out

) else (

make_parameter_xml "wrap_v" "integer" (0 as string) out

make_parameter_xml "crop_v" "integer" (1 as string) out

)

make_parameter_xml "wrap_mode" "integer" (1 as string) out

dumpComponentTransformParameterForMapCoords "uvw_transform" map out

)

end_asset out  

return uvwURL

)

fn dumpUVWGenObjectForMap parentURL map style out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenObject"

)

begin_asset uvwURL "UVWGenObject" "UVW" "" out 

make_parameter_xml "duvw_scale" "float" (1.0 as string) out 

if style == listOfMAPCoordsStyles[1] then(

dumpComponentTransformParameterForPoint3MapCoords "uvw_transform" map out

)

else(

dumpComponentTransformParameterForMapCoords "uvw_transform" map out

)

end_asset out  

return uvwURL

)

fn dumpUVWGenChannel parentURL map_channel out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenChannel"

)

begin_asset uvwURL "UVWGenChannel" "UVW" "" out 

make_parameter_xml "uvw_channel" "integer" (map_channel as string) out 

end_asset out  

return uvwURL

)

fn dumpUVWGenObjectScale parentURL map_scale out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenObject"

)

begin_asset uvwURL "UVWGenObject" "UVW" "" out 

make_parameter_xml "duvw_scale" "float" (map_scale as string) out 

end_asset out  

return uvwURL

)

fn dumpBitmapBuffer parentURL map out =(

bitmapURL = parentURL +"/BitmapBuffer"

begin_asset bitmapURL "BitmapBuffer" "bitmap" "" out 

resolvedPath = filenamefrompath map.fileName

--print "dumpBitmapBuffer------------------------------------->"

--print "saveDirForBMPFiles:"

--print saveDirForBMPFiles

--if saveDirForBMPFiles != undefined then(

--resolvedPath = saveDirForBMPFiles + "\\" + resolvedPath

--)

gammaval = vrayGetBitmapGamma map

make_parameter_xml "file" "string" resolvedPath out handler:"FileBrowserHandler"

-- The bitmap buffer filter type is in a different order than listed in the 3dsmax ui. It goes "No Filter", "Pyramid", "Summed area"

bitmap_buffer_filter_remap= #( 1, 2, 0 )

-- The +1 is to account for 3dsmax 1-based array index math

make_parameter_xml "filter_type" "integer"  bitmap_buffer_filter_remap[map.filtering+1] out handler:"ComboBoxHandler"

make_parameter_xml "filter_blur" "float"  map.coords.blur out

make_parameter_xml "color_space" "integer" 1 out

if (gammaval != undefined) then (

make_parameter_xml "gamma" "float"  (1.0/gammaval) out

)

end_asset out 

return bitmapURL

)

fn dumpTexCombineColor url colorVal texUrl texMult texOn out isColor:true=(

begin_asset url "TexCombineColor" "texture" "" out

if isColor then(

make_color_parameter_xml "color" colorVal out

)else(

colorVal = colorVal * 255

floatColor = Color colorVal colorVal colorVal

make_color_parameter_xml "color" floatColor out

)

if (texUrl != undefined) and (texOn) then(

make_parameter_xml "texture" "acolor texture" texUrl out

)else(

make_parameter_xml "texture" "acolor texture" "" out

)

make_parameter_xml "texture_multiplier" "float" texMult out

end_asset out

)

fn dumpTexVRayHDRI=undefined

fn dumpTexMulti=undefined

fn dumpTexFalloff=undefined

fn dumpTexChecker=undefined

arrBitMapTxtPaths = #()

listNormalBumpFeatures = #()

--saveDirForBMPFiles = undefined

-- Right now we are only going to be handling basic bitmaps

-- parentURL is the url of our parent

-- mapUse is a string to help us come up with unique urls...an example would be passing "Diffuse" if this was a diffuse map or "Reflection" if this was a map being used for reflection

fn dumpMap map parentURL mapUse out =(

if map == undefined then(

return undefined

)

--clOfMAP = classof map

--clOf = classof clOfMAP

--print "dumpMap----classof map METHOD:"

--print clOfMAP

--print clOf

mapUrl = parentURL + "/Texture"

case (classof map) of (

Bitmaptexture:(

--resolvedPath = filenamefrompath map.fileName

--filename = resolvedPath

--FileResolutionManager.getFullFilePath &resolvedPath #Bitmap

resolvedPath = mapPaths.getFullFilePath map.fileName

--print "Source path for bitmap file:"

--print resolvedPath

if resolvedPath != "" then (

appendIfUnique arrBitMapTxtPaths resolvedPath

)

else (

print "WARNING!"

format "Unresolved path for %\n" map.fileName

)

--print filename

dumpTexBitmap mapUrl map out

)

Speckle:(

dumpTexSpeckle mapUrl map out

)

Bricks:(

dumpTexTiles mapUrl map out

)

Mix:(

dumpTexMix mapUrl map out

)

Noise:(

dumpTexNoiseMax mapUrl map out

)

Cellular:(

dumpTexCellular mapUrl map out

)

VRayCompTex:(

dumpTexCompMax mapUrl map out

)

Color_Correction:(

dumpTexColorCorrection mapUrl map out

)

VRayMultiSubTex:(

dumpTexMulti mapUrl map out

)

VRayNormalMap:(

dumpMap map.normal_map parentURL mapUse out

)

Normal_Bump:(

listNormalBumpFeatures = #(map.normal_map,map.map1on,map.mult_spin,map.method)

)

Checker:(

dumpTexChecker mapUrl map out

)

Falloff:(

dumpTexFalloff mapUrl map out

)

VRayHDRI:(

resolvedHDRIPath = mapPaths.getFullFilePath map.HDRIMapName

if resolvedHDRIPath != "" then (

appendIfUnique arrBitMapTxtPaths resolvedHDRIPath

)

else (

print "WARNING!"

format "Unresolved path for %\n" map.HDRIMapName

)

dumpTexVRayHDRI mapUrl map out

)

default:(

format "Map of type %: " (classof map)

format "Unknown map - skipped\n"

)

)

)

-- url will be used as the TexBitmap url we don't build  url because this gets done in dumpMap 

fn dumpTexBitmap url map out =(

uvwURL = ""

if map.coords.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.coords.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

bitmapURL = dumpBitmapBuffer url map out 

begin_asset url "TexBitmap" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

make_parameter_xml "bitmap" "plugin" bitmapURL out 

-- Placement type in TexBitmap has 3 options, "Whole texture", "Crop", and "Place". I am not sure how "Whole texture" is possible in 3dsmax

-- so this will actually only allow "crop" or "place". We add 1 to bypass "Whole texture", map.cropPlace 0 for crop, 1 for place

make_parameter_xml "placement_type" "integer" (map.cropPlace + 1) out handler:"ComboBoxHandler"

if map.apply then (

make_parameter_xml "u" "float" map.clipu out

make_parameter_xml "v" "float" map.clipv out

make_parameter_xml "w" "float" map.clipw out

make_parameter_xml "h" "float" map.cliph out

if map.cropPlace == 1 and map.useJitter then (

make_parameter_xml "jitter" "float" map.jitter out

)

)

if map.coords.Noise_On then (

make_bool_parameter_xml "uv_noise_on" map.coords.Noise_On out

make_bool_parameter_xml "uv_noise_animate" map.coords.Noise_Animate out

make_parameter_xml "uv_noise_amount" "float" map.coords.Noise_Amount out

make_parameter_xml "uv_noise_levels" "float" map.coords.Noise_Levels out

make_parameter_xml "uv_noise_size" "float" map.coords.Noise_Size out

make_parameter_xml "un_noise_phase" "float" map.coords.phase out

)

make_parameter_xml "alpha_from_intensity" "integer" map.alphaSource out

make_acolortexture_parameter_xml "nouvw_color" (Color 0 0 0 0) out bAlpha:true

end_asset out 

)

fn dumpTexSpeckle url map out =(

uvwURL = ""

if map.coords.coordType == 2 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[1] out

)

else if map.coords.coordType == 0 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[1] out

)

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map.map1 != undefined then(

--print "dumpTexSpeckle"

--print map.map1

texUrl1 = finalUrl1 + "/Texture"

dumpMap map.map1 finalUrl1 "color1" out

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map.map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map.map2 finalUrl1 "color2" out

)

dumpTexCombineColor finalUrl1 map.color1 texUrl1 1.0 map.map1On out

dumpTexCombineColor finalUrl2 map.color2 texUrl2 1.0 map.map2On out

begin_asset url "TexSpeckle" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

make_parameter_xml "size" "float" map.size out

make_parameter_xml "color1" "acolor texture" finalUrl1 out

make_parameter_xml "color2" "acolor texture" finalUrl2 out

end_asset out 

)

fn dumpTexTiles url map out =(

uvwURL = ""

if map.coords.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.coords.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

mapMortar = map.Mortar_Map

mapTiles = map.Bricks

finalUrl1 = url + "/color_mortar"

texUrl1 = undefined

if mapMortar != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap mapMortar finalUrl1 "color_mortar" out 

)

finalUrl2 = url + "/color_tiles"

texUrl2 = undefined

if mapTiles != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap mapTiles finalUrl2 "color_tiles" out 

)

--dumpTexCombineColor url colorVal texUrl texMult texOn out isColor:true

mortarColor = map.Mortar_Color

tilesColor = map.Brick_Color

dumpTexCombineColor finalUrl1 mortarColor texUrl1 1.0 true out

dumpTexCombineColor finalUrl2 tilesColor texUrl2 1.0 true out

begin_asset url "TexTiles" "texture" "" out 

make_parameter_xml "texture_multiplier_mode" "integer" "1" out handler:"ComboBoxHandler" isUserData:true

make_parameter_xml "uvwgen" "plugin" uvwURL out 

--dumpTextureParamsListVals parentURL baseParamName out listOfVals isColor:true shouldGammaCorrect:false

dumpTextureParamsListVals url "color_mortar" out #(mortarColor, mapMortar, 1.0, true) isColor:true

dumpTextureParamsListVals url "color_tiles" out #(tilesColor, mapTiles, 1.0, true) isColor:true

make_parameter_xml "horizontal_count" "float" map.Horizontal_Count out

make_parameter_xml "vertical_count" "float" map.Vertical_Count out

make_parameter_xml "color_variance" "float" map.Color_Variance out

make_parameter_xml "fade_variance" "float" map.Fade_Variance out

make_parameter_xml "horizontal_gap" "float" map.Horizontal_Gap out

make_parameter_xml "vertical_gap" "float" map.Vertical_Gap out

make_parameter_xml "holes" "integer" map.Holes out

make_parameter_xml "edge_roughness" "float" map.Edge_Roughness out

make_parameter_xml "random_seed" "integer" map.Random_Seed out

make_parameter_xml "line_shift" "float" map.Line_Shift out

make_parameter_xml "random_shift" "float" map.Random_Shift out

make_parameter_xml "row_modify" "bool" map.Use_Row_Edit out

make_parameter_xml "per_row" "integer" map.Per_Row out

make_parameter_xml "row_change" "float" map.Change_Row out

make_parameter_xml "column_modify" "bool" map.Use_Column_Edit out

make_parameter_xml "per_column" "integer" map.Per_Column out

make_parameter_xml "column_change" "float" map.Change_Column out

end_asset out 

)

fn dumpTexMix url map out =(

map1 = map.map1

map2 = map.map2

mixMap = map.mask

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "color1" out 

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "color2" out 

)

finalUrl3 = url + "/mix_map"

texUrl3 = ""

if mixMap != undefined then(

texUrl3 = finalUrl3 + "/Texture"

dumpMap mixMap finalUrl3 "mix_map" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

mixColor = ( Color 0.5 0.5 0.5 )

map1On = map.map1Enabled

map2On = map.map2Enabled

mixOn = map.maskEnabled

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 1.0 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 1.0 map2On out

dumpTexCombineColor finalUrl3 mixColor texUrl3 1.0 mixOn out

begin_asset url "TexMix" "texture" "" out

dumpTextureParamsListVals url "color1" out #(mapColor1, map1, 1.0, map1On) isColor:true

dumpTextureParamsListVals url "color2" out #(mapColor2, map2, 1.0, map2On) isColor:true

dumpTextureParamsListVals url "mix_map" out #(mixColor, mixMap, 1.0, mixOn) isColor:true

make_parameter_xml "mix_amount" "float" ( map.mixAmount as float/100.0 ) out

useCurveVal =  boolToInteger(map.useCurve)

make_parameter_xml "use_curve" "integer" useCurveVal out

make_parameter_xml "transition_lower" "float" map.lower out

make_parameter_xml "transition_upper" "float" map.upper out

end_asset out 

)

fn dumpTexNoiseMax url map out =(

--uvwURL = dumpUVWGenChannel url map.coords.mapChannel out

uvwURL = ""

if map.coords.coordType == 2 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[1] out

)

else if map.coords.coordType == 0 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[1] out

)

map1 = map.map1

map2 = map.map2

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "color1" out 

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "color2" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

map1On = map.map1Enabled

map2On = map.map2Enabled

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 1.0 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 1.0 map2On out

begin_asset url "TexNoiseMax" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

dumpTextureParamsListVals url "color1" out #(mapColor1, map1, 1.0, map1On) isColor:true

dumpTextureParamsListVals url "color2" out #(mapColor2, map2, 1.0, map2On) isColor:true

make_parameter_xml "size" "float" map.size out

make_parameter_xml "phase" "float" map.phase out

make_parameter_xml "iterations" "float" map.levels out

make_parameter_xml "low" "float" map.thresholdLow out

make_parameter_xml "high" "float" map.thresholdHigh out

make_parameter_xml "type" "integer" map.type out

end_asset out 

)

fn dumpTexFalloff url map out =(

map1 = map.map1

map2 = map.map2

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "color1" out 

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "color2" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

mapMult1 = map.map1Amount as float/100.0

mapMult2 = map.map2Amount as float/100.0

map1On = map.map1On

map2On = map.map2On

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 mapMult1 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 mapMult2 map2On out

begin_asset url "TexFalloff" "texture" "" out

dumpTextureParamsListVals url "color1" out #(mapColor1, map1, mapMult1, map1On) isColor:true

dumpTextureParamsListVals url "color2" out #(mapColor2, map2, mapMult2, map2On) isColor:true

make_parameter_xml "type" "integer" map.type out

if map.direction == 4 then (

make_parameter_xml "direction_type" "integer" 3 out

)

else if map.direction == 3 then (

make_parameter_xml "direction_type" "integer" 4 out

)

else (

make_parameter_xml "direction_type" "integer" map.direction out

)

make_parameter_xml "fresnel_ior" "float" map.ior out

make_bool_parameter_xml "dist_extrapolate" map.extrapolateOn out

make_parameter_xml "dist_near" "float" map.nearDistance out

make_parameter_xml "dist_far" "float" map.farDistance out

end_asset out 

)

fn dumpTexChecker url map out =(

if map.coords.mappingType > 0 then return undefined

uvwURL = ""

if map.coords.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.coords.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

map1 = map.map1

map2 = map.map2

finalUrl1 = url + "/black_color"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "black_color" out 

)

finalUrl2 = url + "/white_color"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "white_color" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

map1On = map.map1Enabled

map2On = map.map2Enabled

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 1.0 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 1.0 map2On out

begin_asset url "TexChecker" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

dumpTextureParamsListVals url "white_color" out #(mapColor2, map2, 1.0, map2On) isColor:true

dumpTextureParamsListVals url "black_color" out  #(mapColor1, map1, 1.0, map1On) isColor:true

make_parameter_xml "uv_noise_on" "integer" (boolToInteger map.coords.Noise_On) out

make_parameter_xml "uv_noise_amount" "float" map.coords.Noise_Amount out

make_parameter_xml "uv_noise_levels" "float" map.coords.Noise_Levels out

make_parameter_xml "uv_noise_size" "float" map.coords.Noise_Size out

make_parameter_xml "un_noise_phase" "float" map.coords.phase out

end_asset out 

)

fn dumpTexCellular url map out =(

uvwURL = ""

if map.coords.coordType == 2 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[1] out

)

else if map.coords.coordType == 0 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[1] out

)

mapCell = map.cellMap

mapDiv1 = map.divMap1

mapDiv2 = map.divMap2

finalUrl1 = url + "/center_color"

texUrl1 = ""

if mapCell != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap mapCell finalUrl1 "center_color" out 

)

finalUrl2 = url + "/edge_color"

texUrl2 = ""

if mapDiv1 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap mapDiv1 finalUrl2 "edge_color" out 

)

finalUrl3 = url + "/bg_color"

texUrl3 = ""

if mapDiv2 != undefined then(

texUrl3 = finalUrl3 + "/Texture"

dumpMap mapDiv2 finalUrl3 "bg_color" out 

)

mapCellColor = map.cellColor

mapDiv1Color = map.divColor1

mapDiv2Color = map.divColor2

mapCellOn = map.map1Enabled

mapDiv1On = map.map2Enabled

mapDiv2On = map.map3Enabled

dumpTexCombineColor finalUrl1 mapCellColor texUrl1 1.0 mapCellOn out

dumpTexCombineColor finalUrl2 mapDiv1Color texUrl2 1.0 mapDiv1On out

dumpTexCombineColor finalUrl3 mapDiv2Color texUrl3 1.0 mapDiv2On out

begin_asset url "TexCellular" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

dumpTextureParamsListVals url "center_color" out #(mapCellColor, mapCell, 1.0, mapCellOn) isColor:true

dumpTextureParamsListVals url "edge_color" out #(mapDiv1Color, mapDiv1, 1.0, mapDiv1On) isColor:true

dumpTextureParamsListVals url "bg_color" out #(mapDiv2Color, mapDiv2, 1.0, mapDiv2On) isColor:true

make_parameter_xml "size" "float" map.size out

make_parameter_xml "spread" "float" map.spread out

make_parameter_xml "type" "integer" map.type out

make_bool_parameter_xml "fractal" map.fractal out

make_parameter_xml "fractal_iterations" "float" map.iteration out

make_parameter_xml "fractal_roughness" "float" map.roughness out

make_parameter_xml "low" "float" map.lowThresh out

make_parameter_xml "middle" "float" map.midThresh out

make_parameter_xml "high" "float" map.highThresh out

end_asset out 

)

fn dumpTexCompMax url map out =(

mapSourceA = map.sourceA

mapSourceB = map.sourceB

finalUrl1 = url + "/sourceA"

texUrl1 = ""

if mapSourceA != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap mapSourceA finalUrl1 "sourceA" out 

)

finalUrl2 = url + "/sourceB"

texUrl2 = ""

if mapSourceB != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap mapSourceB finalUrl2 "sourceB" out 

)

begin_asset url "TexCompMax" "texture" "" out

make_parameter_xml "sourceA" "acolor texture" texUrl1 out handler:"TextureHandler"

make_parameter_xml "sourceB" "acolor texture" texUrl2 out handler:"TextureHandler"

make_parameter_xml "operator" "integer" map.operator out

end_asset out

)

fn dumpTexColorCorrection url map out =(

colcormap = map.map

finalUrl = url + "/texture_map"

texUrl = ""

if colcormap != undefined then(

texUrl = finalUrl + "/Texture"

dumpMap colcormap finalUrl "texture_map" out 

)

begin_asset url "ColorCorrection" "texture" "" out

make_parameter_xml "texture_map" "acolor texture" texUrl out handler:"TextureHandler"

make_color_parameter_xml "source_color" map.color out gammaCorrect:false

make_parameter_xml "rewire_red" "integer" map.rewireR out

make_parameter_xml "rewire_green" "integer" map.rewireG out

make_parameter_xml "rewire_blue" "integer" map.rewireB out

make_parameter_xml "rewire_alpha" "integer" map.rewireA out

make_parameter_xml "hue_shift" "float" map.hueShift out

make_parameter_xml "saturation" "float" map.saturation out

make_color_parameter_xml "hue_tint" map.tint out gammaCorrect:false

make_parameter_xml "tint_strength" "float" map.tintStrength out

make_parameter_xml "brightness" "float" map.brightness out

make_parameter_xml "contrast" "float" map.contrast out

make_parameter_xml "lightness_mode" "integer" map.lightnessMode out

end_asset out 

)

fn dumpTexAColorFromColor url inColor out=(

begin_asset url "TexAColor" "texture" "" out

make_parameter_xml "texture" "acolor texture" (vraymax_color_to_xml_string inColor) out handler:"ColorPickerHandler"

end_asset out 

)

fn dumpTexMulti url map out =(

mapDefault = map.default_texmap

finalUrl = url + "/default_texture"

texUrl = ""

if mapDefault != undefined then(

texUrl = finalUrl + "/Texture"

dumpMap mapDefault finalUrl "default_texture" out 

)

local listOfTexMaps = map.texmap

local finalURLList = #()

local texURLList = #()

local entry = "multitex%"

s= stringstream ""

for i=1 to listOfTexMaps.count do (

format entry map.texmap_id[i] to:s

ifinalUrl = url + "/" + (s as string)

itexUrl = ""

if listOfTexMaps[i] != undefined then(

itexUrl = ifinalUrl + "/Texture"

dumpMap listOfTexMaps[i] ifinalUrl (s as string) out 

)

append finalURLList ifinalUrl

append texURLList itexUrl

free s

)

mapDefaultColor = map.default_color

mapDefaultMult = map.default_texmap_mult / 100.0f

mapDefaultOn = map.default_texmap_on

dumpTexCombineColor finalUrl mapDefaultColor texUrl mapDefaultMult mapDefaultOn out

for i=1 to listOfTexMaps.count do (

dumpTexCombineColor finalURLList[i] map.texmap_color[i] texURLList[i] (map.texmap_mult[i] / 100.0f) map.texmap_mapOn[i] out

)

begin_asset url "TexMulti" "texture" "" out

make_parameter_xml "mode" "integer" map.fro-m_id out

dumpTextureParamsListVals url "default_texture" out #(mapDefaultColor, mapDefault, mapDefaultMult, mapDefaultOn) isColor:true

make_list_parameter_xml "ids_list" "integer" "list" map.texmap_id out

make_list_parameter_xml "textures_list" "plugin" "list" finalURLList out

end_asset out 

)

fn dumpTexVRayHDRI url map out =(

uvwURL = ""

if map.UVGen.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.UVGen.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

--dump BitmapBuffer

local bitmapURL = url +"/TexBitmap/BitmapBuffer"

begin_asset bitmapURL "BitmapBuffer" "bitmap" "" out 

resolvedPath = filenamefrompath map.HDRIMapName

make_parameter_xml "file" "string" resolvedPath out handler:"FileBrowserHandler"

-- The bitmap buffer filter type is in a different order than listed in the 3dsmax ui. It goes "No Filter", "Pyramid", "Summed area"

--bitmap_buffer_filter_remap= #( 1, 2, 0 )

-- The +1 is to account for 3dsmax 1-based array index math

make_parameter_xml "filter_type" "integer"  1 out handler:"ComboBoxHandler"

make_parameter_xml "filter_blur" "float"  map.UVGen.blur out

make_parameter_xml "color_space" "integer" 0 out

make_parameter_xml "gamma" "float"  1.0 out

end_asset out 

local multiplier = map.multiplier * map.renderMultiplier

local colorspace = map.color_space

local custgamma = 1.0

if colorspace == 3 then (

local filetype = getFilenameType map.HDRIMapName

if toLower(filetype) ==  ".exr" then (

colorspace = 0

custgamma = 1.0

) else (

colorSpace=1;

custgamma = vrayGetBitmapGamma map

if (gammaval != undefined) then (

custgamma = 1.0 / custgamma

) else (

custgamma = 1.0

)

)

)

if colorspace == 1 then (

custgamma = map.gamma

)

--If we have any modifications to the color space or the gamma, apply a TexMaxGamma

local texMaxGammaCreate = (colorspace!=0 or abs(custgamma-1.0)>1e-6 or abs(multiplier-1.0)>1e-6)

local texBitmapURL = url

if texMaxGammaCreate then texBitmapURL = url +"/TexBitmap"

begin_asset texBitmapURL "TexBitmap" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

make_parameter_xml "bitmap" "plugin" bitmapURL out 

-- Placement type in TexBitmap has 3 options, "Whole texture", "Crop", and "Place". I am not sure how "Whole texture" is possible in 3dsmax

-- so this will actually only allow "crop" or "place". We add 1 to bypass "Whole texture", map.cropPlace 0 for crop, 1 for place

local mapCropPlace = 0

if map.cropplace_on then (

case cropplace_mode of (

0: (

mapCropPlace = 1

)

1: (

mapCropPlace = 2

)

)

)

make_parameter_xml "placement_type" "integer" mapCropPlace out handler:"ComboBoxHandler"

make_parameter_xml "alpha_from_intensity" "integer" map.alphaSource out

make_acolortexture_parameter_xml "nouvw_color" (Color 0 0 0 0) out bAlpha:true

end_asset out

if texMaxGammaCreate then (

begin_asset url "TexMaxGamma" "texture" "" out

make_parameter_xml "input" "acolor texture" texBitmapURL out handler:"TextureHandler"

make_parameter_xml "multiplier" "float"  map.multiplier out

make_parameter_xml "color_space" "integer"  colorspace out

make_parameter_xml "gamma" "float"  custgamma out

end_asset out

)

)

fn getParamType param =(

case( classof param) of (

Color:(

return "color"

)

worldUnits:(

return "float"

)

Float:(

return "float"

)

BooleanClass:(

return "bool"

)

integer:(

return "integer"

)

default:(

return "plugin"

)

)

)

-- If you need to manually specify the type you can pass in the V-Ray parameter type otherwise we'll just try to get it from the classof param

fn dumpParam param paramName out paramType:undefined paramValue:undefined gammaCorrect:undefined isUserData:undefined handler:"default"= (

if param == undefined  then

return undefined

paramType = paramType

if paramType == undefined then(

paramType = getParamType param 

)

case( paramType ) of(

"color":(

make_color_parameter_xml paramName param out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

"plugin":(

-- to make this a bit easier I'm going to make sure I pass the url 

if paramValue != undefined then(

make_parameter_xml paramName "plugin" paramValue out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

"bool":(

-- bools don't go into integers without a bit of coercion.

make_bool_parameter_xml paramName param out isUserData:isUserData handler:handler

)

default:(

-- most of our types can just be made generically in their string form

make_parameter_xml paramName paramType (param as string) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

)

-- Some of our color/tex param names don't follow the same protocol so we need to account for them if we want this automated

-- I couldn't see a way to make a lookup table, so I am just using 2 arrays and making sure I place the related names at the same index in each

param_lookup=#("roughness", "hilightGlossiness", "reflectionGlossiness", "reflectionIOR", "refractionGlossiness", "refractionIOR", "translucent", "translucency")

color_lookup=#("diffuse_roughness", "hilight_glossiness", "reflection_glossiness", "reflection_ior", "refraction_glossiness", "refraction_ior", "translucency_color", "translucency")

vraymtl_params = getPropNames(VRayMtl)

vray2sidedmtl_params = getPropNames(VRay2SidedMtl)

-- Some helpers that exist in our userdata params for BRDFVRayMtl do not actually exist as 3dsmax params, so we need to set defaults or our TexCombineColor 

-- may not get setup properly

-- although the name is "color", in the case of float params it does expect a float

default_color_names=#("opacity", "environment", "translucency")

default_color_values=#( 1.0,  (Color 0 0 0 ),  (Color 0 0 0 ) )

-- This will evaluate mat.property 

-- mat should be a VRayMtl instance

-- property should be a string

fn execVRayMtlParam mat property=(

-- execute only works on global scope

global execParam_current_object

execParam_current_object =  mat

specialParamIndex = findItem param_lookup property

-- some of our params don't follow the naming protocol that others follow

if specialParamIndex > 0 then(

property = color_lookup[specialParamIndex] 

)

propIdx = findItem vraymtl_params (property as name)

if propIdx <= 0 then(

return undefined

)

--return execute( "execParam_current_object." + property )

return getproperty mat property

)

fn execVRay2SidedMtlParam mat property=(

specialParamIndex = findItem param_lookup property

-- some of our params don't follow the naming protocol that others follow

if specialParamIndex > 0 then(

property = color_lookup[specialParamIndex] 

)

propIdx = findItem vray2sidedmtl_params (property as name)

if propIdx <= 0 then(

return undefined

)

return getproperty mat property

)

-- This will return a list that contains the colorVal / floatVal, the texture, the tex mult, and the  tex on flag

fn getTextureParamList mat maxParamName isColor:true=(

--print "getTextureParamList START"

--print mat

--print (classof mat)

--print maxParamName

case( classof mat )of(

VRayMtl:(

colorVal = execVRayMtlParam mat maxParamName

--print colorVal

texVal = execVRayMtlParam mat ("texmap_" + maxParamName)

--print texVal

texOnVal = execVRayMtlParam mat ("texmap_" + maxParamName + "_on" )

texMultVal = execVRayMtlParam mat ("texmap_" + maxParamName + "_multiplier" )

)

VRay2SidedMtl:(

colorVal = execVRay2SidedMtlParam mat maxParamName

--print colorVal

texVal = execVRay2SidedMtlParam mat ("texmap_" + maxParamName)

--print texVal

texOnVal = execVRay2SidedMtlParam mat ("texmap_" + maxParamName + "_on" )

texMultVal = execVRay2SidedMtlParam mat ("texmap_" + maxParamName + "_multiplier" )

)

Standardmaterial:(

if maxParamName == undefined then (

colorVal = (Color 0 0 0)

texVal = undefined

texOnVal = undefined

texMultVal = undefined

)

else(

colorVal = getproperty mat maxParamName

texVal = getproperty mat (maxParamName + "Map")

texOnVal = getproperty mat (maxParamName + "MapEnable")

texMultVal = getproperty mat (maxParamName + "MapAmount")

)

)

default:(

)

)

-- We default to texture on as true, texture mult as 1.0 and color as black 

if texOnVal == undefined then(

texOnVal = true

)

if texMultVal == undefined then(

texMultVal = 100

)

if colorVal == undefined then (

defColorIndex = findItem default_color_names maxParamName

if defColorIndex > 0 then(

colorVal = default_color_values[defColorIndex]

)else(

format "unknown default color value for parameter \"%\"\n" maxParamName

)

)

return #(colorVal, texVal, texMultVal, texOnVal )

)

-- url will be the total top-level url, 

-- paramName is the name of BRDFVRayMtl parameter

-- mat is the VRayMtl

-- maxParamName is the name of the parameter in the 3dsmax VRayMtl 

-- specify isColor:false for float parameters

fn dumpColorTexHandlerParam url paramName mat maxParamName out isColor:true=(

finalUrl = url + "/" + paramName

paramVals = getTextureParamList mat maxParamName isColor:isColor

colorVal = paramVals[1]

texVal = paramVals[2]

texMultVal = paramVals[3]

texOnVal = paramVals[4]

texUrl = undefined

if texVal != undefined then(

texUrl = finalUrl + "/Texture"

)

dumpMap texVal finalUrl paramName out 

dumpTexCombineColor finalUrl colorVal texUrl  (texMultVal as float / 100.0) texOnVal out isColor:isColor

)

-- This function dumps the 4 userdata params that are plugged into a TexCombineColor.

-- Generally, there will be a color/float, a texture, a texture multiplier, and a texture enable value. 

-- The final parameter set will reference the TexCombineColor asset that reduces to the actual BRDFVRayMtl parameter

fn dumpTextureParams parentURL baseParamName mat maxParamName out isColor:true shouldGammaCorrect:false=(

texCombineColorUrl = (parentURL + "/" + baseParamName)

handlerName = ""

colorParamName = ""

paramType = ""

if isColor then(

handlerName = "ColorTexFrameHandler"

colorParamName = baseParamName +"_color"

paramType = "acolor texture"

)else(

handlerName = "FloatTexFrameHandler"

colorParamName = baseParamName +"_float"

paramType = "float texture"

)

gammaCorrectValue = undefined

if shouldGammaCorrect then(

gammaCorrectValue = true

)

-- Our actual tex combine url

make_parameter_xml baseParamName paramType texCombineColorUrl out gammaCorrect:gammaCorrectValue handler:handlerName

-- the 3dsmax parameter values

paramVals = getTextureParamList mat maxParamName isColor:isColor 

colorVal = paramVals[1]

texVal = paramVals[2]

texMultVal = paramVals[3]

texOnVal = paramVals[4]

-- the underlying userdata params we use in our xml to store the info that will be fed to the TexCombineColor

texParamName = baseParamName+ "_tex" 

texMultParamName = baseParamName + "_tex_mult" 

texOnParamName = baseParamName + "_tex_on"

-- And the userdata params we use to setup the TexCombineColor

texUrl = ""

if texVal != undefined then(

texUrl = (texCombineColorURL+"/Texture" )

)

dumpParam texUrl texParamName out paramType:"acolor texture" paramValue:texUrl isUserData:true handler:"TextureHandler"

dumpParam (texMultVal as float / 100.0f) texMultParamName out isUserData:true 

dumpParam texOnVal texOnParamName out isUserData:true 

dumpParam colorVal colorParamName out isUserData:true

)

fn dumpTextureParamsListVals parentURL baseParamName out listOfVals isColor:true shouldGammaCorrect:false=(

texCombineColorUrl = (parentURL + "/" + baseParamName)

handlerName = ""

colorParamName = ""

paramType = ""

if isColor then(

handlerName = "ColorTexFrameHandler"

colorParamName = baseParamName +"_color"

paramType = "acolor texture"

)else(

handlerName = "FloatTexFrameHandler"

colorParamName = baseParamName +"_float"

paramType = "float texture"

)

gammaCorrectValue = undefined

if shouldGammaCorrect then(

gammaCorrectValue = true

)

-- Our actual tex combine url

make_parameter_xml baseParamName paramType texCombineColorUrl out gammaCorrect:gammaCorrectValue handler:handlerName

colorVal = listOfVals[1]

texVal = listOfVals[2]

texMultVal = listOfVals[3]

texOnVal = listOfVals[4]

-- the underlying userdata params we use in our xml to store the info that will be fed to the TexCombineColor

texParamName = baseParamName+ "_tex" 

texMultParamName = baseParamName + "_tex_mult" 

texOnParamName = baseParamName + "_tex_on"

-- And the userdata params we use to setup the TexCombineColor

texUrl = ""

if texVal != undefined then(

texUrl = (texCombineColorURL+"/Texture" )

)

dumpParam texUrl texParamName out paramType:"acolor texture" paramValue:texUrl isUserData:true handler:"TextureHandler"

dumpParam texMultVal texMultParamName out isUserData:true 

dumpParam texOnVal texOnParamName out isUserData:true 

dumpParam colorVal colorParamName out isUserData:true

)

-- This function actually writes out the Texture plugins, it needs to be called prior to serializing the owner asset

-- mat is the VRayMtl to grab maps from

-- parentURL is the url to use as the parent of the textures

fn dumpVRayMtlTexmaps mat parentURL out isTexValOpacity:true doExportEnvironment:false=(

if mat == undefined then(

return undefined

)

dumpColorTexHandlerParam parentURL "diffuse" mat "diffuse" out

dumpColorTexHandlerParam parentURL "roughness" mat "roughness" out isColor:false

dumpColorTexHandlerParam parentURL "reflect" mat "reflection" out 

dumpColorTexHandlerParam parentURL "hilight_glossiness" mat "hilightGlossiness" out  isColor:false

dumpColorTexHandlerParam parentURL "reflect_glossiness" mat "reflectionGlossiness" out isColor:false

dumpColorTexHandlerParam parentURL "anisotropy" mat "anisotropy" out isColor:false

dumpColorTexHandlerParam parentURL "anisotropy_rotation" mat "anisotropy_rotation" out isColor:false

dumpColorTexHandlerParam parentURL "fresnel_ior" mat "reflectionIOR" out  isColor:false

dumpColorTexHandlerParam parentURL "refract" mat "refraction" out 

dumpColorTexHandlerParam parentURL "refract_glossiness" mat "refractionGlossiness" out  isColor:false

dumpColorTexHandlerParam parentURL "refract_ior" mat "refractionIOR" out  isColor:false

dumpColorTexHandlerParam parentURL "translucency_color" mat "translucent" out

if isTexValOpacity then(

dumpColorTexHandlerParam parentURL "opacity" mat "opacity" out isColor:false

)

if doExportEnvironment then(

dumpColorTexHandlerParam parentURL "environment_override" mat "environment" out 

)

dumpUVWGenChannel parentURL mat.anisotropy_channel out uvwURL:(parentURL + "/AnisoUVWGen") 

-- These would actually require separate materials they are not currently supported as vismats

--.texmap_bump : texturemap

--.texmap_displacement : texturemap

-- maps

--dumpMap mat.texmap_environment  parentURL "Environment" out    

--dumpMap mat.texmap_opacity  parentURL "Opacity" out   

)

-- This function fills out the parameters for the BRDFVRayMtl itself

fn dumpBRDFVRayMtl mat out basemat:undefined = (

if mat == undefined then(

return undefined

)

local brdfURL = ""

if (basemat != undefined) then (

brdfURL = "/" + basemat + "/BRDFVRayMtl"

)

else (

brdfURL = "/" + mat.name + "/BRDFVRayMtl"

)

-- params not in BRDFVRayMtl

--.option_traceDiffuse : boolean

--.effect_id : integer

--.override_effect_id : boolean

--.option_clampTextures : boolean

texVal = execVRayMtlParam mat "texmap_opacity"

texValEnvironment = execVRayMtlParam mat "texmap_environment"

--print "######################dumpBRDFVRayMtl#########################"

--format "material % diffuse color: % \n" mat.name mat.diffuse

--format "material % diffuse texmap multiplier: % \n" mat.name mat.texmap_diffuse_multiplier

--print texVal

bTexVal = (texVal != undefined)

bExportEnvironment = (texValEnvironment != undefined)

--print bTexVal

-- Need to look for texmaps and write them out before we write out our brdf

dumpVRayMtlTexmaps mat brdfURL out isTexValOpacity:bTexVal doExportEnvironment:bExportEnvironment

begin_asset brdfURL "BRDFVRayMtl" "BRDF" "BRDFVRayMtlLayout" out 

-- reflection

dumpParam mat.reflection_subdivs "reflect_subdivs" out 

dumpParam mat.reflection_fresnel "fresnel" out 

dumpParam mat.reflection_maxDepth "reflect_depth" out 

dumpParam mat.reflection_exitColor "reflect_exit_color" out

dumpParam mat.reflection_fresnel "fresnel" out 

dumpParam mat.reflection_useInterpolation "refl_interpolation_on" out

dumpParam mat.reflection_lockGlossiness "hilight_glossiness_lock" out 

dumpParam mat.reflection_lockIOR "fresnel_ior_lock" out 

dumpParam mat.reflection_dimDistance "reflect_dim_distance" out 

dumpParam mat.reflection_dimDistance_on "reflect_dim_distance_on" out 

dumpParam mat.reflection_dimDistance_falloff "reflect_dim_distance_falloff" out 

dumpParam mat.reflection_affectAlpha "reflect_affect_alpha" out 

  

-- refraction

dumpParam mat.refraction_subdivs "refract_subdivs" out

dumpParam mat.refraction_fogColor "fog_color" out 

dumpParam mat.refraction_fogMult "fog_mult" out 

dumpParam mat.refraction_fogBias "fog_bias" out 

dumpParam mat.refraction_affectShadows "refract_affect_shadows" out 

dumpParam mat.refraction_affectAlpha "refract_affect_alpha" out 

dumpParam mat.refraction_maxDepth "refract_depth" out 

dumpParam mat.refraction_exitColor "refract_exit_color" out 

dumpParam mat.refraction_useExitColor "refract_exit_color_on" out 

dumpParam mat.refraction_useInterpolation "refr_interpolation_on" out 

dumpParam mat.refraction_dispersion "dispersion" out 

dumpParam mat.refraction_dispersion_on "dispersion_on" out 

dumpParam mat.translucency_on "translucency" out 

dumpParam mat.translucency_thickness "translucency_thickness" out 

dumpParam mat.translucency_scatterCoeff "translucency_scatter_coeff" out 

dumpParam mat.translucency_fbCoeff "translucency_scatter_dir" out 

dumpParam mat.translucency_multiplier "translucency_light_mult" out 

  

-- brdf

dumpParam mat.brdf_type "brdf_type" out

dumpParam mat.anisotropy_derivation "anisotropy_derivation" out 

dumpParam mat.anisotropy_axis "anisotropy_axis" out 

-- we build a uvwgenchannel based on mat.anisotropy_channel in our dumpMaps function

make_parameter_xml "anisotropy_uvwgen" "plugin"  (brdfURL + "/AnisoUVWGen")  out 

dumpParam mat.soften "hilight_soften" out 

-- options

dumpParam mat.brdf_fixDarkEdges "option_fix_dark_edges" out 

dumpParam mat.option_traceReflection "reflect_trace" out 

dumpParam mat.option_traceRefraction "refract_trace" out 

dumpParam mat.option_doubleSided "option_double_sided" out 

dumpParam mat.option_reflectOnBack "option_reflect_on_back" out 

dumpParam mat.option_useIrradMap "option_use_irradiance_map" out 

dumpParam mat.refraction_fogUnitsScale_on "fog_unit_scale_on" out 

dumpParam mat.option_cutOff "option_cutoff" out 

dumpParam mat.preservationMode "option_energy_mode" out 

dumpParam mat.option_environment_priority "environment_priority" out 

dumpParam mat.option_traceDiffuseAndGlossy "option_glossy_rays_as_gi" out

-- This is a userdata param that marks this material as 3dsmax compatible, it uses multipliers as a blend amount, not a scalar multiplier

make_parameter_xml "texture_multiplier_mode" "integer" "1" out handler:"ComboBoxHandler" isUserData:true

-- interpolation

dumpParam mat.reflect_minRate "refl_imap_min_rate" out 

    dumpParam mat.reflect_maxRate "refl_imap_max_rate" out 

    dumpParam mat.reflect_interpSamples "refl_imap_samples" out 

dumpParam mat.reflect_colorThreshold "refl_imap_color_thresh" out 

dumpParam mat.reflect_normalThreshold "refl_imap_norm_thresh" out 

  

dumpParam mat.refract_minRate "refr_imap_min_rate" out 

    dumpParam mat.refract_maxRate "refr_imap_max_rate" out 

    dumpParam mat.refract_interpSamples "refr_imap_samples" out 

dumpParam mat.refract_colorThreshold "refr_imap_color_thresh" out 

dumpParam mat.refract_normalThreshold "refr_imap_norm_thresh" out 

-- maps  

dumpTextureParams brdfURL "diffuse" mat "diffuse" out shouldGammaCorrect:true

dumpTextureParams brdfURL "roughness" mat "roughness" out isColor:false

dumpTextureParams brdfURL "reflect" mat "reflection" out 

dumpTextureParams brdfURL "hilight_glossiness" mat "hilightGlossiness" out  isColor:false

dumpTextureParams brdfURL "reflect_glossiness" mat "reflectionGlossiness" out isColor:false

dumpTextureParams brdfURL "anisotropy" mat "anisotropy" out isColor:false

dumpTextureParams brdfURL "anisotropy_rotation" mat "anisotropy_rotation" out isColor:false

dumpTextureParams brdfURL "fresnel_ior" mat "reflectionIOR" out  isColor:false

dumpTextureParams brdfURL "refract" mat "refraction" out 

dumpTextureParams brdfURL "refract_glossiness" mat "refractionGlossiness" out  isColor:false

dumpTextureParams brdfURL "refract_ior" mat "refractionIOR" out  isColor:false

dumpTextureParams brdfURL "translucency_color" mat "translucent" out 

if bTexVal then(

dumpTextureParams brdfURL "opacity" mat "opacity" out isColor:false

)

if bExportEnvironment then(

dumpTextureParams brdfURL "environment_override" mat "environment" out shouldGammaCorrect:true

)

-- The following maps would require additional material types / support that is currently not available for our material editor. We can add it in the future

--.texmap_bump : texturemap

--.texmap_bump_on : boolean

--.texmap_bump_multiplier : float

--.texmap_displacement : texturemap

--.texmap_displacement_on : boolean

--.texmap_displacement_multiplier : float  

  

end_asset out

return brdfURL

)

fn dumpBRDFDiffuse mat out basemat:undefined =(

if mat == undefined then(

return undefined

)

local brdfURL = ""

if (basemat != undefined) then (

brdfURL = "/" + basemat + "/BRDFDiffuse"

)

else (

brdfURL = "/" + mat.name + "/BRDFDiffuse"

)

--print "Enter dumpBRDFDiffuse"

colorVal = getproperty  mat "diffuse"

--format "diffuse color: %\n" colorVal

texColorVal = getproperty  mat "diffuseMap"

texColorValMult = getproperty  mat "diffuseMapAmount"

--format "diffuse map amount: %\n" texColorValMult

texColorValOn = getproperty  mat "diffuseMapEnable"

local texUrl = ""

if texColorVal != undefined then(

texUrl = (brdfURL+"/color/Texture")

dumpMap texColorVal (brdfURL+"/color") "color_tex" out

)

--dumpColorTexHandlerParam brdfURL "roughness" mat "diffuseRoughness" out isColor:false

begin_asset brdfURL "BRDFDiffuse" "BRDF" "DiffuseLayer" out

make_color_parameter_xml "color" colorVal out gammaCorrect:true

make_parameter_xml "color_tex" "acolor texture" texUrl out gammaCorrect:true

make_parameter_xml "color_tex_mult" "float" (texColorValMult as float / 100.0f) out

make_color_parameter_xml "transparency" (Color 0 0 0) out gammaCorrect:true

--dumpTextureParams brdfURL "roughness" mat "diffuseRoughness" out isColor:false

end_asset out

return brdfURL

)

fn dumpMtlSingleBRDF url brdfURL out =(

begin_asset url "MtlSingleBRDF" "material" "MtlSingleBRDFLayout" out

make_parameter_xml "brdf" "plugin" brdfURL out 

end_asset out

)

fn dumpVRayMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

-- We are going to write our VRayMtl out as a BRDFVRayMtl wrapped in a MtlSingleBRDF

local baseMtlURL=undefined

local singleMatURL = ""

if (basemat != undefined) then (

baseMtlURL = (basemat + "_" + mat.name)

singleMatURL = baseMtlURL

)

else (

singleMatURL = mat.name

)

--open_tag "vismat" out

brdfURL = dumpBRDFVRayMtl mat out basemat:baseMtlURL

singleMatURL = ("/" + singleMatURL)

dumpMtlSingleBRDF  singleMatURL brdfURL out 

--close_tag "vismat" out

return singleMatURL

)

fn dumpSubMaterial mat out basemat:undefined = (

local mtlURL = undefined

case( classof mat )of(

VRayMtl:(

local defDispl = mat.texmap_displacement

local defBump = mat.texmap_bump

if defDispl == undefined and defBump == undefined then(

mtlURL = dumpVRayMtl mat out basemat:basemat

)

else(

mtlURL =dumpMtlASGVIS mat out basemat:basemat

)

)

Standardmaterial:(

mtlURL = dumpMtlASGVIS mat out basemat:basemat

)

VRayMtlWrapper:(

mtlURL = dumpVRayMtlWrapper mat out basemat:basemat

)

Multimaterial:(

mtlURL = dumpMultiMtl mat out basemat:basemat

)

VRay2SidedMtl:(

mtlURL = dumpVRay2SidedMtl mat out basemat:basemat

)

default:(

if ( mat != undefined ) do (

print "WARRNING!"

format "Unsupported material % of class % - skipped\n" mat.name ((classof mat) as string)

)

)

)

return mtlURL

)

fn dumpVRay2SidedMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

local matURL = ""

local baseMtlURL = undefined

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

matURL = baseMtlURL

)

else (

matURL = mat.name

)

local frontMaterialURL = ""

case( classof mat.frontMtl )of(

VRayMtl:(

local defDispl = mat.frontMtl.texmap_displacement

local defBump = mat.frontMtl.texmap_bump

if defDispl == undefined and defBump == undefined then(

frontMaterialURL = dumpVRayMtl mat.frontMtl out basemat:baseMtlURL

)

else(

frontMaterialURL =dumpMtlASGVIS mat.frontMtl out basemat:baseMtlURL

)

)

Standardmaterial:(

frontMaterialURL = dumpMtlASGVIS mat.frontMtl out basemat:baseMtlURL

)

VRayMtlWrapper:(

frontMaterialURL = dumpVRayMtlWrapper mat.frontMtl out basemat:baseMtlURL

)

Multimaterial:(

frontMaterialURL = dumpMultiMtl mat.frontMtl out basemat:baseMtlURL

)

default:(

if ( mat.frontMtl != undefined ) do (

print "WARRNING!"

format "Unsupported front material % for VRay2SidedMtl with name % - skipped\n" mat.frontMtl.name mat.name

)

)

)

local backMaterialURL = ""

case( classof mat.backMtl )of(

VRayMtl:(

local defDispl = mat.backMtl.texmap_displacement

local defBump = mat.backMtl.texmap_bump

if defDispl == undefined and defBump == undefined then(

backMaterialURL = dumpVRayMtl mat.backMtl out basemat:baseMtlURL

)

else(

backMaterialURL =dumpMtlASGVIS mat.backMtl out basemat:baseMtlURL

)

)

Standardmaterial:(

backMaterialURL = dumpMtlASGVIS mat.backMtl out basemat:baseMtlURL

)

VRayMtlWrapper:(

backMaterialURL = dumpVRayMtlWrapper mat.backMtl out basemat:baseMtlURL

)

Multimaterial:(

backMaterialURL = dumpMultiMtl mat.backMtl out basemat:baseMtlURL

)

default:(

if ( mat.backMtl != undefined ) do (

print "WARRNING!"

format "Unsupported back material % for VRay2SidedMtl with name % - skipped\n" mat.backMtl.name mat.name

)

)

)

matURL = ("/" + matURL)

--dumpParam param paramName out paramType:undefined paramValue:undefined gammaCorrect:undefined isUserData:undefined handler:"default"

--dumpTextureParams parentURL baseParamName mat maxParamName out isColor:true shouldGammaCorrect:false

paramType = getParamType mat.translucency

--print paramType

strColorTrans = vraymax_color_to_xml_string mat.translucency

--print strColorTrans

finalUrl = matURL + "/translucency"

texUrl = ""

if mat.texmap_translucency != undefined then(

texUrl = finalUrl + "/Texture"

dumpMap mat.texmap_translucency finalUrl "translucency" out 

)

begin_asset  matURL "Mtl2Sided" "material" "TwoSidedMatLayout" out

--make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined

make_parameter_xml "front" "plugin" frontMaterialURL out handler:"MaterialPickerHandler"

make_parameter_xml "back" "plugin" backMaterialURL out handler:"MaterialPickerHandler"

make_color_parameter_xml "translucency" mat.translucency out

make_parameter_xml "translucency_tex" "acolor texture" texUrl out

make_parameter_xml "translucency_tex_mult" "float" (mat.texmap_translucency_multiplier as float / 100.0f) out

dumpParam mat.force1SidedSubMtls "force_1sided" out

end_asset out

return matURL

)

fn dumpMtlASGVIS mat out basemat:undefined =(

if mat == undefined then

return undefined

local brdfURL=undefined

local baseMtlURL=undefined

local asgvismatURL = ""

if (basemat != undefined) then (

baseMtlURL = (basemat + "_" + mat.name)

asgvismatURL = baseMtlURL

)

else (

asgvismatURL = mat.name

)

local listOfBumpProps = #()

case( classof mat )of(

VRayMtl:(

brdfURL = dumpBRDFVRayMtl mat out basemat:baseMtlURL

listOfBumpProps = #("texmap_bump","texmap_bump_multiplier","texmap_bump_on")

)

Standardmaterial:(

brdfURL = dumpBRDFDiffuse mat out basemat:baseMtlURL

listOfBumpProps = #("bumpMap","bumpMapAmount","bumpMapEnable")

)

default:(

format "Unsupported material % wrapped in MtlASGVIS - skipped\n" mat.name

)

)

texBumpVal = getproperty  mat listOfBumpProps[1]

texBumpValMult = getproperty  mat listOfBumpProps[2]

texBumpValOn = getproperty  mat listOfBumpProps[3]

asgvismatURL = ("/" + asgvismatURL)

local bumptexUrl = ""

listNormalBumpFeatures = #()

if texBumpVal != undefined then (

bumptexUrl = (asgvismatURL+"/Texture")

dumpMap texBumpVal asgvismatURL "bump_tex" out

if (listNormalBumpFeatures.count>0 ) then (

dumpMap listNormalBumpFeatures[1] asgvismatURL "bump_tex" out

)

)

--dumpParam param paramName out paramType:undefined paramValue:undefined gammaCorrect:undefined isUserData:undefined handler:"default"

--dumpTextureParams parentURL baseParamName mat maxParamName out isColor:true shouldGammaCorrect:false

begin_asset  asgvismatURL "MtlASGVIS" "material" "defvrmat" out

--make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined

--make_list_parameter_xml paramName listType paramType listOfValues out gammaCorrect:undefined handler:"default" isUserData:undefined

make_list_parameter_xml "brdfs" "plugin" "list" #(brdfURL) out

if (listNormalBumpFeatures.count>0 ) then (

make_parameter_xml "bump_tex" "plugin" bumptexUrl out handler:"TextureHandler"

make_parameter_xml "map_type" "integer" (listNormalBumpFeatures[4]+1) out

make_parameter_xml "bump_tex_mult" "float" listNormalBumpFeatures[3] out

make_bool_parameter_xml "bump_on" listNormalBumpFeatures[2] out

)

else (

make_parameter_xml "bump_tex" "plugin" bumptexUrl out handler:"TextureHandler"

make_parameter_xml "bump_tex_mult" "float" (texBumpValMult as float / 100.0f) out

make_bool_parameter_xml "bump_on" texBumpValOn out

)

end_asset out

return asgvismatURL

)

fn dumpVRayMtlWrapper mat out basemat:undefined =(

if mat == undefined then

return undefined

local baseMtlURL = undefined

local wrapMtlURL = ""

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

wrapMtlURL = baseMtlURL

)

else (

wrapMtlURL = mat.name

)

-- We are going to write our VRayMtl out as a BRDFVRayMtl wrapped in a MtlSingleBRDF

--wrapMtlURL = ("/" + mat.name)

--singleMatURL = ("/" + mat.baseMtl.name)

--open_tag "vismat" out

local brdfURL=undefined

case( classof mat.baseMtl )of(

VRayMtl: (

local defDispl = mat.baseMtl.texmap_displacement

local defBump = mat.baseMtl.texmap_bump

if defDispl == undefined and defBump == undefined then(

brdfURL = dumpVRayMtl mat.baseMtl out basemat:baseMtlURL

)

else(

brdfURL =dumpMtlASGVIS mat.baseMtl out basemat:baseMtlURL

)

)

Standardmaterial: brdfURL = dumpMtlASGVIS mat.baseMtl out basemat:baseMtlURL

VRay2SidedMtl:(

brdfURL = dumpVRay2SidedMtl mat.baseMtl out basemat:baseMtlURL

)

Multimaterial:(

brdfURL = dumpMultiMtl mat.baseMtl out basemat:baseMtlURL

)

default:(

if ( mat.baseMtl != undefined ) do (

print "WARRNING!"

format "Unsupported base material % for VRayMtlWrapper with name % - skipped\n" mat.baseMtl.name mat.name

)

)

)

wrapMtlURL = "/" + wrapMtlURL

begin_asset  wrapMtlURL "MtlWrapper" "material" "MtlWrapperLayout" out

make_parameter_xml "base_material" "plugin" brdfURL out handler:"MaterialPickerHandler"

dumpParam mat.generateGIMult "generate_gi" out 

dumpParam mat.receiveGIMult "receive_gi" out

--dumpParam mat.generateCaustics "generate_caustics" out --bool/float

dumpParam mat.causticsMult "receive_caustics" out

dumpParam mat.matteSurface "matte_surface" out

--dumpParam mat.secondaryMatte "matte_for_secondary_rays" out --bool/int

dumpParam mat.alphaContribution "alpha_contribution" out

dumpParam mat.matteSurface "matte_surface" out

dumpParam mat.matte_shadows "shadows" out

dumpParam mat.matte_shadowsAffectAlpha "affect_alpha" out

dumpParam mat.matte_shadowColor "shadow_tint_color" out

dumpParam mat.matte_shadowBrightness "shadow_brightness" out

dumpParam mat.matte_reflectionMultiplier "reflection_amount" out

dumpParam mat.matte_refractionMultiplier "refraction_amount" out

dumpParam mat.matte_giMultiplier "gi_amount" out

dumpParam mat.matte_noGIOnOtherMattes "no_gi_on_other_mattes" out

dumpParam mat.matte_giSurfaceID "gi_surface_id" out

end_asset out

return wrapMtlURL

fn dumpMultiMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

local baseMtlURL = undefined

local multiMtlURL = ""

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

multiMtlURL = baseMtlURL

)

else (

multiMtlURL = mat.name

)

local listMtlMulti = mat.materialList

local urlList = #()

for i=1 to listMtlMulti.count do (

local brdfURL=undefined

case( classof listMtlMulti[i] )of(

VRayMtl: (

local defDispl = listMtlMulti[i].texmap_displacement

local defBump = listMtlMulti[i].texmap_bump

if defDispl == undefined and defBump == undefined then(

brdfURL = dumpVRayMtl listMtlMulti[i] out basemat:baseMtlURL

)

else(

brdfURL =dumpMtlASGVIS listMtlMulti[i] out basemat:baseMtlURL

)

)

Standardmaterial: brdfURL = dumpMtlASGVIS listMtlMulti[i] out basemat:baseMtlURL

VRay2SidedMtl:(

brdfURL = dumpVRay2SidedMtl listMtlMulti[i] out basemat:baseMtlURL

)

default:(

if ( listMtlMulti[i] != undefined ) do (

print "WARRNING!"

format "Unsupported material % for MtlMulti with name % - skipped\n" (listMtlMulti[i]).name mat.name

)

)

)

append urlList brdfURL

)

multiMtlURL = "/" + multiMtlURL

begin_asset  multiMtlURL "MtlMulti" "material" "MultiMatLayout" out

--make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined

--make_list_parameter_xml paramName listType paramType listOfValues out gammaCorrect:undefined handler:"default" isUserData:undefined

make_list_parameter_xml "ids_list" "integer" "list" mat.materialIDList out

make_list_parameter_xml "mtls_list" "plugin" "list" urlList out

end_asset out

return multiMtlURL

)

fn dumpVRayBRDFLayered mat out basemat:undefined =(

if mat == undefined then

return undefined

local brdfLayeredURL = ""

if (basemat != undefined) then (

brdfLayeredURL = basemat + "/BRDFLayered"

)

else (

brdfLayeredURL = mat.name + "/BRDFLayered"

)

local listCoatBlendTexMaps = mat.texmap_blend

local listCoatBlendColors = mat.blend

local listCoatBlendTexMultipliers = mat.texmap_blend_multiplier

local paramName = ""

local finalUrl = ""

local texURL = ""

local brdfURL = ""

local urlList = #()

local texURLList = #()

local listCoatAvailableMtls = for availMtl in mat.coatMtl where availMtl != undefined collect availMtl

for i=listCoatAvailableMtls.count to 1 by -1 do (

paramName = "texmap_blend_" + ((i-1) as string)

finalUrl = "/" + brdfLayeredURL + "/" + paramName

texURL = finalUrl + "/Texture"

if ( listCoatBlendTexMaps[i] == undefined ) then (

dumpTexAColorFromColor texURL listCoatBlendColors[i] out

append texURLList texURL

) else (

dumpMap listCoatBlendTexMaps[i] finalUrl paramName out 

dumpTexCombineColor finalUrl listCoatBlendColors[i] texURL  (listCoatBlendTexMultipliers[i] as float / 100.0) true out

append texURLList finalUrl

)

brdfURL=dumpSubMaterial listCoatAvailableMtls[i] out basemat:basemat

append urlList brdfURL

)

brdfURL=dumpSubMaterial mat.baseMtl out basemat:basemat

append urlList brdfURL

append texURLList ""

brdfLayeredURL = "/" + brdfLayeredURL

begin_asset brdfLayeredURL "BRDFLayered" "BRDF" "BRDFLayeredLayout" out

make_list_parameter_xml "weights" "plugin" "list" texURLList out

make_list_parameter_xml "brdfs" "plugin" "list" urlList out

make_bool_parameter_xml "additive_mode" mat.additiveMode out

end_asset out

return brdfLayeredURL

)

fn dumpVRayBlendMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

-- We are going to write our VRayBlendMtl out as a BRDFLayered wrapped in a MtlSingleBRDF

local baseMtlURL = undefined

local singleMatURL = ""

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

singleMatURL = baseMtlURL

)

else (

singleMatURL = mat.name

)

local brdfURL = dumpVRayBRDFLayered mat out basemat:baseMtlURL

singleMatURL = ("/" + singleMatURL)

dumpMtlSingleBRDF  singleMatURL brdfURL out 

return singleMatURL

)

 

-- for now we only work on VRayMtl types

fn dumpMaterials = (

saveDir = getSavePath caption:"Vismat Export Directory" 

if saveDir == undefined then(

return undefined

)

format "Exporting scene materials...\n"

for i=1 to 24 do (

m = meditmaterials[i]

case( classof m )of(

VRayMtl:(

format "Processing %: " m.name

fileName =  (saveDir + "\\" + m.name + ".vismat")

format "saving vismat to %\n" fileName

f = openFile fileName mode:"w"

open_tag "vismat" f

dumpVRayMtl m f

close_tag "vismat" f

flush f

close f

)

VRay2SidedMtl:(

format "Processing %: " m.name

fileName =  (saveDir + "\\" + m.name + ".vismat")

format "saving vismat to %\n" fileName

f = openFile fileName mode:"w"

open_tag "vismat" f

dumpVRay2SidedMtl m f

close_tag "vismat" f

flush f

close f

)

default:(

)

)

)

format "Done\n"

)

fn clearArrBitMapTxtPaths = (

arrBitMapTxtPaths = #()

)

fn createBmpFilesInVismatFolder saveDir = (

if saveDir == undefined then(

return undefined

)

--print arrBitMapTxtPaths.count

for i=1 to arrBitMapTxtPaths.count do (

bmpFile = filenamefrompath arrBitMapTxtPaths[i]

--print "File name:"

--print bmpFile

bmpFileTargetPath = saveDir + "\\" + bmpFile

--print "Target path:"

--print bmpFileTargetPath

--print (doesFileExist bmpFileTargetPath)

if (doesFileExist bmpFileTargetPath) then

deleteFile bmpFileTargetPath

copyresult = copyFile arrBitMapTxtPaths[i]  bmpFileTargetPath

if copyresult then

format "copying the file % \n from % \n to % \n was Successfully \n" bmpFile (getFilenamePath arrBitMapTxtPaths[i]) saveDir

else

format "copying the file % \n from % \n to % \n was NOT Successfully \n" bmpFile (getFilenamePath arrBitMapTxtPaths[i]) saveDir

)

)

fn openVismatTag f = (

open_tag "vismat" f

)

fn closeVismatTag f = (

close_tag "vismat" f

)

fn dumpSelectedMaterial mat f  vismatmode:undefined= (

if mat == undefined then

return undefined

case( classof mat )of(

VRayMtl:(

defDispl = mat.texmap_displacement

defBump = mat.texmap_bump

if defDispl == undefined and defBump == undefined then(

dumpVRayMtl mat f

)

else(

dumpMtlASGVIS mat f

)

)

VRay2SidedMtl:(

if vismatmode == undefined then

dumpVRay2SidedMtl mat f

else

dumpVRay2SidedMtl mat f basemat:""

)

VRayMtlWrapper:(

if vismatmode == undefined then (

dumpVRayMtlWrapper mat f

)

else

dumpVRayMtlWrapper mat f basemat:""

)

Standardmaterial:(

dumpMtlASGVIS mat f

)

Multimaterial:(

dumpMultiMtl mat f

)

VRayBlendMtl:(

if vismatmode == undefined then

dumpVRayBlendMtl mat f

else

dumpVRayBlendMtl mat f basemat:""

)

default:(

format "Convertion for % is not done: " mat.name

format "Unknown material - skipped\n"

)

)

)

macroScript ExportVismats category:"VRay"  buttontext:"Export VRMAT from scene materials" tooltip:"Exports vrmat files" (

dumpMaterials()

)

fn registerMenuItems = (

if menuMan.registerMenuContext 0x67e0e9ff then(

local quadMenu=menuMan.getViewportRightClickMenu #nonePressed

if (quadMenu!=undefined) do (

local menu=quadMenu.getMenu 1

)

local menuIndex

if (menu!=undefined) do (

menuIndex=findMenuItemIdx menu "V-Ray scene converter"

appendMenuItem menu "ExportVismats" "VRay"

)

)

)

--registerMenuItems()

На сайте c 17.12.2015
Сообщений: 1098
Mozart:


Пожизненный бан
smiley-fool.gif
На сайте c 14.06.2012
Сообщений: 15078
Москва

Я домотал до низа!

Начать надо хотя бы с того, что не ставить макс в русскую папку.

6c5dfd5c1a59ebe129ef5d38dac0ef0c.png

По закону глупости должен найтись умник, который процитирует первый пост )))

На сайте c 06.06.2011
Сообщений: 642
Деревня
Цитата EugeneTheModeler:

Здраствуйте, есть проблема : при выборе в списке доступных материалов во вкладке Vray доступны только три материала, как видно на скриншоте. А где  vrayblendmtl и другие? Крякнут врей нормально, выбран рендерером. Вот зацепка: сразу после установки vray в 3ds max начинает постоянно выскакивать ошибка при запуске(второй скриншот) код ошибки выкладываю вконце

06ec77d36efbb2368bcbd144d4d15ce6.jpg

b4d63753bee276c2de7e05cbb46a18dc.jpg

include "$startupScripts\\vrayutils.ms"

-- You can call this on any built-in value that will properly convert to a string

-- without any extra work...like floats ints bools strings...

fn value_to_xml value container out = (

if container != undefined then(

format "<%><%></%>\n" container value container to:out

)else(

format "%" value to:out

)

)

fn value_to_xml_string value container  =(

    s = stringstream ""

    value_to_xml value container s

    return s as string

)

-- Generic parameter - all inputs are expected to be strings

--Makes parameter element of <parameters>..</parameters> section of xml

--paramType:- bool, integer, float, string, vector, acolor texture, float texture, color, list, componentTransform, transform, output vector texture, output float texture, output acolor texture, plugin

--paramValue:- if there is parameter value it's nested in <value>..</value> element

--out:- output stream(file)

--gammaCorrect:- true if exists such parameter attribute.  It is boolean flag tells us whether a given parameter needs gamma correction before being sent to V-Ray. 

--handler:- ComboBoxHandler, FileBrowserHandler, TextureTransformHandler, CheckBoxHandler, DoubleSpinBoxHandler, ColorTexFrameHandler, FloatTexFrameHandler, TextureHandler, LockButtonHandler, UVWHandler

--isUserData:-  true if exists such parameter attribute. This is helper param for the UI and will not be sent to V-Ray.

fn make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined=(

userDataString=""

gammaCorrectString=""

handlerName = handler

if gammaCorrect != undefined then(

gammaCorrectString = " gammaCorrect=\"1\""

)

if isUserData != undefined then(

userDataString=" isUserData=\"1\""

)

format "\t\t\t\t\t<parameter%% handler=\"%\" name=\"%\" type=\"%\">\n\t\t\t\t\t\t<value>%</value>\n\t\t\t\t\t</parameter>\n" userDataString gammaCorrectString handlerName paramName paramType paramValue  to:out

)

--Makes list parameter element of <parameters>..</parameters> section of xml

--listType:- it is the type of parameter stored in the list

--paramType:- bool, integer, float, string, vector, acolor texture, float texture, color, list, componentTransform, transform, output vector texture, output float texture, output acolor texture, plugin

--listOfValues:- container of values. Each value nested in <entry>..</entry> element compaund <list>..</list> element 

--out:- output stream(file)

--gammaCorrect:- true if exists such parameter attribute.  It is boolean flag tells us whether a given parameter needs gamma correction before being sent to V-Ray. 

--handler:- ComboBoxHandler, FileBrowserHandler, TextureTransformHandler, CheckBoxHandler, DoubleSpinBoxHandler, ColorTexFrameHandler, FloatTexFrameHandler, TextureHandler, LockButtonHandler, UVWHandler

--isUserData:-  true if exists such parameter attribute. This is helper param for the UI and will not be sent to V-Ray.

fn make_list_parameter_xml paramName listType paramType listOfValues out gammaCorrect:undefined handler:"default" isUserData:undefined=(

userDataString=""

gammaCorrectString=""

handlerName = handler

if gammaCorrect != undefined then(

gammaCorrectString = " gammaCorrect=\"1\""

)

if isUserData != undefined then(

userDataString=" isUserData=\"1\""

)

formatedentry = stringstream ""

entry = "\t\t\t\t\t\t\t\t<entry>%</entry>\n"

numOfValues = listOfValues.count

for i=1 to numOfValues - 1 do (

format entry listOfValues[i] to:formatedentry

)

entry = "\t\t\t\t\t\t\t\t<entry>%</entry>"

if numOfValues > 0 then (

format entry listOfValues[numOfValues] to:formatedentry

) else (

format entry "" to:formatedentry

)

paramValue = formatedentry as string

format "\t\t\t\t\t<parameter%% handler=\"%\" name=\"%\" listType=\"%\" type=\"%\">\n\t\t\t\t\t\t<value>\n\t\t\t\t\t\t\t<list>\n%\n\t\t\t\t\t\t\t</list>\n\t\t\t\t\t\t</value>\n\t\t\t\t\t</parameter>\n" userDataString gammaCorrectString handlerName paramName listType paramType paramValue  to:out

)

--The next four functions surve bool/color type parameter creation which need of additional work around convertion to string

fn boolToInteger paramVal = (

val = 0

    if paramVal != false then(

        val = 1

)

return val

)

fn make_bool_parameter_xml paramName paramVal out isUserData:undefined handler:"default"=(    

val = boolToInteger( paramVal )

return make_parameter_xml paramName "bool" (value_to_xml_string val undefined )  out isUserData:isUserData handler:handler

)

fn vraymax_color_to_xml_string val =(

s = stringstream ""

format "<r>%</r><g>%</g><b>%</b>" (val.r as float/255.0f) (val.g as float/255.0f) (val.b as float/255.0f) to:s

return s as string

)

fn vraymax_colorwithalpha_to_xml_string val =(

s = stringstream ""

format "<r>%</r><g>%</g><b>%</b><a>%</a>" (val.r as float/255.0f) (val.g as float/255.0f) (val.b as float/255.0f) (val.a as float/255.0f) to:s

return s as string

)

fn make_color_parameter_xml paramName val out gammaCorrect:undefined isUserData:undefined handler:"default" bAlpha:false=(

if bAlpha == true then (

make_parameter_xml paramName "color" (vraymax_colorwithalpha_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

) else (

make_parameter_xml paramName "color" (vraymax_color_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

fn make_acolortexture_parameter_xml paramName val out gammaCorrect:undefined isUserData:undefined handler:"default" bAlpha:false=(

if bAlpha == true then (

make_parameter_xml paramName "acolor texture" (vraymax_colorwithalpha_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler 

) else (

make_parameter_xml paramName "acolor texture" (vraymax_color_to_xml_string val ) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

--Generally open_tag and close_tag methods are used for creating root nodes

fn open_tag tag out tabs:""=(

format "%<%>\n" tabs tag to:out

)

fn close_tag tag out tabs:""=(

format "%</%>\n" tabs tag  to:out

)

--begin_asset and end_asset are responsible for Asset element creation

--Assets mach  V-Ray plugins

--url: - a scene-unique string identifier for the asset

--pluginType: - generally the same as the underlying V-Ray Plugin's type. 

--pluginFamily: - usually it is the same as pluginType

--layout: -  this lets us know what user interface layout knows how to deal with this kind of asset

--out: - output file

fn begin_asset url pluginType pluginFamily layout out =(

format "\t<Asset url=\"%\" type=\"%\" layout=\"%\" renderer=\"vray\">\n\t\t<plugin>\n\t\t\t<vrayplugin name=\"%\" type=\"%\">\n\t\t\t\t<parameters>\n" url pluginFamily layout pluginType pluginFamily to:out

)

fn end_asset out =(

close_tag "parameters" out tabs:"\t\t\t\t"

close_tag "vrayplugin" out tabs:"\t\t\t"

close_tag "plugin" out tabs:"\t\t"

close_tag "Asset" out tabs:"\t"

)

--

listOfMAPCoordsStyles = #("Point3", "UV")

fn dumpComponentTransformParameterForMapCoords paramName map out=(

s= stringstream ""

local uvMap

if ((classof map) == VRayHDRI ) then uvMap = map.UVGen

else uvMap = map.coords

-- We don't fully support all the rotation, etc, in our material editor at this point. So I can set these values but they will not be editable.

-- At this time I am just bringing over values that will show up and be editable in our material editor.

format "\n" to:s

tabs ="\t\t\t\t\t\t\t\t"

format "\t\t\t\t\t\t\t<componentTransform>\n" to:s

format "%<x_rotation>%</x_rotation>\n"  tabs uvMap.u_angle to:s

format "%<y_rotation>%</y_rotation>\n"  tabs uvMap.v_angle to:s

local wRot = uvMap.w_angle

local sign = 1

if wRot < 0 then sign = -1

if abs(wRot) > 360 then (

wRot = abs(wRot) - 360

wRot = sign * wRot

)

if wRot > 0 then (

wRot = 360 - wRot

) else if wRot < 0 then (

wRot = -1 * wRot

)

format "%<z_rotation>%</z_rotation>\n"  tabs wRot to:s

format "%<x_offset>%</x_offset>\n" tabs uvMap.UVTransform[4][1] to:s

format "%<y_offset>%</y_offset>\n" tabs uvMap.UVTransform[4][2] to:s

format "%<z_offset>%</z_offset>\n"  tabs uvMap.UVTransform[4][3] to:s

--width = map.coords.realWorldWidth

--height = map.coords.realWorldHeight

--if not map.coords.realWorldScale then(

--width = 1.0 / width

--height = 1.0 / height

--)

format "%<x_scale>%</x_scale>\n" tabs uvMap.U_Tiling to:s

format "%<y_scale>%</y_scale>\n" tabs uvMap.V_Tiling to:s

format "%<z_scale>1</z_scale>\n"  tabs to:s

format "%<x_mirror>%</x_mirror>\n" tabs (boolToInteger uvMap.u_mirror ) to:s

format "%<y_mirror>%</y_mirror>\n" tabs (boolToInteger uvMap.v_mirror ) to:s

format "%<z_mirror>0</z_mirror>\n"  tabs to:s

format "\t\t\t\t\t\t\t</componentTransform>\n" to:s

format "\t\t\t\t\t\t" to:s

make_parameter_xml paramName "componentTransform" (s as string) out handler:"TextureTransformHandler"

)

fn dumpComponentTransformParameterForPoint3MapCoords paramName map out=(

s= stringstream ""

local uvMap

if ((classof map) == VRayHDRI ) then uvMap = map.UVGen

else uvMap = map.coords

-- We don't fully support all the rotation, etc, in our material editor at this point. So I can set these values but they will not be editable.

-- At this time I am just bringing over values that will show up and be editable in our material editor.

format "\n" to:s

tabs ="\t\t\t\t\t\t\t\t"

format "\t\t\t\t\t\t\t<componentTransform>\n" to:s

format "%<x_rotation>%</x_rotation>\n"  tabs uvMap.angle.x to:s

format "%<y_rotation>%</y_rotation>\n"  tabs uvMap.angle.y to:s

format "%<z_rotation>%</z_rotation>\n"  tabs uvMap.angle.z to:s

format "%<x_offset>%</x_offset>\n" tabs uvMap.offset.x to:s

format "%<y_offset>%</y_offset>\n" tabs uvMap.offset.y to:s

format "%<z_offset>%</z_offset>\n"  tabs uvMap.offset.z to:s

format "%<x_scale>%</x_scale>\n" tabs uvMap.tiling.x to:s

format "%<y_scale>%</y_scale>\n" tabs uvMap.tiling.y to:s

format "%<z_scale>%</z_scale>\n"  tabs uvMap.tiling.z to:s

format "%<x_mirror>0</x_mirror>\n" tabs to:s

format "%<y_mirror>0</y_mirror>\n" tabs to:s

format "%<z_mirror>0</z_mirror>\n"  tabs to:s

format "\t\t\t\t\t\t\t</componentTransform>\n" to:s

format "\t\t\t\t\t\t" to:s

make_parameter_xml paramName "componentTransform" (s as string) out handler:"TextureTransformHandler"

)

-- If you want to manually specify the url you can but be careful that it is unique for the vismat you are exporting.

fn dumpUVWGenChannelForMap parentURL map style out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenChannel"

)

local uvMap

if ((classof map) == VRayHDRI ) then uvMap = map.UVGen

else uvMap = map.coords

begin_asset uvwURL "UVWGenChannel" "UVW" "" out 

make_parameter_xml "uvw_channel" "integer" (uvMap.mapChannel as string) out 

if style == listOfMAPCoordsStyles[1] then(

dumpComponentTransformParameterForPoint3MapCoords "uvw_transform" map out

)

else(

if (uvMap.U_Tile) then (

make_parameter_xml "wrap_u" "integer" (1 as string) out

make_parameter_xml "crop_u" "integer" (0 as string) out

) else (

make_parameter_xml "wrap_u" "integer" (0 as string) out

make_parameter_xml "crop_u" "integer" (1 as string) out

)

if (uvMap.V_Tile) then (

make_parameter_xml "wrap_v" "integer" (1 as string) out

make_parameter_xml "crop_v" "integer" (0 as string) out

) else (

make_parameter_xml "wrap_v" "integer" (0 as string) out

make_parameter_xml "crop_v" "integer" (1 as string) out

)

make_parameter_xml "wrap_mode" "integer" (1 as string) out

dumpComponentTransformParameterForMapCoords "uvw_transform" map out

)

end_asset out  

return uvwURL

)

fn dumpUVWGenObjectForMap parentURL map style out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenObject"

)

begin_asset uvwURL "UVWGenObject" "UVW" "" out 

make_parameter_xml "duvw_scale" "float" (1.0 as string) out 

if style == listOfMAPCoordsStyles[1] then(

dumpComponentTransformParameterForPoint3MapCoords "uvw_transform" map out

)

else(

dumpComponentTransformParameterForMapCoords "uvw_transform" map out

)

end_asset out  

return uvwURL

)

fn dumpUVWGenChannel parentURL map_channel out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenChannel"

)

begin_asset uvwURL "UVWGenChannel" "UVW" "" out 

make_parameter_xml "uvw_channel" "integer" (map_channel as string) out 

end_asset out  

return uvwURL

)

fn dumpUVWGenObjectScale parentURL map_scale out uvwURL: undefined =(

if uvwURL == undefined then(

uvwURL = parentURL + "/UVWGenObject"

)

begin_asset uvwURL "UVWGenObject" "UVW" "" out 

make_parameter_xml "duvw_scale" "float" (map_scale as string) out 

end_asset out  

return uvwURL

)

fn dumpBitmapBuffer parentURL map out =(

bitmapURL = parentURL +"/BitmapBuffer"

begin_asset bitmapURL "BitmapBuffer" "bitmap" "" out 

resolvedPath = filenamefrompath map.fileName

--print "dumpBitmapBuffer------------------------------------->"

--print "saveDirForBMPFiles:"

--print saveDirForBMPFiles

--if saveDirForBMPFiles != undefined then(

--resolvedPath = saveDirForBMPFiles + "\\" + resolvedPath

--)

gammaval = vrayGetBitmapGamma map

make_parameter_xml "file" "string" resolvedPath out handler:"FileBrowserHandler"

-- The bitmap buffer filter type is in a different order than listed in the 3dsmax ui. It goes "No Filter", "Pyramid", "Summed area"

bitmap_buffer_filter_remap= #( 1, 2, 0 )

-- The +1 is to account for 3dsmax 1-based array index math

make_parameter_xml "filter_type" "integer"  bitmap_buffer_filter_remap[map.filtering+1] out handler:"ComboBoxHandler"

make_parameter_xml "filter_blur" "float"  map.coords.blur out

make_parameter_xml "color_space" "integer" 1 out

if (gammaval != undefined) then (

make_parameter_xml "gamma" "float"  (1.0/gammaval) out

)

end_asset out 

return bitmapURL

)

fn dumpTexCombineColor url colorVal texUrl texMult texOn out isColor:true=(

begin_asset url "TexCombineColor" "texture" "" out

if isColor then(

make_color_parameter_xml "color" colorVal out

)else(

colorVal = colorVal * 255

floatColor = Color colorVal colorVal colorVal

make_color_parameter_xml "color" floatColor out

)

if (texUrl != undefined) and (texOn) then(

make_parameter_xml "texture" "acolor texture" texUrl out

)else(

make_parameter_xml "texture" "acolor texture" "" out

)

make_parameter_xml "texture_multiplier" "float" texMult out

end_asset out

)

fn dumpTexVRayHDRI=undefined

fn dumpTexMulti=undefined

fn dumpTexFalloff=undefined

fn dumpTexChecker=undefined

arrBitMapTxtPaths = #()

listNormalBumpFeatures = #()

--saveDirForBMPFiles = undefined

-- Right now we are only going to be handling basic bitmaps

-- parentURL is the url of our parent

-- mapUse is a string to help us come up with unique urls...an example would be passing "Diffuse" if this was a diffuse map or "Reflection" if this was a map being used for reflection

fn dumpMap map parentURL mapUse out =(

if map == undefined then(

return undefined

)

--clOfMAP = classof map

--clOf = classof clOfMAP

--print "dumpMap----classof map METHOD:"

--print clOfMAP

--print clOf

mapUrl = parentURL + "/Texture"

case (classof map) of (

Bitmaptexture:(

--resolvedPath = filenamefrompath map.fileName

--filename = resolvedPath

--FileResolutionManager.getFullFilePath &resolvedPath #Bitmap

resolvedPath = mapPaths.getFullFilePath map.fileName

--print "Source path for bitmap file:"

--print resolvedPath

if resolvedPath != "" then (

appendIfUnique arrBitMapTxtPaths resolvedPath

)

else (

print "WARNING!"

format "Unresolved path for %\n" map.fileName

)

--print filename

dumpTexBitmap mapUrl map out

)

Speckle:(

dumpTexSpeckle mapUrl map out

)

Bricks:(

dumpTexTiles mapUrl map out

)

Mix:(

dumpTexMix mapUrl map out

)

Noise:(

dumpTexNoiseMax mapUrl map out

)

Cellular:(

dumpTexCellular mapUrl map out

)

VRayCompTex:(

dumpTexCompMax mapUrl map out

)

Color_Correction:(

dumpTexColorCorrection mapUrl map out

)

VRayMultiSubTex:(

dumpTexMulti mapUrl map out

)

VRayNormalMap:(

dumpMap map.normal_map parentURL mapUse out

)

Normal_Bump:(

listNormalBumpFeatures = #(map.normal_map,map.map1on,map.mult_spin,map.method)

)

Checker:(

dumpTexChecker mapUrl map out

)

Falloff:(

dumpTexFalloff mapUrl map out

)

VRayHDRI:(

resolvedHDRIPath = mapPaths.getFullFilePath map.HDRIMapName

if resolvedHDRIPath != "" then (

appendIfUnique arrBitMapTxtPaths resolvedHDRIPath

)

else (

print "WARNING!"

format "Unresolved path for %\n" map.HDRIMapName

)

dumpTexVRayHDRI mapUrl map out

)

default:(

format "Map of type %: " (classof map)

format "Unknown map - skipped\n"

)

)

)

-- url will be used as the TexBitmap url we don't build  url because this gets done in dumpMap 

fn dumpTexBitmap url map out =(

uvwURL = ""

if map.coords.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.coords.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

bitmapURL = dumpBitmapBuffer url map out 

begin_asset url "TexBitmap" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

make_parameter_xml "bitmap" "plugin" bitmapURL out 

-- Placement type in TexBitmap has 3 options, "Whole texture", "Crop", and "Place". I am not sure how "Whole texture" is possible in 3dsmax

-- so this will actually only allow "crop" or "place". We add 1 to bypass "Whole texture", map.cropPlace 0 for crop, 1 for place

make_parameter_xml "placement_type" "integer" (map.cropPlace + 1) out handler:"ComboBoxHandler"

if map.apply then (

make_parameter_xml "u" "float" map.clipu out

make_parameter_xml "v" "float" map.clipv out

make_parameter_xml "w" "float" map.clipw out

make_parameter_xml "h" "float" map.cliph out

if map.cropPlace == 1 and map.useJitter then (

make_parameter_xml "jitter" "float" map.jitter out

)

)

if map.coords.Noise_On then (

make_bool_parameter_xml "uv_noise_on" map.coords.Noise_On out

make_bool_parameter_xml "uv_noise_animate" map.coords.Noise_Animate out

make_parameter_xml "uv_noise_amount" "float" map.coords.Noise_Amount out

make_parameter_xml "uv_noise_levels" "float" map.coords.Noise_Levels out

make_parameter_xml "uv_noise_size" "float" map.coords.Noise_Size out

make_parameter_xml "un_noise_phase" "float" map.coords.phase out

)

make_parameter_xml "alpha_from_intensity" "integer" map.alphaSource out

make_acolortexture_parameter_xml "nouvw_color" (Color 0 0 0 0) out bAlpha:true

end_asset out 

)

fn dumpTexSpeckle url map out =(

uvwURL = ""

if map.coords.coordType == 2 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[1] out

)

else if map.coords.coordType == 0 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[1] out

)

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map.map1 != undefined then(

--print "dumpTexSpeckle"

--print map.map1

texUrl1 = finalUrl1 + "/Texture"

dumpMap map.map1 finalUrl1 "color1" out

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map.map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map.map2 finalUrl1 "color2" out

)

dumpTexCombineColor finalUrl1 map.color1 texUrl1 1.0 map.map1On out

dumpTexCombineColor finalUrl2 map.color2 texUrl2 1.0 map.map2On out

begin_asset url "TexSpeckle" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

make_parameter_xml "size" "float" map.size out

make_parameter_xml "color1" "acolor texture" finalUrl1 out

make_parameter_xml "color2" "acolor texture" finalUrl2 out

end_asset out 

)

fn dumpTexTiles url map out =(

uvwURL = ""

if map.coords.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.coords.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

mapMortar = map.Mortar_Map

mapTiles = map.Bricks

finalUrl1 = url + "/color_mortar"

texUrl1 = undefined

if mapMortar != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap mapMortar finalUrl1 "color_mortar" out 

)

finalUrl2 = url + "/color_tiles"

texUrl2 = undefined

if mapTiles != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap mapTiles finalUrl2 "color_tiles" out 

)

--dumpTexCombineColor url colorVal texUrl texMult texOn out isColor:true

mortarColor = map.Mortar_Color

tilesColor = map.Brick_Color

dumpTexCombineColor finalUrl1 mortarColor texUrl1 1.0 true out

dumpTexCombineColor finalUrl2 tilesColor texUrl2 1.0 true out

begin_asset url "TexTiles" "texture" "" out 

make_parameter_xml "texture_multiplier_mode" "integer" "1" out handler:"ComboBoxHandler" isUserData:true

make_parameter_xml "uvwgen" "plugin" uvwURL out 

--dumpTextureParamsListVals parentURL baseParamName out listOfVals isColor:true shouldGammaCorrect:false

dumpTextureParamsListVals url "color_mortar" out #(mortarColor, mapMortar, 1.0, true) isColor:true

dumpTextureParamsListVals url "color_tiles" out #(tilesColor, mapTiles, 1.0, true) isColor:true

make_parameter_xml "horizontal_count" "float" map.Horizontal_Count out

make_parameter_xml "vertical_count" "float" map.Vertical_Count out

make_parameter_xml "color_variance" "float" map.Color_Variance out

make_parameter_xml "fade_variance" "float" map.Fade_Variance out

make_parameter_xml "horizontal_gap" "float" map.Horizontal_Gap out

make_parameter_xml "vertical_gap" "float" map.Vertical_Gap out

make_parameter_xml "holes" "integer" map.Holes out

make_parameter_xml "edge_roughness" "float" map.Edge_Roughness out

make_parameter_xml "random_seed" "integer" map.Random_Seed out

make_parameter_xml "line_shift" "float" map.Line_Shift out

make_parameter_xml "random_shift" "float" map.Random_Shift out

make_parameter_xml "row_modify" "bool" map.Use_Row_Edit out

make_parameter_xml "per_row" "integer" map.Per_Row out

make_parameter_xml "row_change" "float" map.Change_Row out

make_parameter_xml "column_modify" "bool" map.Use_Column_Edit out

make_parameter_xml "per_column" "integer" map.Per_Column out

make_parameter_xml "column_change" "float" map.Change_Column out

end_asset out 

)

fn dumpTexMix url map out =(

map1 = map.map1

map2 = map.map2

mixMap = map.mask

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "color1" out 

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "color2" out 

)

finalUrl3 = url + "/mix_map"

texUrl3 = ""

if mixMap != undefined then(

texUrl3 = finalUrl3 + "/Texture"

dumpMap mixMap finalUrl3 "mix_map" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

mixColor = ( Color 0.5 0.5 0.5 )

map1On = map.map1Enabled

map2On = map.map2Enabled

mixOn = map.maskEnabled

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 1.0 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 1.0 map2On out

dumpTexCombineColor finalUrl3 mixColor texUrl3 1.0 mixOn out

begin_asset url "TexMix" "texture" "" out

dumpTextureParamsListVals url "color1" out #(mapColor1, map1, 1.0, map1On) isColor:true

dumpTextureParamsListVals url "color2" out #(mapColor2, map2, 1.0, map2On) isColor:true

dumpTextureParamsListVals url "mix_map" out #(mixColor, mixMap, 1.0, mixOn) isColor:true

make_parameter_xml "mix_amount" "float" ( map.mixAmount as float/100.0 ) out

useCurveVal =  boolToInteger(map.useCurve)

make_parameter_xml "use_curve" "integer" useCurveVal out

make_parameter_xml "transition_lower" "float" map.lower out

make_parameter_xml "transition_upper" "float" map.upper out

end_asset out 

)

fn dumpTexNoiseMax url map out =(

--uvwURL = dumpUVWGenChannel url map.coords.mapChannel out

uvwURL = ""

if map.coords.coordType == 2 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[1] out

)

else if map.coords.coordType == 0 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[1] out

)

map1 = map.map1

map2 = map.map2

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "color1" out 

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "color2" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

map1On = map.map1Enabled

map2On = map.map2Enabled

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 1.0 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 1.0 map2On out

begin_asset url "TexNoiseMax" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

dumpTextureParamsListVals url "color1" out #(mapColor1, map1, 1.0, map1On) isColor:true

dumpTextureParamsListVals url "color2" out #(mapColor2, map2, 1.0, map2On) isColor:true

make_parameter_xml "size" "float" map.size out

make_parameter_xml "phase" "float" map.phase out

make_parameter_xml "iterations" "float" map.levels out

make_parameter_xml "low" "float" map.thresholdLow out

make_parameter_xml "high" "float" map.thresholdHigh out

make_parameter_xml "type" "integer" map.type out

end_asset out 

)

fn dumpTexFalloff url map out =(

map1 = map.map1

map2 = map.map2

finalUrl1 = url + "/color1"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "color1" out 

)

finalUrl2 = url + "/color2"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "color2" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

mapMult1 = map.map1Amount as float/100.0

mapMult2 = map.map2Amount as float/100.0

map1On = map.map1On

map2On = map.map2On

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 mapMult1 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 mapMult2 map2On out

begin_asset url "TexFalloff" "texture" "" out

dumpTextureParamsListVals url "color1" out #(mapColor1, map1, mapMult1, map1On) isColor:true

dumpTextureParamsListVals url "color2" out #(mapColor2, map2, mapMult2, map2On) isColor:true

make_parameter_xml "type" "integer" map.type out

if map.direction == 4 then (

make_parameter_xml "direction_type" "integer" 3 out

)

else if map.direction == 3 then (

make_parameter_xml "direction_type" "integer" 4 out

)

else (

make_parameter_xml "direction_type" "integer" map.direction out

)

make_parameter_xml "fresnel_ior" "float" map.ior out

make_bool_parameter_xml "dist_extrapolate" map.extrapolateOn out

make_parameter_xml "dist_near" "float" map.nearDistance out

make_parameter_xml "dist_far" "float" map.farDistance out

end_asset out 

)

fn dumpTexChecker url map out =(

if map.coords.mappingType > 0 then return undefined

uvwURL = ""

if map.coords.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.coords.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

map1 = map.map1

map2 = map.map2

finalUrl1 = url + "/black_color"

texUrl1 = undefined

if map1 != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap map1 finalUrl1 "black_color" out 

)

finalUrl2 = url + "/white_color"

texUrl2 = undefined

if map2 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap map2 finalUrl2 "white_color" out 

)

mapColor1 = map.color1

mapColor2 = map.color2

map1On = map.map1Enabled

map2On = map.map2Enabled

dumpTexCombineColor finalUrl1 mapColor1 texUrl1 1.0 map1On out

dumpTexCombineColor finalUrl2 mapColor2 texUrl2 1.0 map2On out

begin_asset url "TexChecker" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

dumpTextureParamsListVals url "white_color" out #(mapColor2, map2, 1.0, map2On) isColor:true

dumpTextureParamsListVals url "black_color" out  #(mapColor1, map1, 1.0, map1On) isColor:true

make_parameter_xml "uv_noise_on" "integer" (boolToInteger map.coords.Noise_On) out

make_parameter_xml "uv_noise_amount" "float" map.coords.Noise_Amount out

make_parameter_xml "uv_noise_levels" "float" map.coords.Noise_Levels out

make_parameter_xml "uv_noise_size" "float" map.coords.Noise_Size out

make_parameter_xml "un_noise_phase" "float" map.coords.phase out

end_asset out 

)

fn dumpTexCellular url map out =(

uvwURL = ""

if map.coords.coordType == 2 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[1] out

)

else if map.coords.coordType == 0 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[1] out

)

mapCell = map.cellMap

mapDiv1 = map.divMap1

mapDiv2 = map.divMap2

finalUrl1 = url + "/center_color"

texUrl1 = ""

if mapCell != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap mapCell finalUrl1 "center_color" out 

)

finalUrl2 = url + "/edge_color"

texUrl2 = ""

if mapDiv1 != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap mapDiv1 finalUrl2 "edge_color" out 

)

finalUrl3 = url + "/bg_color"

texUrl3 = ""

if mapDiv2 != undefined then(

texUrl3 = finalUrl3 + "/Texture"

dumpMap mapDiv2 finalUrl3 "bg_color" out 

)

mapCellColor = map.cellColor

mapDiv1Color = map.divColor1

mapDiv2Color = map.divColor2

mapCellOn = map.map1Enabled

mapDiv1On = map.map2Enabled

mapDiv2On = map.map3Enabled

dumpTexCombineColor finalUrl1 mapCellColor texUrl1 1.0 mapCellOn out

dumpTexCombineColor finalUrl2 mapDiv1Color texUrl2 1.0 mapDiv1On out

dumpTexCombineColor finalUrl3 mapDiv2Color texUrl3 1.0 mapDiv2On out

begin_asset url "TexCellular" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

dumpTextureParamsListVals url "center_color" out #(mapCellColor, mapCell, 1.0, mapCellOn) isColor:true

dumpTextureParamsListVals url "edge_color" out #(mapDiv1Color, mapDiv1, 1.0, mapDiv1On) isColor:true

dumpTextureParamsListVals url "bg_color" out #(mapDiv2Color, mapDiv2, 1.0, mapDiv2On) isColor:true

make_parameter_xml "size" "float" map.size out

make_parameter_xml "spread" "float" map.spread out

make_parameter_xml "type" "integer" map.type out

make_bool_parameter_xml "fractal" map.fractal out

make_parameter_xml "fractal_iterations" "float" map.iteration out

make_parameter_xml "fractal_roughness" "float" map.roughness out

make_parameter_xml "low" "float" map.lowThresh out

make_parameter_xml "middle" "float" map.midThresh out

make_parameter_xml "high" "float" map.highThresh out

end_asset out 

)

fn dumpTexCompMax url map out =(

mapSourceA = map.sourceA

mapSourceB = map.sourceB

finalUrl1 = url + "/sourceA"

texUrl1 = ""

if mapSourceA != undefined then(

texUrl1 = finalUrl1 + "/Texture"

dumpMap mapSourceA finalUrl1 "sourceA" out 

)

finalUrl2 = url + "/sourceB"

texUrl2 = ""

if mapSourceB != undefined then(

texUrl2 = finalUrl2 + "/Texture"

dumpMap mapSourceB finalUrl2 "sourceB" out 

)

begin_asset url "TexCompMax" "texture" "" out

make_parameter_xml "sourceA" "acolor texture" texUrl1 out handler:"TextureHandler"

make_parameter_xml "sourceB" "acolor texture" texUrl2 out handler:"TextureHandler"

make_parameter_xml "operator" "integer" map.operator out

end_asset out

)

fn dumpTexColorCorrection url map out =(

colcormap = map.map

finalUrl = url + "/texture_map"

texUrl = ""

if colcormap != undefined then(

texUrl = finalUrl + "/Texture"

dumpMap colcormap finalUrl "texture_map" out 

)

begin_asset url "ColorCorrection" "texture" "" out

make_parameter_xml "texture_map" "acolor texture" texUrl out handler:"TextureHandler"

make_color_parameter_xml "source_color" map.color out gammaCorrect:false

make_parameter_xml "rewire_red" "integer" map.rewireR out

make_parameter_xml "rewire_green" "integer" map.rewireG out

make_parameter_xml "rewire_blue" "integer" map.rewireB out

make_parameter_xml "rewire_alpha" "integer" map.rewireA out

make_parameter_xml "hue_shift" "float" map.hueShift out

make_parameter_xml "saturation" "float" map.saturation out

make_color_parameter_xml "hue_tint" map.tint out gammaCorrect:false

make_parameter_xml "tint_strength" "float" map.tintStrength out

make_parameter_xml "brightness" "float" map.brightness out

make_parameter_xml "contrast" "float" map.contrast out

make_parameter_xml "lightness_mode" "integer" map.lightnessMode out

end_asset out 

)

fn dumpTexAColorFromColor url inColor out=(

begin_asset url "TexAColor" "texture" "" out

make_parameter_xml "texture" "acolor texture" (vraymax_color_to_xml_string inColor) out handler:"ColorPickerHandler"

end_asset out 

)

fn dumpTexMulti url map out =(

mapDefault = map.default_texmap

finalUrl = url + "/default_texture"

texUrl = ""

if mapDefault != undefined then(

texUrl = finalUrl + "/Texture"

dumpMap mapDefault finalUrl "default_texture" out 

)

local listOfTexMaps = map.texmap

local finalURLList = #()

local texURLList = #()

local entry = "multitex%"

s= stringstream ""

for i=1 to listOfTexMaps.count do (

format entry map.texmap_id[i] to:s

ifinalUrl = url + "/" + (s as string)

itexUrl = ""

if listOfTexMaps[i] != undefined then(

itexUrl = ifinalUrl + "/Texture"

dumpMap listOfTexMaps[i] ifinalUrl (s as string) out 

)

append finalURLList ifinalUrl

append texURLList itexUrl

free s

)

mapDefaultColor = map.default_color

mapDefaultMult = map.default_texmap_mult / 100.0f

mapDefaultOn = map.default_texmap_on

dumpTexCombineColor finalUrl mapDefaultColor texUrl mapDefaultMult mapDefaultOn out

for i=1 to listOfTexMaps.count do (

dumpTexCombineColor finalURLList[i] map.texmap_color[i] texURLList[i] (map.texmap_mult[i] / 100.0f) map.texmap_mapOn[i] out

)

begin_asset url "TexMulti" "texture" "" out

make_parameter_xml "mode" "integer" map.fro-m_id out

dumpTextureParamsListVals url "default_texture" out #(mapDefaultColor, mapDefault, mapDefaultMult, mapDefaultOn) isColor:true

make_list_parameter_xml "ids_list" "integer" "list" map.texmap_id out

make_list_parameter_xml "textures_list" "plugin" "list" finalURLList out

end_asset out 

)

fn dumpTexVRayHDRI url map out =(

uvwURL = ""

if map.UVGen.mapping == 0 then(

uvwURL = dumpUVWGenChannelForMap url map listOfMAPCoordsStyles[2] out

)

else if map.UVGen.mapping == 2 then(

uvwURL = dumpUVWGenObjectForMap url map listOfMAPCoordsStyles[2] out

)

--dump BitmapBuffer

local bitmapURL = url +"/TexBitmap/BitmapBuffer"

begin_asset bitmapURL "BitmapBuffer" "bitmap" "" out 

resolvedPath = filenamefrompath map.HDRIMapName

make_parameter_xml "file" "string" resolvedPath out handler:"FileBrowserHandler"

-- The bitmap buffer filter type is in a different order than listed in the 3dsmax ui. It goes "No Filter", "Pyramid", "Summed area"

--bitmap_buffer_filter_remap= #( 1, 2, 0 )

-- The +1 is to account for 3dsmax 1-based array index math

make_parameter_xml "filter_type" "integer"  1 out handler:"ComboBoxHandler"

make_parameter_xml "filter_blur" "float"  map.UVGen.blur out

make_parameter_xml "color_space" "integer" 0 out

make_parameter_xml "gamma" "float"  1.0 out

end_asset out 

local multiplier = map.multiplier * map.renderMultiplier

local colorspace = map.color_space

local custgamma = 1.0

if colorspace == 3 then (

local filetype = getFilenameType map.HDRIMapName

if toLower(filetype) ==  ".exr" then (

colorspace = 0

custgamma = 1.0

) else (

colorSpace=1;

custgamma = vrayGetBitmapGamma map

if (gammaval != undefined) then (

custgamma = 1.0 / custgamma

) else (

custgamma = 1.0

)

)

)

if colorspace == 1 then (

custgamma = map.gamma

)

--If we have any modifications to the color space or the gamma, apply a TexMaxGamma

local texMaxGammaCreate = (colorspace!=0 or abs(custgamma-1.0)>1e-6 or abs(multiplier-1.0)>1e-6)

local texBitmapURL = url

if texMaxGammaCreate then texBitmapURL = url +"/TexBitmap"

begin_asset texBitmapURL "TexBitmap" "texture" "" out

make_parameter_xml "uvwgen" "plugin" uvwURL out

make_parameter_xml "bitmap" "plugin" bitmapURL out 

-- Placement type in TexBitmap has 3 options, "Whole texture", "Crop", and "Place". I am not sure how "Whole texture" is possible in 3dsmax

-- so this will actually only allow "crop" or "place". We add 1 to bypass "Whole texture", map.cropPlace 0 for crop, 1 for place

local mapCropPlace = 0

if map.cropplace_on then (

case cropplace_mode of (

0: (

mapCropPlace = 1

)

1: (

mapCropPlace = 2

)

)

)

make_parameter_xml "placement_type" "integer" mapCropPlace out handler:"ComboBoxHandler"

make_parameter_xml "alpha_from_intensity" "integer" map.alphaSource out

make_acolortexture_parameter_xml "nouvw_color" (Color 0 0 0 0) out bAlpha:true

end_asset out

if texMaxGammaCreate then (

begin_asset url "TexMaxGamma" "texture" "" out

make_parameter_xml "input" "acolor texture" texBitmapURL out handler:"TextureHandler"

make_parameter_xml "multiplier" "float"  map.multiplier out

make_parameter_xml "color_space" "integer"  colorspace out

make_parameter_xml "gamma" "float"  custgamma out

end_asset out

)

)

fn getParamType param =(

case( classof param) of (

Color:(

return "color"

)

worldUnits:(

return "float"

)

Float:(

return "float"

)

BooleanClass:(

return "bool"

)

integer:(

return "integer"

)

default:(

return "plugin"

)

)

)

-- If you need to manually specify the type you can pass in the V-Ray parameter type otherwise we'll just try to get it from the classof param

fn dumpParam param paramName out paramType:undefined paramValue:undefined gammaCorrect:undefined isUserData:undefined handler:"default"= (

if param == undefined  then

return undefined

paramType = paramType

if paramType == undefined then(

paramType = getParamType param 

)

case( paramType ) of(

"color":(

make_color_parameter_xml paramName param out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

"plugin":(

-- to make this a bit easier I'm going to make sure I pass the url 

if paramValue != undefined then(

make_parameter_xml paramName "plugin" paramValue out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

"bool":(

-- bools don't go into integers without a bit of coercion.

make_bool_parameter_xml paramName param out isUserData:isUserData handler:handler

)

default:(

-- most of our types can just be made generically in their string form

make_parameter_xml paramName paramType (param as string) out gammaCorrect:gammaCorrect isUserData:isUserData handler:handler

)

)

)

-- Some of our color/tex param names don't follow the same protocol so we need to account for them if we want this automated

-- I couldn't see a way to make a lookup table, so I am just using 2 arrays and making sure I place the related names at the same index in each

param_lookup=#("roughness", "hilightGlossiness", "reflectionGlossiness", "reflectionIOR", "refractionGlossiness", "refractionIOR", "translucent", "translucency")

color_lookup=#("diffuse_roughness", "hilight_glossiness", "reflection_glossiness", "reflection_ior", "refraction_glossiness", "refraction_ior", "translucency_color", "translucency")

vraymtl_params = getPropNames(VRayMtl)

vray2sidedmtl_params = getPropNames(VRay2SidedMtl)

-- Some helpers that exist in our userdata params for BRDFVRayMtl do not actually exist as 3dsmax params, so we need to set defaults or our TexCombineColor 

-- may not get setup properly

-- although the name is "color", in the case of float params it does expect a float

default_color_names=#("opacity", "environment", "translucency")

default_color_values=#( 1.0,  (Color 0 0 0 ),  (Color 0 0 0 ) )

-- This will evaluate mat.property 

-- mat should be a VRayMtl instance

-- property should be a string

fn execVRayMtlParam mat property=(

-- execute only works on global scope

global execParam_current_object

execParam_current_object =  mat

specialParamIndex = findItem param_lookup property

-- some of our params don't follow the naming protocol that others follow

if specialParamIndex > 0 then(

property = color_lookup[specialParamIndex] 

)

propIdx = findItem vraymtl_params (property as name)

if propIdx <= 0 then(

return undefined

)

--return execute( "execParam_current_object." + property )

return getproperty mat property

)

fn execVRay2SidedMtlParam mat property=(

specialParamIndex = findItem param_lookup property

-- some of our params don't follow the naming protocol that others follow

if specialParamIndex > 0 then(

property = color_lookup[specialParamIndex] 

)

propIdx = findItem vray2sidedmtl_params (property as name)

if propIdx <= 0 then(

return undefined

)

return getproperty mat property

)

-- This will return a list that contains the colorVal / floatVal, the texture, the tex mult, and the  tex on flag

fn getTextureParamList mat maxParamName isColor:true=(

--print "getTextureParamList START"

--print mat

--print (classof mat)

--print maxParamName

case( classof mat )of(

VRayMtl:(

colorVal = execVRayMtlParam mat maxParamName

--print colorVal

texVal = execVRayMtlParam mat ("texmap_" + maxParamName)

--print texVal

texOnVal = execVRayMtlParam mat ("texmap_" + maxParamName + "_on" )

texMultVal = execVRayMtlParam mat ("texmap_" + maxParamName + "_multiplier" )

)

VRay2SidedMtl:(

colorVal = execVRay2SidedMtlParam mat maxParamName

--print colorVal

texVal = execVRay2SidedMtlParam mat ("texmap_" + maxParamName)

--print texVal

texOnVal = execVRay2SidedMtlParam mat ("texmap_" + maxParamName + "_on" )

texMultVal = execVRay2SidedMtlParam mat ("texmap_" + maxParamName + "_multiplier" )

)

Standardmaterial:(

if maxParamName == undefined then (

colorVal = (Color 0 0 0)

texVal = undefined

texOnVal = undefined

texMultVal = undefined

)

else(

colorVal = getproperty mat maxParamName

texVal = getproperty mat (maxParamName + "Map")

texOnVal = getproperty mat (maxParamName + "MapEnable")

texMultVal = getproperty mat (maxParamName + "MapAmount")

)

)

default:(

)

)

-- We default to texture on as true, texture mult as 1.0 and color as black 

if texOnVal == undefined then(

texOnVal = true

)

if texMultVal == undefined then(

texMultVal = 100

)

if colorVal == undefined then (

defColorIndex = findItem default_color_names maxParamName

if defColorIndex > 0 then(

colorVal = default_color_values[defColorIndex]

)else(

format "unknown default color value for parameter \"%\"\n" maxParamName

)

)

return #(colorVal, texVal, texMultVal, texOnVal )

)

-- url will be the total top-level url, 

-- paramName is the name of BRDFVRayMtl parameter

-- mat is the VRayMtl

-- maxParamName is the name of the parameter in the 3dsmax VRayMtl 

-- specify isColor:false for float parameters

fn dumpColorTexHandlerParam url paramName mat maxParamName out isColor:true=(

finalUrl = url + "/" + paramName

paramVals = getTextureParamList mat maxParamName isColor:isColor

colorVal = paramVals[1]

texVal = paramVals[2]

texMultVal = paramVals[3]

texOnVal = paramVals[4]

texUrl = undefined

if texVal != undefined then(

texUrl = finalUrl + "/Texture"

)

dumpMap texVal finalUrl paramName out 

dumpTexCombineColor finalUrl colorVal texUrl  (texMultVal as float / 100.0) texOnVal out isColor:isColor

)

-- This function dumps the 4 userdata params that are plugged into a TexCombineColor.

-- Generally, there will be a color/float, a texture, a texture multiplier, and a texture enable value. 

-- The final parameter set will reference the TexCombineColor asset that reduces to the actual BRDFVRayMtl parameter

fn dumpTextureParams parentURL baseParamName mat maxParamName out isColor:true shouldGammaCorrect:false=(

texCombineColorUrl = (parentURL + "/" + baseParamName)

handlerName = ""

colorParamName = ""

paramType = ""

if isColor then(

handlerName = "ColorTexFrameHandler"

colorParamName = baseParamName +"_color"

paramType = "acolor texture"

)else(

handlerName = "FloatTexFrameHandler"

colorParamName = baseParamName +"_float"

paramType = "float texture"

)

gammaCorrectValue = undefined

if shouldGammaCorrect then(

gammaCorrectValue = true

)

-- Our actual tex combine url

make_parameter_xml baseParamName paramType texCombineColorUrl out gammaCorrect:gammaCorrectValue handler:handlerName

-- the 3dsmax parameter values

paramVals = getTextureParamList mat maxParamName isColor:isColor 

colorVal = paramVals[1]

texVal = paramVals[2]

texMultVal = paramVals[3]

texOnVal = paramVals[4]

-- the underlying userdata params we use in our xml to store the info that will be fed to the TexCombineColor

texParamName = baseParamName+ "_tex" 

texMultParamName = baseParamName + "_tex_mult" 

texOnParamName = baseParamName + "_tex_on"

-- And the userdata params we use to setup the TexCombineColor

texUrl = ""

if texVal != undefined then(

texUrl = (texCombineColorURL+"/Texture" )

)

dumpParam texUrl texParamName out paramType:"acolor texture" paramValue:texUrl isUserData:true handler:"TextureHandler"

dumpParam (texMultVal as float / 100.0f) texMultParamName out isUserData:true 

dumpParam texOnVal texOnParamName out isUserData:true 

dumpParam colorVal colorParamName out isUserData:true

)

fn dumpTextureParamsListVals parentURL baseParamName out listOfVals isColor:true shouldGammaCorrect:false=(

texCombineColorUrl = (parentURL + "/" + baseParamName)

handlerName = ""

colorParamName = ""

paramType = ""

if isColor then(

handlerName = "ColorTexFrameHandler"

colorParamName = baseParamName +"_color"

paramType = "acolor texture"

)else(

handlerName = "FloatTexFrameHandler"

colorParamName = baseParamName +"_float"

paramType = "float texture"

)

gammaCorrectValue = undefined

if shouldGammaCorrect then(

gammaCorrectValue = true

)

-- Our actual tex combine url

make_parameter_xml baseParamName paramType texCombineColorUrl out gammaCorrect:gammaCorrectValue handler:handlerName

colorVal = listOfVals[1]

texVal = listOfVals[2]

texMultVal = listOfVals[3]

texOnVal = listOfVals[4]

-- the underlying userdata params we use in our xml to store the info that will be fed to the TexCombineColor

texParamName = baseParamName+ "_tex" 

texMultParamName = baseParamName + "_tex_mult" 

texOnParamName = baseParamName + "_tex_on"

-- And the userdata params we use to setup the TexCombineColor

texUrl = ""

if texVal != undefined then(

texUrl = (texCombineColorURL+"/Texture" )

)

dumpParam texUrl texParamName out paramType:"acolor texture" paramValue:texUrl isUserData:true handler:"TextureHandler"

dumpParam texMultVal texMultParamName out isUserData:true 

dumpParam texOnVal texOnParamName out isUserData:true 

dumpParam colorVal colorParamName out isUserData:true

)

-- This function actually writes out the Texture plugins, it needs to be called prior to serializing the owner asset

-- mat is the VRayMtl to grab maps from

-- parentURL is the url to use as the parent of the textures

fn dumpVRayMtlTexmaps mat parentURL out isTexValOpacity:true doExportEnvironment:false=(

if mat == undefined then(

return undefined

)

dumpColorTexHandlerParam parentURL "diffuse" mat "diffuse" out

dumpColorTexHandlerParam parentURL "roughness" mat "roughness" out isColor:false

dumpColorTexHandlerParam parentURL "reflect" mat "reflection" out 

dumpColorTexHandlerParam parentURL "hilight_glossiness" mat "hilightGlossiness" out  isColor:false

dumpColorTexHandlerParam parentURL "reflect_glossiness" mat "reflectionGlossiness" out isColor:false

dumpColorTexHandlerParam parentURL "anisotropy" mat "anisotropy" out isColor:false

dumpColorTexHandlerParam parentURL "anisotropy_rotation" mat "anisotropy_rotation" out isColor:false

dumpColorTexHandlerParam parentURL "fresnel_ior" mat "reflectionIOR" out  isColor:false

dumpColorTexHandlerParam parentURL "refract" mat "refraction" out 

dumpColorTexHandlerParam parentURL "refract_glossiness" mat "refractionGlossiness" out  isColor:false

dumpColorTexHandlerParam parentURL "refract_ior" mat "refractionIOR" out  isColor:false

dumpColorTexHandlerParam parentURL "translucency_color" mat "translucent" out

if isTexValOpacity then(

dumpColorTexHandlerParam parentURL "opacity" mat "opacity" out isColor:false

)

if doExportEnvironment then(

dumpColorTexHandlerParam parentURL "environment_override" mat "environment" out 

)

dumpUVWGenChannel parentURL mat.anisotropy_channel out uvwURL:(parentURL + "/AnisoUVWGen") 

-- These would actually require separate materials they are not currently supported as vismats

--.texmap_bump : texturemap

--.texmap_displacement : texturemap

-- maps

--dumpMap mat.texmap_environment  parentURL "Environment" out    

--dumpMap mat.texmap_opacity  parentURL "Opacity" out   

)

-- This function fills out the parameters for the BRDFVRayMtl itself

fn dumpBRDFVRayMtl mat out basemat:undefined = (

if mat == undefined then(

return undefined

)

local brdfURL = ""

if (basemat != undefined) then (

brdfURL = "/" + basemat + "/BRDFVRayMtl"

)

else (

brdfURL = "/" + mat.name + "/BRDFVRayMtl"

)

-- params not in BRDFVRayMtl

--.option_traceDiffuse : boolean

--.effect_id : integer

--.override_effect_id : boolean

--.option_clampTextures : boolean

texVal = execVRayMtlParam mat "texmap_opacity"

texValEnvironment = execVRayMtlParam mat "texmap_environment"

--print "######################dumpBRDFVRayMtl#########################"

--format "material % diffuse color: % \n" mat.name mat.diffuse

--format "material % diffuse texmap multiplier: % \n" mat.name mat.texmap_diffuse_multiplier

--print texVal

bTexVal = (texVal != undefined)

bExportEnvironment = (texValEnvironment != undefined)

--print bTexVal

-- Need to look for texmaps and write them out before we write out our brdf

dumpVRayMtlTexmaps mat brdfURL out isTexValOpacity:bTexVal doExportEnvironment:bExportEnvironment

begin_asset brdfURL "BRDFVRayMtl" "BRDF" "BRDFVRayMtlLayout" out 

-- reflection

dumpParam mat.reflection_subdivs "reflect_subdivs" out 

dumpParam mat.reflection_fresnel "fresnel" out 

dumpParam mat.reflection_maxDepth "reflect_depth" out 

dumpParam mat.reflection_exitColor "reflect_exit_color" out

dumpParam mat.reflection_fresnel "fresnel" out 

dumpParam mat.reflection_useInterpolation "refl_interpolation_on" out

dumpParam mat.reflection_lockGlossiness "hilight_glossiness_lock" out 

dumpParam mat.reflection_lockIOR "fresnel_ior_lock" out 

dumpParam mat.reflection_dimDistance "reflect_dim_distance" out 

dumpParam mat.reflection_dimDistance_on "reflect_dim_distance_on" out 

dumpParam mat.reflection_dimDistance_falloff "reflect_dim_distance_falloff" out 

dumpParam mat.reflection_affectAlpha "reflect_affect_alpha" out 

  

-- refraction

dumpParam mat.refraction_subdivs "refract_subdivs" out

dumpParam mat.refraction_fogColor "fog_color" out 

dumpParam mat.refraction_fogMult "fog_mult" out 

dumpParam mat.refraction_fogBias "fog_bias" out 

dumpParam mat.refraction_affectShadows "refract_affect_shadows" out 

dumpParam mat.refraction_affectAlpha "refract_affect_alpha" out 

dumpParam mat.refraction_maxDepth "refract_depth" out 

dumpParam mat.refraction_exitColor "refract_exit_color" out 

dumpParam mat.refraction_useExitColor "refract_exit_color_on" out 

dumpParam mat.refraction_useInterpolation "refr_interpolation_on" out 

dumpParam mat.refraction_dispersion "dispersion" out 

dumpParam mat.refraction_dispersion_on "dispersion_on" out 

dumpParam mat.translucency_on "translucency" out 

dumpParam mat.translucency_thickness "translucency_thickness" out 

dumpParam mat.translucency_scatterCoeff "translucency_scatter_coeff" out 

dumpParam mat.translucency_fbCoeff "translucency_scatter_dir" out 

dumpParam mat.translucency_multiplier "translucency_light_mult" out 

  

-- brdf

dumpParam mat.brdf_type "brdf_type" out

dumpParam mat.anisotropy_derivation "anisotropy_derivation" out 

dumpParam mat.anisotropy_axis "anisotropy_axis" out 

-- we build a uvwgenchannel based on mat.anisotropy_channel in our dumpMaps function

make_parameter_xml "anisotropy_uvwgen" "plugin"  (brdfURL + "/AnisoUVWGen")  out 

dumpParam mat.soften "hilight_soften" out 

-- options

dumpParam mat.brdf_fixDarkEdges "option_fix_dark_edges" out 

dumpParam mat.option_traceReflection "reflect_trace" out 

dumpParam mat.option_traceRefraction "refract_trace" out 

dumpParam mat.option_doubleSided "option_double_sided" out 

dumpParam mat.option_reflectOnBack "option_reflect_on_back" out 

dumpParam mat.option_useIrradMap "option_use_irradiance_map" out 

dumpParam mat.refraction_fogUnitsScale_on "fog_unit_scale_on" out 

dumpParam mat.option_cutOff "option_cutoff" out 

dumpParam mat.preservationMode "option_energy_mode" out 

dumpParam mat.option_environment_priority "environment_priority" out 

dumpParam mat.option_traceDiffuseAndGlossy "option_glossy_rays_as_gi" out

-- This is a userdata param that marks this material as 3dsmax compatible, it uses multipliers as a blend amount, not a scalar multiplier

make_parameter_xml "texture_multiplier_mode" "integer" "1" out handler:"ComboBoxHandler" isUserData:true

-- interpolation

dumpParam mat.reflect_minRate "refl_imap_min_rate" out 

    dumpParam mat.reflect_maxRate "refl_imap_max_rate" out 

    dumpParam mat.reflect_interpSamples "refl_imap_samples" out 

dumpParam mat.reflect_colorThreshold "refl_imap_color_thresh" out 

dumpParam mat.reflect_normalThreshold "refl_imap_norm_thresh" out 

  

dumpParam mat.refract_minRate "refr_imap_min_rate" out 

    dumpParam mat.refract_maxRate "refr_imap_max_rate" out 

    dumpParam mat.refract_interpSamples "refr_imap_samples" out 

dumpParam mat.refract_colorThreshold "refr_imap_color_thresh" out 

dumpParam mat.refract_normalThreshold "refr_imap_norm_thresh" out 

-- maps  

dumpTextureParams brdfURL "diffuse" mat "diffuse" out shouldGammaCorrect:true

dumpTextureParams brdfURL "roughness" mat "roughness" out isColor:false

dumpTextureParams brdfURL "reflect" mat "reflection" out 

dumpTextureParams brdfURL "hilight_glossiness" mat "hilightGlossiness" out  isColor:false

dumpTextureParams brdfURL "reflect_glossiness" mat "reflectionGlossiness" out isColor:false

dumpTextureParams brdfURL "anisotropy" mat "anisotropy" out isColor:false

dumpTextureParams brdfURL "anisotropy_rotation" mat "anisotropy_rotation" out isColor:false

dumpTextureParams brdfURL "fresnel_ior" mat "reflectionIOR" out  isColor:false

dumpTextureParams brdfURL "refract" mat "refraction" out 

dumpTextureParams brdfURL "refract_glossiness" mat "refractionGlossiness" out  isColor:false

dumpTextureParams brdfURL "refract_ior" mat "refractionIOR" out  isColor:false

dumpTextureParams brdfURL "translucency_color" mat "translucent" out 

if bTexVal then(

dumpTextureParams brdfURL "opacity" mat "opacity" out isColor:false

)

if bExportEnvironment then(

dumpTextureParams brdfURL "environment_override" mat "environment" out shouldGammaCorrect:true

)

-- The following maps would require additional material types / support that is currently not available for our material editor. We can add it in the future

--.texmap_bump : texturemap

--.texmap_bump_on : boolean

--.texmap_bump_multiplier : float

--.texmap_displacement : texturemap

--.texmap_displacement_on : boolean

--.texmap_displacement_multiplier : float  

  

end_asset out

return brdfURL

)

fn dumpBRDFDiffuse mat out basemat:undefined =(

if mat == undefined then(

return undefined

)

local brdfURL = ""

if (basemat != undefined) then (

brdfURL = "/" + basemat + "/BRDFDiffuse"

)

else (

brdfURL = "/" + mat.name + "/BRDFDiffuse"

)

--print "Enter dumpBRDFDiffuse"

colorVal = getproperty  mat "diffuse"

--format "diffuse color: %\n" colorVal

texColorVal = getproperty  mat "diffuseMap"

texColorValMult = getproperty  mat "diffuseMapAmount"

--format "diffuse map amount: %\n" texColorValMult

texColorValOn = getproperty  mat "diffuseMapEnable"

local texUrl = ""

if texColorVal != undefined then(

texUrl = (brdfURL+"/color/Texture")

dumpMap texColorVal (brdfURL+"/color") "color_tex" out

)

--dumpColorTexHandlerParam brdfURL "roughness" mat "diffuseRoughness" out isColor:false

begin_asset brdfURL "BRDFDiffuse" "BRDF" "DiffuseLayer" out

make_color_parameter_xml "color" colorVal out gammaCorrect:true

make_parameter_xml "color_tex" "acolor texture" texUrl out gammaCorrect:true

make_parameter_xml "color_tex_mult" "float" (texColorValMult as float / 100.0f) out

make_color_parameter_xml "transparency" (Color 0 0 0) out gammaCorrect:true

--dumpTextureParams brdfURL "roughness" mat "diffuseRoughness" out isColor:false

end_asset out

return brdfURL

)

fn dumpMtlSingleBRDF url brdfURL out =(

begin_asset url "MtlSingleBRDF" "material" "MtlSingleBRDFLayout" out

make_parameter_xml "brdf" "plugin" brdfURL out 

end_asset out

)

fn dumpVRayMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

-- We are going to write our VRayMtl out as a BRDFVRayMtl wrapped in a MtlSingleBRDF

local baseMtlURL=undefined

local singleMatURL = ""

if (basemat != undefined) then (

baseMtlURL = (basemat + "_" + mat.name)

singleMatURL = baseMtlURL

)

else (

singleMatURL = mat.name

)

--open_tag "vismat" out

brdfURL = dumpBRDFVRayMtl mat out basemat:baseMtlURL

singleMatURL = ("/" + singleMatURL)

dumpMtlSingleBRDF  singleMatURL brdfURL out 

--close_tag "vismat" out

return singleMatURL

)

fn dumpSubMaterial mat out basemat:undefined = (

local mtlURL = undefined

case( classof mat )of(

VRayMtl:(

local defDispl = mat.texmap_displacement

local defBump = mat.texmap_bump

if defDispl == undefined and defBump == undefined then(

mtlURL = dumpVRayMtl mat out basemat:basemat

)

else(

mtlURL =dumpMtlASGVIS mat out basemat:basemat

)

)

Standardmaterial:(

mtlURL = dumpMtlASGVIS mat out basemat:basemat

)

VRayMtlWrapper:(

mtlURL = dumpVRayMtlWrapper mat out basemat:basemat

)

Multimaterial:(

mtlURL = dumpMultiMtl mat out basemat:basemat

)

VRay2SidedMtl:(

mtlURL = dumpVRay2SidedMtl mat out basemat:basemat

)

default:(

if ( mat != undefined ) do (

print "WARRNING!"

format "Unsupported material % of class % - skipped\n" mat.name ((classof mat) as string)

)

)

)

return mtlURL

)

fn dumpVRay2SidedMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

local matURL = ""

local baseMtlURL = undefined

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

matURL = baseMtlURL

)

else (

matURL = mat.name

)

local frontMaterialURL = ""

case( classof mat.frontMtl )of(

VRayMtl:(

local defDispl = mat.frontMtl.texmap_displacement

local defBump = mat.frontMtl.texmap_bump

if defDispl == undefined and defBump == undefined then(

frontMaterialURL = dumpVRayMtl mat.frontMtl out basemat:baseMtlURL

)

else(

frontMaterialURL =dumpMtlASGVIS mat.frontMtl out basemat:baseMtlURL

)

)

Standardmaterial:(

frontMaterialURL = dumpMtlASGVIS mat.frontMtl out basemat:baseMtlURL

)

VRayMtlWrapper:(

frontMaterialURL = dumpVRayMtlWrapper mat.frontMtl out basemat:baseMtlURL

)

Multimaterial:(

frontMaterialURL = dumpMultiMtl mat.frontMtl out basemat:baseMtlURL

)

default:(

if ( mat.frontMtl != undefined ) do (

print "WARRNING!"

format "Unsupported front material % for VRay2SidedMtl with name % - skipped\n" mat.frontMtl.name mat.name

)

)

)

local backMaterialURL = ""

case( classof mat.backMtl )of(

VRayMtl:(

local defDispl = mat.backMtl.texmap_displacement

local defBump = mat.backMtl.texmap_bump

if defDispl == undefined and defBump == undefined then(

backMaterialURL = dumpVRayMtl mat.backMtl out basemat:baseMtlURL

)

else(

backMaterialURL =dumpMtlASGVIS mat.backMtl out basemat:baseMtlURL

)

)

Standardmaterial:(

backMaterialURL = dumpMtlASGVIS mat.backMtl out basemat:baseMtlURL

)

VRayMtlWrapper:(

backMaterialURL = dumpVRayMtlWrapper mat.backMtl out basemat:baseMtlURL

)

Multimaterial:(

backMaterialURL = dumpMultiMtl mat.backMtl out basemat:baseMtlURL

)

default:(

if ( mat.backMtl != undefined ) do (

print "WARRNING!"

format "Unsupported back material % for VRay2SidedMtl with name % - skipped\n" mat.backMtl.name mat.name

)

)

)

matURL = ("/" + matURL)

--dumpParam param paramName out paramType:undefined paramValue:undefined gammaCorrect:undefined isUserData:undefined handler:"default"

--dumpTextureParams parentURL baseParamName mat maxParamName out isColor:true shouldGammaCorrect:false

paramType = getParamType mat.translucency

--print paramType

strColorTrans = vraymax_color_to_xml_string mat.translucency

--print strColorTrans

finalUrl = matURL + "/translucency"

texUrl = ""

if mat.texmap_translucency != undefined then(

texUrl = finalUrl + "/Texture"

dumpMap mat.texmap_translucency finalUrl "translucency" out 

)

begin_asset  matURL "Mtl2Sided" "material" "TwoSidedMatLayout" out

--make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined

make_parameter_xml "front" "plugin" frontMaterialURL out handler:"MaterialPickerHandler"

make_parameter_xml "back" "plugin" backMaterialURL out handler:"MaterialPickerHandler"

make_color_parameter_xml "translucency" mat.translucency out

make_parameter_xml "translucency_tex" "acolor texture" texUrl out

make_parameter_xml "translucency_tex_mult" "float" (mat.texmap_translucency_multiplier as float / 100.0f) out

dumpParam mat.force1SidedSubMtls "force_1sided" out

end_asset out

return matURL

)

fn dumpMtlASGVIS mat out basemat:undefined =(

if mat == undefined then

return undefined

local brdfURL=undefined

local baseMtlURL=undefined

local asgvismatURL = ""

if (basemat != undefined) then (

baseMtlURL = (basemat + "_" + mat.name)

asgvismatURL = baseMtlURL

)

else (

asgvismatURL = mat.name

)

local listOfBumpProps = #()

case( classof mat )of(

VRayMtl:(

brdfURL = dumpBRDFVRayMtl mat out basemat:baseMtlURL

listOfBumpProps = #("texmap_bump","texmap_bump_multiplier","texmap_bump_on")

)

Standardmaterial:(

brdfURL = dumpBRDFDiffuse mat out basemat:baseMtlURL

listOfBumpProps = #("bumpMap","bumpMapAmount","bumpMapEnable")

)

default:(

format "Unsupported material % wrapped in MtlASGVIS - skipped\n" mat.name

)

)

texBumpVal = getproperty  mat listOfBumpProps[1]

texBumpValMult = getproperty  mat listOfBumpProps[2]

texBumpValOn = getproperty  mat listOfBumpProps[3]

asgvismatURL = ("/" + asgvismatURL)

local bumptexUrl = ""

listNormalBumpFeatures = #()

if texBumpVal != undefined then (

bumptexUrl = (asgvismatURL+"/Texture")

dumpMap texBumpVal asgvismatURL "bump_tex" out

if (listNormalBumpFeatures.count>0 ) then (

dumpMap listNormalBumpFeatures[1] asgvismatURL "bump_tex" out

)

)

--dumpParam param paramName out paramType:undefined paramValue:undefined gammaCorrect:undefined isUserData:undefined handler:"default"

--dumpTextureParams parentURL baseParamName mat maxParamName out isColor:true shouldGammaCorrect:false

begin_asset  asgvismatURL "MtlASGVIS" "material" "defvrmat" out

--make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined

--make_list_parameter_xml paramName listType paramType listOfValues out gammaCorrect:undefined handler:"default" isUserData:undefined

make_list_parameter_xml "brdfs" "plugin" "list" #(brdfURL) out

if (listNormalBumpFeatures.count>0 ) then (

make_parameter_xml "bump_tex" "plugin" bumptexUrl out handler:"TextureHandler"

make_parameter_xml "map_type" "integer" (listNormalBumpFeatures[4]+1) out

make_parameter_xml "bump_tex_mult" "float" listNormalBumpFeatures[3] out

make_bool_parameter_xml "bump_on" listNormalBumpFeatures[2] out

)

else (

make_parameter_xml "bump_tex" "plugin" bumptexUrl out handler:"TextureHandler"

make_parameter_xml "bump_tex_mult" "float" (texBumpValMult as float / 100.0f) out

make_bool_parameter_xml "bump_on" texBumpValOn out

)

end_asset out

return asgvismatURL

)

fn dumpVRayMtlWrapper mat out basemat:undefined =(

if mat == undefined then

return undefined

local baseMtlURL = undefined

local wrapMtlURL = ""

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

wrapMtlURL = baseMtlURL

)

else (

wrapMtlURL = mat.name

)

-- We are going to write our VRayMtl out as a BRDFVRayMtl wrapped in a MtlSingleBRDF

--wrapMtlURL = ("/" + mat.name)

--singleMatURL = ("/" + mat.baseMtl.name)

--open_tag "vismat" out

local brdfURL=undefined

case( classof mat.baseMtl )of(

VRayMtl: (

local defDispl = mat.baseMtl.texmap_displacement

local defBump = mat.baseMtl.texmap_bump

if defDispl == undefined and defBump == undefined then(

brdfURL = dumpVRayMtl mat.baseMtl out basemat:baseMtlURL

)

else(

brdfURL =dumpMtlASGVIS mat.baseMtl out basemat:baseMtlURL

)

)

Standardmaterial: brdfURL = dumpMtlASGVIS mat.baseMtl out basemat:baseMtlURL

VRay2SidedMtl:(

brdfURL = dumpVRay2SidedMtl mat.baseMtl out basemat:baseMtlURL

)

Multimaterial:(

brdfURL = dumpMultiMtl mat.baseMtl out basemat:baseMtlURL

)

default:(

if ( mat.baseMtl != undefined ) do (

print "WARRNING!"

format "Unsupported base material % for VRayMtlWrapper with name % - skipped\n" mat.baseMtl.name mat.name

)

)

)

wrapMtlURL = "/" + wrapMtlURL

begin_asset  wrapMtlURL "MtlWrapper" "material" "MtlWrapperLayout" out

make_parameter_xml "base_material" "plugin" brdfURL out handler:"MaterialPickerHandler"

dumpParam mat.generateGIMult "generate_gi" out 

dumpParam mat.receiveGIMult "receive_gi" out

--dumpParam mat.generateCaustics "generate_caustics" out --bool/float

dumpParam mat.causticsMult "receive_caustics" out

dumpParam mat.matteSurface "matte_surface" out

--dumpParam mat.secondaryMatte "matte_for_secondary_rays" out --bool/int

dumpParam mat.alphaContribution "alpha_contribution" out

dumpParam mat.matteSurface "matte_surface" out

dumpParam mat.matte_shadows "shadows" out

dumpParam mat.matte_shadowsAffectAlpha "affect_alpha" out

dumpParam mat.matte_shadowColor "shadow_tint_color" out

dumpParam mat.matte_shadowBrightness "shadow_brightness" out

dumpParam mat.matte_reflectionMultiplier "reflection_amount" out

dumpParam mat.matte_refractionMultiplier "refraction_amount" out

dumpParam mat.matte_giMultiplier "gi_amount" out

dumpParam mat.matte_noGIOnOtherMattes "no_gi_on_other_mattes" out

dumpParam mat.matte_giSurfaceID "gi_surface_id" out

end_asset out

return wrapMtlURL

fn dumpMultiMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

local baseMtlURL = undefined

local multiMtlURL = ""

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

multiMtlURL = baseMtlURL

)

else (

multiMtlURL = mat.name

)

local listMtlMulti = mat.materialList

local urlList = #()

for i=1 to listMtlMulti.count do (

local brdfURL=undefined

case( classof listMtlMulti[i] )of(

VRayMtl: (

local defDispl = listMtlMulti[i].texmap_displacement

local defBump = listMtlMulti[i].texmap_bump

if defDispl == undefined and defBump == undefined then(

brdfURL = dumpVRayMtl listMtlMulti[i] out basemat:baseMtlURL

)

else(

brdfURL =dumpMtlASGVIS listMtlMulti[i] out basemat:baseMtlURL

)

)

Standardmaterial: brdfURL = dumpMtlASGVIS listMtlMulti[i] out basemat:baseMtlURL

VRay2SidedMtl:(

brdfURL = dumpVRay2SidedMtl listMtlMulti[i] out basemat:baseMtlURL

)

default:(

if ( listMtlMulti[i] != undefined ) do (

print "WARRNING!"

format "Unsupported material % for MtlMulti with name % - skipped\n" (listMtlMulti[i]).name mat.name

)

)

)

append urlList brdfURL

)

multiMtlURL = "/" + multiMtlURL

begin_asset  multiMtlURL "MtlMulti" "material" "MultiMatLayout" out

--make_parameter_xml paramName paramType paramValue out gammaCorrect:undefined handler:"default" isUserData:undefined

--make_list_parameter_xml paramName listType paramType listOfValues out gammaCorrect:undefined handler:"default" isUserData:undefined

make_list_parameter_xml "ids_list" "integer" "list" mat.materialIDList out

make_list_parameter_xml "mtls_list" "plugin" "list" urlList out

end_asset out

return multiMtlURL

)

fn dumpVRayBRDFLayered mat out basemat:undefined =(

if mat == undefined then

return undefined

local brdfLayeredURL = ""

if (basemat != undefined) then (

brdfLayeredURL = basemat + "/BRDFLayered"

)

else (

brdfLayeredURL = mat.name + "/BRDFLayered"

)

local listCoatBlendTexMaps = mat.texmap_blend

local listCoatBlendColors = mat.blend

local listCoatBlendTexMultipliers = mat.texmap_blend_multiplier

local paramName = ""

local finalUrl = ""

local texURL = ""

local brdfURL = ""

local urlList = #()

local texURLList = #()

local listCoatAvailableMtls = for availMtl in mat.coatMtl where availMtl != undefined collect availMtl

for i=listCoatAvailableMtls.count to 1 by -1 do (

paramName = "texmap_blend_" + ((i-1) as string)

finalUrl = "/" + brdfLayeredURL + "/" + paramName

texURL = finalUrl + "/Texture"

if ( listCoatBlendTexMaps[i] == undefined ) then (

dumpTexAColorFromColor texURL listCoatBlendColors[i] out

append texURLList texURL

) else (

dumpMap listCoatBlendTexMaps[i] finalUrl paramName out 

dumpTexCombineColor finalUrl listCoatBlendColors[i] texURL  (listCoatBlendTexMultipliers[i] as float / 100.0) true out

append texURLList finalUrl

)

brdfURL=dumpSubMaterial listCoatAvailableMtls[i] out basemat:basemat

append urlList brdfURL

)

brdfURL=dumpSubMaterial mat.baseMtl out basemat:basemat

append urlList brdfURL

append texURLList ""

brdfLayeredURL = "/" + brdfLayeredURL

begin_asset brdfLayeredURL "BRDFLayered" "BRDF" "BRDFLayeredLayout" out

make_list_parameter_xml "weights" "plugin" "list" texURLList out

make_list_parameter_xml "brdfs" "plugin" "list" urlList out

make_bool_parameter_xml "additive_mode" mat.additiveMode out

end_asset out

return brdfLayeredURL

)

fn dumpVRayBlendMtl mat out basemat:undefined =(

if mat == undefined then

return undefined

-- We are going to write our VRayBlendMtl out as a BRDFLayered wrapped in a MtlSingleBRDF

local baseMtlURL = undefined

local singleMatURL = ""

if (basemat != undefined) then (

if (basemat == "") then

baseMtlURL = mat.name

else

baseMtlURL = basemat + "_" + mat.name

singleMatURL = baseMtlURL

)

else (

singleMatURL = mat.name

)

local brdfURL = dumpVRayBRDFLayered mat out basemat:baseMtlURL

singleMatURL = ("/" + singleMatURL)

dumpMtlSingleBRDF  singleMatURL brdfURL out 

return singleMatURL

)

 

-- for now we only work on VRayMtl types

fn dumpMaterials = (

saveDir = getSavePath caption:"Vismat Export Directory" 

if saveDir == undefined then(

return undefined

)

format "Exporting scene materials...\n"

for i=1 to 24 do (

m = meditmaterials[i]

case( classof m )of(

VRayMtl:(

format "Processing %: " m.name

fileName =  (saveDir + "\\" + m.name + ".vismat")

format "saving vismat to %\n" fileName

f = openFile fileName mode:"w"

open_tag "vismat" f

dumpVRayMtl m f

close_tag "vismat" f

flush f

close f

)

VRay2SidedMtl:(

format "Processing %: " m.name

fileName =  (saveDir + "\\" + m.name + ".vismat")

format "saving vismat to %\n" fileName

f = openFile fileName mode:"w"

open_tag "vismat" f

dumpVRay2SidedMtl m f

close_tag "vismat" f

flush f

close f

)

default:(

)

)

)

format "Done\n"

)

fn clearArrBitMapTxtPaths = (

arrBitMapTxtPaths = #()

)

fn createBmpFilesInVismatFolder saveDir = (

if saveDir == undefined then(

return undefined

)

--print arrBitMapTxtPaths.count

for i=1 to arrBitMapTxtPaths.count do (

bmpFile = filenamefrompath arrBitMapTxtPaths[i]

--print "File name:"

--print bmpFile

bmpFileTargetPath = saveDir + "\\" + bmpFile

--print "Target path:"

--print bmpFileTargetPath

--print (doesFileExist bmpFileTargetPath)

if (doesFileExist bmpFileTargetPath) then

deleteFile bmpFileTargetPath

copyresult = copyFile arrBitMapTxtPaths[i]  bmpFileTargetPath

if copyresult then

format "copying the file % \n from % \n to % \n was Successfully \n" bmpFile (getFilenamePath arrBitMapTxtPaths[i]) saveDir

else

format "copying the file % \n from % \n to % \n was NOT Successfully \n" bmpFile (getFilenamePath arrBitMapTxtPaths[i]) saveDir

)

)

fn openVismatTag f = (

open_tag "vismat" f

)

fn closeVismatTag f = (

close_tag "vismat" f

)

fn dumpSelectedMaterial mat f  vismatmode:undefined= (

if mat == undefined then

return undefined

case( classof mat )of(

VRayMtl:(

defDispl = mat.texmap_displacement

defBump = mat.texmap_bump

if defDispl == undefined and defBump == undefined then(

dumpVRayMtl mat f

)

else(

dumpMtlASGVIS mat f

)

)

VRay2SidedMtl:(

if vismatmode == undefined then

dumpVRay2SidedMtl mat f

else

dumpVRay2SidedMtl mat f basemat:""

)

VRayMtlWrapper:(

if vismatmode == undefined then (

dumpVRayMtlWrapper mat f

)

else

dumpVRayMtlWrapper mat f basemat:""

)

Standardmaterial:(

dumpMtlASGVIS mat f

)

Multimaterial:(

dumpMultiMtl mat f

)

VRayBlendMtl:(

if vismatmode == undefined then

dumpVRayBlendMtl mat f

else

dumpVRayBlendMtl mat f basemat:""

)

default:(

format "Convertion for % is not done: " mat.name

format "Unknown material - skipped\n"

)

)

)

macroScript ExportVismats category:"VRay"  buttontext:"Export VRMAT from scene materials" tooltip:"Exports vrmat files" (

dumpMaterials()

)

fn registerMenuItems = (

if menuMan.registerMenuContext 0x67e0e9ff then(

local quadMenu=menuMan.getViewportRightClickMenu #nonePressed

if (quadMenu!=undefined) do (

local menu=quadMenu.getMenu 1

)

local menuIndex

if (menu!=undefined) do (

menuIndex=findMenuItemIdx menu "V-Ray scene converter"

appendMenuItem menu "ExportVismats" "VRay"

)

)

)

--registerMenuItems()

Yehat правильно написалsmiley-dirol.gif

На сайте c 18.03.2013
Сообщений: 25
Киев

Уже по тексту в ссылке видно что V-ray установлен не верно. Ну и если окошко всплывает с предупреждением. Как вы тогда можете утверждать что у вас установилось все верно? Предупреждение.  Отправляет вас к скрипту StartUP который запускает вирей.

Как уже было написано выше у вас 3D max установлен в РУССКУЮ ПАПКУ. Переустановите 3Ds max в папку в которой в пути не будет русских букв (шрифтов). И это касается ВСЕХ программ и плагинов. ЗАПОМНИТЕ это правило никогда не ставить софт в папки где на пути встречается русский язык. Только английский. Название компьютера тоже должно быть на АНГЛИЙСКОМ. Во избежание будущих проблем с другими плагинами и программами. 

На сайте c 05.05.2017
Сообщений: 3
ninja_3, спасибо, переустановлю и переименую
На сайте c 14.11.2010
Сообщений: 602
Москва
Уффффф.... это что за кошмар ..... палец устал кружок поднимать (((
Читают эту тему: