Skip to content

Commit

Permalink
Clean material names and set material shading should be done by fix m…
Browse files Browse the repository at this point in the history
…aterials not fix mmd model.
  • Loading branch information
Yusarina committed Feb 28, 2024
1 parent 283939c commit ec0c9f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 22 deletions.
23 changes: 1 addition & 22 deletions tools/armature.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ def execute(self, context):
except TypeError:
print('Color Management View Transform "Standard" not found!')

# Set shading to 3D view
set_material_shading()

# Remove Rigidbodies and joints
if context.scene.remove_rigidbodies_joints:
to_delete = []
Expand Down Expand Up @@ -322,10 +319,6 @@ def execute(self, context):

Common.sort_shape_keys(mesh.name, shapekey_order)


# Clean material names. Combining mats would do this too
Common.clean_material_names(mesh)

# Remove empty shape keys and then save the shape key order
Common.clean_shapekeys(mesh)
Common.save_shapekey_order(mesh.name)
Expand Down Expand Up @@ -1163,7 +1156,7 @@ def add_eye_children(eye_bone, parent_name):
if not source_engine:
try:
bpy.ops.mmd_tools_local.set_shadeless_glsl_shading()
set_material_shading()
Common.set_material_shading()
except RuntimeError:
pass

Expand Down Expand Up @@ -1236,17 +1229,3 @@ def check_hierarchy(check_parenting, correct_hierarchy_array):
return {'result': False, 'message': bone.name + t('FixArmature.notParentTo1') + previous + t('FixArmature.notParentTo2')}

return {'result': True}


def set_material_shading():
# Set shading to 3D view
for area in bpy.context.screen.areas: # iterate through areas in current screen
if area.type == 'VIEW_3D':
for space in area.spaces: # iterate through spaces in current VIEW_3D area
if space.type == 'VIEW_3D': # check if space is a 3D view
space.shading.type = 'MATERIAL' # set the viewport shading to rendered
space.shading.studio_light = 'forest.exr'
space.shading.studiolight_rotate_z = 0.0
space.shading.studiolight_background_alpha = 0.0
if bpy.app.version >= (2, 82):
space.shading.render_pass = 'COMBINED'
13 changes: 13 additions & 0 deletions tools/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2360,3 +2360,16 @@ def op_override(operator, context_override: Dict[str, Any], context: Optional[bp
args.append(undo)

return operator(*args, **operator_args)

def set_material_shading():
# Set shading to 3D view
for area in bpy.context.screen.areas: # iterate through areas in current screen
if area.type == 'VIEW_3D':
for space in area.spaces: # iterate through spaces in current VIEW_3D area
if space.type == 'VIEW_3D': # check if space is a 3D view
space.shading.type = 'MATERIAL' # set the viewport shading to rendered
space.shading.studio_light = 'forest.exr'
space.shading.studiolight_rotate_z = 0.0
space.shading.studiolight_background_alpha = 0.0
if bpy.app.version >= (2, 82):
space.shading.render_pass = 'COMBINED'
3 changes: 3 additions & 0 deletions tools/material.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def poll(cls, context):
def execute(self, context):
armature = Common.get_armature()
meshes = Common.get_meshes_objects()

Common.set_material_shading()

# If all materials are transparent, make them visible. Also set transparency always to Z-Transparency
# Make materials exportable in Blender 2.80 and remove glossy mmd shader look
# Common.remove_toon_shader(mesh)
Expand Down

0 comments on commit ec0c9f1

Please sign in to comment.