Notifications
Clear all
[Closed] Texture Baking Question?
Nov 08, 2007 6:47 pm
I have been trying to make a script to bake Ambient Occlusion in into textures, but I have not been able to.
I have search trough all the forums and help file as well as the huge
Macro_BakeTextures.mcr script but could not find the answer
.
For some reason I cant seem to get the occlusion pass or any other that I choose to render.
Please see the RenderTOtexture.jpg, all the box01*.jpg images were made with the render to texture script in max and the test.jpg is the one made with the script
As you can see looks very similar to the complete pass made by Max. ! Hmm Im lost anyone has any input on this?
It almost seems like it render just the complete pass no mater which Bake Element I choose.
Is there any hidden switch Im missing or something else?
fn RenderToTexturePass obj currentMapType Xsize Ysize channel fullFileName virtualFrameBufferState =
(
-- Get File Properties
MapPath = getFilenamePath fullFileName
MapName = getFilenameFile fullFileName
MapType = getFilenameType fullFileName
-- Set File Properties
currentMapType.outputSzX = Xsize
currentMapType.outputSzY = Ysize
currentMapType.filename = MapName
currentMapType.fileType = MapType
-- Ambient Occlusion Settings
currentMapType.autoSzOn = true
currentMapType.bright = color 255 255 255 0
currentMapType.dark = color 0 0 0 0
currentMapType.elementName = "Ambient Occlusion"
currentMapType.falloff = 1.0
currentMapType.maxDistance = 0.8
currentMapType.samples = 16
currentMapType.spread = 0.8
currentMapType.enabled = true
currentMapType.targetMapSlotName = "diffusemap"
-- Interface: INodeBakeProjProperties
BakeProj = obj.INodeBakeProjProperties
BakeProj.enabled = false-- Enable/Disable Projection Baking for the node
BakeProj.projectionMod = undefined -- Get/Set the Projection Modifier
BakeProj.projectionModTarget =""-- Get/Set the Projection Modifier Target
BakeProj.cropAlpha = false -- Get/Set whether Alpha will be cropped
BakeProj.projSpace = #Raytrace -- Get/Set the Projection Space projSpace enums: {#raytrace|#uvw_match}
BakeProj.normalSpace = #tangent -- Get/Set the Normal Space. normalSpace enums: {#world|#screen|#local|#tangent}
BakeProj.tangentYDir = #Y_Down -- Get/Set the Y Tangent Direction. Get/Set the Y Tangent Direction.
BakeProj.tangentXDir = #X_Right -- Get/Set the X Tangent Direction. tangentXDir enums: {#X_Right|#X_Left}
BakeProj.useCage = true -- Get/Set whether to use the Cage.
BakeProj.rayOffset = 10.0 -- Get/Set the Ray Offset value.
BakeProj.hitResolveMode = #furthest -- Get/Set the Hit Resolve Mode. hitResolveMode enums: {#closest|#furthest}
BakeProj.hitMatchMtlID = false -- Get/Set whether to match the Material IDs when projecting.
BakeProj.hitWorkingModel = false --
BakeProj.warnRayMiss = true -- Get/Set whether to warn of missed ray hits.
BakeProj.rayMissColor = (color 255 0 0) -- Get/Set the warn color for missed ray hits.
BakeProj.heightMapMin = -10.0 -- Get/Set the HeightMap Min. Value.
BakeProj.heightMapMax = 10.0 -- Get/Set the HeightMap Max. Value.
BakeProj.heightBufMin = 0.0
BakeProj.heightBufMax = 0.0
BakeProj.BakeObjectLevel = true
BakeProj.BakeSubObjLevels = true
BakeProj.useObjectBakeForMtl = true
BakeProj.proportionalOutput = false
BakeProj.subObjBakeChannel = 1
--- Methods
-- obj.removeBakeElementByIndex 1 -- Removes the indexed Bake Element.
-- obj.getBakeElement 1 -- Returns the indexed Bake Element.
-- Interface: INodeBakeProperties
BakeProp = obj.INodeBakeProperties
BakeProp.bakeEnabled = true -- Enables/Disables Texture Baking for the node.
BakeProp.bakeChannel = 1 -- Gets/Sets the Texure Baking channel of the node.
BakeProp.nDilations = 2 -- Gets/Sets the nDilation value of the node. (Pading)
BakeProp.flags = 1 --Gets/Sets the Texture Baking flags. bit 1 of flag will be set to signify map channel conflict
BakeProp.surfaceArea = 0.0 -- Gets/Sets the Texture Baking Surface Area.
BakeProp.areaScale = 0.0 -- Gets/Sets the Texture Baking Area Scaling.
-- Methods
BakeProp.addBakeElement currentMapType -- Adds a Bake Element.
curBM = bitmap 500 500
render rendertype:#bakeSelected frame:0 to:curBM vfb:true cancelled:&wasCanceled disableBitmapProxies:true
BakeProp.removeAllBakeElements() -- Removes all BakeElements.
BakePropbakeEnabled = false
format "rendering node:% channel:%
" obj.name BakeProp.bakeChannel
)
-- -- remove any bake elements
-- local nBakeElements = bakeInterface.NumBakeElements()
-- for nEle = nBakeElements to 1 by -1 do
-- bakeInterface.removeBakeElementByIndex nEle
obj=$
PassType=Ambient_Occlusion()
RenderToTexturePass obj PassType 512 512 1 "D:\\RT\ est.jpg" true
Thanks in advance.
Guillermo Leal
4 Replies
Nov 08, 2007 6:47 pm
has anyone ever done anything related to Texture Baking in Maxscript? I would really appreciate any input you could give me.
Thanks,
Guillermo Leal.
Nov 08, 2007 6:47 pm
I tried a while ago, but I couldn’t get it to work (bitmap creation error if I recall). Sorry I can’t help.
Shane
Nov 08, 2007 6:47 pm
yes i have, just try the script and you will see that it renders fine, but it dosent create the element but a complete render.
Guillermo Leal.