FlailingFog / KK-Blender-Porter-Pack

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

KKBP 7.0.0. new saturation method is just ugly #603

Closed hdddestroyer closed 1 month ago

hdddestroyer commented 2 months ago

This is just a feedback post, because the color banding is terrible. banding

I'll stick to 6.6.3 until it's fixed.

MoriMorinya commented 1 month ago

Temporary fix: Edit converttextures.py in %APPDATA%\Blender Foundation\Blender\4.2\extensions\user_default\kkbp\importing\ using notepad and replace all the code with this:

'''
This file can be run by any blender version between 2.90 and 3.6 to import and saturate all of the pmx textures
'''
import bpy, sys, os, datetime
from pathlib import Path

if __name__ == '__main__':
    # Use datetime instead of time() because the latter doesn't work 
    timer = datetime.datetime.now().minute * 60 + datetime.datetime.now().second + datetime.datetime.now().microsecond / 1e6

    # Set the view transform or the files will not save correctly
    bpy.context.scene.view_settings.view_transform = 'Standard'

    filter = int(sys.argv[-1])
    pmx_import_dir = sys.argv[-2]
    addon_dir = sys.argv[-3]

    # Collect all images in this folder and all subfolders into an array
    ignore_list = [
            "cf_m_eyeline_00_up_MT_CT.png",
            "cf_m_eyeline_down_MT_CT.png",
            "cf_m_noseline_00_MT_CT.png",
            "cf_m_mayuge_00_MT_CT.png",
            "cf_m_eyeline_kage_MT.png",
        ]

    directory = pmx_import_dir
    fileList = Path(directory).rglob('*.png')
    if filter:
        files = [file for file in fileList if file.is_file() and "_MT" in file.name and file.name not in ignore_list]
    else:
        files = [file for file in fileList if file.is_file()]

    first = True
    for image_file in files:
        # Skip this file if it has already been converted
        if os.path.isfile(os.path.join(pmx_import_dir, 'saturated_files', str(image_file.name).replace('_MT','_ST'))):
            print('|File already converted. Skipping {}'.format(image_file.name))
        else:
            # Run the "null" processing step
            print('|Processing image {}'.format(image_file.name))
            image = bpy.data.images.load(str(image_file))

            # Reload the image without any saturation
            image.reload()

            # Save the image directly without modification
            image.save_render(str(os.path.join(directory, "saturated_files", image_file.name.replace('_MT', '_ST'))))

            # Remove the image from memory
            bpy.data.images.remove(image)

    print('|Image conversion operation took {} seconds'.format(abs(round(((datetime.datetime.now().minute * 60 + datetime.datetime.now().second + datetime.datetime.now().microsecond / 1e6) - timer), 3))))
    bpy.ops.wm.quit_blender()

This will cause it to skip the saturation process and thus not cause weird artifcating.

If you feel like the colors are "off", you can manually saturate the images using a batch image editor like https://github.com/Sidneys1/BatchImageProcessor/releases/tag/v2.0.1

FlailingFog commented 1 month ago

wtf, how did I not notice this before... It looks like I accidentally left something in when I was trying to learn how the saturation code worked a few months ago. In converttextures.py change "return lutcol_bot;" back to "return lutColor;" and it will match the 6.6.3 saturation code. I'll update the 7.0 release with this change

FlailingFog commented 1 month ago

fixed in 7.0.1