FlailingFog / KK-Blender-Porter-Pack

Plugin pack for exporting Koikatsu characters to Blender.
Other
373 stars 30 forks source link

Add normals to the Optimize Materials button #542

Closed FrankV724 closed 7 months ago

FrankV724 commented 7 months ago

Inside finalizematerials.py, we can add three simple lines to add the normal map to the optimized material.

First addition:

                if mat.node_tree.nodes.get('Image Texture'):
                    if ' light.png' in mat.node_tree.nodes['Image Texture'].image.name:
                        light_image = mat.node_tree.nodes['Image Texture'].image.name
                        dark_image  = mat.node_tree.nodes['Image Texture'].image.name.replace('light', 'dark')
                        normal_image  = mat.node_tree.nodes['Image Texture'].image.name.replace('light', 'normal') # here
                    else:
                        dark_image = mat.node_tree.nodes['Image Texture'].image.name
                        light_image  = mat.node_tree.nodes['Image Texture'].image.name.replace('dark', 'light')
                        normal_image  = mat.node_tree.nodes['Image Texture'].image.name.replace('dark', 'normal') # here

Second addition:

                    new_node.nodes['MapMain'].image = bpy.data.images[light_image]
                    new_node.nodes['Darktex'].image = bpy.data.images[dark_image]
                    new_node.nodes['MapNorm'].image = bpy.data.images[normal_image] # here
FlailingFog commented 7 months ago

Thanks, I added your edits in.