Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Max: Optional Renderable Camera Validator for Render Instance #5286

Merged
merged 14 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions openpype/hosts/max/api/lib_rendersettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def set_render_camera(self, selection):
rt.viewport.setCamera(sel)
break
if not found:
raise RuntimeError("Camera not found")
raise RuntimeError("Active Camera not found")

def render_output(self, container):
folder = rt.maxFilePath
Expand Down Expand Up @@ -113,7 +113,8 @@ def arnold_setup(self):
# for setting up renderable camera
arv = rt.MAXToAOps.ArnoldRenderView()
render_camera = rt.viewport.GetCamera()
arv.setOption("Camera", str(render_camera))
if render_camera:
arv.setOption("Camera", str(render_camera))

# TODO: add AOVs and extension
img_fmt = self._project_settings["max"]["RenderSettings"]["image_format"] # noqa
Expand Down
3 changes: 3 additions & 0 deletions openpype/hosts/max/plugins/publish/collect_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ def process(self, instance):
aovs = RenderProducts().get_aovs(instance.name)
files_by_aov.update(aovs)

camera = rt.viewport.GetCamera()
instance.data["cameras"] = [camera.name] if camera else None # noqa

if "expectedFiles" not in instance.data:
instance.data["expectedFiles"] = list()
instance.data["files"] = list()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class ValidateMaxContents(pyblish.api.InstancePlugin):
order = pyblish.api.ValidatorOrder
families = ["camera",
"maxScene",
"maxrender",
"review"]
hosts = ["max"]
label = "Max Scene Contents"
Expand Down
46 changes: 46 additions & 0 deletions openpype/hosts/max/plugins/publish/validate_renderable_camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# -*- coding: utf-8 -*-
import pyblish.api
from openpype.pipeline import (
PublishValidationError,
OptionalPyblishPluginMixin)
from openpype.pipeline.publish import RepairAction
from openpype.hosts.max.api.lib import get_current_renderer

from pymxs import runtime as rt


class ValidateRenderableCamera(pyblish.api.InstancePlugin,
OptionalPyblishPluginMixin):
"""Validates Renderable Camera

Check if the renderable camera used for rendering
"""

order = pyblish.api.ValidatorOrder
families = ["maxrender"]
hosts = ["max"]
label = "Renderable Camera"
optional = True
actions = [RepairAction]

def process(self, instance):
if not self.is_active(instance.data):
return
if not instance.data["cameras"]:
raise PublishValidationError(
"No renderable Camera found in scene."
)

@classmethod
def repair(cls, instance):

rt.viewport.setType(rt.Name("view_camera"))
camera = rt.viewport.GetCamera()
cls.log.info(f"Camera {camera} set as renderable camera")
renderer_class = get_current_renderer()
renderer = str(renderer_class).split(":")[0]
if renderer == "Arnold":
arv = rt.MAXToAOps.ArnoldRenderView()
arv.setOption("Camera", str(camera))
arv.close()
instance.data["cameras"] = [camera.name]
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ def _use_published_name(self, data, project_settings):
if renderer == "Redshift_Renderer":
plugin_data["redshift_SeparateAovFiles"] = instance.data.get(
"separateAovFiles")

if instance.data["cameras"]:
plugin_info["Camera0"] = None
plugin_info["Camera"] = instance.data["cameras"][0]
plugin_info["Camera1"] = instance.data["cameras"][0]
self.log.debug("plugin data:{}".format(plugin_data))
plugin_info.update(plugin_data)

Expand Down