Skip to content

Commit

Permalink
Merge branch 'develop' into enhancement/maya_load_published_workfile_…
Browse files Browse the repository at this point in the history
…as_template
  • Loading branch information
tokejepsen authored Apr 29, 2024
2 parents e75f44f + fdc86c6 commit 02f2381
Show file tree
Hide file tree
Showing 114 changed files with 2,753 additions and 913 deletions.
2 changes: 1 addition & 1 deletion client/ayon_core/addon/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
# When addon was moved from ayon-core codebase
# - this is used to log the missing addon
MOVED_ADDON_MILESTONE_VERSIONS = {
"applications": VersionInfo(2, 0, 0),
"applications": VersionInfo(0, 2, 0),
}

# Inherit from `object` for Python 2 hosts
Expand Down
21 changes: 20 additions & 1 deletion client/ayon_core/hosts/blender/plugins/publish/extract_abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import bpy

from ayon_core.lib import BoolDef
from ayon_core.pipeline import publish
from ayon_core.hosts.blender.api import plugin

Expand All @@ -17,6 +18,8 @@ def process(self, instance):
if not self.is_active(instance.data):
return

attr_values = self.get_attr_values_from_data(instance.data)

# Define extract output file path
stagingdir = self.staging_dir(instance)
folder_name = instance.data["folderEntity"]["name"]
Expand Down Expand Up @@ -46,7 +49,8 @@ def process(self, instance):
bpy.ops.wm.alembic_export(
filepath=filepath,
selected=True,
flatten=False
flatten=False,
subdiv_schema=attr_values.get("subdiv_schema", False)
)

plugin.deselect_all()
Expand All @@ -65,6 +69,21 @@ def process(self, instance):
self.log.debug("Extracted instance '%s' to: %s",
instance.name, representation)

@classmethod
def get_attribute_defs(cls):
return [
BoolDef(
"subdiv_schema",
label="Alembic Mesh Subdiv Schema",
tooltip="Export Meshes using Alembic's subdivision schema.\n"
"Enabling this includes creases with the export but "
"excludes the mesh's normals.\n"
"Enabling this usually result in smaller file size "
"due to lack of normals.",
default=False
)
]


class ExtractModelABC(ExtractABC):
"""Extract model as ABC."""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from ayon_core.lib import PreLaunchHook
from ayon_applications import PreLaunchHook
from ayon_core.hosts.fusion import FUSION_HOST_DIR


Expand Down
37 changes: 37 additions & 0 deletions client/ayon_core/hosts/houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,43 @@ def get_current_context_template_data_with_folder_attrs():
return template_data


def set_review_color_space(opengl_node, review_color_space="", log=None):
"""Set ociocolorspace parameter for the given OpenGL node.
Set `ociocolorspace` parameter of the given OpenGl node
to to the given review_color_space value.
If review_color_space is empty, a default colorspace corresponding to
the display & view of the current Houdini session will be used.
Args:
opengl_node (hou.Node): ROP node to set its ociocolorspace parm.
review_color_space (str): Colorspace value for ociocolorspace parm.
log (logging.Logger): Logger to log to.
"""

if log is None:
log = self.log

# Set Color Correction parameter to OpenColorIO
colorcorrect_parm = opengl_node.parm("colorcorrect")
if colorcorrect_parm.eval() != 2:
colorcorrect_parm.set(2)
log.debug(
"'Color Correction' parm on '{}' has been set to"
" 'OpenColorIO'".format(opengl_node.path())
)

opengl_node.setParms(
{"ociocolorspace": review_color_space}
)

log.debug(
"'OCIO Colorspace' parm on '{}' has been set to "
"the view color space '{}'"
.format(opengl_node, review_color_space)
)


def get_context_var_changes():
"""get context var changes."""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from ayon_applications import PreLaunchHook, LaunchTypes


class SetDefaultDisplayView(PreLaunchHook):
"""Set default view and default display for houdini via OpenColorIO.
Houdini's defaultDisplay and defaultView are set by
setting 'OCIO_ACTIVE_DISPLAYS' and 'OCIO_ACTIVE_VIEWS'
environment variables respectively.
More info: https://www.sidefx.com/docs/houdini/io/ocio.html#set-up
"""

app_groups = {"houdini"}
launch_types = {LaunchTypes.local}

def execute(self):

OCIO = self.launch_context.env.get("OCIO")

# This is a cheap way to skip this hook if either global color
# management or houdini color management was disabled because the
# OCIO var would be set by the global OCIOEnvHook
if not OCIO:
return

houdini_color_settings = \
self.data["project_settings"]["houdini"]["imageio"]["workfile"]

if not houdini_color_settings["enabled"]:
self.log.info(
"Houdini workfile color management is disabled."
)
return

# 'OCIO_ACTIVE_DISPLAYS', 'OCIO_ACTIVE_VIEWS' are checked
# as Admins can add them in Ayon env vars or Ayon tools.

default_display = houdini_color_settings["default_display"]
if default_display:
# get 'OCIO_ACTIVE_DISPLAYS' value if exists.
self._set_context_env("OCIO_ACTIVE_DISPLAYS", default_display)

default_view = houdini_color_settings["default_view"]
if default_view:
# get 'OCIO_ACTIVE_VIEWS' value if exists.
self._set_context_env("OCIO_ACTIVE_VIEWS", default_view)

def _set_context_env(self, env_var, default_value):
env_value = self.launch_context.env.get(env_var, "")
new_value = ":".join(
key for key in [default_value, env_value] if key
)
self.log.info(
"Setting {} environment to: {}"
.format(env_var, new_value)
)
self.launch_context.env[env_var] = new_value
43 changes: 20 additions & 23 deletions client/ayon_core/hosts/houdini/plugins/create/create_review.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""Creator plugin for creating openGL reviews."""
from ayon_core.hosts.houdini.api import plugin
from ayon_core.hosts.houdini.api import lib, plugin
from ayon_core.lib import EnumDef, BoolDef, NumberDef

import os
Expand All @@ -14,6 +14,13 @@ class CreateReview(plugin.HoudiniCreator):
label = "Review"
product_type = "review"
icon = "video-camera"
review_color_space = ""

def apply_settings(self, project_settings):
super(CreateReview, self).apply_settings(project_settings)
color_settings = project_settings["houdini"]["imageio"]["workfile"]
if color_settings["enabled"]:
self.review_color_space = color_settings.get("review_color_space")

def create(self, product_name, instance_data, pre_create_data):

Expand Down Expand Up @@ -85,10 +92,20 @@ def create(self, product_name, instance_data, pre_create_data):

instance_node.setParms(parms)

# Set OCIO Colorspace to the default output colorspace
# Set OCIO Colorspace to the default colorspace
# if there's OCIO
if os.getenv("OCIO"):
self.set_colorcorrect_to_default_view_space(instance_node)
# Fall to the default value if cls.review_color_space is empty.
if not self.review_color_space:
# cls.review_color_space is an empty string
# when the imageio/workfile setting is disabled or
# when the Review colorspace setting is empty.
from ayon_core.hosts.houdini.api.colorspace import get_default_display_view_colorspace # noqa
self.review_color_space = get_default_display_view_colorspace()

lib.set_review_color_space(instance_node,
self.review_color_space,
self.log)

to_lock = ["id", "productType"]

Expand Down Expand Up @@ -131,23 +148,3 @@ def get_pre_create_attr_defs(self):
minimum=0.0001,
decimals=3)
]

def set_colorcorrect_to_default_view_space(self,
instance_node):
"""Set ociocolorspace to the default output space."""
from ayon_core.hosts.houdini.api.colorspace import get_default_display_view_colorspace # noqa

# set Color Correction parameter to OpenColorIO
instance_node.setParms({"colorcorrect": 2})

# Get default view space for ociocolorspace parm.
default_view_space = get_default_display_view_colorspace()
instance_node.setParms(
{"ociocolorspace": default_view_space}
)

self.log.debug(
"'OCIO Colorspace' parm on '{}' has been set to "
"the default view color space '{}'"
.format(instance_node, default_view_space)
)
30 changes: 4 additions & 26 deletions client/ayon_core/hosts/houdini/plugins/load/load_alembic.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,33 +45,11 @@ def load(self, context, name=None, namespace=None, data=None):
alembic = container.createNode("alembic", node_name=node_name)
alembic.setParms({"fileName": file_path})

# Add unpack node
unpack_name = "unpack_{}".format(name)
unpack = container.createNode("unpack", node_name=unpack_name)
unpack.setInput(0, alembic)
unpack.setParms({"transfer_attributes": "path"})
# Position nodes nicely
container.moveToGoodPosition()
container.layoutChildren()

# Add normal to points
# Order of menu ['point', 'vertex', 'prim', 'detail']
normal_name = "normal_{}".format(name)
normal_node = container.createNode("normal", node_name=normal_name)
normal_node.setParms({"type": 0})

normal_node.setInput(0, unpack)

null = container.createNode("null", node_name="OUT")
null.setInput(0, normal_node)

# Ensure display flag is on the Alembic input node and not on the OUT
# node to optimize "debug" displaying in the viewport.
alembic.setDisplayFlag(True)

# Set new position for unpack node else it gets cluttered
nodes = [container, alembic, unpack, normal_node, null]
for nr, node in enumerate(nodes):
node.setPosition([0, (0 - nr)])

self[:] = nodes
nodes = [container, alembic]

return pipeline.containerise(
node_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import hou


class ExtractComposite(publish.Extractor):
class ExtractComposite(publish.Extractor,
publish.ColormanagedPyblishPluginMixin):

order = pyblish.api.ExtractorOrder
label = "Extract Composite (Image Sequence)"
Expand Down Expand Up @@ -45,8 +46,14 @@ def process(self, instance):
"frameEnd": instance.data["frameEndHandle"],
}

from pprint import pformat

self.log.info(pformat(representation))
if ext.lower() == "exr":
# Inject colorspace with 'scene_linear' as that's the
# default Houdini working colorspace and all extracted
# OpenEXR images should be in that colorspace.
# https://www.sidefx.com/docs/houdini/render/linear.html#image-formats
self.set_representation_colorspace(
representation, instance.context,
colorspace="scene_linear"
)

instance.data["representations"].append(representation)
11 changes: 10 additions & 1 deletion client/ayon_core/hosts/houdini/plugins/publish/extract_opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import hou


class ExtractOpenGL(publish.Extractor):
class ExtractOpenGL(publish.Extractor,
publish.ColormanagedPyblishPluginMixin):

order = pyblish.api.ExtractorOrder - 0.01
label = "Extract OpenGL"
Expand Down Expand Up @@ -46,6 +47,14 @@ def process(self, instance):
"camera_name": instance.data.get("review_camera")
}

if ropnode.evalParm("colorcorrect") == 2: # OpenColorIO enabled
colorspace = ropnode.evalParm("ociocolorspace")
# inject colorspace data
self.set_representation_colorspace(
representation, instance.context,
colorspace=colorspace
)

if "representations" not in instance.data:
instance.data["representations"] = []
instance.data["representations"].append(representation)
Loading

0 comments on commit 02f2381

Please sign in to comment.