Exemple #1
0
    def draw(self, context):
        material = context.active_object.active_material
        mmd_material = material.mmd_material

        layout = self.layout

        fnMat = FnMaterial(material)

        col = layout.column()
        col.label(text='Texture:')
        r = col.row(align=True)
        tex = fnMat.get_texture()
        if tex:
            if tex.type == 'IMAGE' and tex.image:
                r.prop(tex.image, 'filepath', text='')
                r.operator('mmd_tools.material_remove_texture',
                           text='',
                           icon='PANEL_CLOSE')
            else:
                r.operator('mmd_tools.material_remove_texture',
                           text='Remove',
                           icon='PANEL_CLOSE')
                r.label(icon='ERROR')
        else:
            r.operator('mmd_tools.material_open_texture',
                       text='Add',
                       icon=ICON_FILE_FOLDER)

        col = layout.column()
        col.label(text='Sphere Texture:')
        r = col.row(align=True)
        tex = fnMat.get_sphere_texture()
        if tex:
            if tex.type == 'IMAGE' and tex.image:
                r.prop(tex.image, 'filepath', text='')
                r.operator('mmd_tools.material_remove_sphere_texture',
                           text='',
                           icon='PANEL_CLOSE')
            else:
                r.operator('mmd_tools.material_remove_sphere_texture',
                           text='Remove',
                           icon='PANEL_CLOSE')
                r.label(icon='ERROR')
        else:
            r.operator('mmd_tools.material_open_sphere_texture',
                       text='Add',
                       icon=ICON_FILE_FOLDER)
        col.row(align=True).prop(mmd_material,
                                 'sphere_texture_type',
                                 expand=True)

        col = layout.column()
        row = col.row()
        row.prop(mmd_material, 'is_shared_toon_texture')
        r = row.row()
        r.active = mmd_material.is_shared_toon_texture
        r.prop(mmd_material, 'shared_toon_texture')
        r = col.row()
        r.active = not mmd_material.is_shared_toon_texture
        r.prop(mmd_material, 'toon_texture')
Exemple #2
0
    def __importMaterials(self):
        self.__importTextures()

        pmxModel = self.__model

        self.__materialFaceCountTable = []
        for i in pmxModel.materials:
            mat = bpy.data.materials.new(name=self.__safe_name(i.name, max_length=50))
            self.__materialTable.append(mat)
            mmd_mat = mat.mmd_material
            mmd_mat.name_j = i.name
            mmd_mat.name_e = i.name_e
            mmd_mat.ambient_color = i.ambient
            mmd_mat.diffuse_color = i.diffuse[0:3]
            mmd_mat.alpha = i.diffuse[3]
            mmd_mat.specular_color = i.specular
            mmd_mat.shininess = i.shininess
            mmd_mat.is_double_sided = i.is_double_sided
            mmd_mat.enabled_drop_shadow = i.enabled_drop_shadow
            mmd_mat.enabled_self_shadow_map = i.enabled_self_shadow_map
            mmd_mat.enabled_self_shadow = i.enabled_self_shadow
            mmd_mat.enabled_toon_edge = i.enabled_toon_edge
            mmd_mat.edge_color = i.edge_color
            mmd_mat.edge_weight = i.edge_size
            mmd_mat.sphere_texture_type = str(i.sphere_texture_mode)
            if i.is_shared_toon_texture:
                mmd_mat.is_shared_toon_texture = True
                mmd_mat.shared_toon_texture = i.toon_texture
            else:
                mmd_mat.is_shared_toon_texture = False
                if i.toon_texture >= 0:
                    mmd_mat.toon_texture = self.__textureTable[i.toon_texture]
                else:
                    mmd_mat.toon_texture = ''
            mmd_mat.comment = i.comment

            self.__materialFaceCountTable.append(int(i.vertex_count/3))
            self.__meshObj.data.materials.append(mat)
            fnMat = FnMaterial(mat)
            if i.texture != -1:
                texture_slot = fnMat.create_texture(self.__textureTable[i.texture])
                texture_slot.texture.use_mipmap = self.__use_mipmap
                self.__imageTable[len(self.__materialTable)-1] = texture_slot.texture.image
            if i.sphere_texture_mode == 2:
                amount = self.__spa_blend_factor
            else:
                amount = self.__sph_blend_factor
            if i.sphere_texture != -1 and amount != 0.0:
                texture_slot = fnMat.create_sphere_texture(self.__textureTable[i.sphere_texture])
                texture_slot.diffuse_color_factor = amount
                if i.sphere_texture_mode == 3 and getattr(pmxModel.header, 'additional_uvs', 0):
                    texture_slot.uv_layer = 'UV1' # for SubTexture
                    mmd_mat.sphere_texture_type = mmd_mat.sphere_texture_type # re-update
Exemple #3
0
 def execute(self, context):
     obj = context.active_object
     current_idx = obj.active_material_index
     next_index = current_idx + 1
     try:
         FnMaterial.swap_materials(obj,
                                   current_idx,
                                   next_index,
                                   reverse=True,
                                   swap_slots=True)
     except MaterialNotFoundError:
         self.report({'ERROR'}, 'Materials not found')
         return {'CANCELLED'}
     obj.active_material_index = next_index
     return {'FINISHED'}
Exemple #4
0
def _set_material(prop, value):
    if value not in bpy.data.materials.keys():
        prop['material_id'] = -1
        return
    mat = bpy.data.materials[value]
    fnMat = FnMaterial(mat)
    prop['material_id'] = fnMat.material_id
Exemple #5
0
def _get_material(prop):
    mat_id = prop.get('material_id')
    if mat_id < 0:
        return ''
    fnMat = FnMaterial.from_material_id(mat_id)
    if not fnMat:
        return ''
    return fnMat.material.name
Exemple #6
0
def _get_material(prop):
    mat_id = prop.get('material_id')
    if mat_id < 0:
        return ''
    fnMat = FnMaterial.from_material_id(mat_id)
    if not fnMat:
        return ''
    return fnMat.material.name
Exemple #7
0
def _toggleUseSphereTexture(self, context):
    root = self.id_data
    rig = mmd_model.Model(root)
    use_sphere = self.use_sphere_texture
    for i in rig.meshes():
        for m in i.data.materials:
            if m is None:
                continue
            FnMaterial(m).use_sphere_texture(use_sphere, i)
Exemple #8
0
def _update_material_morph_data(prop, context):
    if not prop.name.startswith('mmd_bind'):
        return
    from mmd_tools.core.shader import _MaterialMorph
    mat_id = prop.get('material_id', -1)
    if mat_id >= 0:
        mat = getattr(FnMaterial.from_material_id(mat_id), 'material', None)
        _MaterialMorph.update_morph_inputs(mat, prop)
    elif mat_id == -1:
        for mat in FnModel(prop.id_data).materials():
            _MaterialMorph.update_morph_inputs(mat, prop)
Exemple #9
0
 def execute(self, context):
     obj = context.active_object
     root = mmd_model.Model.findRoot(obj)
     rig = mmd_model.Model(root)
     for meshObj in rig.meshes():
         mats_to_delete = []
         for mat in meshObj.data.materials:
             if mat and "_temp" in mat.name:
                 mats_to_delete.append(mat)
         for temp_mat in reversed(mats_to_delete):
             base_mat_name = temp_mat.name.split('_temp')[0]
             try:
                 FnMaterial.swap_materials(meshObj, temp_mat.name,
                                           base_mat_name)
             except MaterialNotFoundError:
                 self.report({'WARNING'},
                             'Base material for %s was not found' %
                             temp_mat.name)
             else:
                 temp_idx = meshObj.data.materials.find(temp_mat.name)
                 mat = meshObj.data.materials.pop(index=temp_idx)
                 if mat.users < 1:
                     bpy.data.materials.remove(mat)
     return {'FINISHED'}
Exemple #10
0
def _updateDiffuseColor(prop, context):
    FnMaterial(prop.id_data).update_diffuse_color()
Exemple #11
0
    def __importMaterials(self):
        self.__importTextures()

        pmxModel = self.__model

        self.__materialFaceCountTable = []
        for i in pmxModel.materials:
            mat = bpy.data.materials.new(name=i.name)
            self.__materialTable.append(mat)
            mmd_mat = mat.mmd_material
            mat.diffuse_color = i.diffuse[0:3]
            mat.alpha = i.diffuse[3]
            mat.specular_color = i.specular[0:3]
            mat.specular_alpha = i.specular[3]
            mat.use_shadows = i.enabled_self_shadow
            mat.use_transparent_shadows = i.enabled_self_shadow
            mat.use_cast_buffer_shadows = i.enabled_self_shadow_map  # only buffer shadows
            if hasattr(mat, 'use_cast_shadows'):
                # "use_cast_shadows" is not supported in older Blender (< 2.71),
                # so we still use "use_cast_buffer_shadows".
                mat.use_cast_shadows = i.enabled_self_shadow_map
            if mat.alpha < 1.0 or mat.specular_alpha < 1.0 or i.texture != -1:
                mat.use_transparency = True
                mat.transparency_method = 'Z_TRANSPARENCY'

            mmd_mat.name_j = i.name
            mmd_mat.name_e = i.name_e
            mmd_mat.ambient_color = i.ambient
            mmd_mat.is_double_sided = i.is_double_sided
            mmd_mat.enabled_drop_shadow = i.enabled_drop_shadow
            mmd_mat.enabled_self_shadow_map = i.enabled_self_shadow_map
            mmd_mat.enabled_self_shadow = i.enabled_self_shadow
            mmd_mat.enabled_toon_edge = i.enabled_toon_edge
            if (len(i.edge_color) == 4):  # If it cames from PMD it will not
                # have edge color and assigning an empty array
                # will raise an error(ValueError)
                mmd_mat.edge_color = i.edge_color
            mmd_mat.edge_weight = i.edge_size
            mmd_mat.sphere_texture_type = str(i.sphere_texture_mode)
            if i.is_shared_toon_texture:
                mmd_mat.is_shared_toon_texture = True
                mmd_mat.shared_toon_texture = i.toon_texture
            else:
                mmd_mat.is_shared_toon_texture = False
                if i.toon_texture >= 0:
                    mmd_mat.toon_texture = self.__textureTable[i.toon_texture]
                else:
                    mmd_mat.toon_texture = ''
            mmd_mat.comment = i.comment

            self.__materialFaceCountTable.append(int(i.vertex_count / 3))
            self.__meshObj.data.materials.append(mat)
            fnMat = FnMaterial(mat)
            if i.texture != -1:
                texture_slot = fnMat.create_texture(
                    self.__textureTable[i.texture])
                texture_slot.texture.use_mipmap = self.__use_mipmap
            if i.sphere_texture_mode == 2:
                amount = self.__spa_blend_factor
                blend = 'ADD'
            else:
                amount = self.__sph_blend_factor
                blend = 'MULTIPLY'
            if i.sphere_texture != -1 and amount != 0.0:
                texture_slot = fnMat.create_sphere_texture(
                    self.__textureTable[i.sphere_texture])
                if isinstance(texture_slot.texture.image, bpy.types.Image):
                    texture_slot.texture.image.use_alpha = False
                texture_slot.diffuse_color_factor = amount
                texture_slot.blend_type = blend
Exemple #12
0
def _updateAlpha(prop, context):
    FnMaterial(prop.id_data).update_alpha()
Exemple #13
0
def _updateSpecularColor(prop, context):
    FnMaterial(prop.id_data).update_specular_color()
Exemple #14
0
 def execute(self, context):
     mat = context.active_object.active_material
     fnMat = FnMaterial(mat)
     fnMat.create_sphere_texture(self.filepath, context.active_object)
     return {'FINISHED'}
Exemple #15
0
def _updateToonTexture(prop, context):
    FnMaterial(prop.id_data).update_toon_texture()
Exemple #16
0
 def execute(self, context):
     mat = context.active_object.active_material
     fnMat = FnMaterial(mat)
     fnMat.remove_sphere_texture()
     return {'FINISHED'}
Exemple #17
0
def _updateIsDoubleSided(prop, context):
    FnMaterial(prop.id_data).update_is_double_sided()
Exemple #18
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        rig = mmd_model.Model(root)
        mmd_root = root.mmd_root
        morph = mmd_root.material_morphs[mmd_root.active_morph]
        mat_data = morph.data[morph.active_data]

        meshObj = rig.findMesh(mat_data.related_mesh)
        if meshObj is None:
            self.report({'ERROR'}, "The model mesh can't be found")
            return {'CANCELLED'}
        try:
            work_mat_name = mat_data.material + '_temp'
            work_mat, base_mat = FnMaterial.swap_materials(
                meshObj, work_mat_name, mat_data.material)
        except MaterialNotFoundError:
            self.report({'ERROR'}, "Material not found")
            return {'CANCELLED'}

        copy_idx = meshObj.data.materials.find(work_mat.name)
        base_mmd_mat = base_mat.mmd_material
        work_mmd_mat = work_mat.mmd_material

        if mat_data.offset_type == "MULT":
            try:
                diffuse_offset = divide_vector_components(
                    work_mmd_mat.diffuse_color, base_mmd_mat.diffuse_color
                ) + [special_division(work_mmd_mat.alpha, base_mmd_mat.alpha)]
                specular_offset = divide_vector_components(
                    work_mmd_mat.specular_color, base_mmd_mat.specular_color)
                edge_offset = divide_vector_components(work_mmd_mat.edge_color,
                                                       base_mmd_mat.edge_color)
                mat_data.diffuse_color = diffuse_offset
                mat_data.specular_color = specular_offset
                mat_data.shininess = special_division(work_mmd_mat.shininess,
                                                      base_mmd_mat.shininess)
                mat_data.ambient_color = divide_vector_components(
                    work_mmd_mat.ambient_color, base_mmd_mat.ambient_color)
                mat_data.edge_color = edge_offset
                mat_data.edge_weight = special_division(
                    work_mmd_mat.edge_weight, base_mmd_mat.edge_weight)

            except DivisionError:
                mat_data.offset_type = "ADD"  # If there is any 0 division we automatically switch it to type ADD
            except ValueError:
                self.report({'ERROR'}, 'An unexpected error happened')
                # We should stop on our tracks and re-raise the exception
                raise

        if mat_data.offset_type == "ADD":
            diffuse_offset = list(work_mmd_mat.diffuse_color -
                                  base_mmd_mat.diffuse_color) + [
                                      work_mmd_mat.alpha - base_mmd_mat.alpha
                                  ]
            specular_offset = list(work_mmd_mat.specular_color -
                                   base_mmd_mat.specular_color)
            edge_offset = Vector(work_mmd_mat.edge_color) - Vector(
                base_mmd_mat.edge_color)
            mat_data.diffuse_color = diffuse_offset
            mat_data.specular_color = specular_offset
            mat_data.shininess = work_mmd_mat.shininess - base_mmd_mat.shininess
            mat_data.ambient_color = work_mmd_mat.ambient_color - base_mmd_mat.ambient_color
            mat_data.edge_color = list(edge_offset)
            mat_data.edge_weight = work_mmd_mat.edge_weight - base_mmd_mat.edge_weight

        mat = meshObj.data.materials.pop(index=copy_idx)
        if mat.users < 1:
            bpy.data.materials.remove(mat)
        return {'FINISHED'}
Exemple #19
0
def _updateEnabledToonEdge(prop, context):
    FnMaterial(prop.id_data).update_enabled_toon_edge()
Exemple #20
0
def _updateSelfShadow(prop, context):
    FnMaterial(prop.id_data).update_self_shadow()
Exemple #21
0
def _updateDropShadow(prop, context):
    FnMaterial(prop.id_data).update_drop_shadow()
Exemple #22
0
def _updateAmbientColor(prop, context):
    FnMaterial(prop.id_data).update_ambient_color()
Exemple #23
0
def _updateShininess(prop, context):
    FnMaterial(prop.id_data).update_shininess()
Exemple #24
0
 def execute(self, context):
     mat = context.active_object.active_material
     fnMat = FnMaterial(mat)
     fnMat.create_sphere_texture(self.filepath)
     return {'FINISHED'}
Exemple #25
0
 def execute(self, context):
     mat = context.active_object.active_material
     fnMat = FnMaterial(mat)
     fnMat.remove_texture()
     return {'FINISHED'}
Exemple #26
0
def _updateEdgeColor(prop, context):
    FnMaterial(prop.id_data).update_edge_color()
Exemple #27
0
def _updateSphereMapType(prop, context):
    FnMaterial(prop.id_data).update_sphere_texture_type(context.active_object)
Exemple #28
0
    def execute(self, context):
        obj = context.active_object
        root = mmd_model.Model.findRoot(obj)
        rig = mmd_model.Model(root)
        mmd_root = root.mmd_root
        morph = mmd_root.material_morphs[mmd_root.active_morph]
        mat_data = morph.data[morph.active_data]

        meshObj = rig.findMesh(mat_data.related_mesh)
        if meshObj is None:
            self.report({'ERROR'}, "The model mesh can't be found")
            return {'CANCELLED'}

        base_mat = meshObj.data.materials.get(mat_data.material, None)
        if base_mat is None:
            self.report({'ERROR'},
                        'Material "%s" not found' % mat_data.material)
            return {'CANCELLED'}

        work_mat_name = base_mat.name + '_temp'
        if work_mat_name in bpy.data.materials:
            self.report({'ERROR'},
                        'Temporary material "%s" is in use' % work_mat_name)
            return {'CANCELLED'}

        work_mat = base_mat.copy()
        work_mat.name = work_mat_name
        meshObj.data.materials.append(work_mat)
        FnMaterial.swap_materials(meshObj, base_mat.name, work_mat.name)
        base_mmd_mat = base_mat.mmd_material
        work_mmd_mat = work_mat.mmd_material
        work_mmd_mat.material_id = -1

        # Apply the offsets
        if mat_data.offset_type == "MULT":
            diffuse_offset = multiply_vector_components(
                base_mmd_mat.diffuse_color, mat_data.diffuse_color[0:3])
            specular_offset = multiply_vector_components(
                base_mmd_mat.specular_color, mat_data.specular_color)
            edge_offset = multiply_vector_components(base_mmd_mat.edge_color,
                                                     mat_data.edge_color)
            ambient_offset = multiply_vector_components(
                base_mmd_mat.ambient_color, mat_data.ambient_color)
            work_mmd_mat.diffuse_color = diffuse_offset
            work_mmd_mat.alpha *= mat_data.diffuse_color[3]
            work_mmd_mat.specular_color = specular_offset
            work_mmd_mat.shininess *= mat_data.shininess
            work_mmd_mat.ambient_color = ambient_offset
            work_mmd_mat.edge_color = edge_offset
            work_mmd_mat.edge_weight *= mat_data.edge_weight
        elif mat_data.offset_type == "ADD":
            diffuse_offset = Vector(base_mmd_mat.diffuse_color) + Vector(
                mat_data.diffuse_color[0:3])
            specular_offset = Vector(base_mmd_mat.specular_color) + Vector(
                mat_data.specular_color)
            edge_offset = Vector(base_mmd_mat.edge_color) + Vector(
                mat_data.edge_color)
            ambient_offset = Vector(base_mmd_mat.ambient_color) + Vector(
                mat_data.ambient_color)
            work_mmd_mat.diffuse_color = list(diffuse_offset)
            work_mmd_mat.alpha += mat_data.diffuse_color[3]
            work_mmd_mat.specular_color = list(specular_offset)
            work_mmd_mat.shininess += mat_data.shininess
            work_mmd_mat.ambient_color = list(ambient_offset)
            work_mmd_mat.edge_color = list(edge_offset)
            work_mmd_mat.edge_weight += mat_data.edge_weight

        return {'FINISHED'}
Exemple #29
0
def _updateEdgeWeight(prop, context):
    FnMaterial(prop.id_data).update_edge_weight()
    def __importMaterials(self):
        self.__importTextures()

        pmxModel = self.__model

        self.__materialFaceCountTable = []
        for i in pmxModel.materials:
            mat = bpy.data.materials.new(name=i.name)
            self.__materialTable.append(mat)
            mmd_mat = mat.mmd_material
            mat.diffuse_color = i.diffuse[0:3]
            mat.alpha = i.diffuse[3]
            mat.specular_color = i.specular[0:3]
            mat.specular_alpha = i.specular[3]
            mat.use_shadows = i.enabled_self_shadow
            mat.use_transparent_shadows = i.enabled_self_shadow
            mat.use_cast_buffer_shadows = i.enabled_self_shadow_map # only buffer shadows
            if hasattr(mat, 'use_cast_shadows'):
                # "use_cast_shadows" is not supported in older Blender (< 2.71),
                # so we still use "use_cast_buffer_shadows".
                mat.use_cast_shadows = i.enabled_self_shadow_map
            if mat.alpha < 1.0 or mat.specular_alpha < 1.0 or i.texture != -1:
                mat.use_transparency = True
                mat.transparency_method = 'Z_TRANSPARENCY'

            mmd_mat.name_j = i.name
            mmd_mat.name_e = i.name_e
            mmd_mat.ambient_color = i.ambient
            mmd_mat.is_double_sided = i.is_double_sided
            mmd_mat.enabled_drop_shadow = i.enabled_drop_shadow
            mmd_mat.enabled_self_shadow_map = i.enabled_self_shadow_map
            mmd_mat.enabled_self_shadow = i.enabled_self_shadow
            mmd_mat.enabled_toon_edge = i.enabled_toon_edge
            if(len(i.edge_color)==4):# If it cames from PMD it will not
                # have edge color and assigning an empty array
                # will raise an error(ValueError)
                mmd_mat.edge_color = i.edge_color
            mmd_mat.edge_weight = i.edge_size
            mmd_mat.sphere_texture_type = str(i.sphere_texture_mode)
            if i.is_shared_toon_texture:
                mmd_mat.is_shared_toon_texture = True
                mmd_mat.shared_toon_texture = i.toon_texture
            else:
                mmd_mat.is_shared_toon_texture = False
                if i.toon_texture >= 0:
                    mmd_mat.toon_texture = self.__textureTable[i.toon_texture]
                else:
                    mmd_mat.toon_texture = ''
            mmd_mat.comment = i.comment

            self.__materialFaceCountTable.append(int(i.vertex_count/3))
            self.__meshObj.data.materials.append(mat)
            fnMat = FnMaterial(mat)
            if i.texture != -1:
                texture_slot = fnMat.create_texture(self.__textureTable[i.texture])
                texture_slot.texture.use_mipmap = self.__use_mipmap
            if i.sphere_texture_mode == 2:
                amount = self.__spa_blend_factor
                blend = 'ADD'
            else:
                amount = self.__sph_blend_factor
                blend = 'MULTIPLY'
            if i.sphere_texture != -1 and amount != 0.0:
                texture_slot = fnMat.create_sphere_texture(self.__textureTable[i.sphere_texture])
                if isinstance(texture_slot.texture.image, bpy.types.Image):
                    texture_slot.texture.image.use_alpha = False
                texture_slot.diffuse_color_factor = amount
                texture_slot.blend_type = blend
Exemple #31
0
    def __importMaterials(self):
        self.__importTextures()

        pmxModel = self.__model

        self.__materialFaceCountTable = []
        for i in pmxModel.materials:
            mat = bpy.data.materials.new(name=i.name)
            self.__materialTable.append(mat)
            mmd_mat = mat.mmd_material
            mat.use_nodes = True
            mat.diffuse_color = i.diffuse[0:4]
            mat.specular_color = i.specular[0:3]
            mat.specular_intensity = i.specular[3]
            mat.shadow_method = 'HASHED'
            mat.blend_method = 'HASHED'
            mat.use_screen_refraction = True
            #mat.use_shadows = i.enabled_self_shadow
            #mat.use_transparent_shadows = i.enabled_self_shadow
            #mat.use_cast_buffer_shadows = i.enabled_self_shadow_map # only buffer shadows
            #if hasattr(mat, 'use_cast_shadows'):
                # "use_cast_shadows" is not supported in older Blender (< 2.71),
                # so we still use "use_cast_buffer_shadows".
                #mat.use_cast_shadows = i.enabled_self_shadow_map
            #if mat.alpha < 1.0 or mat.specular_alpha < 1.0 or i.texture != -1:
                #mat.use_transparency = True
                #mat.transparency_method = 'Z_TRANSPARENCY'
            #fit for cycles
            mat.node_tree.links.clear()
            shader = mat.node_tree.nodes['Principled BSDF']
            #texture = None
            outplug = shader.outputs[0]

            mat.node_tree.links.new(mat.node_tree.nodes['Material Output'].inputs['Surface'], outplug)
            mat.node_tree.nodes['Material Output'].location.x = shader.location.x + 500
            mat.node_tree.nodes['Material Output'].location.y = shader.location.y - 150

            mmd_mat.name_j = i.name
            mmd_mat.name_e = i.name_e
            mmd_mat.ambient_color = i.ambient
            mmd_mat.is_double_sided = i.is_double_sided
            mmd_mat.enabled_drop_shadow = i.enabled_drop_shadow
            mmd_mat.enabled_self_shadow_map = i.enabled_self_shadow_map
            mmd_mat.enabled_self_shadow = i.enabled_self_shadow
            mmd_mat.enabled_toon_edge = i.enabled_toon_edge
            if(len(i.edge_color)==4):# If it cames from PMD it will not
                # have edge color and assigning an empty array
                # will raise an error(ValueError)
                mmd_mat.edge_color = i.edge_color
            mmd_mat.edge_weight = i.edge_size
            mmd_mat.sphere_texture_type = str(i.sphere_texture_mode)
            if i.is_shared_toon_texture:
                mmd_mat.is_shared_toon_texture = True
                mmd_mat.shared_toon_texture = i.toon_texture
            else:
                mmd_mat.is_shared_toon_texture = False
                if i.toon_texture >= 0:
                    mmd_mat.toon_texture = self.__textureTable[i.toon_texture]
                else:
                    mmd_mat.toon_texture = ''
            mmd_mat.comment = i.comment

            self.__materialFaceCountTable.append(int(i.vertex_count/3))
            self.__meshObj.data.materials.append(mat)
            fnMat = FnMaterial(mat)
            if i.texture != -1:
                texnode = fnMat.create_texture(self.__textureTable[i.texture],shader)
                #texture_slot = fnMat.create_texture(self.__textureTable[i.texture])
                #texture_slot.texture.use_mipmap = self.__use_mipmap
                mat.node_tree.links.new(shader.inputs['Base Color'], texnode.outputs['Color'])
                mat.node_tree.links.new(shader.inputs['Alpha'], texnode.outputs['Alpha'])
            '''