baking - automatic unwrap CHANNEL

baking - automatic unwrap CHANNEL

Anonymous
Not applicable
358 Views
0 Replies
Message 1 of 1

baking - automatic unwrap CHANNEL

Anonymous
Not applicable
Hello.
I'm working at script which "replace" standard render to texture dialog, into my own automatic.
The problem is with BAKE CHANNEL or Unwrap Channel.
When I use simply Render to texture and checked USE AUTOMATIC UNWRAP in Mapping Coordinates = everything work fine, autoflatten is good and the texture too.
When I use my script I got black image - the same when i use USE EXISTING CHANNEL in Render to texture dialog.
Everything should be at the 1. channel of automatic unwrap, but baking I don't know why, use EXISTING CHANNEL instead of AUTOMATIC UNWRAP CHANNEL also 1. but the different one.
I hope it's clear what I wrote.
Below my code
UNWRAP
--function creating automatic unwrap
fn unwrap obj_toUVW =
(

flattenAngle = 45
flattenSpacing = 0.02
flattenRotate = true
flattenFillHoles = true

unwrapMod = unwrap_UVW()
unwrapMod.setAlwaysEdit false
unwrapMod.setMapChannel 1
unwrapMod.setFlattenAngle flattenAngle
unwrapMod.setFlattenSpacing flattenSpacing
unwrapMod.setFlattenNormalize true
unwrapMod.setFlattenRotate flattenRotate
unwrapMod.setFlattenFillHoles flattenFillHoles
unwrapMod.setApplyToWholeObject true
unwrapMod.name = "Automatic Flatten UVs"
unwrapMod.setDebugLevel 0

setAppData unwrapMod 0x41dd73d5 #object
addModifier obj_toUVW unwrapMod

unwrapMod.flattenMapByMatID flattenAngle flattenSpacing true 2 flattenRotate flattenFillHoles


)

CLEAR UNWRAP

fn DeleteAutoFlatten _obj =
(
-- test each modifier on the object. Count down since we may be deleting modifiers
for nMod = _obj.modifiers.count to 1 by -1 do
(
-- get the next modifier
local unwrapMod = _obj.modifiers

if (classof unwrapMod) == Unwrap_UVW then
(
-- it's an unwrap modifier,
if unwrapMod.name == "Automatic Flatten UVs" then
(
--format "removing auto unwrapper: % \n" unwrapMod.name
deleteModifier _obj unwrapMod
)
) -- end, it's an unwrapper
) -- end, for each modifier
)

BAKE
--function generating bake renders.
fn renderLightmap obj currentMapType Xsize Ysize fileName factor virtualFrameBufferState save_path=
(

DeleteAutoFlatten obj
unwrap obj
addname=obj.name
factor = factor as string
fPath=save_path as string
--diferent name for all renders
-- char _ is a separator beetwen render name common with object and name common with factor
--ex. BOX01_3 Object name BOX01, render number 3
fName=addname +"_"+ factor
fType=getFilenameType fileName


bi = obj.INodeBakeProperties
currentMapType.outputSzX=Xsize
currentMapType.outputSzY=Ysize
currentMapType.filename=fName
currentMapType.fileType=fType


bi.bakeEnabled = true
bi.bakeChannel = 1


bi.addBakeElement currentMapType
undisplay(render rendertype:#bakeSelected outputwidth:Xsize outputheight:Ysize outputfile:(fPath+"\\"+fName+fType) vfb:virtualFrameBufferState progressbar: true)
bi.removeAllBakeElements()
bi.bakeEnabled = false
format "rendering node:% channel:%\n" obj.name bi.bakeChannel
)


p.s. I try tu use different number of channels but nothing helps. I'm exhausted trying to solved it. It is almost 2am at the clock in my country, so goodnight or maybe good morning 😛

Thank you for help.
Greetings from Poland.




-----------------------------------------------
I try all day and no progress. The funniest thing is that when I use my script like always, but I have open BAKE DIALOG in the max, everytfing is ok.
0 Likes
359 Views
0 Replies
Replies (0)