|
楼主 |
发表于 2023-3-1 17:31:14
|
显示全部楼层
- fn RTTgetFilename o tMark oName eName fType=(
- --TimeMark
- tDate=getLocalTime()
- for i=1 to tDate.count do (tDate[i]=tDate[i] as string)
- tDate[1]=substring tDate[1] 3 2
- for i=2 to tDate.count do (if (tDate[i].count == 1) do (tDate[i]="0"+tDate[i]))
- if tMark=="Time" then timeM=tDate[1]+tDate[2]+tDate[3]+" "
- else timeM=""
-
- --FilePath, Name
- FilePath=maxFilePath
- if maxFilePath=="" do (FilePath=(getDir #image)+"\")
- CurrentFileName=(filterString maxFileName ".max")[1]
- ObjName=" "+o.name
- if oName!="Object" do ObjName=""
- ElementName=" "+eName
- FileType="."+fType
-
- --Check ExistFile
- FullDir = FilePath+timeM+CurrentFileName+ObjName+ElementName+FileType
- fExist=true
- fNtm=1
- while fExist do
- (
- fExist=(doesFileExist FullDir)
- if fExist do (FullDir = FilePath+timeM+CurrentFileName+ObjName+ElementName+"["+(fNtm as string)+"]"+FileType)
- fNtm+=1
- )
- --Return FileName
- FullDir
- )
- fn RTTexecuter mode o mSize=if(selection.count==1) do
- (
- FileNormal=(RTTgetFilename o "" "Object" "Normal" "jpg")
- FileColor=(RTTgetFilename o "" "Object" "Color" "jpg")
- FileAmbientOcclussionP=(RTTgetFilename o "" "Object" "AOP" "jpg")
- FileAmbientOcclussionS=(RTTgetFilename o "" "Object" "AOS" "jpg")
- FileUvw=(RTTgetFilename o "" "Object" "Uvw" "jpg")
- FileMask=(RTTgetFilename o "" "Object" "Mask" "jpg")
- FileUVMask=(RTTgetFilename o "" "Object" "UVMask" "jpg")
-
- pBake = o.iNodeBakeProperties
- pProj = o.INodeBakeProjProperties
-
- --Normalmap Element
- NmMap=NormalsMap()
- NmMap.enabled=true
- NmMap.elementName="_Normal"
- NmMap.fileType=FileNormal
- NmMap.fileName=filenameFromPath NmMap.fileType
- NmMap.filenameUnique=false
- NmMap.filterOn=false
- NmMap.autoSzOn=false
- NmMap.outputSzX=mSize
- NmMap.outputSzY=mSize
- NmMap.targetMapSlotName="" --String
- NmMap.useNormalBump=false
- NmMap.useHeightAsAlpha=false
- --NmMap.bitmap=undefined --<Bitmap>
- --Color Map Projection
- ColorMap=DiffuseMap()
- ColorMap.enabled=true
- ColorMap.elementName="_ColorProject"
- ColorMap.fileType=FileColor
- ColorMap.fileName=filenameFromPath ColorMap.fileType
- ColorMap.filenameUnique=false
- ColorMap.filterOn=true
- ColorMap.autoSzOn=false
- ColorMap.outputSzX=mSize
- ColorMap.outputSzY=mSize
- ColorMap.targetMapSlotName=""
- ColorMap.lightingOn=false
- ColorMap.shadowsOn=false
- --ColorMap.bitmap=undefined
-
- --Ambient Occlussion Map Projection
- AoMap=CompleteMap()
- AoMap.enabled=true
- AoMap.elementName="_OcclusionProject"
- AoMap.fileType=FileAmbientOcclussionP
- AoMap.fileName=filenameFromPath AoMap.fileType
- AoMap.filenameUnique=false
- AoMap.filterOn=true
- AoMap.autoSzOn=false
- AoMap.outputSzX=mSize
- AoMap.outputSzY=mSize
- AoMap.targetMapSlotName=""
- AoMap.shadowsOn=true
- --AoMap.bitmap=undefined
- --Ambient Occlussion Map Solo
- AoMapSolo=CompleteMap()
- AoMapSolo.enabled=true
- AoMapSolo.elementName="_OcclusionSolo"
- AoMapSolo.fileType=FileAmbientOcclussionS
- AoMapSolo.fileName=filenameFromPath AoMap.fileType
- AoMapSolo.filenameUnique=false
- AoMapSolo.filterOn=true
- AoMapSolo.autoSzOn=false
- AoMapSolo.outputSzX=mSize
- AoMapSolo.outputSzY=mSize
- AoMapSolo.targetMapSlotName=""
- AoMapSolo.shadowsOn=true
- --AoMap.bitmap=undefined
-
- --Ambient Occlussion Material
- tProjectMaterial=standard()
- tProjectMaterial.name="AO_TempoMat"
- tProjectMaterial.shaderType=1
- tProjectMaterial.ambient=(color 255 255 255)
- tProjectMaterial.diffuse=(color 255 255 255)
- tProjectMaterial.specular=(color 255 255 255)
- --MaskMap
- MaskMap=AlphaMap()
- MaskMap.enabled=true
- MaskMap.elementName="_Mask"
- MaskMap.fileType=FileMask
- MaskMap.fileName=filenameFromPath MaskMap.fileType
- MaskMap.filenameUnique=false
- MaskMap.filterOn=false
- MaskMap.autoSzOn=false
- MaskMap.outputSzX=mSize
- MaskMap.outputSzY=mSize
- MaskMap.targetMapSlotName=""
- --MaskMap.bitmap=undefined
-
-
- --Projection Mapping
- pProj.enabled=true
- --Get Projection Modifier
- modProject=projection()
- for i=1 to o.modifiers.count do (if o.modifiers[i].name=="Projection" do modProject=o.modifiers[i])
- pProj.projectionMod=modProject --maxObject : Read|Write Get/Set the Projection Modifier.
- --pProj.projectionModTarget="Sphere001" -- string : Read|Write
- pProj.BakeObjectLevel=true
- pProj.BakeSubObjLevels=true
- pProj.useObjectBakeForMtl=true
- pProj.proportionalOutput=false
- --Mapping Coordinates
- pProj.subObjBakeChannel=1
- --Filter Option
- pProj.cropAlpha=false -- boolean : Read|Write Get/Set whether Alpha will be cropped.
- --Method
- pProj.projSpace=#raytrace -- #raytrace #uvw_match
- pProj.useCage=true
- pProj.rayOffset=10.0
- --Resolve Hit
- pProj.hitResolveMode=#furthest --#closest #furthest
- pProj.hitMatchMtlID=false --Hit Only Matching Material ID
- pProj.hitWorkingModel=false --Include Working Model
- pProj.warnRayMiss=true
- pProj.rayMissColor=red
- --Normal Map Space
- pProj.normalSpace=#tangent --#world #screen #local #tangent
- pProj.tangentXDir=#X_Right -- #X_Right #X_Left ::: Red +X -X
- pProj.tangentYDir=#Y_Down --#Y_Up #Y_Down ::: Green, -Y +Y
- --Height Map
- pProj.heightMapMin=(-20.0)
- pProj.heightMapMax=(20.0)
- --obj.INodeBakeProjProperties.heightBufMin=0.0 -- float : Read|Write
- --obj.INodeBakeProjProperties.heightBufMax=100.0 --float : Read|Write
-
- --Renderer Setting (SuperSampler)
- BakeScanline_Default=Default_Scanline_Renderer()
- --Option
- BakeScanline_Default.mapping=true
- BakeScanline_Default.shadows=true
- BakeScanline_Default.enableSSE=false
- BakeScanline_Default.autoReflect=true
- BakeScanline_Default.forceWireframe=false
- BakeScanline_Default.wireThickness=1.0
- --Antialliasing
- BakeScanline_Default.antiAliasing=true
- BakeScanline_Default.filterMaps=true
- BakeScanline_Default.antiAliasFilter=Area()
- BakeScanline_Default.antiAliasFilterSize=1.5
- --Global SyperSampling
- BakeScanline_Default.enablePixelSampler=true
- BakeScanline_Default.globalSamplerEnabled=true
- BakeScanline_Default.globalSamplerClassByName="Max 2.5 Star"
- BakeScanline_Default.globalSamplerSampleMaps=true
- BakeScanline_Default.globalSamplerQuality=0.5
- BakeScanline_Default.globalSamplerAdaptive=true
- BakeScanline_Default.globalSamplerAdaptiveThresh=0.1
- --Object Motion Blur
- BakeScanline_Default.objectMoti[안내]태그제한으로등록되지않습니다-xxonBlur‎=true
- BakeScanline_Default.objectBlurSamples=10
- BakeScanline_Default.objectBlurDuration=0.5
- BakeScanline_Default.objectBlurSubdivisions=10
- --Image Motion Blur
- BakeScanline_Default.imageMoti[안내]태그제한으로등록되지않습니다-xxonBlur‎=true
- BakeScanline_Default.imageBlurTrans=false
- BakeScanline_Default.imageBlurDuration=0.5
- BakeScanline_Default.imageBlurEnv=false
- --Auto Reflect/Refract Maps
- BakeScanline_Default.autoReflectLevels=1
- --Color Range Limiting
- BakeScanline_Default.colorClampType=0 -- 0-Clamp 1-Scale
- --Memory Management
- BakeScanline_Default.conserveMemory=false
-
- --Light Tracer
- LightTracerAO=LightTrace()
- LightTracerAO.global_multiplier=1.0
- LightTracerAO.object_multiplier=1.0
- LightTracerAO.sky_lights_on=true
- LightTracerAO.sky_lights=1.0
- LightTracerAO.rays=250
- LightTracerAO.filter_size=0.5
- LightTracerAO.ray_bias=0.03
- LightTracerAO.cone_angle=88.0
- LightTracerAO.color_bleed=1.0
- LightTracerAO.color_filter=(color 255 255 255)
- LightTracerAO.extra_ambient=(color 0 0 0)
- LightTracerAO.bounces=0
- LightTracerAO.volumes_on=true
- LightTracerAO.volumes=1.0
- LightTracerAO.adaptive_undersampling_on=true
- LightTracerAO.initial_sample_spacing=4 --0:1x1 1:2x2 2:4x4 3:8x8 4:16x16 5:32x32
- LightTracerAO.subdivide_down_to=0 --0:1x1 1:2x2 2:4x4 3:8x8 4:16x16 5:32x32
- LightTracerAO.subdivision_contrast=5.0
- LightTracerAO.show_samples=false
- --LightTracerAO.rayengine=ReferenceTarget:Ray_Engine
-
- --Baking
- pBake.bakeEnabled = true
- pBake.bakeChannel = 1
- pBake.nDilations = 2
-
- case mode of(
-
- "Normal":(
- pProj.enabled=true
- pBake.removeAllBakeElements()
- pBake.addBakeElement NmMap
-
- bRenderer = renderers.current
- renderers.current = BakeScanline_Default
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- renderers.current = bRenderer
- )
-
-
- "Color":(
- pProj.enabled=true
- pBake.removeAllBakeElements()
- pBake.addBakeElement ColorMap
-
- bRenderer = renderers.current
- renderers.current = BakeScanline_Default
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- renderers.current = bRenderer
- )
-
- "Mask":(
- pProj.enabled=false
- pBake.removeAllBakeElements()
- pBake.addBakeElement MaskMap
-
- bRenderer = renderers.current
- renderers.current = BakeScanline_Default
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- renderers.current = bRenderer
- )
-
- "AOs":(
- tBackupMat=selection[1].material
- selection[1].material=tProjectMaterial
- pProj.enabled=false
- pBake.removeAllBakeElements()
- pBake.addBakeElement AoMapSolo
- SkylightAO=Skylight()
- SceneRadiosity.radiosity=LightTracerAO
-
- bRenderer = renderers.current
- renderers.current = BakeScanline_Default
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- renderers.current = bRenderer
-
- delete SkylightAO
- SceneRadiosity.radiosity=undefined
- selection[1].material=tBackupMat
- )
-
- "AOp":(
- tBackupMat=selection[1].material
- selection[1].material=tProjectMaterial
- tBackupProNode=#()
- tBackupProNodeMat=#()
- for i=1 to selection[1].projection.geomNodes.count do(
- tProjectNode=selection[1].projection.geomNodes[i]
- append tBackupProNode tProjectNode
- append tBackupProNodeMat tProjectNode.material
- tProjectNode.material=tProjectMaterial
- )
-
- pProj.enabled=true
- pBake.removeAllBakeElements()
- pBake.addBakeElement AoMap
- SkylightAO=Skylight()
- SceneRadiosity.radiosity=LightTracerAO
-
- bRenderer = renderers.current
- renderers.current = BakeScanline_Default
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- renderers.current = bRenderer
-
- delete SkylightAO
- SceneRadiosity.radiosity=undefined
-
- selection[1].material=tBackupMat
- for i=1 to tBackupProNode.count do(tBackupProNode[i].material=tBackupProNodeMat[i])
- )
-
- "Uvw":(
- if (getCommandPanelTaskMode() != #modify)then(setCommandPanelTaskMode #modify)
- UnwrapExist=false
- for i=1 to o.modifiers.count do(if(o.modifiers[i].name=="Unwrap UVW") do UnwrapExist=true)
- if UnwrapExist==false do modPanel.addModToSelection (Unwrap_UVW ()) ui:on
- oUV=o.Unwrap_UVW
- oUV.renderuv_width=mSize
- oUV.renderuv_height=mSize
- oUV.renderuv_edgeColor=(color 255 255 255)
- oUV.renderuv_edgealpha=0.3
- oUV.renderuv_showframebuffer=false
- oUV.renderUV FileUvw
- bmapUVW=openBitMap FileUvw
- --deleteFile FileUvw
- if UnwrapExist==false do (deleteModifier selection oUV)
- --bmapUVW
- )
-
- "All":(
- bRenderer = renderers.current
- renderers.current = BakeScanline_Default
-
- pProj.enabled=true
- --color
- pBake.removeAllBakeElements()
- pBake.addBakeElement ColorMap
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- --normal AOp
- pBake.removeAllBakeElements()
- pBake.addBakeElement NmMap
- pBake.addBakeElement AoMap
-
- tBackupMat=selection[1].material
- selection[1].material=tProjectMaterial
- tBackupProNode=#()
- tBackupProNodeMat=#()
- for i=1 to selection[1].projection.geomNodes.count do(
- tProjectNode=selection[1].projection.geomNodes[i]
- append tBackupProNode tProjectNode
- append tBackupProNodeMat tProjectNode.material
- tProjectNode.material=tProjectMaterial
- )
- SkylightAO=Skylight()
- SceneRadiosity.radiosity=LightTracerAO
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- selection[1].material=tBackupMat
- for i=1 to tBackupProNode.count do(tBackupProNode[i].material=tBackupProNodeMat[i])
-
-
- pProj.enabled=false
- --AOs
- pBake.removeAllBakeElements()
- pBake.addBakeElement AoMapSolo
- tBackupMat=selection[1].material
- selection[1].material=tProjectMaterial
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
- delete SkylightAO
- SceneRadiosity.radiosity=undefined
- selection[1].material=tBackupMat
-
- --Mask
- pBake.removeAllBakeElements()
- pBake.addBakeElement MaskMap
- render rendertype:#bakeSelected vfb:on progressBar:true outputSize:[mSize,mSize]
-
- renderers.current = bRenderer
-
- --UVW
- RTTexecuter "Uvw" o mSize
- )
-
-
- )
- )
- 사용예
- RTTexecuter "Normal" selection[1] 2048 --노말맵을 2048x2048사이즈로 구워서 max scene 파일이 저장된 폴더에 저장.
- RTTexecuter "Mask" selection[1] 2048 --마스크맵 2048x2048
- RTTexecuter "Color" selection[1] 2048 --디퓨즈맵 2048x2048
- RTTexecuter "AOs" selection[1] 2048 --앰비언트 오클루젼맵(projection안된..) 2048x2048
- RTTexecuter "AOp" selection[1] 2048 --앰비언트 오클루젼맵(projection된..) 2048x2048
- RTTexecuter "Uvw" selection[1] 2048 --Uvw Templete..
- RTTexecuter "All" selection[1] 2048
复制代码 |
|