Skip to content

Mesh Permutation System

Hakan Saplakoglu edited this page May 13, 2026 · 1 revision

One of the most important parts of PGPatcher is its mesh permutation system. This system allows for a single mesh to be patched in an infinite number of ways to conform to the various ways it is used in your load order.

How it Works

For each mesh PGPatcher processes:

  1. Find all uses of the mesh in your plugins (could be STAT, ACTI, whatever. If it has a MODL field PGPatcher will look for it)
  2. Read the original mesh once from disk and store in memory (this is the most time consuming part)
  3. Patch the mesh N number of times for each use in plugins - this allows the patchers to run in the context of the use of the mesh, which allows things like alternate textures and MATO information to be a part of the patching pipeline.
  4. Compare the patched mesh to the base mesh - if it is different, save it to the output
  5. Compare the patched mesh to any previously saved meshes to the output - if it is the same, no need to save it again, just use the existing one
  6. At the end, we're left with the minimal possible set of meshes required.

Examples

1. MATO differences

This is important for a lot of mountain meshes. In some uses, it has no MATO, in others it does (snow cover on top). If that MATO is single pass, then parallax is incompatible with it, therefore the parallax patcher will refuse to patch it. BUT it will be happy to patch it for instances without MATO. This will result in at least 2 meshes in the output, one that is patched for parallax, and one that isn't (or if you have upgrade to CM enabled which is compatible, you might have one patched for parallax and one for CM).

2. TXST differences

Alternate textures are used to swap out textures on meshes from within plugins. This presents a problem: let's say PGPatcher patches a mesh for complex material but then an alternate texture swaps out those textures for something else. PGPatcher will also patch the TXST record but OH NO the texture set in the plugins can't do complex material because there is no CM map that matches it! If left alone that would result in a super shiny mesh because the shader would still be environment mapping but without a valid texture in the environment and mask slots. In this case the CM patcher would refuse to patch for CM within that plugin context and spit out a mesh that is unpatched on that shape. This will end up being one of the permutations so that you can enjoy your CM where it's possible and not have broken visuals elsewhere.

This is really important now that there are 4 shader types (vanilla, parallax, CM, PBR) because this system allows you to mix and match them with no consequences (well except for the output being larger on disk).

Clone this wiki locally