Notifications
Clear all

[Closed] Setting padding for texture baking from script

I am writing a script that automatically generates lightmaps for a game I am working on. However, I do not know how to set some settings for texture baking. I want to set, from my script, the amount of padding and the channel to bake for (“Use existing channel” and then setting it to “2”). However, the MAXscript interface seems limited here (3dsmax7) and I cannot get to these settings. This is what I have right now to do the baking:

obj = $
select obj
map = LightingMap()
map.autoSzOn = false
map.directOn = true
map.elementName = "baked"
map.enabled = true
map.filename = (obj.name + "_lightmap.tga")
map.filenameUnique = false
map.filetype = "TGA"
map.filterOn = true
map.inDirectOn = true
map.outputSzX = 128
map.outputSzY = 128
map.shadowsOn = true
map.targetMapSlotName = ""
 
local bakeobject = obj.INodeBakeProperties
bakeobject.removeAllBakeElements()
bakeobject.addBakeElement map
render rendertype:#BakeSelected outputwidth:map.outputSzX outputheight:map.outputSzY vfb:true outputfile:map.filetype
 
bakeobject.removeAllBakeElements()

However, I do not see how to set padding and channel this way. So I took a look at the definition of the macroscript for the interface in the file “Macro_BakeTextures.mcr”. I found out the spinner that controls this is called “sDilations” and it is in the rollout “selectedObjectProps”. Calling this gives undefined, though: “selectedObjectProps.sDilations”.

Can someone tell me how to set these settings?

Thanks in advance!

2 Replies

thepadding=16
obj.InodeBakeproperties.nDilations=thePadding
thechannel=3
obj.InodeBakeproperties.bakeChannel=theChannel

Auch. I feel so stupid…

I looked in the right place in the manual, but I did not know that dilations was padding, so I had not recognised it. Later on I looked in the script and saw that dilations was padding, but I had not remembered that I had seen that setting before.

Anyway, thank you very much!