Jump to content
  • Advertisement
Sign in to follow this  
ingramb

D3DXUVAtlasPack wasted space

This topic is 2501 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using the D3DXUVAtlasPartition/D3DXUVAtlasPack to try to improve my lightmaps. I have a working implementation with promising results. One thing that is still bothering me is that UVAtlasPack will often waste a lot of space in the destination texture. The charts are packed very tightly, but there is lots of empty space at the edges of the texture. For example, I create a 1024x1024 atlas, and only the right 512x1024 region is filled. It's not a matter of my atlas being too big; I can provide a larger atlas (or one that better matches whatever aspect ratio I'm getting), and I will get much better looking results.

I'm currently thinking about running D3DXUVAtlasPack once, reading the generated UVs to find the utilized portion, and then calling D3DXUVAtlasPack again with an adjusted size to match the aspect ratio. Is there a better way to get D3DX to completely fill my atlas, regardless of the dimensions or aspect ratio?

And more generally, does anyone have any good references on UVAtlas? I've read all the docs on msdn and looked at the D3DX sample code, but they're pretty spares, and I haven't been able to find much of anything online.

Share this post


Link to post
Share on other sites
Advertisement
Upon further investigation, it seems that [color=#1C2837][size=2]D3DXUVAtlasPack more or less ignores the requested atlas size, and generates the same uv space packing regardless. So what I've done is this:
[color=#1C2837][size=2]

[color="#1c2837"]1) Call [color=#1C2837][size=2]D3DXUVAtlasPack with "default" square size
[color=#1C2837][size=2]2) Scan the generated UVs, compute min/max
[color=#1C2837][size=2]3) Scale and bias the generated UVs using the min/max, so they all map from 0-1
[color=#1C2837][size=2]4) Adjust my atlas texture size, using an aspect ratio derived from the width/height of the UV space bounding rectangle
[color="#1c2837"]5) I can then pass this texture size and updated UVs to the texture gutter helper to actually generate my re-sampled texture
[color="#1c2837"]

[color="#1c2837"]This seems to work pretty well, although I don't have a whole lot of control over the final aspect ratio. It seems that [color=#1C2837][size=2]D3DXUVAtlasPack[color="#1c2837"] will generally create square atlases, unless there is a long thin rectangular chart somewhere. So my problem is mostly solved, although I would love to know if anyone else has any insight or information regarding UVAtlas.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!