Bake LightingMap for mutliple objects at different resolution with one render call

I'm having a problem where textures come out stretched/shrunk vertically, when I try to bake LightingMap for multiple objects at once, when the output size is set differently on each object. I do this by selecting all the object and calling:

render rendertype:#bakeSelected

I set the output size by doing this:

map = LightingMap()
map.outputSzX = size
map.outputSzY = size

obj.INodeBakeProperties.addBakeElement map
obj.INodeBakeProperties.activeWidth = size
obj.INodeBakeProperties.activeHeight = size

where [size] changes from one object to another.

The problem is that the renderer seems to internally always use either the global render settings height, or the one passed into the "render" call via the outputHeight: named argument, and then squishes the texture back into a square that fits into my [size] value. So for instance, if I set size to 256, and call render with outputHeight:512, the output image file will have actual size of 256x256, but the lightmap information will be squished vertically into the upper half of the image.

Obviously, the solution is to always pass in outputWidth: and outputHeight: arguments matching the outputSzX and outputSzY on the LightingMap, but that's impossible to do when you select multiple objects and render them in one go, and want to have the lightmap size different for each object.

The reason why I really want to render multiple objects at once, rather than each one individually, is that I found out the complete job takes up to 10 times less time (I assume that's because the renderer can reuse some persistent state, that gets discarded when you restart the renderer). Does anyone know of a way to get around this bug?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Maarten's picture

Try this?

Hi,

You could try specifying the outputsize in the render command as one of the parameters and see if it yields better results. I took a look at the maxscript help regarding rendering and this should work (in terms of syntax at least, and does change render output size).
http://docs.autodesk.com/3DSMAX/16/ENU/MAXScript-Help/index.html?url=fil...
Hope it helps, good luck
-Maarten

render rendertype:#bakeSelected outputwidth:100 outputheight:300

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.