I have been trying to write something which will bake the Normal map from a high_poly model to a Low_poly model....but the problem is nothing is getting rendered. Although all the parameters are applied as i can see in the max file....the projection modifier, cage settings, Highpoly picked....also I can see that it is rendering the normal map.....only thing is it is coming blank!! Can anyone find the problem please??
(
global thehighSS = "select the highpoly mesh"
global thelowSS = "select the low poly mesh"
global thePathSS = "C:\\"
rollout nm "Normal_Map" width:194 height:424
(
pickbutton btn_high "High_Poly" pos:[60,24] width:68 height:20
label lbl_high "select the highpoly mesh" pos:[26,50] width:135 height:17
pickbutton btn_low "Low_Poly" pos:[59,76] width:72 height:21
label lbl_low "select the low poly mesh" pos:[25,103] width:144 height:20
GroupBox grp1 "Select Meshes" pos:[8,8] width:176 height:119
button btn_path "Select Path" pos:[56,165] width:80 height:32
label lbl_path "C:\\" pos:[16,203] width:160 height:16
GroupBox grp2 "Path" pos:[8,153] width:176 height:72
dropdownList ddl_dimension "Dimension" pos:[13,235] width:171 height:40 items:#("32", "64", "128", "256", "512", "1024", "2048", "4096")
radiobuttons qualrad "" pos:[29,305] width:118 height:32 labels:#("low", "medium", "high", "best") columns:2
GroupBox grp3 "Quality" pos:[9,283] width:175 height:64
checkbox chk_auto " Auto Unwrap" pos:[37,133] width:120 height:16
button btn_render "Render" pos:[44,383] width:101 height:29
spinner spn_cagedist "" pos:[110,355] width:52 height:16 range:[-100,100,2]
label lbl_cagedist "Cage Distance:" pos:[28,355] width:78 height:22
on btn_high picked o do
(
if superclassof o == geometryclass and classof o != bonegeometry then
(
lbl_high.text = o.name
select o
global highpoly = o
)
else
(
messagebox "Select a mesh" title: "Wrong Selection" beep:true
)
)
on btn_low picked obj do
(
if superclassof obj == geometryclass and classof obj != bonegeometry then
(
lbl_low.text = obj.name
select obj
global lowpoly = obj
)
else
(
messagebox "Select a mesh" title: "Wrong Selection" beep:true
)
)
on btn_path pressed do
(
thePathSS = getSavepath()
if thePathSS != undefined then
(
lbl_path.text = thePathSS
)
else
(
messagebox "No path defined" title: "Path Not Defined" beep:true
)
)
on btn_render pressed do
(
size = ddl_dimension.selected as integer
cagedistance = spn_cagedist.value
for o in geometry do
(
if classof o != bonegeometry do
(
o.material = undefined
o.material = standardMaterial showInViewport:true
)
)
converttopoly lowpoly
theProj = ProjectionMod()
addModifier lowpoly theProj
theProj.addObjectNode highpoly
theProj.autowrapCage()
theProj.resetCage()
theProj.pushCage cagedistance
theProj.addRegisteredProjectionType 1
theProj.projectProjectionType 1
theProj.ignoreBackfacing = true
lowpoly.iNodeBakeProperties.removeAllBakeElements()
lowpoly.INodeBakeProperties.bakeEnabled = true
lowpoly.INodeBakeProperties.bakeChannel = 1
lowpoly.INodeBakeProperties.nDilations = 4
be1 = NormalsMap()
be1.outputSzX = be1.outputSzY = size
be1.fileType = (thePathSS+"\\"+$.name+"_normal.png")
be1.fileName = filenameFromPath be1.fileType
be1.enabled = true
be1.useNormalBump = true
be1.targetMapSlotName = "diffuse"
lowpoly.INodeBakeProperties.addBakeElement be1
NormDiff = bitmaptexture filename:be1.fileType
lowpoly.material = standardmaterial diffuseMap:NormDiff showInViewport:true
render rendertype:#bakeSelected outputwidth:size outputheight:size
completeRedraw()
)
)
createDialog nm
)
By Goonda · 2012-09-12
miauu · 2012-09-12
barigazy · 2012-09-13