Bug Fixes

This commit is contained in:
Rusfort 2025-05-07 19:05:43 +02:00
parent 4e1cea56ae
commit d473ddd7f4
4 changed files with 23 additions and 18 deletions

View File

@ -245,8 +245,8 @@
"COL" "COL"
], ],
"EXTRA_FILES_SUBDIR": "Extra", "EXTRA_FILES_SUBDIR": "Extra",
"OUTPUT_BASE_DIR": "../Asset_Processor_Output", "OUTPUT_BASE_DIR": "../Asset_Processor_Output_Tests",
"OUTPUT_DIRECTORY_PATTERN": "[supplier]/[assetname]", "OUTPUT_DIRECTORY_PATTERN": "[supplier]/[sha5]_[assetname]",
"OUTPUT_FILENAME_PATTERN": "[assetname]_[maptype]_[resolution].[ext]", "OUTPUT_FILENAME_PATTERN": "[assetname]_[maptype]_[resolution].[ext]",
"METADATA_FILENAME": "metadata.json", "METADATA_FILENAME": "metadata.json",
"DEFAULT_NODEGROUP_BLEND_PATH": "G:/02 Content/10-19 Content/19 Catalogs/19.01 Blender Asset Catalogue/_CustomLibraries/Nodes-Linked/PBRSET-Nodes-Testing.blend", "DEFAULT_NODEGROUP_BLEND_PATH": "G:/02 Content/10-19 Content/19 Catalogs/19.01 Blender Asset Catalogue/_CustomLibraries/Nodes-Linked/PBRSET-Nodes-Testing.blend",
@ -254,7 +254,7 @@
"BLENDER_EXECUTABLE_PATH": "C:/Program Files/Blender Foundation/Blender 4.4/blender.exe", "BLENDER_EXECUTABLE_PATH": "C:/Program Files/Blender Foundation/Blender 4.4/blender.exe",
"PNG_COMPRESSION_LEVEL": 6, "PNG_COMPRESSION_LEVEL": 6,
"JPG_QUALITY": 98, "JPG_QUALITY": 98,
"RESOLUTION_THRESHOLD_FOR_JPG": 999999, "RESOLUTION_THRESHOLD_FOR_JPG": 4096,
"IMAGE_RESOLUTIONS": { "IMAGE_RESOLUTIONS": {
"8K": 8192, "8K": 8192,
"4K": 4096, "4K": 4096,

View File

@ -509,6 +509,10 @@ class Configuration:
"""Returns the LLM request timeout in seconds from LLM settings.""" """Returns the LLM request timeout in seconds from LLM settings."""
return self._llm_settings.get('llm_request_timeout', 120) return self._llm_settings.get('llm_request_timeout', 120)
@property
def FILE_TYPE_DEFINITIONS(self) -> dict:
return self._core_settings.get('FILE_TYPE_DEFINITIONS', {})
@property @property
def keybind_config(self) -> dict[str, list[str]]: def keybind_config(self) -> dict[str, list[str]]:
""" """

View File

@ -181,7 +181,7 @@ class ProcessingTask(QRunnable):
log.debug(f" Rule Details: {self.rule}") log.debug(f" Rule Details: {self.rule}")
# --- Calculate SHA5 and Incrementing Value --- # --- Calculate SHA5 and Incrementing Value ---
config = self.engine.config config = self.engine.config_obj
archive_path = self.rule.input_path archive_path = self.rule.input_path
output_dir = self.output_base_path # This is already a Path object from App.on_processing_requested output_dir = self.output_base_path # This is already a Path object from App.on_processing_requested

View File

@ -405,7 +405,7 @@ class ProcessingEngine:
output_base_path=output_base_path, # Pass output path output_base_path=output_base_path, # Pass output path
processed_maps_details_asset=processed_maps_details_asset, processed_maps_details_asset=processed_maps_details_asset,
merged_maps_details_asset=merged_maps_details_asset, merged_maps_details_asset=merged_maps_details_asset,
temp_metadata_path=temp_metadata_path_asset temp_metadata_info=temp_metadata_path_asset
) )
log.info(f"--- Asset '{asset_name}' processed successfully (Supplier: {effective_supplier}). ---") log.info(f"--- Asset '{asset_name}' processed successfully (Supplier: {effective_supplier}). ---")
@ -719,8 +719,8 @@ class ProcessingEngine:
jpg_quality = config.jpg_quality jpg_quality = config.jpg_quality
png_compression_level = config._core_settings.get('PNG_COMPRESSION_LEVEL', 6) png_compression_level = config._core_settings.get('PNG_COMPRESSION_LEVEL', 6)
image_resolutions = config.image_resolutions image_resolutions = config.image_resolutions
output_directory_pattern = config.get('OUTPUT_DIRECTORY_PATTERN', '[supplier]/[assetname]') output_directory_pattern = config.output_directory_pattern
output_filename_pattern = config.get('OUTPUT_FILENAME_PATTERN', '[assetname]_[maptype]_[resolution].[ext]') output_filename_pattern = config.output_filename_pattern
# --- 1. Determine Output Bit Depth --- # --- 1. Determine Output Bit Depth ---
source_bpc = source_info.get('source_bit_depth', 8) source_bpc = source_info.get('source_bit_depth', 8)
@ -878,11 +878,11 @@ class ProcessingEngine:
try: try:
cv2.imwrite(str(output_path_temp), img_save_final, save_params) cv2.imwrite(str(output_path_temp), img_save_final, save_params)
saved_successfully = True saved_successfully = True
log.info(f" > Saved {map_type} ({resolution_key}, {output_bit_depth}-bit) as {output_format}") log.info(f" > Saved {current_map_identifier} ({resolution_key}, {output_bit_depth}-bit) as {output_format}")
except Exception as save_err: except Exception as save_err:
log.error(f"Save failed ({output_format}) for {map_type} {resolution_key}: {save_err}") log.error(f"Save failed ({output_format}) for {current_map_identifier} {resolution_key}: {save_err}")
if output_bit_depth == 16 and output_format.startswith("exr") and fallback_fmt_16 != output_format and fallback_fmt_16 == "png": if output_bit_depth == 16 and output_format.startswith("exr") and fallback_fmt_16 != output_format and fallback_fmt_16 == "png":
log.warning(f"Attempting fallback PNG save for {map_type} {resolution_key}") log.warning(f"Attempting fallback PNG save for {current_map_identifier} {resolution_key}")
actual_format_saved = "png"; output_ext = ".png" actual_format_saved = "png"; output_ext = ".png"
# Regenerate path with .png extension for fallback # Regenerate path with .png extension for fallback
token_data_fallback = token_data.copy() token_data_fallback = token_data.copy()
@ -910,18 +910,18 @@ class ProcessingEngine:
img_fallback_save_final = img_fallback img_fallback_save_final = img_fallback
is_3_channel_fallback = len(img_fallback.shape) == 3 and img_fallback.shape[2] == 3 is_3_channel_fallback = len(img_fallback.shape) == 3 and img_fallback.shape[2] == 3
if is_3_channel_fallback: # PNG is non-EXR if is_3_channel_fallback: # PNG is non-EXR
log.debug(f"Converting RGB to BGR for fallback PNG save {map_type} ({resolution_key})") log.debug(f"Converting RGB to BGR for fallback PNG save {current_map_identifier} ({resolution_key})")
try: img_fallback_save_final = cv2.cvtColor(img_fallback, cv2.COLOR_RGB2BGR) try: img_fallback_save_final = cv2.cvtColor(img_fallback, cv2.COLOR_RGB2BGR)
except Exception as cvt_err_fb: log.error(f"Failed RGB->BGR conversion for fallback PNG: {cvt_err_fb}. Saving original."); except Exception as cvt_err_fb: log.error(f"Failed RGB->BGR conversion for fallback PNG: {cvt_err_fb}. Saving original.");
try: try:
cv2.imwrite(str(output_path_temp), img_fallback_save_final, save_params_fallback) cv2.imwrite(str(output_path_temp), img_fallback_save_final, save_params_fallback)
saved_successfully = True saved_successfully = True
log.info(f" > Saved {map_type} ({resolution_key}) using fallback PNG") log.info(f" > Saved {current_map_identifier} ({resolution_key}) using fallback PNG")
except Exception as fallback_err: except Exception as fallback_err:
log.error(f"Fallback PNG save failed for {map_type} {resolution_key}: {fallback_err}", exc_info=True) log.error(f"Fallback PNG save failed for {current_map_identifier} {resolution_key}: {fallback_err}", exc_info=True)
else: else:
log.error(f"No suitable fallback available or applicable for failed save of {map_type} ({resolution_key}) as {output_format}.") log.error(f"No suitable fallback available or applicable for failed save of {current_map_identifier} ({resolution_key}) as {output_format}.")
# --- 6. Return Result --- # --- 6. Return Result ---
@ -939,7 +939,7 @@ class ProcessingEngine:
return None # Indicate save failure return None # Indicate save failure
except Exception as e: except Exception as e:
log.error(f"Unexpected error in _save_image for {map_type} ({resolution_key}): {e}", exc_info=True) log.error(f"Unexpected error in _save_image for {current_map_identifier} ({resolution_key}): {e}", exc_info=True)
return None return None
@ -1056,6 +1056,7 @@ class ProcessingEngine:
effective_map_type_for_processing = "MAP_ROUGH" effective_map_type_for_processing = "MAP_ROUGH"
# --- End of new gloss map filename logic --- # --- End of new gloss map filename logic ---
log.debug(f"DEBUG POST-RETAG: effective_map_type_for_processing='{effective_map_type_for_processing}' for file '{source_path_rel.name}'")
original_extension = source_path_rel.suffix.lower() # Get from path original_extension = source_path_rel.suffix.lower() # Get from path
log.info(f"-- Asset '{asset_name}': Processing Individual Map: {effective_map_type_for_processing} (Source: {source_path_rel.name}, EffectiveIsGlossSourceForLoad: {effective_is_gloss_source_for_load}, OriginalRuleItemType: {original_item_type_override}) --") log.info(f"-- Asset '{asset_name}': Processing Individual Map: {effective_map_type_for_processing} (Source: {source_path_rel.name}, EffectiveIsGlossSourceForLoad: {effective_is_gloss_source_for_load}, OriginalRuleItemType: {original_item_type_override}) --")
@ -1070,7 +1071,7 @@ class ProcessingEngine:
try: try:
# --- Loop through target resolutions from static config --- # --- Loop through target resolutions from static config ---
for res_key, target_dim_px in resolutions.items(): for res_key, target_dim_px in resolutions.items():
log.debug(f"Processing {map_type} for resolution: {res_key}...") log.debug(f"Processing {effective_map_type_for_processing} for resolution: {res_key}...")
# --- 1. Load and Transform Source (using helper + cache) --- # --- 1. Load and Transform Source (using helper + cache) ---
# This now only runs for files that have an item_type_override # This now only runs for files that have an item_type_override
@ -1520,8 +1521,8 @@ class ProcessingEngine:
# --- Generate Path and Save --- # --- Generate Path and Save ---
# Get the new separate patterns from config # Get the new separate patterns from config
output_directory_pattern = self.config_obj.get('OUTPUT_DIRECTORY_PATTERN', '[supplier]/[assetname]') output_directory_pattern = self.config_obj.output_directory_pattern
output_filename_pattern = self.config_obj.get('OUTPUT_FILENAME_PATTERN', '[assetname]_[maptype]_[resolution].[ext]') output_filename_pattern = self.config_obj.output_filename_pattern
metadata_filename_base = self.config_obj.metadata_filename # e.g., "metadata.json" metadata_filename_base = self.config_obj.metadata_filename # e.g., "metadata.json"
metadata_ext = Path(metadata_filename_base).suffix.lstrip('.') or 'json' metadata_ext = Path(metadata_filename_base).suffix.lstrip('.') or 'json'
metadata_maptype = Path(metadata_filename_base).stem # Use filename stem as maptype token metadata_maptype = Path(metadata_filename_base).stem # Use filename stem as maptype token