|
|
|
|
@@ -405,7 +405,7 @@ class ProcessingEngine:
|
|
|
|
|
output_base_path=output_base_path, # Pass output path
|
|
|
|
|
processed_maps_details_asset=processed_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}). ---")
|
|
|
|
|
@@ -719,8 +719,8 @@ class ProcessingEngine:
|
|
|
|
|
jpg_quality = config.jpg_quality
|
|
|
|
|
png_compression_level = config._core_settings.get('PNG_COMPRESSION_LEVEL', 6)
|
|
|
|
|
image_resolutions = config.image_resolutions
|
|
|
|
|
output_directory_pattern = config.get('OUTPUT_DIRECTORY_PATTERN', '[supplier]/[assetname]')
|
|
|
|
|
output_filename_pattern = config.get('OUTPUT_FILENAME_PATTERN', '[assetname]_[maptype]_[resolution].[ext]')
|
|
|
|
|
output_directory_pattern = config.output_directory_pattern
|
|
|
|
|
output_filename_pattern = config.output_filename_pattern
|
|
|
|
|
|
|
|
|
|
# --- 1. Determine Output Bit Depth ---
|
|
|
|
|
source_bpc = source_info.get('source_bit_depth', 8)
|
|
|
|
|
@@ -878,11 +878,11 @@ class ProcessingEngine:
|
|
|
|
|
try:
|
|
|
|
|
cv2.imwrite(str(output_path_temp), img_save_final, save_params)
|
|
|
|
|
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:
|
|
|
|
|
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":
|
|
|
|
|
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"
|
|
|
|
|
# Regenerate path with .png extension for fallback
|
|
|
|
|
token_data_fallback = token_data.copy()
|
|
|
|
|
@@ -910,18 +910,18 @@ class ProcessingEngine:
|
|
|
|
|
img_fallback_save_final = img_fallback
|
|
|
|
|
is_3_channel_fallback = len(img_fallback.shape) == 3 and img_fallback.shape[2] == 3
|
|
|
|
|
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)
|
|
|
|
|
except Exception as cvt_err_fb: log.error(f"Failed RGB->BGR conversion for fallback PNG: {cvt_err_fb}. Saving original.");
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
cv2.imwrite(str(output_path_temp), img_fallback_save_final, save_params_fallback)
|
|
|
|
|
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:
|
|
|
|
|
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:
|
|
|
|
|
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 ---
|
|
|
|
|
@@ -939,7 +939,7 @@ class ProcessingEngine:
|
|
|
|
|
return None # Indicate save failure
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -1056,6 +1056,7 @@ class ProcessingEngine:
|
|
|
|
|
effective_map_type_for_processing = "MAP_ROUGH"
|
|
|
|
|
# --- 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
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
# --- Loop through target resolutions from static config ---
|
|
|
|
|
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) ---
|
|
|
|
|
# This now only runs for files that have an item_type_override
|
|
|
|
|
@@ -1520,8 +1521,8 @@ class ProcessingEngine:
|
|
|
|
|
|
|
|
|
|
# --- Generate Path and Save ---
|
|
|
|
|
# Get the new separate patterns from config
|
|
|
|
|
output_directory_pattern = self.config_obj.get('OUTPUT_DIRECTORY_PATTERN', '[supplier]/[assetname]')
|
|
|
|
|
output_filename_pattern = self.config_obj.get('OUTPUT_FILENAME_PATTERN', '[assetname]_[maptype]_[resolution].[ext]')
|
|
|
|
|
output_directory_pattern = self.config_obj.output_directory_pattern
|
|
|
|
|
output_filename_pattern = self.config_obj.output_filename_pattern
|
|
|
|
|
metadata_filename_base = self.config_obj.metadata_filename # e.g., "metadata.json"
|
|
|
|
|
metadata_ext = Path(metadata_filename_base).suffix.lstrip('.') or 'json'
|
|
|
|
|
metadata_maptype = Path(metadata_filename_base).stem # Use filename stem as maptype token
|
|
|
|
|
|