OPTIMIZE_KEEP_UV / OPTIMIZE_PROTECT_UV / OPTIMIZE_EXCLUDE_UV meaning

Question and answer about Polygon Cruncher SDK
Post Reply
mootools
Site Admin
Posts: 287
Joined: Thu Jul 05, 2007 11:06 am
Contact:

OPTIMIZE_KEEP_UV / OPTIMIZE_PROTECT_UV / OPTIMIZE_EXCLUDE_UV meaning

Post by mootools » Mon Nov 06, 2017 12:15 pm

The optimizer proposes different ways to handle the CUVWChannel sets you might provide with you mesh.
These different methods are the following:

Code: Select all

       // Keep uv is on. If not defined, UV are removed
       // OPTIMIZE_PROTECT_UV/OPTIMIZE_KEEP_UV are optional, if none used then
       // UV are optimized with minimal take care of them (something like OPTIMIZE_PRESERVE_UV)
       OPTIMIZE_KEEP_UV = 0x400,
       OPTIMIZE_PROTECT_UV = 0x800,
       OPTIMIZE_EXCLUDE_UV = 0x1000,
       OPTIMIZE_UV_MASK = (OPTIMIZE_PROTECT_UV|OPTIMIZE_EXCLUDE_UV),
First of all, If you want to keep the uv provided with your mesh (through CUVWChannel) you have to specify OPTIMIZE_KEEP_UV.
Without that flag, UVs are ignored during optimization process.

if your mesh does not have UVs seams, there is no real difference between these modes.
Note that an UV seams exists when you have different UVs value falling at the same geometric point.
This might occur when you have a break between different texture along an edge for example.

Saying that:

OPTIMIZE_KEEP_UV used alone keeps the UVs along the optimization process.
There is a minimal care of UV seams, and the flag is perfect if your mesh does not have such seams.

OPTIMIZE_PROTECT_UV will protect UV seams as long as it is possible.
If the specified required optimization ratio is too high, there might be seam losses.

OPTIMIZE_EXCLUDE_UV freezes UV seams, meaning that a point that has seams cannot be optimized.

One more important thing to know is that you can define a tolerance for detecting UV seams.
This is done through CSceneOptimizer::SetUVWTolerance.

Let's say you set the UVW tolerance to 0.0001. This means:

- the point has an an UV seams if the difference between 2 of its UVs is greater than 0.0001
- the point is not a seam if the difference between 2 of its UVs is lower than 0.0001

Only point that are on a seams are affected by OPTIMIZE_PROTECT_UV or OPTIMIZE_KEEP_UV

avareed
Posts: 2
Joined: Tue Nov 04, 2025 8:51 am
Contact:

Re: OPTIMIZE_KEEP_UV / OPTIMIZE_PROTECT_UV / OPTIMIZE_EXCLUDE_UV meaning

Post by avareed » Wed Dec 03, 2025 2:45 pm

### 1. **OPTIMIZE_KEEP_UV**

* This option tells the optimizer to **keep the existing UV coordinates intact**.
* Use this when your mesh already has UV mapping for textures (diffuse, normal, lightmap, etc.) and you don’t want the optimization process to alter them.
* **Example:** You have a detailed texture applied to a model and want to reduce polygon count without breaking the texture alignment.

---

### 2. **OPTIMIZE_PROTECT_UV**

* This option is more protective than `KEEP`. It tries to **preserve UVs as much as possible**, but it may allow minor adjustments if necessary for mesh optimization.
* Use this when maintaining texture integrity is critical, but slight changes in UVs are acceptable for better performance.
* **Example:** Optimizing a complex character model where minor UV shifts won’t be noticeable.

---

### 3. **OPTIMIZE_EXCLUDE_UV**

* This option tells the optimizer to **ignore the UVs entirely** during optimization.
* The UV coordinates may be destroyed or remapped as the optimizer focuses solely on reducing polygons or simplifying geometry.
* **Example:** When UVs are not needed (e.g., invisible parts of a mesh, collision meshes, or procedural meshes where textures aren’t applied).

---

**Summary Table:**

| Option | UV Handling | Use Case |
| ------------------- | ---------------------------- | ------------------------------------------------------ |
| OPTIMIZE_KEEP_UV | Preserve exactly | Textured meshes where UVs must remain unchanged |
| OPTIMIZE_PROTECT_UV | Preserve as much as possible | Textured meshes where minor adjustments are acceptable |
| OPTIMIZE_EXCLUDE_UV | Ignore / remap | Meshes without textures or where UVs don’t matter |

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests