[Closed] Lightmap texture baking result is different
Hello everyone.
I have a problem with a script that bakes textures. I read a lot of threads about this subject and I managed to get a script that almost works. Let me explain. When I use the standard Render To Texture interface, the texture I have in my bitmap file is not the same as the image I have in the render window (the preview). However, when using my script, the image I get in the bitmap file is exactly the result from the render window. Here is my script and the 4 result images to demonstrate the problem.
I tried to use the “RTT_methods” function as seen in Macro_BakeTextures.mcr but with no success.
fn renderToTextureRadiosityLightMap fullFileName objToBake showRendering width height = (
fPath = getFilenamePath fullFileName
fName = getFilenameFile fullFileName
fType = getFilenameType fullFileName
LM_Var = LightingMap()
LM_Var.filename = RTT_methods.MakeBakeElementFileName objToBake LM_Var (fPath+fName+fType) "" fType
LM_Var.enabled = true
LM_Var.outputSzX = width
LM_Var.filenameUnique = false
LM_Var.outputSzY= height
LM_Var.filterOn = true
LM_Var.autoSzOn = false
LM_Var.targetMapSlotName = ""
LM_Var.shadowsOn = true
LM_Var.directOn = true
LM_Var.indirectOn = true
bakeProperties = objToBake.INodeBakeProperties
bakeProperties.addBakeElement LM_Var
bakeProperties.bakeChannel = 2
bakeProperties.bakeEnabled = true
bakeProperties.nDilations = 2
bmap = bitmap width height
bmap.filename = (fPath+fName+"_bmp"+fType)
wasCanceled = false
render rendertype:#bakeSelected to:bmap vfb:showRendering cancelled:&wasCanceled disableBitmapProxies:true
save bmap
bakeProperties.removeAllBakeElements()
bakeProperties.bakeEnabled = false
)
Please note that I can uncheck “Mapping” in the renderer to remove the brick texture from rendering but it doesn’t fix the problem at its base.
Result in the Render window(preview) from “Render To Texture” dialog
Result in the bitmap file from “Render To Texture” dialog (This is the result I want when using the MaxScript)
Result in the Render window(preview), generated from MaxScript (the fbitmap ile had the _bmp in its filename)
Result in the bitmap, generated from MaxScript (the fbitmap ile had the _bmp in its filename)
Basicly I want to be able to render the “Lightmap” result in a bitmap, and not only the output result from the Render Window. Any idea ?
- Matt Stevens
Hi Matt ,
Try this
change this – LM_Var.filename = RTT_methods.MakeBakeElementFileName objToBake LM_Var (fPath+fName+fType) “” fType
to – LM_Var.filetype = (fPath+fName+fType)
i have no idea why it works but it works.
(Ref: http://forums.cgsociety.org/showpost.php?p=1781563&postcount=9 )
Akram
It worked. Thanks a lot. I still don’t understand what is the difference between LightingMap.filename and LightingMap.filetype, but my script is working so I’ll leave it that way.
Thanks again
- Matt Stevens