Ejemplo n.º 1
0
    def process(self, instance):

        if instance.data.get("renderer") != "vray":
            # If not V-Ray ignore..
            return

        vray_settings = cmds.ls("vraySettings", type="VRaySettingsNode")
        assert vray_settings, "Please ensure a VRay Settings Node is present"

        renderlayer = instance.data['setMembers']

        if not lib.get_attr_in_layer(self.enabled_attr, layer=renderlayer):
            # If not distributed rendering enabled, ignore..
            return

        # If distributed rendering is enabled but it is *not* set to ignore
        # during batch mode we invalidate the instance
        if not lib.get_attr_in_layer(self.ignored_attr, layer=renderlayer):
            raise RuntimeError("Renderlayer has distributed rendering enabled "
                               "but is not set to ignore in batch mode.")
Ejemplo n.º 2
0
    def get_render_attribute(self, attr, layer):
        """Get attribute from render options.

        Args:
            attr (str): name of attribute to be looked up.

        Returns:
            Attribute value

        """
        return lib.get_attr_in_layer("defaultRenderGlobals.{}".format(attr),
                                     layer=layer)
    def process(self, instance):

        # Check if Extend Frames is toggled
        if not instance.data("extendFrames", False):
            return

        # Get renderer
        renderer = instance.data["renderer"]
        self.log.info("Renderer found: {}".format(renderer))

        rp_node_types = {"vray": ["VRayRenderElement", "VRayRenderElementSet"],
                         "arnold": ["aiAOV"],
                         "redshift": ["RedshiftAOV"]}

        if renderer not in rp_node_types.keys():
            self.log.error("Unsupported renderer found: '{}'".format(renderer))
            return

        result = []

        # Collect all AOVs / Render Elements
        layer = instance.data["setMembers"]
        node_type = rp_node_types[renderer]
        render_elements = cmds.ls(type=node_type)

        # Check if AOVs / Render Elements are enabled
        for element in render_elements:
            enabled = lib.get_attr_in_layer("{}.enabled".format(element),
                                            layer=layer)
            if not enabled:
                continue

            pass_name = self.get_pass_name(renderer, element)
            render_pass = "******" % (instance.data["subset"], pass_name)

            result.append(render_pass)

        self.log.info("Found {} render elements / AOVs for "
                      "'{}'".format(len(result), instance.data["subset"]))

        instance.data["renderPasses"] = result
Ejemplo n.º 4
0
    def get_invalid(cls, instance):

        invalid = False

        renderer = instance.data['renderer']
        layer = instance.data['setMembers']
        cameras = instance.data.get("cameras", [])

        # Get the node attributes for current renderer
        attrs = lib.RENDER_ATTRS.get(renderer, lib.RENDER_ATTRS['default'])
        prefix = lib.get_attr_in_layer(cls.ImagePrefixes[renderer],
                                       layer=layer)
        padding = lib.get_attr_in_layer("{node}.{padding}".format(**attrs),
                                        layer=layer)

        anim_override = lib.get_attr_in_layer("defaultRenderGlobals.animation",
                                              layer=layer)
        if not anim_override:
            invalid = True
            cls.log.error("Animation needs to be enabled. Use the same "
                          "frame for start and end to render single frame")

        if not prefix.lower().startswith("maya/<scene>"):
            invalid = True
            cls.log.error("Wrong image prefix [ {} ] - "
                          "doesn't start with: 'maya/<scene>'".format(prefix))

        if not re.search(cls.R_LAYER_TOKEN, prefix):
            invalid = True
            cls.log.error("Wrong image prefix [ {} ] - "
                          "doesn't have: '<renderlayer>' or "
                          "'<layer>' token".format(prefix))

        if len(cameras) > 1:
            if not re.search(cls.R_CAMERA_TOKEN, prefix):
                invalid = True
                cls.log.error("Wrong image prefix [ {} ] - "
                              "doesn't have: '<camera>' token".format(prefix))

        # renderer specific checks
        if renderer == "vray":
            # no vray checks implemented yet
            pass
        elif renderer == "redshift":
            if re.search(cls.R_AOV_TOKEN, prefix):
                invalid = True
                cls.log.error("Do not use AOV token [ {} ] - "
                              "Redshift automatically append AOV name and "
                              "it doesn't make much sense with "
                              "Multipart EXR".format(prefix))

        elif renderer == "renderman":
            file_prefix = cmds.getAttr("rmanGlobals.imageFileFormat")
            dir_prefix = cmds.getAttr("rmanGlobals.imageOutputDir")

            if file_prefix.lower() != cls.ImagePrefixTokens[renderer].lower():
                invalid = True
                cls.log.error("Wrong image prefix [ {} ]".format(file_prefix))

            if dir_prefix.lower() != cls.RendermanDirPrefix.lower():
                invalid = True
                cls.log.error("Wrong directory prefix [ {} ]".format(
                    dir_prefix))

        else:
            multipart = cmds.getAttr("defaultArnoldDriver.mergeAOVs")
            if multipart:
                if re.search(cls.R_AOV_TOKEN, prefix):
                    invalid = True
                    cls.log.error("Wrong image prefix [ {} ] - "
                                  "You can't use '<renderpass>' token "
                                  "with merge AOVs turned on".format(prefix))
            else:
                if not re.search(cls.R_AOV_TOKEN, prefix):
                    invalid = True
                    cls.log.error("Wrong image prefix [ {} ] - "
                                  "doesn't have: '<renderpass>' or "
                                  "token".format(prefix))

        # prefix check
        if prefix.lower() != cls.ImagePrefixTokens[renderer].lower():
            cls.log.warning("warning: prefix differs from "
                            "recommended {}".format(
                                cls.ImagePrefixTokens[renderer]))

        if padding != cls.DEFAULT_PADDING:
            invalid = True
            cls.log.error("Expecting padding of {} ( {} )".format(
                cls.DEFAULT_PADDING, "0" * cls.DEFAULT_PADDING))

        return invalid