0
\$\begingroup\$

Using UVAtlas (Direct3D 9) Packed charts are separated by a user-specified gutter width. The gutter width is the amount of separation between charts, and allows for bilinear interpolation and mip-mapping to avoid rendering artifacts at chart boundaries. D3DX provides an interface for automatically filling in these gutters - see ID3DXTextureGutterHelper for more information.

How I can do that? I call ApplyGuttersTex, after calling ResampleTex but nothing changed.

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

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:

  1. 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.
  2. Copy UVs from UVAtlasMesh to clonedMesh into D3DDECLUSAGE_TEXCOORD 0.
  3. Copy UVs from originalMesh to clonedMesh into D3DDECLUSAGE_TEXCOORD 1.
  4. Create a blank texture with same width, height and format as the original mesh texture, it'll be called optimizedTexture.
  5. D3DXCreateTextureGutterHelper(originalMeshTextureWidth, originalMeshTextureHeight, clonedMesh, gutterSize, &gutterHelper);
  6. 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.

\$\endgroup\$
3
  • \$\begingroup\$ Thanks a lot! But... it's correct procedure of building atlas texture, but i need to fill gutter on atlas texture for seamless mip-mapping. A already have atlas and try to use ApplyGuttersTex() immediately after gutterHelper->ResampleTex(). But nothing changed. :( \$\endgroup\$
    – KindDragon
    Commented Sep 5, 2011 at 8:41
  • \$\begingroup\$ It also can be used as a correct procedure for filling gutter as well, if you regenerate the atlas texture :) ApplyGutterTex() can only recompute all of the gutter texels of class "2", which means gutter needs to know the face texel belongs to along with barycentric coordinates of the first two vertices of that face, so its used in a complex conjunction with SetBary/Gutter/Face/TexelMap. Why bother when you can just supply a mesh for which atlas was generated and a large gutter size to the to the D3DXCreateTextureGutterHelper(). \$\endgroup\$
    – EnoughTea
    Commented Sep 5, 2011 at 10:21
  • \$\begingroup\$ thank you! I simply do not saw gutter, because I had gutterSize equal to one. \$\endgroup\$
    – KindDragon
    Commented Sep 5, 2011 at 14:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .