Ejemplo n.º 1
0
def filterPlane():
    """Change query and modify image plane properties."""
    variable = get_property("plane:variable")
    channel = get_property("plane:channel")

    if variable == channel or channel == "":
        _logger.debug("filterPlane (%s)", variable)
    else:
        _logger.debug("filterPlane (%s -> %s)", variable, channel)

    _PYFILTER_MANAGER.run_operations_for_stage("filterPlane")
Ejemplo n.º 2
0
    def should_run(self):
        """Determine whether or not this filter should be run.

        This operation will run if we are rendering to ip and have something to set.

        :return: Whether or not this operation should run.
        :rtype: bool

        """
        if get_property("image:filename") != "ip":
            return False

        # Only enable the operation if something is set.
        return any(
            (
                self.res_scale,
                self.sample_scale,
                self.disable_aovs,
                self.disable_blur,
                self.disable_deep,
                self.disable_displacement,
                self.disable_matte,
                self.disable_subd,
                self.disable_tilecallback,
                self.bucket_size,
                self.transparent_samples,
            )
        )
Ejemplo n.º 3
0
    def should_run(self):
        """Determine whether or not this filter should be run.

        This operation will run if we are rendering to ip and have something to set.

        :return: Whether or not this operation should run.
        :rtype: bool

        """
        if get_property("image:filename") != "ip":
            return False

        # Only enable the operation if something is set.
        return any((
            self.res_scale,
            self.sample_scale,
            self.disable_aovs,
            self.disable_blur,
            self.disable_deep,
            self.disable_displacement,
            self.disable_matte,
            self.disable_subd,
            self.disable_tilecallback,
            self.bucket_size,
            self.transparent_samples,
        ))
Ejemplo n.º 4
0
    def filterInstance(self):
        """Modify object properties.

        :return:

        """
        if self.disable_displacement:
            set_property("object:displace", [])

        if self.disable_subd:
            set_property("object:rendersubd", 0)

        if self.disable_matte:
            if get_property("object:matte") or get_property("object:phantom"):
                set_property("object:renderable", False)

            elif get_property("object:surface") == "opdef:/Shop/v_matte":
                set_property("object:renderable", False)
Ejemplo n.º 5
0
    def filter_instance(self):
        """Modify object properties.

        :return:

        """
        if self.disable_displacement:
            set_property("object:displace", [])

        if self.disable_subd:
            set_property("object:rendersubd", 0)

        if self.disable_matte:
            if get_property("object:matte") or get_property("object:phantom"):
                set_property("object:renderable", False)

            elif get_property("object:surface") == "opdef:/Shop/v_matte":
                set_property("object:renderable", False)
Ejemplo n.º 6
0
    def filter_plane(self):
        """Modify aov properties.

        :return:

        """
        # We can't disable the main image plane or Mantra won't render.
        if self.disable_aovs and get_property("plane:variable") != "Cf+Af":
            set_property("plane:disable", 1)
Ejemplo n.º 7
0
    def filter_instance(self):
        """Apply constant black shader to objects.

        :return:

        """
        matte = get_property("object:matte")
        phantom = get_property("object:phantom")
        surface = get_property("object:surface")

        set_property("object:overridedetail", True)

        if matte or phantom or surface == "matte":
            set_property("object:phantom", 1)

        else:
            set_property("object:surface", self.CONST_SHADER.split())
            set_property("object:displace", None)
Ejemplo n.º 8
0
    def filterPlane(self):
        """Modify aov properties.

        :return:

        """
        # We can't disable the main image plane or Mantra won't render.
        if self.disable_aovs and get_property("plane:variable") != "Cf+Af":
            set_property("plane:disable", 1)
Ejemplo n.º 9
0
    def test(self, mock_transform):
        mock_name = MagicMock(spec=str)

        result = prop.get_property(mock_name)

        self.assertEqual(result, mock_transform.return_value)

        mock_transform.assert_called_with(
            self.mock_mantra.property.return_value)
Ejemplo n.º 10
0
    def filterInstance(self):
        """Apply constant black shader to objects.

        :return:

        """
        matte = get_property("object:matte")
        phantom = get_property("object:phantom")
        surface = get_property("object:surface")

        set_property("object:overridedetail", True)

        if matte or phantom or surface == "matte":
            set_property("object:phantom", 1)

        else:
            set_property("object:surface", self.CONST_SHADER.split())
            set_property("object:displace", None)
Ejemplo n.º 11
0
    def filter_camera(self):
        """Apply camera properties.

        :return:

        """
        render_type = get_property("renderer:rendertype")

        if not self.all_passes and render_type != "beauty":
            _logger.warning("Not a beauty render, skipping deepresolver")
            return

        if self.disable_deep_image:
            _logger.info("Disabling deep resolver")
            set_property("image:deepresolver", [])

        else:
            # Look for existing args.
            deep_args = get_property("image:deepresolver")

            # If deep rendering is not enabled the args will be empty.
            if not deep_args:
                # If a resolver type and filename was passed then we will create
                # args for the resolver type to enable deep output.
                if self.resolver and self.filename:
                    deep_args = [self.resolver]

                # Log an error and abort.
                else:
                    _logger.error(
                        "Cannot set deepresolver: deep output is not enabled")

                    return

            # Modify the args to include any passed along options.
            self._modify_deep_args(deep_args)

            _logger.debug(
                "Setting 'image:deepresolver': %s",
                " ".join([str(arg) for arg in deep_args]),
            )

            set_property("image:deepresolver", deep_args)
Ejemplo n.º 12
0
def filterFog():
    """Modify fog related properties.

    Called just prior to the ray_end statement which locks off the settings for
    a fog object. The function can query fog: settings and possibly alter them.

    """
    _logger.debug("filterFog (%s)", get_property("object:name"))

    _PYFILTER_MANAGER.run_operations_for_stage("filterFog")
Ejemplo n.º 13
0
def test_get_property(mocker, patch_soho):
    """Test ht.pyfilter.property.get_property."""
    mock_transform = mocker.patch("ht.pyfilter.property._transform_values")

    mock_name = mocker.MagicMock(spec=str)

    result = prop.get_property(mock_name)

    assert result == mock_transform.return_value

    mock_transform.assert_called_with(patch_soho.mantra.property.return_value)
Ejemplo n.º 14
0
    def filterCamera(self):
        """Apply camera properties.

        :return:

        """
        render_type = get_property("renderer:rendertype")

        if not self.all_passes and render_type != "beauty":
            logger.warning("Not a beauty render, skipping deepresolver")
            return

        if self.disable_deep_image:
            logger.info("Disabling deep resolver")
            set_property("image:deepresolver", [])

        else:
            # Look for existing args.
            deep_args = get_property("image:deepresolver")

            # If deep rendering is not enabled the args will be empty.
            if not deep_args:
                # If a resolver type and filename was passed then we will create
                # args for the resolver type to enable deep output.
                if self.resolver and self.filename:
                    deep_args = [self.resolver]

                # Log an error and abort.
                else:
                    logger.error("Cannot set deepresolver: deep output is not enabled")

                    return

            # Modify the args to include any passed along options.
            self._modify_deep_args(deep_args)

            logger.debug(
                "Setting 'image:deepresolver': {}".format(" ".join([str(arg) for arg in deep_args]))
            )

            set_property("image:deepresolver", deep_args)
Ejemplo n.º 15
0
    def filter_camera(self):
        """Apply camera properties.

        :return:

        """
        if self.res_scale is not None:
            resolution = get_property("image:resolution")

            resolution = _scale_resolution(resolution, self.res_scale)

            set_property("image:resolution", resolution)

        if self.sample_scale is not None:
            samples = get_property("image:samples")

            samples = _scale_samples(samples, self.sample_scale)

            set_property("image:samples", samples)

        if self.bucket_size is not None:
            set_property("image:bucket", self.bucket_size)

        # Set the blurquality values to 0 to disable blur.
        if self.disable_blur:
            set_property("renderer:blurquality", 0)
            set_property("renderer:rayblurquality", 0)

        # Set the deepresolver to have no args, thus stopping it from running.
        if self.disable_deep:
            set_property("image:deepresolver", [])

        if self.disable_tilecallback:
            set_property("render:tilecallback", "")

        if self.transparent_samples:
            set_property("image:transparentsamples", self.transparent_samples)
Ejemplo n.º 16
0
    def filterCamera(self):
        """Apply camera properties.

        :return:

        """
        if self.res_scale is not None:
            resolution = get_property("image:resolution")

            resolution = _scale_resolution(resolution, self.res_scale)

            set_property("image:resolution", resolution)

        if self.sample_scale is not None:
            samples = get_property("image:samples")

            samples = _scale_samples(samples, self.sample_scale)

            set_property("image:samples", samples)

        if self.bucket_size is not None:
            set_property("image:bucket", self.bucket_size)

        # Set the blurquality values to 0 to disable blur.
        if self.disable_blur:
            set_property("renderer:blurquality", 0)
            set_property("renderer:rayblurquality", 0)

        # Set the deepresolver to have no args, thus stopping it from running.
        if self.disable_deep:
            set_property("image:deepresolver", [])

        if self.disable_tilecallback:
            set_property("render:tilecallback", "")

        if self.transparent_samples:
            set_property("image:transparentsamples", self.transparent_samples)
Ejemplo n.º 17
0
    def set_property(self):
        """Set the property under mantra.

        :return:

        """
        import hou

        # Is this property being applied using a name mask.
        if self.mask is not None:
            # Get the name of the item that is currently being filtered.
            property_value = get_property(self.mask_property_name)

            # If the mask pattern doesn't match, abort.
            if not hou.patternMatch(self.mask, property_value):
                return

        # Call the super class function to set the property.
        super(MaskedPropertySetter, self).set_property()
Ejemplo n.º 18
0
    def set_property(self):
        """Set the property to the value.

        :return:

        """
        import hou

        # Is this property being applied to a specific render type.
        if self.rendertype is not None:
            # Get the rendertype for the current pass.
            rendertype = get_property("renderer:rendertype")

            # If the type pattern doesn't match, abort.
            if not hou.patternMatch(self.rendertype, rendertype):
                return

        _logger.debug("Setting property '%s' to %s", self.name, self.value)

        # Update the property value.
        set_property(self.name, self.value)
Ejemplo n.º 19
0
    def filterPlane(self):
        """Modify image planes to ensure one will output Pz.

        This will disable all planes that are not C and Pz.

        :return:

        """
        channel = get_property("plane:channel")

        if channel == "Pz":
            # If the channel is Pz but we've already forcibly set one to Pz
            # then we need to disable the plane.
            if self.data["set_pz"]:
                set_property("plane:disable", True)

                return

            # The plane is Pz and we have yet to indicate we've got a Pz so
            # store the data.
            else:
                self.data["set_pz"] = True

                return

        # If we haven't found a Pz plane yet and this channel isn't a primary
        # output channel then we will force it to be Pz.
        if not self.data["set_pz"] and channel not in ("C", "Of"):
            set_property("plane:variable", "Pz")
            set_property("plane:vextype", "float")
            set_property("plane:channel", "Pz")
            set_property("plane:pfilter", "minmax min")
            set_property("plane:quantize", None)
            self.data["set_pz"] = True

        # Disable any other planes.
        elif channel not in ("C", ):
            set_property("plane:disable", True)
Ejemplo n.º 20
0
    def filterPlane(self):
        """Modify image planes to ensure one will output Pz.

        This will disable all planes that are not C and Pz.

        :return:

        """
        channel = get_property("plane:channel")

        if channel == "Pz":
            # If the channel is Pz but we've already forcibly set one to Pz
            # then we need to disable the plane.
            if self.data["set_pz"]:
                set_property("plane:disable", True)

                return

            # The plane is Pz and we have yet to indicate we've got a Pz so
            # store the data.
            else:
                self.data["set_pz"] = True

                return

        # If we haven't found a Pz plane yet and this channel isn't a primary
        # output channel then we will force it to be Pz.
        if not self.data["set_pz"] and channel not in ("C", "Of"):
            set_property("plane:variable", "Pz")
            set_property("plane:vextype", "float")
            set_property("plane:channel", "Pz")
            set_property("plane:pfilter", "minmax min")
            set_property("plane:quantize", None)
            self.data["set_pz"] = True

        # Disable any other planes.
        elif channel not in ("C", ):
            set_property("plane:disable", True)