View Full Version : Render To Texture with Maxscrip
09-26-2008, 07:56 AM
Hey all, im trying to make an interface that does a render to texture of the diffuse channel, specifying the size, output dir, output file type etc. I have looked in the help under RTT_Methods but am now more confused than when I started. Can anyone give me a bit of a starting point to the RTT interface and how to do it. Cheers!!!
09-26-2008, 05:55 PM
It took me a while to figure this out also. For some time I just thought it couldn't be done, but after staring at the help docs long enough, and a bit of trial and error, I got it working.
The two interfaces you want to look at are INodeBakeProperties and INodeBakeProjProperties. Plus, take a look at the Macro_BakeTextures.mcr file (if you're feeling brave).
Here's a sample script to render the diffuse channel from one object to another:
-- add project modifier and projection objects
fn addProjMod lowResObj highResObjs cageOffset =
modMode = getCommandPanelTaskMode()
projMod = projection()
addModifier lowResObj projMod
for obj in highResObjs do
projMod.displayCage = true
projMod.name = "ProjMod"
-- set up the objects
theObj = sphere radius:50 segs:32 mapcoords:on
theProjObj = sphere radius:50.5 segs:32 mapcoords:on
theProjObj.material = standard diffuseMap:(Perlin_Marble ())
-- define variables
renderSize = 512
fileName = theObj.name + "_Diffuse.tif"
filePath = "c:\\" + diff.filename
-- the bake object needs to be selected
-- set up the bake interfaces
bakeProps = theObj.INodeBakeProperties
bakeProjProps = theObj.INodeBakeProjProperties
-- add diffuse element
diff = DiffuseMap()
-- file name
diff.filename = fileName
diff.filetype = filePath
-- map size
diff.outputSzX = renderSize
diff.outputSzY = renderSize
diff.enabled = true
bakeProjProps.enabled = true
bakeProjProps.projectionMod = (addProjMod theObj #(theProjObj) 1)
-- open and close RTT
macros.run "Render" "BakeDialog"
-- do the render
curBM = bitmap renderSize renderSize
render rendertype:#bakeSelected frame:0 to:curBM vfb:true cancelled:&wasCanceled
-- display the diffuse map
display (openBitMap filePath)
10-22-2008, 01:15 AM
Cheers for that. It works great, only it always saves the element as 640x480, not the specified 1024x1024. It renders as 1024x1024 but only saves the top left 640x480 segement of it.
Im using vray and the VRay_DiffuseFilterMap() Element and im setting the element size, and the curBM (bitmap) size and even the render() size all with the same property (1024)
11-05-2008, 11:26 PM
It seems that if i choose .exr as an output format it will only save a 640x480 segment of the render, while using .tiff will save the whole 1024x1024 image. Weird
11-06-2008, 06:10 PM
Have you seen this thread (http://forums.cgsociety.org/showthread.php?f=98&t=689229&highlight=rtt)?
Look towards the end where he talks about the difference between rendering directly to the bitmap versus copying the result to a new bitmap and then saving that one. That might help with this issue too.
11-06-2008, 06:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.