FlailingFog / KK-Blender-Porter-Pack

Plugin pack for exporting Koikatsu characters to Blender.
304 stars 28 forks source link

Add normals to the Optimize Materials button #542

Closed FrankV724 closed 2 weeks ago

FrankV724 commented 2 weeks 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 2 weeks ago

Thanks, I added your edits in.