[Closed] baking textures and antialiasing problems…
yep – read through it twice! it’s BIG.
anyways, props go to my friend chris c. in NY for figuring this out for me. he’s becoming quite the RTT guru since i last worked with him. anyways…
the heart of the problem lies in the fact i was rendering the bakeMap directly to a bitmap…
bitm = bitmap Rsize Rsize
render rendertype:#bakeSelected ... to:bitm
what this was doing was when RTT generates it’s internal bitmap & then saves it as the outputfile (.tga) it’s blending the alpha. however if i create a placeholder bitmap & copy the contents of the internal bitmap into it i retain the exact output of the bakeMap…
render rendertype:#bakeSelected vfb:off progressBar:true outputSize:[Rsize,Rsize]
rendPath = (maxfilepath + outputFile + ".tga")
tempBitmap = bitmap rsize rsize filename:rendPath
copy bakemap.bitmap tempBitmap
save tempBitmap
this created a new problem. if i changed anything in the script, like dilations or even tried to run the script on a different object, i would continue to get the same rendered result everytime. the bakemap.bitmap remains static during further script evaluations. there’s no command to unload the bakemap.bitmip or delete it. after poking around a bit, i discovered good ‘ol gc light:true works fine.
so, for posterity sake, here’s the full script…
fn RTTit obj Rsize outputFile=
(
bakeMap = diffusemap()
bakeMap.outputSzX = Rsize
bakeMap.outputSzY = Rsize
bakeMap.fileType = ".tga"
bakeMap.filterOn = false
bakeMap.shadowsOn =off
bakeMap.lightingon = off
bakeMap.targetMapSlotName = "Diffuse"
bakeMap.enabled = true
obj.INodeBakeProperties.addBakeElement bakeMap
obj.INodeBakeProperties.bakeEnabled = on
obj.INodeBakeProperties.flags = 1
obj.INodeBakeProperties.bakeChannel = 1
obj.INodeBakeProperties.nDilations = 1
render rendertype:#bakeSelected vfb:off progressBar:true outputSize:[Rsize,Rsize]
rendPath = (maxfilepath + outputFile + ".tga")
tempBitmap = bitmap rsize rsize filename:rendPath
copy bakemap.bitmap tempBitmap
save tempBitmap
obj.iNodeBakeProperties.removeAllBakeElements()
gc light:true -- must call this to clear the bakeMap.bitmap otherwise the first render will always get pasted in the tempBitmap
)
RTTit $ 1024 "test"
again thanks chris & pixelMonkey for your help!
Sorry, can’t help you with the antialiasing question, but I have a question about your script:
Does that actually bake out the diffuse element? Here, it seems to bake out the complete map, i.e. including all shading, shadows etc.
– MartinB
hi martin,
interesting that you’re seeing a complete map. here & in the studio it’s rendering just the diffuse as expected. are you using an earlier max version than 2009? i seem to recall something while i was trolling through the docs & the .mcr that something was 2008-09 only, but i’m not sure what & i don’t think it’s in the script.
if the vfb property was set to true, you would definitely see the complete map, but the rendered .tga in photoshop is showing me just the diffuse.
could you create a simple sphere in an empty scene with one light and let me know what you get in photoshop?
thx
I created a simple sphere, and an omni light source, switched from mr to scanline.
Selected the sphere and ran your original code in 3ds Max 2009 64bit. I get a shaded result of the sphere’s color, like what I would expect from a completemap output.
The second version of the function gave me the expected result, a solid color.
– MartinB