[Closed] Render to texture scripting
Hi all
So I am trying to write a script that sets up some render to texture settings per object and then render them out in a batch process sort of way, change settings, render, change settings, render…etc
I can get everything to work except, and this is what makes me feel very dumb, is there a way to tell it to render the render to texture? How do I tell it to go…?
Thanks
Jesse
local curBM;
select obj; -- select the object
-- bake the object
local w = obj.renderWidth();
local h = obj.renderHeight();
if w == 0 or h == 0 then return false;
if (curBM == undefined) or (curBM.width != w ) or (curBM.height != h) then (
if curBM != undefined then unDisplay( curBM );
curBM = bitmap w h;
)
local vfbOn = false;
local wasCanceled = false
local nFrame = currentTime;
render rendertype:#bakeSelected frame:nFrame to:curBM vfb:vfbOn cancelled:&wasCanceled quiet:true;
The important part is the “#bakeSelected.”
Sorry for the late reply. That looks great. I will give it a try.
Thanks
ok I gave that a try. Clearly I am clueless
It does render an image, but it does not render the settings I have set up for that object in the Render to texture.
Essentially what I am trying to write it a batch lightmap creator.
Have your objects selected…hit go. It bakes out all light maps, edits some scene lights, repeats until finished for total lights in the scene, saving out a large group of lightmaps for all objects, named accordingly with different light settings.
On a side note
Why does
SelectedObjects[1].modifiers[#unwrap_uvw].flattenmapnoParams()
Work great as a single line but does nothing if put in a loop as
for i = 1 to selectedobjects.count do
(
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
SelectedObjects[i].modifiers[#unwrap_uvw].unwrap.setMapChannel 2
[size=1][size=1][size=1][color=white]SelectedObjects[i].modifiers[#unwrap_uvw].flattenmapnoParams()
)
[/size]
Thanks for any help[/color][/size][/size]
This is propably some unwrap issues or something but put this before flattening command.
[size=1][size=1][size=1][color=white]SelectedObjects[i].modifiers[#unwrap_uvw].selectFaces (SelectedObjects[i].faces as bitArray)
[/size][/color][/size][/size]I hope it works. Works for me anyway
To get it to render, if your script makes changes to the settings in the actual “Render to Texture” dialog box while it’s open, you can use the following line to press the Render button:
gTextureBakeDialog.bRender.pressed()
If not, it might be helpful to post your script so we can see exactly what you’re trying to do.
And about the unwrap code not working, this may or may not be the problem, but make sure you have the modify panel displayed when that part of the code is run by using this line:
max modify mode