Hi!
I'm writing a script to render lightmaps to texture and I'm running into crashes. I did my best to put together a simple crashing scenario. I have a script that will render 10 lightmaps for a selected object and save them to exr files.
After the script is finished running a 3ds max error will pop up closing down the application. I have noticed that all maxscript code gets executed properly. So even when crashing all textures will be saved correctly and the last print will have executed. I have not been able to make the code stable. Even though some variations will not run into the crash I found that adding more unrelated functionality to working variations will lead to a crash.
I'm using 3ds Max 2017 and VRay Adv 3.40.02.
I'm writing a script to render lightmaps to texture and I'm running into crashes. I did my best to put together a simple crashing scenario. I have a script that will render 10 lightmaps for a selected object and save them to exr files.
After the script is finished running a 3ds max error will pop up closing down the application. I have noticed that all maxscript code gets executed properly. So even when crashing all textures will be saved correctly and the last print will have executed. I have not been able to make the code stable. Even though some variations will not run into the crash I found that adding more unrelated functionality to working variations will lead to a crash.
I'm using 3ds Max 2017 and VRay Adv 3.40.02.
Code:
macroScript LightMapsTest category:"MyLightmapper" buttonText:"Light Maps Test" toolTip:"Light Maps Test" ( rollout LightMaps "LightMaps" width:512 height:216 ( button btn_bake_generate "Bake Lightmaps" on btn_bake_generate pressed do ( print "*************** GENERATING LIGHTMAPS ********************" -- Check if the renderer is set to Vray current_renderer = Renderers.current as string found = findstring current_renderer "V_Ray_Adv" if found == undefined then ( return undefined ) -- Set variables obj = selection[1]; size = 16 output_dir = "C:/Renders/"; -- Check if the object selected is defined and if it is a a geometry if obj == undefined then( return undefined ) found = false for obj2 in geometry do ( found = (found or ( obj2 == obj )) ) if found == false then ( print "Object sent to render is not a geometry" return undefined ) object_name = selection[1].name; for i = 1 to 10 do ( -- Create the bitmap in which the image will be saved file = output_dir + object_name + i as string + ".exr" deleteFile file tempBitmap = bitmap size size filename:file save tempBitmap -- Define the bakemap bakeMap = vraylightingmap(); bakeMap.enabled = true bakeMap.filterOn = true bakeMap.atmosphereOn = true bakeMap.shadowOn = true bakeMap.bitmap = tempBitmap bakeMap.vrayVFB = false bakeMap.color_mapping = false bakeMap.multiplier = 1.0f -- add the bakemap to the obj obj.iNodeBakeProperties.removeAllBakeElements() obj.INodeBakeProperties.addBakeElement bakeMap obj.INodeBakeProperties.bakeEnabled = on obj.INodeBakeProperties.flags = 1 obj.INodeBakeProperties.bakeChannel = 2 obj.INodeBakeProperties.nDilations = 1 -- render to texture render rendertype:#bakeSelected vfb:off progressBar:true outputSize:[size,size] to:tempBitmap -- set OpenEXR settings fopenexr.SetCompression 0 fopenexr.setSaveScanline true fopenexr.setLayerOutputType 0 0 fopenexr.setLayerOutputFormat 0 0 fopenexr.delAllAttributes --Save the texture save tempBitmap close tempBitmap ) print "********** END OF GENERATING LIGHTMAPS *****************" ) ) createdialog LightMaps )
Comment