Last active
July 9, 2023 08:29
-
-
Save alaingalvan/4bd4b8b94737c655a16cb58188410f76 to your computer and use it in GitHub Desktop.
A Marmoset Toolbag 3 plugin for rendering batches of scene data automatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Batch Rendering | |
To render a set of scenes individually, you could create a scene with the lights/camera set up | |
how you would like, then run this plugin after configuring a list of files you want to render. | |
""" | |
import mset | |
import os.path | |
# List of scenes to load and render | |
sceneList = [ | |
"" | |
] | |
# Renders all scenes in the scene list | |
def batchRender(renderVideo=False): | |
for index, sceneFile in enumerate(sceneList): | |
if(not os.path.isfile(sceneFile)): | |
print("Scene " + sceneFile + " does not exist! Continuing...") | |
continue | |
try: | |
mset.loadScene(sceneFile) | |
if renderVideo: | |
videoOut = os.path.abspath(os.path.join( | |
mset.getScenePath(), "..", 'video'+str(index)+".avi")) | |
mset.exportVideo(path=videoOut) | |
else: | |
mset.exportScreenshot() | |
except FileNotFoundError: | |
print("The file is not a scene file!") | |
# UI Functionality | |
window = mset.UIWindow("Batch Renderer") | |
window.visible = True | |
def addScene(): | |
path = mset.showOpenFileDialog() | |
if path != '': | |
sceneList.append(path) | |
renderUI() | |
def editScene(field, index): | |
path = mset.showOpenFileDialog() | |
if path != '': | |
field.value = path | |
sceneList[index] = path | |
def renderUI(): | |
window.clearElements() | |
add_button = mset.UIButton("Add Scene") | |
add_button.onClick = addScene | |
window.addElement(add_button) | |
window.addReturn() | |
for index, scene in enumerate(sceneList): | |
field = mset.UITextField() | |
field.value = scene | |
window.addElement(field) | |
file_button = mset.UIButton("...") | |
file_button.onClick = lambda f=field, i=index: editScene(f, i) | |
window.addElement(file_button) | |
window.addReturn() | |
window.addReturn() | |
render_button = mset.UIButton("Render Image") | |
render_button.onClick = lambda: batchRender(False) | |
window.addElement(render_button) | |
video_button = mset.UIButton("Render Animation") | |
video_button.onClick = lambda: batchRender(True) | |
window.addElement(video_button) | |
close_button = mset.UIButton("Close") | |
close_button.onClick = lambda: mset.shutdownPlugin() | |
window.addElement(close_button) | |
renderUI() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have over 3000 Scenes, and I want to start render in the night, and it will render Scenes in queue. Is it possible? I use Marmoset Toolbag 4