ScriptSpot

Forum topic · General Scripting

Render to Texture Padding Issue

By jeremiah_bigley · 2013-01-13

Description

Hey guys! I am pretty stuck. I am 95% there on my script and the padding is giving me an issue. Was hoping someone could help tell me why I am having this problem.

Problem: After my first render, if I change the padding, it doesn't render out the new padding amount. I am not really sure why. It seemed to update in the render after I updated at least the save location and padding... sometimes.

I am not clearing the bake elements because I would like to keep it there. Idea is to setup using predefined preset in the script, render, tweak some settings in it, and then render again.

global bp = $.INodeBakeProperties
global prjp = $.INodeBakeProjProperties


fn RTTBigleyCastTools Xsize Ysize channel padding fullfilename =
(
    bp.bakeEnabled = true
    bp.bakeChannel = channel
    bp.ndilations = padding

    fPath = getFilenamePath fullfilename
    fName = getFilenameFile fullfilename
    fType = getFilenameType fullfilename

    be.outputSzX = Xsize
    be.outputSzY = Ysize
    be.filenameUnique = true
    be.filename = fName
    be.fileType = fType

    render rendertype:#bakeSelected outputwidth: Xsize outputheight: Ysize outputfile:(fPath+fName+fType)  vfb: false
)


-- Sets up a Test Normal Map RTT Element
bp.removeAllBakeElements()
bp.bakeEnabled = true
bp.bakeChannel = 1
bp.nDilations = 4

prjp = $.INodeBakeProjProperties
prjp.hitMatchMtlID = true
prjp.enabled = true
prjp.warnRayMiss = true

nmtest = Normalsmap()
nmtest.enabled = true
nmtest.outputSzX = nmtest.outputSzY = 512
nmtest.filenameUnique = true
nmtest.elementname = "Normal Map Test"
nmtest.filename = (maxfilepath + $.name + "_nmtest.tga")
bp.addBakeElement nmtest


-- Renders and Saves bitmap
be = bp.getBakeElement 1 -- Assigns the obj bake element to the variable be

RTTBigleyCastTools be.outputSzX be.outputSzY bp.bakeChannel bp.ndilations be.filename

if be.bitmap != undefined do
(
    newbitmap =  bitmap be.outputSzX be.outputSzY

    copy be.bitmap newbitmap
    newbitmap.filename = edtFilePath.text
    display be.bitmap
    save newbitmap

    close newbitmap
    close be.bitmap
)

Any help would be very much appreciated.

Comments (3)

padding isn't the problem

jeremiah_bigley · 2013-01-13

ok so what it is..

the display be.bitmap is displaying the same image from the last render. If I move objects around and rebake, I get the previous render.

so the close be.bitmap isn't closing it out?

jeremiah_bigley · 2013-01-13

I normally close it first before I do anything. But I gave it a shot trying to open it, bake, and then close it... and it is still a no go.

If I set the padding to 2, render, I get a render with a padding of 2. If I go back and change the settings to 64 (regardless if I change them in my script or the actualy panel), render, I will get a render with a padding of 2 (should be 64).

I have tried so many different things and nothing seems to be working.

miauu · 2013-01-13

i found that RTT stuff sometimes not work properly.With RTTAssist there was some problems that I solved by doing the following: open the default RTT Dialog, bake close the default RTT dialog. You can check the ToTex and RTTAssist code.