Added new Dekogon Namin Scheme to Merge Textures Script

This commit is contained in:
Killergnom
2024-10-15 22:22:23 +02:00
parent deed018b01
commit 04208ebe6e
11 changed files with 94 additions and 79 deletions

View File

@@ -2,20 +2,25 @@ import cv2
import sys
import numpy as np
import os
import time
if len(sys.argv) < 2:
print("Please provide the input files.")
time.sleep(5)
sys.exit(1)
basecolor_file = None
normal_file = None
rma_file = None
basecolor_prefixes = ["_alb.","_albedo."]
normal_prefixes = ["_nrm.", "_normal."]
# Loop through the command-line arguments
for arg in sys.argv[1:]:
if '_alb.' in arg.lower():
if any(prefix in arg.lower() for prefix in basecolor_prefixes):
basecolor_file = arg
elif '_nrm.' in arg.lower():
elif any(prefix in arg.lower() for prefix in normal_prefixes):
normal_file = arg
elif '_rma.' in arg.lower():
rma_file = arg
@@ -23,6 +28,7 @@ for arg in sys.argv[1:]:
# Check if all files are provided
if not all([basecolor_file, normal_file, rma_file]):
print("Please provide all input files: base_color, normal, roughness, ambient_occlusion, and metallic.")
time.sleep(5)
sys.exit(1)
basecolor = cv2.imread(basecolor_file, cv2.IMREAD_COLOR)
@@ -39,7 +45,9 @@ NMO = np.array([metallicb, normalg, normalr, aob])
#result = re.search(r'TX_(.*)_', basecolor_file)
output_filename = os.path.basename(basecolor_file)
output_filename = output_filename.removeprefix("TX_")
output_filename = output_filename.removeprefix("T_")
output_filename = output_filename.removesuffix("_ALB.PNG")
output_filename = output_filename.removesuffix("_Albedo.PNG")
if not os.path.exists(os.path.join(os.path.dirname(basecolor_file),"merged")):
os.mkdir(os.path.join(os.path.dirname(basecolor_file),"merged"))
@@ -49,4 +57,7 @@ output_dir = os.path.join(os.path.dirname(basecolor_file),"merged")
#output_dir = re.search(r'^(.+)\\.+$', basecolor_file).group(1)
cv2.imwrite(output_dir + f"\\{output_filename}_BCR.png", BCR.T)
cv2.imwrite(output_dir + f"\\{output_filename}_NMO.png", NMO.T)
cv2.imwrite(output_dir + f"\\{output_filename}_NMO.png", NMO.T)
print("Textures successfully merged!")
time.sleep(5)