Added Texture Folder + Scripts
This commit is contained in:
43
Texturing/MergeTextures/merge_textures_dekogon.py
Normal file
43
Texturing/MergeTextures/merge_textures_dekogon.py
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import cv2
|
||||||
|
import sys
|
||||||
|
import numpy as np
|
||||||
|
import re
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print("Please provide the input files.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
basecolor_file = None
|
||||||
|
normal_file = None
|
||||||
|
rma_file = None
|
||||||
|
|
||||||
|
# Loop through the command-line arguments
|
||||||
|
for arg in sys.argv[1:]:
|
||||||
|
if '_alb.' in arg.lower():
|
||||||
|
basecolor_file = arg
|
||||||
|
elif '_nrm.' in arg.lower():
|
||||||
|
normal_file = arg
|
||||||
|
elif '_rma.' in arg.lower():
|
||||||
|
rma_file = arg
|
||||||
|
|
||||||
|
# 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.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
basecolor = cv2.imread(basecolor_file, cv2.IMREAD_COLOR)
|
||||||
|
normal = cv2.imread(normal_file, cv2.IMREAD_COLOR)
|
||||||
|
orm = cv2.imread(rma_file, cv2.IMREAD_COLOR)
|
||||||
|
|
||||||
|
basecolorb, basecolorg, basecolorr = basecolor.T
|
||||||
|
normalb, normalg, normalr = normal.T
|
||||||
|
aob, metallicb, roughnessb, = orm.T
|
||||||
|
|
||||||
|
BCR = np.array([basecolorb, basecolorg, basecolorr, roughnessb])
|
||||||
|
NMO = np.array([metallicb, normalg, normalr, aob])
|
||||||
|
|
||||||
|
result = re.search(r'TX_(.*)_', basecolor_file)
|
||||||
|
output_dir = re.search(r'^(.+)\\.+$', basecolor_file).group(1)
|
||||||
|
|
||||||
|
cv2.imwrite(output_dir + f"\\{result.group(1)}_BCR.png", BCR.T)
|
||||||
|
cv2.imwrite(output_dir + f"\\{result.group(1)}_NMO.png", NMO.T)
|
||||||
BIN
Texturing/OptimizeTextures/optimize_textures.exe
Normal file
BIN
Texturing/OptimizeTextures/optimize_textures.exe
Normal file
Binary file not shown.
34
Texturing/OptimizeTextures/optimize_textures.py
Normal file
34
Texturing/OptimizeTextures/optimize_textures.py
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
from unittest import skip
|
||||||
|
from PIL import Image
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
if len(sys.argv) < 1:
|
||||||
|
print("Please provide the input files.")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
inputTexs = sys.argv
|
||||||
|
|
||||||
|
if not os.path.exists(os.path.join(os.path.dirname(inputTexs[1]),"optimized")):
|
||||||
|
os.mkdir(os.path.join(os.path.dirname(inputTexs[1]),"optimized"))
|
||||||
|
|
||||||
|
export_path = os.path.join(os.path.dirname(inputTexs[1]),"optimized")
|
||||||
|
|
||||||
|
#export_path = os.mkdir(os.path.join(os.path.dirname(inputTexs[1]),"optimized"))
|
||||||
|
#print (Input_filepath)
|
||||||
|
#print(inputTexs[1])
|
||||||
|
|
||||||
|
for i in range(1,len(inputTexs),1):
|
||||||
|
currentTex = Image.open(inputTexs[i])
|
||||||
|
|
||||||
|
if currentTex.size <= (2048,2048):
|
||||||
|
print (currentTex + "is already smaller than 2048x2048")
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
# downsize the image with an LANCZOS filter (gives the highest quality)
|
||||||
|
resizedTex = currentTex.resize((2048,2048),Image.LANCZOS)
|
||||||
|
|
||||||
|
resizedTex.save(str(export_path) + "\\" + os.path.basename(inputTexs[i]), optimize=True, quality=95)
|
||||||
|
|
||||||
|
print("Textures successfully resized!")
|
||||||
Reference in New Issue
Block a user