There was a code sample on the subject, I've seen it some time ago, just can't remember where. Anyway, I guess you have already called D3DXUVAtlasCreate and got your new mesh with UVs for the optimized version of the original texture. Let's call it UVAtlasMesh.
Well, rest of the stuff is relatively simple. Just as one of your links says, gutter helper needs its mesh's D3DDECLUSAGE_TEXCOORD 0 to contain new set of UVs and D3DDECLUSAGE_TEXCOORD 1 to contain original set of UVs. So check that declaration of your mesh have both of these texcoords. Then the general idea is as follows:
- Prepare a mesh with those 2 texcoords — just clone the mesh you got from AtlasCreate, so it will be your
clonedMesh
. Original mesh (the one you passed to AtlasCreate) will be called originalMesh
in the same imaginative fashion.
- Copy UVs from
UVAtlasMesh
to clonedMesh
into D3DDECLUSAGE_TEXCOORD 0.
- Copy UVs from
originalMesh
to clonedMesh
into D3DDECLUSAGE_TEXCOORD 1.
- Create a blank texture with same width, height and format as the original mesh texture, it'll be called
optimizedTexture
.
D3DXCreateTextureGutterHelper(originalMeshTextureWidth, originalMeshTextureHeight, clonedMesh, gutterSize, &gutterHelper);
gutterHelper->ResampleTex(originalMeshTexture, clonedMesh, D3DDECLUSAGE_TEXCOORD, 1, optimizedTexture);
Scrap clonedMesh and save the optimizedTexture. If it will look blank, recheck everything related to the D3DXUVAtlasCreate and its returned mesh's UVs.