コード例 #1
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)
コード例 #2
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)
コード例 #3
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)
コード例 #4
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)
コード例 #5
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)
コード例 #6
0
    def value(self, value):
        import mantra

        if value is None:
            value = []

        if not isinstance(value, Iterable):
            value = [value]

        mantra.setproperty(self.name, value)

        self._initData()
コード例 #7
0
    def value(self, value):
        import mantra

        if value is None:
            value = []

        if not isinstance(value, Iterable):
            value = [value]

        mantra.setproperty(self.name, value)

        self._initData()
コード例 #8
0
def filterCamera():
    """
    Renders a tile region onto a full res clear backplate with alpha.
    Note that we only use frameNumber here to display the currently rendering frame number.
    """
    tile_params = get_tile_params()

    regionLeft = tile_params["regionLeft"]
    regionRight = tile_params["regionRight"]
    regionBottom = tile_params["regionBottom"]
    regionTop = tile_params["regionTop"]

    regions = [regionLeft, regionRight, regionBottom, regionTop]

    mantra.setproperty('image:crop', regions)
コード例 #9
0
ファイル: property.py プロジェクト: hickb/Houdini-Toolbox
def set_property(name, value):
    """Set a property value.

    :param name: The property name.
    :type name: str
    :param value: The value to set.
    :type value: object
    :return:

    """
    import mantra

    value = _prep_value_to_set(value)

    mantra.setproperty(name, value)
コード例 #10
0
    def value(self, value):
        import mantra

        # Convert to empty list.
        if value is None:
            value = []

        # Convert to a list of a single string value.
        if isinstance(value, (str, unicode)):
            value = [value]

        # If the value is not an iterable then convert it to a list.
        if not isinstance(value, Iterable):
            value = [value]

        mantra.setproperty(self.name, value)

        self._initData()
コード例 #11
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)
コード例 #12
0
    def setProperty(self):
        """Set the property to the value.

        Raises:
            N/A

        Returns:
            None

        """
        # Don't do anything if the property isn't enabled.
        if not self.enabled:
            return

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

        # Update the property value.
        mantra.setproperty(self.name, self.value)
コード例 #13
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)
コード例 #14
0
    def setProperty(self):
        """Set the property to the value.

        Raises:
            N/A

        Returns:
            None

        """
        # Don't do anything if the property isn't enabled.
        if not self.enabled:
            return

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

        # Update the property value.
        mantra.setproperty(self.name, self.value)
コード例 #15
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)
コード例 #16
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())
コード例 #17
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)
コード例 #18
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)
コード例 #19
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)
コード例 #20
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)
コード例 #21
0
def filterInstance() : 
    mantra.setproperty('object:surface', 'op:/shop/AO'.split())
    mantra.setproperty('object:overridedetail', 1)
コード例 #22
0
def filterInstance():
    logger = logging.getLogger('filterInstance')
    if DENOISE:
        mantra.setproperty("object:dorayvariance", 0)
        logger.info("{}:dorayvariance => {}".format(mantra.property('object:name')[0], 0))
コード例 #23
0
def filterRender():
    logger = logging.getLogger('filterRender')
    if DENOISE:
        seed = random.randint(1,1e6)
        mantra.setproperty("image:randomseed", seed)
        logger.info("image:randomseed => {}".format(seed))