コード例 #1
0
 def inital_PBRMaterials(cls):
     for material in mset.getAllMaterials():
         material.setSubroutine('surface', 'Normals')
         material.setSubroutine('microsurface', 'Gloss')
         material.setSubroutine('albedo', 'Albedo')
         material.setSubroutine('diffusion', 'Lambertian')
         material.setSubroutine('reflectivity', 'Adv. Metalness')
         material.setSubroutine('transparency', 'Cutout')
コード例 #2
0
    def refreshinfo(self):
        objects = mset.getAllObjects()
        polycount = 0
        for obj in objects:
            try:
                polycount += len(obj.mesh.triangles)
            except:
                polycount += 0

        self.trianglefaces.info.text = '{:20,d}'.format(polycount)
        self.material_counts.info.text = str(len(mset.getAllMaterials()))
        self.object_counts.info.text = str(len(objects))
コード例 #3
0
    def assign_TDALmaps(cls, folderpath, searchdepth):
        cls.inital_TDALMaterials()
        tempPath = folderpath
        tempExt = global_TextureFormatItems[
            AssignMaterial.affixlist.extlist.listBox.selectedItem]
        mapListDict = AssignMaterial.affixlist.mapListDict
        tempPattern = [
            v.value for v in AssignMaterial.affixlist.mapListDict.values()
        ]

        if tempPath != '':
            texturefiles = cls.collect_Files(filenameExt=tempExt,
                                             searchPath=tempPath,
                                             patterns=tempPattern,
                                             depth=searchdepth)
            materials = mset.getAllMaterials()
            for material in materials:
                normalmap = material.name + AssignMaterial.affixlist.mapListDict[
                    'Normal'].value
                roughnessmap = material.name + AssignMaterial.affixlist.mapListDict[
                    'Roughness'].value
                albedomap = material.name + AssignMaterial.affixlist.mapListDict[
                    'BaseColor'].value
                metallicmap = material.name + AssignMaterial.affixlist.mapListDict[
                    'Metallic'].value
                specularmap = material.name + AssignMaterial.affixlist.mapListDict[
                    'Specular'].value
                opacitymap = material.name + AssignMaterial.affixlist.mapListDict[
                    'Opacity'].value

                for texturefile in texturefiles:
                    if normalmap in os.path.basename(texturefile):
                        Mset_material.assign_SurfaceShader_Normals(
                            material, texturefile)
                    if roughnessmap in os.path.basename(texturefile):
                        Mset_material.assign_MicroSurfaceShader_Gloss(
                            material, texturefile)
                    if albedomap in os.path.basename(texturefile):
                        Mset_material.assign_AlbedoShader(
                            material, texturefile)
                    if opacitymap in os.path.basename(texturefile):
                        Mset_material.assign_TransparencyShader_Cutout(
                            material, texturefile)
                    if metallicmap in os.path.basename(texturefile):
                        Mset_material.assign_ReflectivityShader_AdvMetalness_Metalness(
                            material, texturefile)
                    if specularmap in os.path.basename(texturefile):
                        Mset_material.assign_ReflectivityShader_AdvMetalness_Specular(
                            material, texturefile)
コード例 #4
0
    def apply_material(unity_material):
        def setField(mmat, Sub, Field, Value):
            if Value is not None:
                mmat.getSubroutine(Sub).setField(Field, Value)

        inScene = False
        for mat in mset.getAllMaterials():
            if mat.name == unity_material.name:
                inScene = True

        if inScene is False:
            mmat = mset.Material(unity_material.name)
        else:
            mmat = mset.findMaterial(unity_material.name)

        MMU.setFields(mmat)
        setField(mmat, "albedo", 'Color', unity_material._Color.store.rgb)

        setField(mmat, "albedo", 'Albedo Map',
                 unity_material._MainTex.store.path)

        setField(mmat, "surface", 'Normal Map',
                 unity_material._BumpMap.store.path)

        setField(mmat, "microsurface", 'Gloss Map',
                 unity_material._MetallicGlossMap.store.path)

        setField(mmat, "reflectivity", 'Metalness Map',
                 unity_material._MetallicGlossMap.store.path)

        setField(mmat, "occlusion", 'Occlusion Map',
                 unity_material._OcclusionMap.store.path)

        setField(mmat, "emissive", 'Color',
                 unity_material._EmissionColor.store.rgb)

        setField(mmat, "emissive", 'Emissive Map',
                 unity_material._EmissionMap.store.path)
コード例 #5
0
def sunc_scene_materials():
    for mat in mset.getAllMaterials():
        for check in checks_list:
            if mat.name == check.label:
                check.value = True
コード例 #6
0
 def fix_Material(cls, subroutines, shadertype):
     Materials = mset.getAllMaterials()
     for Material in Materials:
         Material.setSubroutine(subroutines, shadertype)
コード例 #7
0
def refresh_scene():
    if os.path.exists(os.path.join(temps_path, "marmo_vars.json")):
        mset.newScene()

        with open(os.path.join(temps_path, "marmo_vars.json"),
                  'r') as openfile:
            marmo_json = json.load(openfile)

        # Create baker object
        baker = mset.BakerObject()

        # Setting up the baker
        baker.outputPath = marmo_json["file_path"]
        baker.outputBits = marmo_json["bits_per_channel"]
        baker.outputSamples = marmo_json["samples"]
        baker.edgePadding = "None"
        baker.outputSoften = 0.5
        baker.useHiddenMeshes = True
        baker.ignoreTransforms = False
        baker.smoothCage = True
        baker.ignoreBackfaces = True
        baker.multipleTextureSets = False
        baker.outputWidth = marmo_json["resolution_x"]
        baker.outputHeight = marmo_json["resolution_y"]

        # Disable all maps
        for maps in baker.getAllMaps():
            maps.enabled = False

        # Configure maps
        normalMap = baker.getMap("Normals")
        normalMap.enabled = marmo_json["export_normals"]
        normalMap.suffix = 'normal'
        normalMap.flipY = marmo_json["flipy_normals"]
        normalMap.flipX = False
        normalMap.dither = False

        curvatureMap = baker.getMap("Curvature")
        curvatureMap.enabled = marmo_json["export_curvature"]

        occlusionMap = baker.getMap("Ambient Occlusion")
        occlusionMap.rayCount = marmo_json["ray_count_occlusion"]
        occlusionMap.enabled = marmo_json["export_occlusion"]

        heightMap = baker.getMap("Height")
        heightMap.innerDistance = 0
        heightMap.enabled = marmo_json["export_height"]
        if marmo_json["flat_height"]:
            heightMap.outerDistance = .01
        else:
            heightMap.outerDistance = marmo_json["cage_height"] / 2 - .02

        matIDMap = baker.getMap("Material ID")
        matIDMap.enabled = marmo_json["export_matid"]

        # Import the models
        baker.importModel(os.path.join(temps_path, "grabdoc_temp_model.fbx"))

        # Set cage offset
        mset.findObject('Low').maxOffset = marmo_json["cage_height"] + .01

        tb_version = mset.getToolbagVersion()

        # Change skybox to Evening Clouds
        if tb_version < 4000:
            mset.findObject('Sky').loadSky(marmo_json["marmo_sky_path"])

        # Rotate all models 90 degrees
        bakeGroup = mset.findObject('GrabDoc')
        bakeGroup.rotation = [90, 0, 0]

        # Make a folder for Mat ID materials
        for mat in mset.getAllMaterials():
            if mat.name.startswith("GD_"):
                mat.setGroup('Mat ID')

        # Baker
        if marmo_json["auto_bake"]:
            baker.bake()

            # Open folder on export
            if marmo_json["open_folder"]:
                os.startfile(marmo_json["file_path_no_ext"])

            # Close marmo if the option is selected
            if marmo_json["close_after_bake"]:
                mset.quit()

            # Hide the _High group
            mset.findObject('High').visible = False

            # Scale up the high poly plane
            mset.findObject('GrabDoc_high GD_Background Plane').scale = [
                300, 300, 300
            ]

            findDefault = mset.findMaterial("Default")

            # Material preview
            if marmo_json["export_normals"]:
                findDefault.getSubroutine('surface').setField(
                    'Normal Map',
                    marmo_json["file_path"][:-4] + '_normal' + '.png')

            if marmo_json["export_occlusion"]:
                findDefault.setSubroutine('occlusion', 'Occlusion')
                findDefault.getSubroutine('occlusion').setField(
                    'Occlusion Map',
                    marmo_json["file_path"][:-4] + '_ao' + '.png')

            # Rename bake material
            findDefault.name = 'Bake Material'

        os.remove(os.path.join(temps_path, "marmo_vars.json"))
コード例 #8
0
import mset

for marmoset_material in mset.getAllMaterials():
    try:
        marmoset_material.getSubroutine("albedo").setField(
            "Color", [255.0, 255.0, 255.0])
    except:
        pass

    try:
        marmoset_material.getSubroutine("emissive").setField(
            "Color", [0.0, 0.0, 0.0])
    except:
        pass
コード例 #9
0
ファイル: arrange_tex.py プロジェクト: solpie/BlendExec
def set_color_value():
    materials = mset.getAllMaterials()
    for mat in materials:
        print('mat:', mat.getSubroutine('albedo').getField("Color"))
        mat.getSubroutine('albedo').setField("Color", [1.0, 1.0, 1.0])
    pass