3ds Max - Max Script - Light mapping issue - rendered image is complete map not light map only

Wednesday, 28 December 2011 10:25 by Chad

I wanted to export the lighting component of a mesh as a light map for use in a game, so I've scripted a 3ds Max script to automate the creation of hundreds of lightmaps. However the generated image is as it appears in the render window - it is the complete map, not just the lighting component.

Your max script may look like the following - replace the lm.fileType with the full path instead of just the extension, do not pass in the outputFile to the render call.

local lm = LightingMap()
 lm.outputSzX = 100
 lm.outputSzY = 100
 lm.autoSzOn = off
 lm.fileType = ".png"
 lm.fileType = "C:\Full\Path\To\Output\Dir\Lightmap1.png"
 lm.shadowsOn = on
 lm.directOn = on
 lm.indirectOn = on
 lm.enabled = on
 
 bakeProps = obj.INodeBakeProperties
  bakeProps.bakeEnabled = true
  bakeProps.flags = 1
  bakeProps.bakeChannel = 3
  bakeProps.nDilations = 16
  bakeProps.addBakeElement lm
 
 local renderedMap = render \
  rendertype:#bakeSelected \
  outputwidth: lm.outputSzX \
  outputheight: lm.outputSzY \
  vfb:on \
  outputFile: outputPath\
  filterMaps:on \
  antiAliasFilter:(catmull_rom())