Notifications
Clear all

[Closed] auto baking script won't work

Hi

I assembled a script that should output me for each frame and each object a lightmap bake and a rendering in which the object is alone:

fn renderLightmap obj currentMapType Xsize Ysize channel fullFileName =
(
	fPath=getFilenamePath fullFileName
	fName=getFilenameFile fullFileName
	fType=getFilenameType fullFileName
	bi = obj.INodeBakeProperties
	currentMapType.outputSzX=Xsize
	currentMapType.outputSzY=Ysize
	currentMapType.filename=fName
	currentMapType.fileType=fType
	bi.addBakeElement currentMapType
	bi.bakeChannel=channel
	bi.bakeEnabled = true
	bi.nDilations = 12
	
	g=1.0/2.2
	bm = bitmap Xsize Ysize gamma:g filename:(fPath+fName+fType)
	
	render rendertype:#bakeSelected outputwidth:Xsize outputheight:Ysize vfb:false to:bm
	
	save bm
	close bm
	
	bi.removeAllBakeElements()
	bi.bakeEnabled = false

	format "rendering node:% channel:%
" obj.name bi.bakeChannel
)

fn renderAlone obj Xsize Ysize fullFileName =
(
	fPath=getFilenamePath fullFileName
	fName=getFilenameFile fullFileName
	fType=getFilenameType fullFileName
	
	allObjects = Geometry
	allObjects.primaryVisibility = False
	obj.primaryVisibility = True
	
	g=1.0/2.2
	bm = bitmap Xsize Ysize gamma:g filename:(fPath+fName+fType)
	
	render outputwidth:Xsize outputheight:Ysize vfb:false to:bm
	
	save bm
	close bm
	
	allObjects.primaryVisibility = True
)

macroScript bakeSelected category: "AutoRender"
(
	t = sliderTime
	 
	--bake map
		print ("baking "+selection[1].name)
		alightMap = LightingMap()
		renderLightmap selection[1] alightMap 128 128 1 ("C:\	mp\\"+selection[1].name+"_unwrap_f"+(t as string)+".tga")

	 print "finished baking"
	--render object alone
		print ("rendering "+selection[1].name)
		renderAlone selection[1] 640 480 ("C:\	mp\\"+selection[1].name+"_single_f"+(t as string)+".tga")
)

macroScript bakeAll category: "AutoRender"
(
	 for t = animationrange.start to animationrange.end do
	 (
			sliderTime = t
			 
		    --bake map
			for obj in Geometry do(
				print ("baking "+obj.name)
				alightMap = LightingMap()
				renderLightmap obj alightMap 128 128 1 ("C:\	mp\\"+obj.name+"_unwrap_f"+(t as string)+".tga")
			)
	 )
	 
	 print "finished baking"
	 
	for t = animationrange.start to animationrange.end do
	(
			--render object alone
			for obj in Geometry do(
				print ("rendering "+obj.name)
				renderAlone obj 640 480 ("C:\	mp\\"+obj.name+"_single_f"+(t as string)+".tga")
			)
	)
)

now – the strange thing is, bakeSelected works fine – but bakeAll outputs only black images. any idea why??