Skip to content

Add a deswizzle/pupu compare to toml editor. #224

@Sebanisu

Description

@Sebanisu

Add Deswizzle/Pupu Compare to .toml Editor

Overview

We should create a comparison view in the .toml editor that shows the deswizzle results from:

  • The original MIM data
  • The generated TOML textures

The goal is to visualize and measure differences between the two outputs.


🧩 Sub-Issues Breakdown

1. Extract and Modularize Deswizzle Logic

Goal: Make deswizzling reusable outside of map-sprite.

Tasks:

  • Move existing deswizzle logic into a shared module (e.g. DeswizzleUtils or TextureDeswizzler).
  • Separate file loading and GPU processing logic — make file loading optional or pluggable.
  • Add an entry point to feed in already-loaded textures and custom output targets.
  • Define a clean API like:
    DeswizzleResult DeswizzleTextures(const std::vector<Texture>& inputTextures, const DeswizzleOptions& options);
  • Ensure output can be redirected (instead of always writing to the map-sprite’s output paths).

Acceptance Criteria:

  • Can call DeswizzleTextures() from anywhere (not tied to map-sprite).
  • Can provide custom texture sources and destination targets.
  • Existing map-sprite still works using the new API.

2. Integrate MIM + TOML Deswizzle into Editor

Goal: Run deswizzle on both MIM and TOML data using the new shared logic.

Tasks:

  • Add functions to:
    • Load and deswizzle MIM texture set.
    • Deswizzle generated TOML texture set.
  • Ensure both outputs share the same dimensions.
  • Cache deswizzle results to avoid recomputation when switching views.

Acceptance Criteria:

  • Both deswizzled versions are accessible to the editor.
  • Deswizzle results match existing expected outputs when tested independently.

3. Implement Texture Comparison Compute Shader

Goal: Compare deswizzled outputs pixel-by-pixel using OpenGL compute shaders.

Tasks:

  • Write/modify compute shader to:
    • Read from two input textures.
    • Output a mask texture (white = different, black = same).
    • Count differing pixels and output the count to a buffer.
  • Compute percent difference:
    percent = (diff_pixels / total_pixels) * 100.0f;
  • Optionally: produce masked versions (MIM-masked, TOML-masked).

Acceptance Criteria:

  • Shader correctly produces mask and difference metrics.
  • Outputs usable by the UI layer.

4. Build Comparison UI (Inline View)

Goal: Add comparison info to the .toml editor panel.

UI Elements:

  • Table or pane with:
    • Left: MIM deswizzle
    • Right: TOML deswizzle
    • Center: numeric info (difference count, %)
  • Reuse existing texture preview logic.

Acceptance Criteria:

  • Can view both deswizzled images side by side.
  • Pixel difference metrics update correctly.

5. Add Optional Comparison Window

Goal: Provide a detailed view with mask visualization and toggles.

Features:

  • Inputs: references to MIM texture, TOML texture, mask texture.
  • Controls to:
    • Toggle between MIM / TOML / Mask.
    • Apply mask (show differing pixels only).
  • Show checkerboard background for visibility (reuse existing draw window logic).

Acceptance Criteria:

  • Separate window displays correctly.
  • Toggles and mask application behave as expected.

6. QA and Validation

Goal: Confirm correctness and consistency.

Tasks:

  • Verify deswizzle output parity between MIM and TOML.
  • Validate compute shader results with test textures.
  • Ensure differences match expected pixel-level discrepancies.
  • Confirm performance is acceptable (no unnecessary re-deswizzling).

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions