generated from cpp-best-practices/gui_starter_template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Description
Enhance the batch window functionality to support loading a single large swizzled image as input, reversing the existing export-to-one-image feature. The input image contains multiple texture pages arranged horizontally. This requires updates to texture loading, path searching, and UV coordinate calculations to handle the unified texture.
Also allow rendering these textures in the editor. With out a way to visualize we won't be able to know if it's working right.
Proposed Changes
-
Add New Filter for Single Image Input
- Introduce a new filter,
filters.swizzle_one_image
, to handle the single swizzled image input. - Add corresponding
filters.swizzle_one_image_map
for associated map files, mirroringfilters.upscale_map
.
- Introduce a new filter,
-
Update Path Search
- Modify
ff_8::path_search
to include fields for the new filter and map paths.
- Modify
-
Texture Loading
- Update
queue_texture_loading
to handle the single large texture, accounting for potential palette conflicts while ignoring texture page IDs. - Optionally explode the single texture into individual texture pages during loading (similar to FFNX approach).
- Add
load_swizzle_as_one_image_textures
based onload_upscale_textures
- Update
-
UV Coordinate Calculation
- Modify UV calculations in
get_triangle_strip
to read from the correct regions of the single texture. - Use
m_draw_swizzle
or a new flag to determine when to use single-image UV coordinates.
- Modify UV calculations in
-
Fallback Handling
- Ensure
fallback_textures
accounts for the new filter, disabling it if the single texture fails to load.
- Ensure
-
Add Combo Boxes / Menus
- One for path to textures and one for path to
.map
files. - These should mimic the ones for Upscales/Swizzles/Deswizzles.
- One for path to textures and one for path to
Pseudocode
Filter Update
switch (selections->batch_input_type) {
case input_types::swizzle_as_one_image:
filters.swizzle_one_image.update(selected_string).enable();
if (selections->batch_input_load_map)
filters.swizzle_one_image_map.update(selected_string).enable();
break;
}
Path Search
struct path_search {
std::shared_ptr<selections_t> selections;
std::optional<coo> opt_coo;
std::string field_name;
std::string filters_swizzle_one_image_value_string;
std::string filters_swizzle_one_image_map_value_string;
// ... other existing fields
};
// In map_sprite
if (m_filters.swizzle_one_image_map.enabled()) {
auto paths = ps.generate_swizzle_one_image_map_paths(".map");
if (!paths.empty()) {
m_filters.upscale_map.disable();
m_filters.deswizzle_map.disable();
load_map(paths.front());
} else {
m_filters.swizzle_one_image_map.disable();
}
}
Texture Loading
if (m_filters.swizzle_one_image.enabled()) {
for (const auto &palette : m_all_unique_values_and_strings.palette().values()) {
future_of_futures.push_back(load_single_swizzle_texture(palette));
}
} else {
// Existing upscale/deswizzle loading logic
}
UV Calculation
if (m_filters.swizzle_one_image.enabled()) {
// Calculate UVs for single texture
// Source X adjusted by texture_page * texture_page_width
// Base this on get_triangle_strip_dest_swizzle
src = to_vec2(ff_8::get_triangle_strip_source_single_swizzle(tile_const, texture_page_width));
} else if (m_filters.upscale.enabled()) {
// Existing upscale logic
}
Considerations
- Texture Page Width: (default 256px)
- Grid Layout: Future enhancement could arrange texture pages in a grid instead of a horizontal strip.
- Palette Conflicts: Ensure palette handling accounts for conflicts in the single texture.
- Performance: Evaluate exploding texture vs. UV adjustment for performance impacts.
Next Steps
- Implement
filters.swizzle_one_image
andfilters.swizzle_one_image_map
. - Update
ff_8::path_search
with new fields and separate instances. - Modify
queue_texture_loading
to handle single texture input. - Adjust
get_triangle_strip
for new UV calculations. - Test with sample large swizzle images to ensure correct texture mapping.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request