Notifications
Clear all

[Closed] Render to Texture script interface in Max 8

I’m wondering if anyone here has any clue on how to invoke the renderer to do a render to texture. I’d like to be able to quickly render UV channel 2 into UV channel 1. I can easily get at the iNodeBakeProperties and set them up to fill in the blanks for the render to texture dialog but I’d like to be able to invoke the render directly and have it save the image to a supplied path. I’ve hunted high and low through the Macro_BakeTextures.mcr script to try to find out how exactly to invoke a render of the bake properties but it’s a bit convoluted it seems (one function points to the next and so on) and I can’t find any documentation in the help files. Any help would be greatly appreciated!! Here’s what I’ve got so far. Thanks again.

 fn _renderCamProjectionMap = 
 (
     projectMap = DiffuseMap()

–use the currntly selected mesh in the scene. Need to make this an argument
projectSurface = $.INodeBakeProperties
projectSurface.addBakeElement projectMap
projectSurface.numElementParams projectMap
projectSurface.setParamValue projectMap 1 0
projectSurface.setParamValue projectMap 2 0
projectMap.fileName = “FrontProjection”
–projectMap.fileType = “.tga”
projectMap.outputSzX = 128
projectMap.outputSzY = 128
projectSurface.bakeChannel = 1
)

3 Replies

The Render To Texture tool in Max is a actually a MAXScript! Just locate its source and read how it was implemented. There is an undocumented mode flag to the render() method which lets it perform texture baking. I have no idea why it was never documented though

Thanks Bobo! I’ll take another look at the Macro_BakeTextures.mcr to try and find that method. I’ve been in there all day and haven’t been able to find where they actually invoke the render (since I have no idea what’s a local function and what’s a max script method) but now that I know it’s an undocumented method I won’t waist any more time trying to cross reference the help file.

Looks like line 2303 has the answer. It appears the rendertype:#bakeselected is the undocumented info.

render rendertype:#bakeSelected frame:nFrame to:curBM vfb:vfbOn cancelled:&wasCanceled
Hope that helps,
-Eric

Edit: It seems to require the to:(bitmap width height) parameter where the width and height match the parameters set in the UI.