Logic Update - Perform MapType transforms before merging
This commit is contained in:
parent
4ffb2ff78c
commit
06552216d5
@ -62,6 +62,44 @@ class IndividualMapProcessingStage(ProcessingStage):
|
|||||||
It updates the AssetProcessingContext with detailed results.
|
It updates the AssetProcessingContext with detailed results.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
def _apply_in_memory_transformations(
|
||||||
|
self,
|
||||||
|
image_data: np.ndarray,
|
||||||
|
processing_map_type: str,
|
||||||
|
invert_normal_green: bool,
|
||||||
|
file_type_definitions: Dict[str, Dict],
|
||||||
|
log_prefix: str # e.g., "Asset 'X', Key Y, Proc. Tag Z"
|
||||||
|
) -> Tuple[np.ndarray, str, List[str]]:
|
||||||
|
"""
|
||||||
|
Applies in-memory transformations (Gloss-to-Rough, Normal Green Invert).
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Tuple containing:
|
||||||
|
- Potentially transformed image data.
|
||||||
|
- Potentially updated processing_map_type (e.g., MAP_GLOSS -> MAP_ROUGH).
|
||||||
|
- List of strings describing applied transformations.
|
||||||
|
"""
|
||||||
|
transformation_notes = []
|
||||||
|
current_image_data = image_data # Start with original data
|
||||||
|
updated_processing_map_type = processing_map_type # Start with original type
|
||||||
|
|
||||||
|
# Gloss-to-Rough
|
||||||
|
if processing_map_type.startswith("MAP_GLOSS"):
|
||||||
|
logger.info(f"{log_prefix}: Applying Gloss-to-Rough conversion.")
|
||||||
|
current_image_data = ipu.invert_image_colors(current_image_data)
|
||||||
|
updated_processing_map_type = processing_map_type.replace("GLOSS", "ROUGH")
|
||||||
|
logger.info(f"{log_prefix}: Map type updated: '{processing_map_type}' -> '{updated_processing_map_type}'")
|
||||||
|
transformation_notes.append("Gloss-to-Rough applied")
|
||||||
|
|
||||||
|
# Normal Green Invert
|
||||||
|
# Use internal 'MAP_NRM' type for check
|
||||||
|
if processing_map_type == "MAP_NRM" and invert_normal_green:
|
||||||
|
logger.info(f"{log_prefix}: Applying Normal Map Green Channel Inversion (Global Setting).")
|
||||||
|
current_image_data = ipu.invert_normal_map_green_channel(current_image_data)
|
||||||
|
transformation_notes.append("Normal Green Inverted (Global)")
|
||||||
|
|
||||||
|
return current_image_data, updated_processing_map_type, transformation_notes
|
||||||
|
|
||||||
def execute(self, context: AssetProcessingContext) -> AssetProcessingContext:
|
def execute(self, context: AssetProcessingContext) -> AssetProcessingContext:
|
||||||
"""
|
"""
|
||||||
Executes the individual map and merged task processing logic.
|
Executes the individual map and merged task processing logic.
|
||||||
@ -222,6 +260,15 @@ class IndividualMapProcessingStage(ProcessingStage):
|
|||||||
status_notes.append("Could not determine source bit depth, defaulted to 8.")
|
status_notes.append("Could not determine source bit depth, defaulted to 8.")
|
||||||
|
|
||||||
current_image_data = source_image_data.copy()
|
current_image_data = source_image_data.copy()
|
||||||
|
# Apply transformations for regular maps AFTER loading
|
||||||
|
log_prefix_regular = f"Asset '{asset_name_for_log}', Key {file_rule_idx}, Proc. Tag {processing_instance_tag}"
|
||||||
|
current_image_data, processing_map_type, transform_notes = self._apply_in_memory_transformations(
|
||||||
|
current_image_data, processing_map_type, invert_normal_green, file_type_definitions, log_prefix_regular
|
||||||
|
)
|
||||||
|
status_notes.extend(transform_notes)
|
||||||
|
# Update base_map_type AFTER potential transformation
|
||||||
|
base_map_type = get_filename_friendly_map_type(processing_map_type, file_type_definitions)
|
||||||
|
|
||||||
|
|
||||||
# --- B. Merged Image Task Processing ---
|
# --- B. Merged Image Task Processing ---
|
||||||
elif isinstance(item_data, dict):
|
elif isinstance(item_data, dict):
|
||||||
@ -309,6 +356,17 @@ class IndividualMapProcessingStage(ProcessingStage):
|
|||||||
|
|
||||||
if processing_status == "Failed": break # Exit outer loop if inner loop failed
|
if processing_status == "Failed": break # Exit outer loop if inner loop failed
|
||||||
|
|
||||||
|
# --- Apply Pre-Merge Transformations using Helper ---
|
||||||
|
if input_image_data is not None: # Only transform if we have data
|
||||||
|
log_prefix_merge_input = f"Asset '{asset_name_for_log}', Key {task_key}, Proc. Tag {processing_instance_tag}, Input {required_map_type_from_rule}"
|
||||||
|
input_image_data, _, transform_notes = self._apply_in_memory_transformations(
|
||||||
|
input_image_data, required_map_type_from_rule, invert_normal_green, file_type_definitions, log_prefix_merge_input
|
||||||
|
)
|
||||||
|
# We don't need the updated map type for the input key, just the transformed data
|
||||||
|
status_notes.extend(transform_notes) # Add notes to the main task's notes
|
||||||
|
|
||||||
|
# --- End Pre-Merge Transformations ---
|
||||||
|
|
||||||
loaded_inputs_for_merge[channel_char] = input_image_data
|
loaded_inputs_for_merge[channel_char] = input_image_data
|
||||||
inputs_used_for_merge[required_map_type_from_rule] = input_source_desc
|
inputs_used_for_merge[required_map_type_from_rule] = input_source_desc
|
||||||
|
|
||||||
@ -423,31 +481,8 @@ class IndividualMapProcessingStage(ProcessingStage):
|
|||||||
|
|
||||||
logger.info(f"Asset '{asset_name_for_log}', Key {item_key}, Proc. Tag {processing_instance_tag}: Entering common processing path for '{base_map_type}' (Internal: '{processing_map_type}')")
|
logger.info(f"Asset '{asset_name_for_log}', Key {item_key}, Proc. Tag {processing_instance_tag}: Entering common processing path for '{base_map_type}' (Internal: '{processing_map_type}')")
|
||||||
|
|
||||||
# In-Memory Transformations
|
|
||||||
transformation_applied = False
|
|
||||||
# Gloss-to-Rough
|
|
||||||
# Use filename-friendly 'GLOSS' or internal 'MAP_GLOSS'
|
|
||||||
if base_map_type == "GLOSS" or processing_map_type.startswith("MAP_GLOSS"):
|
|
||||||
logger.info(f"Asset '{asset_name_for_log}', Key {item_key}, Proc. Tag {processing_instance_tag}: Applying Gloss-to-Rough conversion.")
|
|
||||||
current_image_data = ipu.invert_image_colors(current_image_data)
|
|
||||||
# Update map types
|
|
||||||
new_processing_map_type = processing_map_type.replace("GLOSS", "ROUGH")
|
|
||||||
new_base_map_type = get_filename_friendly_map_type(new_processing_map_type, file_type_definitions)
|
|
||||||
logger.info(f"Asset '{asset_name_for_log}', Key {item_key}, Proc. Tag {processing_instance_tag}: Map type updated: '{processing_map_type}' -> '{new_processing_map_type}', Filename type: '{base_map_type}' -> '{new_base_map_type}'")
|
|
||||||
processing_map_type = new_processing_map_type
|
|
||||||
base_map_type = new_base_map_type
|
|
||||||
status_notes.append("Gloss-to-Rough applied")
|
|
||||||
transformation_applied = True
|
|
||||||
|
|
||||||
# Normal Green Invert
|
|
||||||
# Use filename-friendly 'NRM' or internal 'MAP_NRM'
|
|
||||||
if (base_map_type == "NRM" or processing_map_type == "MAP_NRM") and invert_normal_green:
|
|
||||||
logger.info(f"Asset '{asset_name_for_log}', Key {item_key}, Proc. Tag {processing_instance_tag}: Applying Normal Map Green Channel Inversion (Global Setting).")
|
|
||||||
current_image_data = ipu.invert_normal_map_green_channel(current_image_data)
|
|
||||||
status_notes.append("Normal Green Inverted (Global)")
|
|
||||||
transformation_applied = True
|
|
||||||
|
|
||||||
# Optional Initial Scaling (In Memory)
|
# Optional Initial Scaling (In Memory)
|
||||||
|
# Transformations are now handled earlier by the helper function
|
||||||
image_to_save = None
|
image_to_save = None
|
||||||
scaling_applied = False
|
scaling_applied = False
|
||||||
h_pre_scale, w_pre_scale = current_image_data.shape[:2]
|
h_pre_scale, w_pre_scale = current_image_data.shape[:2]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user