コード例 #1
0
    def filterCamera(self):
        """Apply camera properties."""
        import mantra

        render_type = mantra.property("renderer:rendertype")[0]

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

        # Look for existing args.
        deepresolver = mantra.property("image:deepresolver")

        if deepresolver == ['']:
            logger.error(
                "Cannot set deepresolver: deepresolver is not enabled")
            return

        if deepresolver:
            args = list(deepresolver[0].split())

            try:
                idx = args.index("filename")

            except ValueError as inst:
                logger.exception(inst)
                return

            else:
                args[idx + 1] = self.filepath

                # Set the new list as the property value
                setProperty("image:deepresolver", args)
コード例 #2
0
    def filterCamera(self):
        """Apply camera properties."""
        import mantra

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

            new_res = [int(round(val * self.res_scale)) for val in resolution]

            setProperty("image:resolution", new_res)

        if self.sample_scale:
            samples = mantra.property("image:samples")

            # Need to make sure our values are at least a minimum of 1.
            new_samples = [
                int(math.ceil(val * self.sample_scale)) for val in samples
            ]

            setProperty("image:samples", new_samples)

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

        # Redirect the deepresolver to 'null' to disable deep generation.
        if self.disable_deep:
            setProperty("image:deepresolver", "null")
コード例 #3
0
    def filterCamera(self):
        """Apply camera properties."""
        import mantra

        render_type = mantra.property("renderer:rendertype")[0]

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

        # Look for existing args.
        deep_args = mantra.property("image:deepresolver")

        # If deep rendering is not enabled the args will be emptry so we should
        # log an error and bail out.
        if not deep_args:
            logger.error(
                "Cannot set deepresolver: deepresolver is not enabled")

            return

        try:
            idx = deep_args.index("filename")

        # Somehow there is no filename arg so log an exception and print the
        # args list.
        except ValueError as inst:
            logger.exception(inst)
            logger.error("Deep args: {}".format(deep_args))

        else:
            deep_args[idx + 1] = self.filepath

            # Set the new list as the property value
            setProperty("image:deepresolver", deep_args)
コード例 #4
0
    def filterCamera(self):
        """Apply camera properties."""
        import mantra

        render_type = mantra.property("renderer:rendertype")[0]

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

        # Look for existing args.
        deepresolver = mantra.property("image:deepresolver")

        if deepresolver == [""]:
            logger.error("Cannot set deepresolver: deepresolver is not enabled")
            return

        if deepresolver:
            args = list(deepresolver[0].split())

            try:
                idx = args.index("filename")

            except ValueError as inst:
                logger.exception(inst)
                return

            else:
                args[idx + 1] = self.filepath

                # Set the new list as the property value
                setProperty("image:deepresolver", args)
コード例 #5
0
    def filterCamera(self):
        """Apply camera properties."""
        import mantra

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

            new_res = [int(round(val * self.res_scale)) for val in resolution]

            setProperty("image:resolution", new_res)

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

            # Need to make sure our values are at least a minimum of 1.
            new_samples = [
                max(1, int(math.ceil(val * self.sample_scale)))
                for val in samples
            ]

            setProperty("image:samples", new_samples)

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

        # Set the deepresolver to have no args, thus stopping it from running.
        if self.disable_deep:
            setProperty("image:deepresolver", [])
コード例 #6
0
    def filterCamera(self):
        """Apply camera properties."""
        import mantra

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

            new_res = [int(round(val * self.res_scale)) for val in resolution]

            setProperty("image:resolution", new_res)

        if self.sample_scale:
            samples = mantra.property("image:samples")

            # Need to make sure our values are at least a minimum of 1.
            new_samples = [int(math.ceil(val * self.sample_scale)) for val in samples]

            setProperty("image:samples", new_samples)

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

        # Redirect the deepresolver to 'null' to disable deep generation.
        if self.disable_deep:
            setProperty("image:deepresolver", "null")
コード例 #7
0
ファイル: ht-pyfilter.py プロジェクト: dseeni/Houdini-Toolbox
def filterPlane():
    """Change query and modify image plane properties."""
    variable = mantra.property("plane:variable")[0]
    channel = mantra.property("plane:channel")[0]

    if variable == channel or channel == "":
        logger.debug("filterPlane ({})".format(variable))
    else:
        logger.debug("filterPlane ({} -> {})".format(variable, channel))

    PYFILTER_MANAGER.run_operations_for_stage("filterPlane")
コード例 #8
0
def filterPlane():
    """Change query and modify image plane properties."""
    variable = mantra.property("plane:variable")[0]
    channel = mantra.property("plane:channel")[0]

    if variable == channel or channel == "":
        logger.debug("filterPlane ({})".format(variable))
    else:
        logger.debug("filterPlane ({} -> {})".format(variable, channel))

    PYFILTER_MANAGER.run_operations_for_stage("filterPlane")
コード例 #9
0
ファイル: mantrafilter.py プロジェクト: fsimerey/cgru
def filterCamera():
	if tilerender:
		resolution = mantra.property('image:resolution')
		oldcrop = mantra.property('image:crop')
		if oldcrop[0]>oldcrop[1]: # no crop in ifd file
			oldcrop = [0, 1, 0, 1]
		newcrop = [max(tilecrop[0], oldcrop[0]), min(tilecrop[1], oldcrop[1]),
			   max(tilecrop[2], oldcrop[2]), min(tilecrop[3], oldcrop[3])]
		# convert to pixels
		newpixelcrop = [int(resolution[0] * newcrop[0]), int(resolution[0] * newcrop[1])-1,
				int(resolution[1] * newcrop[2]), int(resolution[1] * newcrop[3])-1]
		mantra.setproperty('image:pixelcrop', newpixelcrop)
コード例 #10
0
ファイル: mantrafilter.py プロジェクト: JackTing/cgru
def filterPlane():
    """This one is called for each image plane - change name here
	NB! only additional image plane files can be changed here - main image
	filename will have to be set through command line
	"""
    global imagesdir
    filename = mantra.property('image:filename')[0]
    print('FilterPlane = "%s"' % filename)
    if filename is None:
        return
    if filename == '':
        return
    if filename.find('nul') == 0:
        return
    if not filename in filteredNames:
        filteredNames.append(filename)
        if imagesdir == '':
            imagesdir = os.path.dirname(filename)

        if tilerender:
            filename += '.tile_%d.exr' % tilenum

        if tmpdir != '':
            pos = filename.rfind("/")
            filename = tmpdir + filename[pos:]

        print('Mantra plane filename:\n%s' % filename)

        mantra.setproperty('plane:planefile', filename)
コード例 #11
0
def filterPlane():
    """
    Reads the image plane filename and then alters it's name to include the co-ordinates
    for proper stitching tools.
    """
    # set to false if you want to simply render tiles within the target folder
    # and not into a 'tiles' sub-folder as stated below.
    tile_params = get_tile_params()

    current_tile = int(tile_params['regionNumber'])

    mantraFileName = mantra.property('image:filename')[0]
    baseFileName = path.basename(mantraFileName)
    filePath = path.dirname(mantraFileName)

    if "/" in filePath:
        separator = "/"
    else:
        separator = "\\"

    paddedNumberRegex = re.compile("([0-9]+)", re.IGNORECASE)
    matches = paddedNumberRegex.findall(baseFileName)
    if matches != None and len(matches) > 0:
        paddingString = matches[len(matches) - 1]
        padding = str(current_tile)
        padding = "_tile" + padding + "_" + paddingString
        fileName = filePath + separator + RightReplace(
            baseFileName, paddingString, padding, 1)
    else:
        splitFilename = path.splitext(baseFileName)
        padding = str(current_tile)
        fileName = filePath + separator + splitFilename[
            0] + "_tile" + padding + "_" + splitFilename[1]

    mantra.setproperty('plane:planefile', fileName)
コード例 #12
0
    def filterPlane(self):
        """Modify aov properties."""
        import mantra

        # We can't disable the main image plane or Mantra won't render.
        if self.disable_aovs and mantra.property("plane:variable")[0] != "Cf+Af":
            setProperty("plane:disable", 1)
コード例 #13
0
ファイル: mantrafilter.py プロジェクト: fsimerey/cgru
def filterPlane():
	"""This one is called for each image plane - change name here
	NB! only additional image plane files can be changed here - main image
	filename will have to be set through command line
	"""
	global imagesdir
	filename = mantra.property('image:filename')[0]
	print('FilterPlane = "%s"' % filename)
	if filename is None:
		return
	if filename == '':
		return
	if filename.find('nul') == 0:
		return
	if not filename in filteredNames:
		filteredNames.append(filename)
		if imagesdir == '':
			imagesdir = os.path.dirname(filename)

		if tilerender:
			filename += '.tile_%d.exr' % tilenum

		if tmpdir != '':
			pos = filename.rfind("/")
			filename = tmpdir + filename[pos:]

		print('Mantra plane filename:\n%s' % filename)

		mantra.setproperty('plane:planefile', filename)
コード例 #14
0
    def _initData(self):
        """Init internal data."""
        import mantra

        values = mantra.property(self.name)

        if len(values) == 1:
            value = values[0]

            if isinstance(value, str):
                # Try to decode the string as a json object.
                try:
                    value = json.loads(value)

                # It can't be converted to a dict so we'll process it manually.
                except ValueError:
                    #Split the string.
                    split_vals = value.split()

                    # If there are multiple values we want to build a
                    # dictionary out of pairs.
                    if len(split_vals) > 2:
                        value = dict(zip(*[iter(split_vals)]*2))

                    # Not multiple values so do any additional processing.
                    else:
                        value = _parseString(value)

        else:
            value = values

        self._value = value
コード例 #15
0
    def filterPlane(self):
        """Modify aov properties."""
        import mantra

        # We can't disable the main image plane or Mantra won't render.
        if self.disable_aovs and mantra.property(
                "plane:variable")[0] != "Cf+Af":
            setProperty("plane:disable", 1)
コード例 #16
0
def filterQuit():
    # Make a proxy jpeg on exit using tiit utility:
    if options.make_proxy:
        if os.path.isdir(
                os.path.split(mantra.property("image:filename")[0])[0]):
            filename = mantra.property("image:filename")[0]
            path, filename = os.path.split(filename)
            path = os.path.join(path, "proxy")
            if not os.path.isdir(path):
                os.mkdir(path)
            filename = os.path.splitext(filename)[0] + ".jpg"
            path = os.path.join(path, filename)
            lut = '/STUDIO/houdini/houdini11.1/luts/nuke_sRGB.blut'
            command = 'LD_PRELOAD=/opt/packages/oiio-1.4.15/lib/libOpenImageIO.so.1.4 \
			/opt/packages/oiio-1.4.15/bin/oiiotool %s --tocolorspace "sRGB" -ch "R,G,B" -o %s' % (
                mantra.property("image:filename")[0], path)
            result = os.popen(command).read()
コード例 #17
0
def filterPlane():
    """Change query and modify image plane properties.

    Raises:
        N/A

    Returns:
        None

    """
    variable = mantra.property("plane:variable")[0]
    channel = mantra.property("plane:channel")[0]

    if variable == channel:
        logging.info("filterPlane ({0})".format(variable))
    else:
        logging.info("filterPlane ({0} -> {1})".format(variable, channel))

    ht.pyfilter.parser.applyProperties(PROPERTIES, "plane")
コード例 #18
0
def filterInstance():
    """Modify object related properties.

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

    """
    logger.debug("filterInstance ({})".format(mantra.property("object:name")[0]))
    PYFILTER_MANAGER.runFilters("filterInstance")
コード例 #19
0
ファイル: ht-pyfilter.py プロジェクト: dseeni/Houdini-Toolbox
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 ({})".format(mantra.property("object:name")[0]))

    PYFILTER_MANAGER.run_operations_for_stage("filterFog")
コード例 #20
0
def filterEndRender():
    #global gilight
    if options.database:
        db = get_db()
        sig = md5(mantra.property('image:filename')[0]).hexdigest()
        doc = db[sig]
        doc['objects'] = ha_objects
        doc['lights'] = ha_lights
        doc['end_time'] = time()
        db[doc.id] = doc
コード例 #21
0
ファイル: mantrafilter.py プロジェクト: ruiying/cgru
def filterCamera():
    if tilerender:
        oldcrop = mantra.property("image:crop")
        newcrop = [
            max(tilecrop[0], oldcrop[0]),
            min(tilecrop[1], oldcrop[1]),
            max(tilecrop[2], oldcrop[2]),
            min(tilecrop[3], oldcrop[3]),
        ]
        mantra.setproperty("image:crop", newcrop)
コード例 #22
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 ({})".format(mantra.property("object:name")[0]))

    PYFILTER_MANAGER.run_operations_for_stage("filterFog")
コード例 #23
0
ファイル: mantrafilter.py プロジェクト: JackTing/cgru
def filterCamera():
    if tilerender:
        resolution = mantra.property('image:resolution')
        oldcrop = mantra.property('image:crop')
        if oldcrop[0] > oldcrop[1]:  # no crop in ifd file
            oldcrop = [0, 1, 0, 1]
        newcrop = [
            max(tilecrop[0], oldcrop[0]),
            min(tilecrop[1], oldcrop[1]),
            max(tilecrop[2], oldcrop[2]),
            min(tilecrop[3], oldcrop[3])
        ]
        # convert to pixels
        newpixelcrop = [
            int(resolution[0] * newcrop[0]),
            int(resolution[0] * newcrop[1]) - 1,
            int(resolution[1] * newcrop[2]),
            int(resolution[1] * newcrop[3]) - 1
        ]
        mantra.setproperty('image:pixelcrop', newpixelcrop)
コード例 #24
0
def build_dictionary(fields):
    store = {}
    fields = fields.split("%")
    # User specified fields:
    for field in fields:
        store[field] = mantra.property(field)[0]
    # Some stuff we always want to log:
    store['filename'] = mantra.property('image:filename')[0]
    store['hostname'] = os.popen('hostname').readlines()[0].strip()
    store['start_time'] = time()
    store['type'] = 'frame'
    store['asset_type'] = getenv("JOB_ASSET_TYPE", "")
    store['asset_name'] = getenv("JOB_ASSET_NAME", "")
    store['user'] = getenv("USER", "")
    store['insider'] = "HaFilterIFD"
    # Sequence id helps to find it in db,
    # Path + name -padding + extension:
    seed = utils.padding(store['filename'])
    store['seq_id'] = md5(seed[0][:-1] + seed[-1]).hexdigest()
    return store
コード例 #25
0
    def setProperty(self):
        # 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.
            filteredItem = mantra.property(self.maskPropertyName)[0]

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

        # Call the super class function to set the property.
        super(MaskedPropertySetting, self).setProperty()
コード例 #26
0
    def setProperty(self):
        # 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.
            filteredItem = mantra.property(self.maskPropertyName)[0]

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

        # Call the super class function to set the property.
        super(MaskedPropertySetting, self).setProperty()
コード例 #27
0
def filterLight():
    # Global Irradiance Pass:
    global ha_lights
    ha_lights.append(mantra.property("light:name")[0])

    if options.irradiance:
        global gilight
        if not gilight:
            print 'GI light from: ' + mantra.property('light:name')[0]
            mantra.setproperty(
                "light:shadow",
                "opdef:/Shop/v_rayshadow shadowtype none".split())
            mantra.setproperty(
                'light:shader', 'opdef:/Shop/v_gilight '.split() +
                options.irradiance.split("%"))
            gilight = True
        else:
            mantra.setproperty(
                'light:shader',
                'opdef:/Shop/v_asadlight lightcolor 0 0 0'.split())

    # Light masking:
    elif options.lights:
        colors = ["1 0 0", "0 1 0", "0 0 1", "1 1 1"]
        lights = get_lights()
        light = mantra.property('light:name')[0]

        for light_group in lights:
            if light in light_group:
                print light
                mantra.setproperty(
                    'light:shader',
                    'opdef:/Shop/v_asadlight lightcolor '.split() +
                    colors[lights.index(light_group)].split())
                return

        # Disable anything else:
        mantra.setproperty('light:shader',
                           'opdef:/Shop/v_asadlight lightcolor 0 0 0 '.split())
コード例 #28
0
ファイル: property.py プロジェクト: hickb/Houdini-Toolbox
def get_property(name):
    """Get a property value.

    :param name: The property name.
    :type name: str
    :return: The value.
    :rtype: object

    """
    import mantra

    values = mantra.property(name)

    return _transform_values(values)
コード例 #29
0
        def wrapper(*args, **kwargs):  # pylint: disable=missing-docstring
            func_name = func.__name__
            class_name = args[0].__class__.__name__

            msg = "{}.{}()".format(class_name, func_name)

            if isinstance(method_or_name, str):
                import mantra

                msg = "{} ({})".format(msg, mantra.property(method_or_name)[0])

            _logger.debug(msg)

            func(*args, **kwargs)
コード例 #30
0
def filterFog():
    """Modify fog related properties.

    Raises:
        N/A

    Returns:
        None

    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.

    """
    logging.info("filterFog ({0})".format(mantra.property("object:name")[0]))
    ht.pyfilter.parser.applyProperties(PROPERTIES, "fog")
コード例 #31
0
def filterCamera():
    # Actually I don't have a clue what's that:
    filename = mantra.property('image:filename')[0]
    mantra.setproperty('plane:planefile', [filename])
    variable = mantra.property("plane:variable")[0]
    channel = mantra.property('plane:channel')
    mantra.setproperty('plane:channel', channel)
    channel = mantra.property('plane:channel')

    # Perform explicite crop on the image:
    if options.crop:
        crop = options.crop.split("%")
        print 'Cropping camera to: %s' % str(crop)
        mantra.setproperty("image:crop", crop)

    # Overwrite mantra image output:
    if options.filename:
        print 'Overwriting mantra output to: %s' % options.filename
        filename = mantra.setproperty('image:filename', options.filename)

    # Create tiled image based on provided params ( horiz. tiles, vert. tiles, current tile).
    if options.tiling:
        tile_parms = options.tiling.split("%")
        crop = compute_crop([int(x) for x in tile_parms])
        mantra.setproperty('image:crop', crop)
        base, ext = os.path.splitext(filename)
        path, file = os.path.split(base)
        base = os.path.join(path, const.TILES_POSTFIX)
        # FIXME: This shouldn't be here at all:
        if not os.path.isdir(base):
            os.mkdir(base)
        base = os.path.join(base, file)
        filename = base + "%s%s%s" % (const.TILE_ID, str(tile_parms[2]), ext)
        mantra.setproperty('image:filename', filename)
        print 'WARNING: Image is altered by tiling: %s with name %s' % (
            crop, filename)
コード例 #32
0
        def wrapper(*args, **kwargs):
            func_name = func.__name__
            class_name = args[0].__class__.__name__

            msg = "{}.{}()".format(class_name, func_name)

            if isinstance(method_or_name, str):
                import mantra

                msg = "{} ({})".format(
                    msg,
                    mantra.property(method_or_name)[0]
                )

            logger.debug(msg)

            func(*args, **kwargs)
コード例 #33
0
def filterPlane():
	global imagesdir
	filename = mantra.property('image:filename')[0]
	print('FilterPlane = "%s"' % filename)
	if filename is None: return
	if filename == '': return
	if filename.find('nul') == 0: return
	if not filename in filteredNames:
		filteredNames.append( filename)
		if imagesdir == '':
			imagesdir = os.path.dirname( filename)
		if tilerender:
			filename += '.tile_%d.exr' % tilenum
		if tmpdir != '':
			pos = filename.rfind("/")
			filename = tmpdir + filename[pos:]
		print('Mantra plane filename:\n' + filename)
		mantra.setproperty('plane:planefile', filename)
コード例 #34
0
ファイル: zdepth.py プロジェクト: tws0002/Houdini-Toolbox
    def filterInstance(self):
        """Apply constant black shaders to objects."""
        matte = Property("object:matte").value
        phantom = Property("object:phantom").value
        surface = Property("object:surface").value

        print matte, phantom, surface

        surface = mantra.property("object:surface")[0]

        setProperty("object:overridedetail", True)

        shader = "opdef:/Shop/v_constant clr 0 0 0".split()

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

        else:
            setProperty("object:surface", shader)
            setProperty("object:displace", None)
コード例 #35
0
ファイル: mantrafilter.py プロジェクト: ruiying/cgru
def filterPlane():
    global imagesdir
    filename = mantra.property("image:filename")[0]
    print 'FilterPlane = "%s"' % filename
    if filename is None:
        return
    if filename == "":
        return
    if filename.find("nul") == 0:
        return
    if not filename in filteredNames:
        filteredNames.append(filename)
        if imagesdir == "":
            imagesdir = os.path.dirname(filename)
        if tilerender:
            filename += ".tile_%d.exr" % tilenum
        if tmpdir != "":
            pos = filename.rfind("/")
            filename = tmpdir + filename[pos:]
        print "Mantra plane filename:\n" + filename
        mantra.setproperty("plane:planefile", filename)
コード例 #36
0
    def _initData(self):
        """Init internal data."""
        import mantra

    	values = mantra.property(self.name)

    	if len(values) == 1:
    	    value = values[0]

    	    if len(value.split()) > 2:
        		split_vals = value.split()

        		value = dict(zip(*[iter(split_vals)]*2))

    	    else:
                value = _parseString(value)

    	else:
    	    value = values

    	self._value = value
コード例 #37
0
ファイル: properties.py プロジェクト: tws0002/Houdini-Toolbox
    def setProperty(self):
        """Set the property to the value."""
        # Don't do anything if the property isn't enabled.
        if not self.enabled:
            return

        import mantra

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

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

        logger.debug(
            "Setting property '{}' to {}".format(self.name, self.value)
        )

        # Update the property value.
        mantra.setproperty(self.name, self.value)
コード例 #38
0
ファイル: HPYCallback.py プロジェクト: akoon/OldPipeline
import mantra
import sys

# mantra -P filter.py
# add next line in filter.py
# mantra.setproperty('renderer:tilecallback', 'E:/home/develop/HPYCallback.py')

tile = mantra.property("tile:ncomplete")[0]
total_tile = mantra.property("tile:ntiles")[0]
if tile%100 == 0:
    print float(tile)/total_tile
コード例 #39
0
    def shouldRun(self):
        """Only run if we are enabled AND rendering to ip."""
        import mantra

        return self.enabled and mantra.property("image:filename")[0] == "ip"
コード例 #40
0
ファイル: tileCallback.py プロジェクト: seashby10/papa-tools
import sys, mantra

tile = mantra.property("tile:ncomplete")[0]
if tile == 1:
    # This is the first tile rendered in the image

    print mantra.property("renderer:name")
    ntiles = mantra.property("tile:ntiles")[0]
    prev_pct = -1
    lap = 0
    lsum = 0

lap += mantra.property("tile:laptime")[0]
pct = tile * 100 / ntiles

if pct != prev_pct:
    mem = mantra.property("tile:memory")[0]
    cords = mantra.property("tile:coords")[0]
    mem = float(mem / 1024) / 1024
    print cords
    print mem / 1024
    total = mantra.property("tile:totaltime")[0]
    fpct = float(tile) / float(ntiles)  # Percent complete
    prev_pct = pct

    print ("%03d%% Complete - Laptime %g/%g - ETA %g seconds\n" % (pct, lap, total, total / fpct))

    lap = 0  # Reset the lap counter
コード例 #41
0
def filterInstance():
    global ha_instance_num
    global ha_objects

    # Global Surface Shader
    if options.globalSurfaceShader or options.globalSurfaceShader == "":
        if os.path.isfile(options.globalSurfaceShader):
            #if the passed string is a path to a VEX shader
            mantra.setproperty('object:surface',
                               options.globalSurfaceShader.split("%"))
        else:
            #if the pass string is a shader string with object scope
            if mantra.property('object:name')[
                    0] in options.globalSurfaceShader.split("%")[1].split(" "):
                mantra.setproperty(
                    'object:surface',
                    options.globalSurfaceShader.split("%")[0].split(" "))

    #	# If irradiance pass was enabled:
    if options.irradiance:
        mantra.setproperty('object:surface',
                           'opdef:/Shop/v_constant'.split("%"))

    #  if matte rendering:
    if options.matte:
        if options.matte == "*": pass
        else:
            objects = options.matte.split("%")
            print objects
            if name in objects:
                mantra.setproperty('object:surface', 'matte')

    # Phantom mode:
    if options.phantom:
        if options.phantom == "*": pass
        else:
            objects = options.phantom.split("%")
            if name in objects:
                mantra.setproperty('object:phantom', "true")

    # Special mode:
    if options.special:
        if options.special == "shadow_matte":
            mantra.setproperty('object:surface',
                               'opdef:/Shop/v_shadowmatte alpha 0'.split())
        elif options.special == "object_matte":
            mantra.setproperty(
                'object:surface',
                'opdef:/Shop/haSpecialPasses type object_matte'.split())
        elif options.special == 'object_id':
            _id = mantra.property('object:id')[0]
            mantra.setproperty(
                'object:surface',
                'opdef:/Shop/v_constant alpha 0 clr '.split() + [_id, 0, 0])
        elif options.special == 'object_n':
            mantra.setproperty(
                'object:surface',
                'opdef:/Shop/haSpecialPasses type object_n'.split())
        elif options.special == 'zdepth':
            mantra.setproperty(
                'object:surface',
                'opdef:/Shop/haSpecialPasses type zdepth'.split())
        elif options.special == 'lambert':
            mantra.setproperty('object:surface',
                               'opdef:/Shop/v_plastic spec 0 0 0'.split())
            print 'Should be lambert on %s' % name
        elif options.special == 'motion':
            mantra.setproperty(
                'object:surface',
                'opdef:/Shop/haSpecialPasses type motion'.split())

    # Light masking:
    if options.lights:
        do_shadows = []
        if options.shadows_in_light_pass: do_shadows = ['do_shadows', 1]
        lights = get_lights()
        if len(lights) > 3: lights = ["light_to_alpha", lights[3][0]]
        else: lights = []
        mantra.setproperty(
            'object:surface',
            'opdef:/Shop/haSpecialPasses type light_mask '.split() +
            do_shadows + lights)
コード例 #42
0
def filterCamera():
	if tilerender:
		oldcrop = mantra.property('image:crop')
		newcrop = [ max(tilecrop[0],oldcrop[0]),min(tilecrop[1],oldcrop[1]),  max(tilecrop[2],oldcrop[2]),min(tilecrop[3],oldcrop[3])]
		mantra.setproperty('image:crop', newcrop)
コード例 #43
0
def filterInstance():
    logger = logging.getLogger('filterInstance')
    if DENOISE:
        mantra.setproperty("object:dorayvariance", 0)
        logger.info("{}:dorayvariance => {}".format(mantra.property('object:name')[0], 0))
コード例 #44
0
ファイル: mantratile.py プロジェクト: all-in-one-of/ALS_lib
tile:ntiles – The total number of tiles in the image.
tile:laptime – The number of seconds taken to render the last tile.
tile:totaltime – The total number of seconds to render since the render began. This does not include time to load the scene, but rather is defined as the time since the first tile began rendering.
tile:coords – The tile bounding box (in pixels).
tile:memory – The amount of RAM in use by mantra.
tile = mantra.property("tile:ncomplete")[0]
'''

def formatTime( s ) :
    H = int( s / 3600 )
    M = int( (s % 3600) / 60 )
    S = round( (s % 3600) % 60, 0 )
    return "%0*d:%0*d:%0*d" % ( 2,H, 2,M, 2,S )

time   = datetime.datetime.now().strftime("%H:%M:%S")
rop    = mantra.property("renderer:name")[0]
ver    = mantra.property("renderer:version")
tile   = mantra.property("tile:ncomplete")[0]
ntiles = mantra.property("tile:ntiles")[0]
lap    = mantra.property("tile:laptime")[0]
total  = mantra.property("tile:totaltime")[0]
mem    = mantra.property("tile:memory")[0] * 0.000001
padzero = len( str( ntiles ) )
prog = float( tile ) / float( ntiles ) * 100.0
sep = "\n==============================================================================\n"
insep = "--------"

if tile == 1 : print "%s[%s] Rendered by %s %s.%s.%s" % ( sep, time, rop, ver[0], ver[1], ver[2] )

print "[%s] %s Tile %0*d / %d %s Tile rendered %s / %s %s memory %.2f Mb %s progress %0*d %%" %\
      ( time, insep, padzero, tile, ntiles, insep, formatTime( lap ), formatTime( total ), insep, mem, insep, 3, prog )