Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardFrangenberg committed Apr 17, 2024
1 parent 872a8f3 commit 3f48019
Show file tree
Hide file tree
Showing 103 changed files with 12,763 additions and 6,626 deletions.
96 changes: 93 additions & 3 deletions Prism/Plugins/Apps/3dsMax/Scripts/Prism_3dsMax_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,15 +885,42 @@ def sm_render_startup(self, origin):
)

@err_catcher(name=__name__)
def sm_render_getAovNames(self):
def sm_render_getAovNames(self, rsFilter=False):
aovs = []
elementMgr = rt.maxOps.GetCurRenderElementMgr()
if not elementMgr.GetElementsActive():
return aovs

for idx in range(elementMgr.NumRenderElements()):
element = elementMgr.GetRenderElement(idx)
aovs.append(element.elementName)
if rsFilter:
if str(element) in ["ReferenceTarget:RsCryptomatte", "ReferenceTarget:RsBeauty"]:
continue

if element.enabled:
aovs.append(element.elementName)

return aovs

@err_catcher(name=__name__)
def sm_render_getAovNamesRedshiftLightGroups(self):
aovs = []
elementMgr = rt.maxOps.GetCurRenderElementMgr()
if not elementMgr.GetElementsActive():
return aovs

availableLightgroups = list(set([light.aovLightGroup for light in list(rt.lights) if hasattr(light, "aovLightGroup")]))
for idx in range(elementMgr.NumRenderElements()):
element = elementMgr.GetRenderElement(idx)
if element.enabled or str(element) in ["ReferenceTarget:RsCryptomatte"]:
lightgroups = []
if hasattr(element, "allLightGroups"):
if element.allLightGroups:
lightgroups = availableLightgroups
else:
lightgroups = list(element.lightGroupList)

aovs.append({"name": element.elementName, "lightgroups": lightgroups, "aovType": str(element)})

return aovs

Expand Down Expand Up @@ -928,6 +955,12 @@ def removeAOV(self, aovName):
def sm_render_preExecute(self, origin):
warnings = []

if getattr(origin, "chb_tileJob", None) and origin.chb_tileJob.isChecked():
rangeType = origin.cb_rangeType.currentText()
startFrame, endFrame = origin.getFrameRange(rangeType)
if startFrame != endFrame and endFrame is not None:
warnings.append(["Tile rendering is only supported for single frames.", "", 2])

if self.sm_render_isVray(origin):
if rt.execute( "renderers.current.output_on"):
warnings.append(["VrayFrameBuffer is activated.", "", 2])
Expand All @@ -942,12 +975,17 @@ def sm_render_preExecute(self, origin):

@err_catcher(name=__name__)
def sm_render_preSubmit(self, origin, rSettings):
isRs = self.getCurrentRenderer(origin) == "Redshift_Renderer"
if isRs and "Beauty" in self.sm_render_getAovNames():
rSettings["outputName"] = rSettings["outputName"].replace("beauty", "Beauty")

if origin.cb_rangeType.currentText() != "Single Frame":
base, ext = os.path.splitext(rSettings["outputName"])
if not base.endswith("_"):
rsOutput = base + "_" + ext
rSettings["outputName"] = rsOutput

rt.renderSceneDialog.close()
outputName = rSettings["outputName"]
if not origin.gb_submit.isHidden() and origin.gb_submit.isChecked():
if hasattr(origin, "chb_redshift") and origin.chb_redshift.isChecked() and not origin.w_redshift.isHidden():
Expand All @@ -957,7 +995,13 @@ def sm_render_preSubmit(self, origin, rSettings):
rSettings["outputName"] = rsOutput
rt.rendTimeType = 2 # needed for framepadding in outputpath

rt.renderSceneDialog.close()
if isRs and getattr(origin, "chb_tileJob", None) and origin.chb_tileJob.isChecked():
rt.execute("renderers.current.SeparateAovFiles = True")
rt.execute("renderers.current.SeparateLightGroupAovFiles = True")
rt.execute("renderers.current.RedshiftFileOutput = True")

rSettings["rendUseActiveView"] = rt.rendUseActiveView
rt.rendUseActiveView = True

elementMgr = rt.maxOps.GetCurRenderElementMgr()
rSettings["elementsActive"] = elementMgr.GetElementsActive()
Expand All @@ -973,6 +1017,8 @@ def sm_render_preSubmit(self, origin, rSettings):
passName,
os.path.basename(outputName).replace(
"beauty", passName
).replace(
"Beauty", passName
),
)
try:
Expand Down Expand Up @@ -1068,6 +1114,8 @@ def sm_render_undoRenderSettings(self, origin, rSettings):
rt.rendSaveFile = rSettings["savefile"]
if "savefilepath" in rSettings:
rt.rendOutputFilename = rSettings["savefilepath"]
if "rendUseActiveView" in rSettings:
rt.rendUseActiveView = rSettings["rendUseActiveView"]

@err_catcher(name=__name__)
def sm_render_getDeadlineParams(self, origin, dlParams, homeDir):
Expand All @@ -1083,6 +1131,7 @@ def sm_render_getDeadlineParams(self, origin, dlParams, homeDir):
dlParams["pluginInfos"]["Version"] = str(self.getAppVersion(origin)[0] - 2 + 2000)
dlParams["pluginInfos"]["MaxVersionToForce"] = dlParams["pluginInfos"]["Build"]
dlParams["pluginInfos"]["PopupHandling"] = "1"
dlParams["pluginInfos"]["IgnoreMissingDLLs"] = "1"

if origin.chb_resOverride.isChecked():
resString = "Render"
Expand All @@ -1101,6 +1150,47 @@ def sm_render_getDeadlineParams(self, origin, dlParams, homeDir):
for idx, cam in enumerate(cams):
dlParams["pluginInfos"]["Camera%s" % idx] = self.getCamName(self, cam)

if dlParams["jobInfos"].get("TileJob") and self.getCurrentRenderer(self) == "Redshift_Renderer":
updateRsOutputPath = os.path.join(
homeDir, "temp", "setRedshiftOutputpath.ms"
)
script = """
(
local du = DeadlineUtil --this is the interface exposed by the Lightning Plug-in which provides communication between Deadline and 3ds Max
du.SetTitle "Pre Frame MXS Script" --set the job title
du.LogMessage "Starting PreFrame MXS Script..." --output a message to the log
fpath = du.GetJobInfoEntry("RegionFilename" + (du.CurrentTask as string))
frameString = formattedPrint du.CurrentFrame format:"04d"
beautyPath = getFilenamePath(fpath) + getFilenameFile(fpath) + frameString + getFilenameType(fpath)
rendOutPutFilename = beautyPath
du.LogMessage("setting Redshift outputpath: " + beautyPath)
elementMgr = maxOps.GetCurRenderElementMgr()
for idx=0 to j=(elementMgr.NumRenderElements()-1) do
(
element = (maxOps.GetCurRenderElementMgr()).GetRenderElement(idx)
du.LogMessage("Redshift AOV enabled: " + (element.enabled as string))
rePath = substituteString fpath "beauty" element.elementName
rePath = substituteString rePath "Beauty" element.elementName
isCrypto = (element as string) == "ReferenceTarget:RsCryptomatte"
isBeauty = (element as string) == "ReferenceTarget:RsBeauty"
if isCrypto or isBeauty then (
frameString = formattedPrint du.CurrentFrame format:"04d"
rePath = getFilenamePath(rePath) + getFilenameFile(rePath) + frameString + getFilenameType(rePath)
)
elementMgr.SetRenderElementFilename idx rePath
du.LogMessage("set Redshift AOV outputpath: " + rePath)
)
true --return true if the task has finished successfully, return false to fail the task.
)--end script
"""
with open(updateRsOutputPath, "w") as f:
f.write(script)
dlParams["pluginInfos"]["PreFrameScript"] = os.path.basename(updateRsOutputPath)
dlParams["arguments"].append(updateRsOutputPath)

if dlParams["sceneDescription"] == "redshift":
dlParams["pluginInfos"]["MAXScriptJob"] = "1"
msPath = self.core.getTempFilepath(ext=".ms", filenamebase="MAXScriptJob_")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class Prism_3dsMax_Variables(object):
def __init__(self, core, plugin):
self.version = "v2.0.0"
self.version = "v2.0.3"
self.pluginName = "3dsMax"
self.pluginType = "App"
self.appShortName = "Max"
Expand Down
2 changes: 1 addition & 1 deletion Prism/Plugins/Apps/Blender/Integration/PrismInit.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def sceneOpen(dummy):

class PrismSave(bpy.types.Operator):
bl_idname = "object.prism_save"
bl_label = "Save"
bl_label = "Save Version"

def execute(self, context):
if platform.system() == "Linux":
Expand Down
53 changes: 39 additions & 14 deletions Prism/Plugins/Apps/Blender/Scripts/Prism_Blender_Functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import logging
import operator
import tempfile
import math

import bpy

Expand Down Expand Up @@ -226,11 +227,18 @@ def setFrameRange(self, origin, startFrame, endFrame):

@err_catcher(name=__name__)
def getFPS(self, origin):
return bpy.context.scene.render.fps
intFps = bpy.context.scene.render.fps
baseFps = bpy.context.scene.render.fps_base
return round(intFps / baseFps, 2)

@err_catcher(name=__name__)
def setFPS(self, origin, fps):
bpy.context.scene.render.fps = int(fps)
if int(fps) == fps:
bpy.context.scene.render.fps = int(fps)
else:
intFps = math.ceil(fps)
bpy.context.scene.render.fps = intFps
bpy.context.scene.render.fps_base = intFps/fps

@err_catcher(name=__name__)
def getResolution(self):
Expand Down Expand Up @@ -260,6 +268,7 @@ def openScene(self, origin, filepath, force=False):
return False

ctx = self.getOverrideContext(dftContext=False)
filepath = os.path.normpath(filepath)
try:
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.open_mainfile(ctx, "INVOKE_DEFAULT", filepath=filepath, display_file_selector=False)
Expand Down Expand Up @@ -622,7 +631,7 @@ def exportBlend(self, outputName, origin, startFrame, endFrame, expNodes):
return outputName

@err_catcher(name=__name__)
def exportUsd(self, outputName, origin, startFrame, endFrame, expNodes):
def exportUsd(self, outputName, origin, startFrame, endFrame, expNodes, catchError=True):
from _bpy import ops as _ops_module
try:
_ops_module.as_string("WM_OT_usd_export")
Expand All @@ -633,20 +642,27 @@ def exportUsd(self, outputName, origin, startFrame, endFrame, expNodes):
return False

self.setFrameRange(origin, startFrame, endFrame)
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.usd_export(
self.getOverrideContext(origin),
filepath=outputName,
export_animation=startFrame != endFrame,
selected_objects_only=(not origin.chb_wholeScene.isChecked()),
)
else:
with bpy.context.temp_override(**self.getOverrideContext(origin)):
try:
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.usd_export(
self.getOverrideContext(origin),
filepath=outputName,
export_animation=startFrame != endFrame,
selected_objects_only=(not origin.chb_wholeScene.isChecked()),
)
else:
with bpy.context.temp_override(**self.getOverrideContext(origin)):
bpy.ops.wm.usd_export(
filepath=outputName,
export_animation=startFrame != endFrame,
selected_objects_only=(not origin.chb_wholeScene.isChecked()),
)
except:
if catchError:
return False
else:
raise

return outputName

@err_catcher(name=__name__)
Expand Down Expand Up @@ -684,8 +700,9 @@ def sm_export_exportAppObjects(
if bpy.app.version < (4, 0, 0):
bpy.ops.object.select_all(ctx, action="DESELECT")
else:
with bpy.context.temp_override(**ctx):
bpy.ops.object.select_all(action="DESELECT")
if ext != ".blend":
with bpy.context.temp_override(**ctx):
bpy.ops.object.select_all(action="DESELECT")

return outputName

Expand Down Expand Up @@ -720,11 +737,19 @@ def getOverrideContext(self, origin=None, context=None, dftContext=True):
for area in screen.areas:
if area.type == "VIEW_3D":
ctx["area"] = area
ctx["region"] = None
return ctx

for area in screen.areas:
if area.type == "IMAGE_EDITOR":
ctx["area"] = area
ctx["region"] = None
return ctx

for area in screen.areas:
if area.type == "NODE_EDITOR":
ctx["area"] = area
ctx["region"] = None
return ctx

return ctx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ def updateInstallerUI(self, userFolders, pItem):
activeVersion = True

if not activeVersion:
bldPaths.setCheckState(0, Qt.Unchecked)
bldItem.setCheckState(0, Qt.Unchecked)
bldCustomItem.setFlags(~Qt.ItemIsEnabled)

except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

class Prism_Blender_Variables(object):
def __init__(self, core, plugin):
self.version = "v2.0.0"
self.version = "v2.0.4"
self.pluginName = "Blender"
self.pluginType = "App"
self.appShortName = "Bld"
Expand Down
59 changes: 43 additions & 16 deletions Prism/Plugins/Apps/Blender/Scripts/widget_import_scenedata.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,23 +184,50 @@ def importData(self, link=False):
# bpy.context.collection.children.link creates collections, which can't have library overrides so we have to use bpy.ops
if link:
if data["collections"]:
bpy.ops.wm.link(
ctx,
directory=self.scenepath + "/Collection/",
files=data["collections"],
)
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.link(
ctx,
directory=self.scenepath + "/Collection/",
files=data["collections"],
)
else:
with bpy.context.temp_override(**ctx):
bpy.ops.wm.link(
directory=self.scenepath + "/Collection/",
files=data["collections"],
)
if data["objects"]:
bpy.ops.wm.link(
ctx, directory=self.scenepath + "/Object/", files=data["objects"]
)
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.link(
ctx, directory=self.scenepath + "/Object/", files=data["objects"]
)
else:
with bpy.context.temp_override(**ctx):
bpy.ops.wm.link(
directory=self.scenepath + "/Object/", files=data["objects"]
)

else:
if data["collections"]:
bpy.ops.wm.append(
ctx,
directory=self.scenepath + "/Collection/",
files=data["collections"],
)
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.append(
ctx,
directory=self.scenepath + "/Collection/",
files=data["collections"],
)
else:
with bpy.context.temp_override(**ctx):
bpy.ops.wm.append(
directory=self.scenepath + "/Collection/",
files=data["collections"],
)
if data["objects"]:
bpy.ops.wm.append(
ctx, directory=self.scenepath + "/Object/", files=data["objects"]
)
if bpy.app.version < (4, 0, 0):
bpy.ops.wm.append(
ctx, directory=self.scenepath + "/Object/", files=data["objects"]
)
else:
with bpy.context.temp_override(**ctx):
bpy.ops.wm.append(
directory=self.scenepath + "/Object/", files=data["objects"]
)
Loading

0 comments on commit 3f48019

Please sign in to comment.